Skip to content
Snippets Groups Projects
Commit 56891118 authored by Andreas Bayha's avatar Andreas Bayha
Browse files

tooling.base.ui: Added UIProvider base class

Added UIProvider base class for IModelElements.

Issue-Ref: 3914
Issue-Url: https://af3-developer.fortiss.org/issues/3914



Signed-off-by: default avatarAndreas Bayha <bayha@fortiss.org>
parent 62a2f060
No related branches found
No related tags found
1 merge request!913914 kernel-Branch
......@@ -8,3 +8,4 @@ LayoutedContentAnchorageController.java 73b103c06edcbf1762654e71a3e524f43c0c50c0
LayoutedDiagramAnchorageController.java 32d7d77daf252d021458c39ebcfe502f26f29a98 YELLOW
LayoutedLinkBendPointController.java 6d5de856f513ca82eab805a0ad9cda8194be011d YELLOW
LayoutedRectangularResizableContentController.java 3232d423572924363702898cf8ba240ce7042b65 YELLOW
ModelElementFXEditorUIProviderBase.java b81bf7fc945d40f1f842876f07ba70799ab65f6d YELLOW
/*-------------------------------------------------------------------------+
| Copyright 2020 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.ui.editor.fx.controller;
import static org.fortiss.tooling.base.ui.editor.fx.controller.ContextMenuUtil.createPrototypeMenu;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.fortiss.tooling.base.model.element.IModelElement;
import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeTableUIProviderBase;
import org.fortiss.tooling.kernel.ui.extension.base.FXEditorBase;
import org.fortiss.tooling.kernel.ui.service.IModelElementHandlerService;
import javafx.scene.Node;
import javafx.scene.control.ContextMenu;
/**
* Base implementation for FX UIProvider for ModelElements.
*
* @author bayha
*/
public abstract class ModelElementFXEditorUIProviderBase<T extends IModelElement>
extends DynamicTreeTableUIProviderBase<T> {
/** The editor used to post selection changes. */
protected final FXEditorBase<?> editor;
/** Constructor. */
public ModelElementFXEditorUIProviderBase(FXEditorBase<?> editor) {
this.editor = editor;
}
/** {@inheritDoc} */
@Override
public Node getIconNode(IModelElement element, int column) {
if(element == null) {
return null;
}
return IModelElementHandlerService.getInstance().getFXIcon(element);
}
/** {@inheritDoc} */
@Override
public ContextMenu createContextMenu(IModelElement element, int column) {
if(element == null || column != 0) {
return null;
}
ContextMenu contextMenu = new ContextMenu();
contextMenu.getItems().addAll(createPrototypeMenu(element, null));
return contextMenu;
}
/** {@inheritDoc} */
@Override
public void select(IModelElement oldValue, IModelElement newValue) {
IStructuredSelection selection =
newValue == null ? StructuredSelection.EMPTY : new StructuredSelection(newValue);
editor.getSite().getSelectionProvider().setSelection(selection);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment