Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • af3/kernel
  • diewald/kernel
2 results
Show changes
Showing
with 387 additions and 81 deletions
......@@ -32,6 +32,7 @@ import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.impl.MVCBundlePartBase;
import javafx.scene.Cursor;
import javafx.scene.Node;
import javafx.scene.control.MenuItem;
import javafx.scene.input.Dragboard;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.input.MouseEvent;
......@@ -104,6 +105,18 @@ public abstract class ControllerBase extends MVCBundlePartBase implements IContr
return true;
}
/** {@inheritDoc} */
@Override
public boolean handleExternalDNDDragOver(Dragboard db, DiagramCoordinate diagramLocation) {
return false;
}
/** {@inheritDoc} */
@Override
public boolean handleExternalDNDDrop(Dragboard db, DiagramCoordinate diagramLocation) {
return false;
}
/** {@inheritDoc} */
@Override
public IDragController getDragController(EDragGesture gesture, Node node,
......
......@@ -42,6 +42,7 @@ import javafx.geometry.Point2D;
import javafx.scene.Cursor;
import javafx.scene.Node;
import javafx.scene.control.MenuItem;
import javafx.scene.input.Dragboard;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.input.MouseEvent;
......@@ -467,4 +468,16 @@ public abstract class LinkControllerBase extends MVCBundlePartBase implements IC
/** Returns the number of bend-points in the model. */
protected abstract int getNumerOfBendPoints();
/** {@inheritDoc} */
@Override
public boolean handleExternalDNDDragOver(Dragboard db, DiagramCoordinate diagramLocation) {
return false;
}
/** {@inheritDoc} */
@Override
public boolean handleExternalDNDDrop(Dragboard db, DiagramCoordinate diagramLocation) {
return false;
}
}
ContentAnchorageVisualBase.java 6722629a940e9f8d973d2176bc3855932d7fa35a GREEN
ContentVisualBase.java d232c6cb7bc54b2430379379eb2985f5a2e12cd3 RED
ContentVisualBase.java 6c9c508803874db2f5ffffb723c1df5664827a5d GREEN
DiagramAnchorageVisualBase.java 05c235152bc79187f0fc9b041435da7968654a78 GREEN
LinkVisualBase.java 909b933b38b7651cac901d767115e173983bef26 GREEN
MVCBundlePartWithEffectsBase.java 6f6fbbb065950ad3acd4dc1fbfdd1348874e51d2 GREEN
VisualBase.java 8d6e74d5c74703dad12847cd5c913fa72707a84a RED
VisualBase.java 276f4f5a881bd3a89c312522f9006e6f0cfd57c9 GREEN
......@@ -41,7 +41,6 @@ public abstract class ContentVisualBase extends VisualBase implements IContentVi
protected final Text text = new Text();
/** The icon of this visual. */
protected final ImageView icon = new ImageView();
// TODO (SB): Magic constant
/** The expanded / collapsed indicator widget. */
protected final ExpandCollapseWidget expandCollapseWidget =
new ExpandCollapseWidget(0, 0, 20, 20, 3);
......
......@@ -49,6 +49,11 @@ import javafx.scene.text.TextAlignment;
* This implementation provides a simple {@link DropShadow} hover effect and a hover label.
*/
public abstract class VisualBase extends MVCBundlePartWithEffectsBase implements IVisual {
/** The default drop shadow radius. */
private static final double DEFAULT_DROP_SHADOW_RAIDUS = 10;
/** The default drop shadow radius. */
private static final double DEFAULT_DROP_SHADOW_OFFSET = 3;
/** The visible shape of this visual. */
private final Shape visualShape;
/** The invisible hit area of this visual. */
......@@ -85,8 +90,8 @@ public abstract class VisualBase extends MVCBundlePartWithEffectsBase implements
protected void createHoverEffect(DiagramLayers layers) {
Color shadow = getHoverShadowColor();
if(shadow != null && visualShape != null) {
// TODO (SB): Magic constant
visualShape.setEffect(new DropShadow(10, 3, 3, shadow));
visualShape.setEffect(new DropShadow(DEFAULT_DROP_SHADOW_RAIDUS,
DEFAULT_DROP_SHADOW_OFFSET, DEFAULT_DROP_SHADOW_OFFSET, shadow));
}
// handle hover text
String text = getHoverText();
......
CircularContentAnchorageVisualBase.java e1d3f982239beb38120c7eda6ecf319ab2779f9c RED
CircularContentAnchorageVisualBase.java c72fb8b95ef1e3650378f1c580c9362ebb852f46 GREEN
CircularContentVisualBase.java cc3caea328e36e90069b915e413c8e7e9522a939 GREEN
CircularDiagramAnchorageVisualBase.java 7a3b92fb1b135c218b9a5e16506acfc74a6b5468 YELLOW
CircularDiagramAnchorageVisualBase.java 7a3b92fb1b135c218b9a5e16506acfc74a6b5468 GREEN
CurveLinkVisualBase.java 5ce3086769004a9eb6800d7eb58379d831ff74b1 GREEN
CurveSegment.java 0e7f70e9526a74aaec2bec4f4fc16295521cf5f2 GREEN
EllipticBorderLocation.java 1e9b3d42c7fcd5495004fb30b0c499096a839967 GREEN
......
......@@ -26,6 +26,9 @@ import javafx.scene.shape.Circle;
/** Base class for {@link IContentAnchorageVisual}s depicted as circles. */
public abstract class CircularContentAnchorageVisualBase extends ContentAnchorageVisualBase {
/** The default insets. */
private static final double DEFAULT_INSET = 2;
/** Constructor. */
public CircularContentAnchorageVisualBase(IContentAnchorageMVCBundle mvcb) {
super(mvcb, new Circle(), new Circle());
......@@ -84,8 +87,7 @@ public abstract class CircularContentAnchorageVisualBase extends ContentAnchorag
/** Returns the insets of the filled circle subtracted from {@link #getDimensions()}. */
protected double getInset() {
// TODO (SB): Magic constant
return 2;
return DEFAULT_INSET;
}
/** {@inheritDoc} */
......
DiamondContentVisualBase.java de349d41b84b2063f74c03ff5ad7290855e997f7 RED
DiamondContentVisualBase.java a81e76e85706ad38b6c22bbcd1cc5a5696737e3d GREEN
LineLinkGraph.java 85a06a553f88f7b9fb4bd9c06411725d9fb160fc GREEN
LineLinkVisualBase.java 5529031f89a96ad0322f011e89dad1ece785bc03 RED
LineLinkVisualBase.java 74968c18bb68859bc795ed9a3b0693d1787e0806 GREEN
LineSegment.java a8658ec5bcd930d417a148861831b9ebb70bb37d GREEN
RectangularBorderLocation.java 824472c353534d1094ae4f735a30a231b885f050 GREEN
RectangularContentAnchorageVisualBase.java 39981dc29cac42d77c6ffe855ecc8ccad1689230 GREEN
RectangularContentVisualBase.java aee9ac3dbd53ce89539252d9984ed103d955be2f RED
RectangularContentVisualBase.java aeeda282f330180b1f339e3230810eccea2e7e7b GREEN
RectangularDiagramAnchorageVisualBase.java 1259d6d110becca9ae02c754036c6693f00de683 GREEN
RhomboidContentVisualBase.java 0c3820cbfd3763c3cb6b1a0cba5cc71d8eecea73 RED
RhomboidContentVisualBase.java 7f4d72e17d58a950814d76509a6d6402bbd7bba7 GREEN
......@@ -34,6 +34,9 @@ import javafx.scene.shape.PathElement;
/** Base class for {@link ContentVisualBase content visuals} depicted by a diamond shape. */
public abstract class DiamondContentVisualBase extends ContentVisualBase {
/** The default text anchor location. */
private static final double DEFAULT_TEXTANCHOR_DIVIDER = 5;
/** Constructor. */
public DiamondContentVisualBase(IContentMVCBundle mvcb) {
super(mvcb, new Path(), new Path());
......@@ -190,7 +193,7 @@ public abstract class DiamondContentVisualBase extends ContentVisualBase {
@Override
protected DiagramCoordinate getTextAnchorLocation() {
DiagramCoordinate textAnchorLocation = super.getTextAnchorLocation();
// TODO (SB): Magic constant
return textAnchorLocation.add(getCurrentBounds().getWidth() / 5, 0);
return textAnchorLocation.add(getCurrentBounds().getWidth() / DEFAULT_TEXTANCHOR_DIVIDER,
0);
}
}
......@@ -36,6 +36,8 @@ import javafx.scene.paint.Paint;
/** Base class for {@link LinkVisualBase link visuals} with straight lines. */
public abstract class LineLinkVisualBase extends LinkVisualBase {
/** The default arrow length. */
private static final double DEFAULT_ARROW_LENGTH = 10.0;
/** Stores the visual segments. */
private final List<LineSegment> segments = new LinkedList<>();
/** Flag storing if the lines have been added. */
......@@ -339,8 +341,7 @@ public abstract class LineLinkVisualBase extends LinkVisualBase {
/** Returns the length of the arrow. */
protected double getArrowLength() {
// TODO (SB): Magic constant
return 10;
return DEFAULT_ARROW_LENGTH;
}
/** Returns the width of the invisible selection line. */
......
......@@ -28,9 +28,11 @@ import javafx.scene.Node;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
// TODO (SB): Check potential code duplication with RectangularContentVisualBase (dragGestureHitTest)
/** Base class for {@link ContentVisualBase content visuals} depicted by rectangles. */
public abstract class RectangularContentVisualBase extends ContentVisualBase {
/** The default corner arc. */
private static final Dimension2D DEFAULT_CORNER_ARC = new Dimension2D(15, 15);
/** Constructor. */
public RectangularContentVisualBase(IContentMVCBundle mvcb) {
super(mvcb, new Rectangle(), new Rectangle());
......@@ -99,39 +101,15 @@ public abstract class RectangularContentVisualBase extends ContentVisualBase {
/** Returns the dimensions of the corner arcs. */
protected Dimension2D getCornerArcDimensions() {
// TODO (SB): Magic constant
return new Dimension2D(15, 15);
return DEFAULT_CORNER_ARC;
}
/** {@inheritDoc} */
@Override
protected EDragGesture dragGestureHitTest(Node node, DiagramCoordinate diagramLocation) {
if(node == getHitAreaShape()) {
double x = diagramLocation.getLocalX(node);
double y = diagramLocation.getLocalY(node);
double l = getHitAreaStartLinkSize();
double r = getHitAreaResizeSize();
Bounds bounds = node.getBoundsInLocal();
// check for move area
double inset = l + r;
Rectangle2D moveArea = new Rectangle2D(inset, inset, bounds.getWidth() - 2 * inset,
bounds.getHeight() - 2 * inset);
if(moveArea.contains(x, y)) {
return EDragGesture.MOVE;
}
if(x < l || y < l || x > bounds.getWidth() - l || y > bounds.getHeight() - l) {
return EDragGesture.NEW_LINK;
}
if(x > bounds.getWidth() - inset && y >= l && y <= bounds.getHeight() - inset) {
return EDragGesture.RESIZE_H;
}
if(y > bounds.getHeight() - inset && x >= l && x <= bounds.getWidth() - inset) {
return EDragGesture.RESIZE_V;
}
if(x > bounds.getWidth() - inset && y > bounds.getHeight() - inset) {
return EDragGesture.RESIZE_VH;
}
return EDragGesture.NONE;
return getRectangularShapeDragGesture(node, diagramLocation, getHitAreaStartLinkSize(),
getHitAreaResizeSize());
}
if(node == getVisualShape() || node == text) {
return EDragGesture.MOVE;
......@@ -139,6 +117,35 @@ public abstract class RectangularContentVisualBase extends ContentVisualBase {
return EDragGesture.NONE;
}
/** Computes the {@link EDragGesture} for the rectangular shape case. */
/* package */ static EDragGesture getRectangularShapeDragGesture(Node node,
DiagramCoordinate diagramLocation, double startLinkSize, double resizeAreaSize) {
double x = diagramLocation.getLocalX(node);
double y = diagramLocation.getLocalY(node);
Bounds bounds = node.getBoundsInLocal();
// check for move area
double inset = startLinkSize + resizeAreaSize;
Rectangle2D moveArea = new Rectangle2D(inset, inset, bounds.getWidth() - 2 * inset,
bounds.getHeight() - 2 * inset);
if(moveArea.contains(x, y)) {
return EDragGesture.MOVE;
}
if(x < startLinkSize || y < startLinkSize || x > bounds.getWidth() - startLinkSize ||
y > bounds.getHeight() - startLinkSize) {
return EDragGesture.NEW_LINK;
}
if(x > bounds.getWidth() - inset && y >= startLinkSize && y <= bounds.getHeight() - inset) {
return EDragGesture.RESIZE_H;
}
if(y > bounds.getHeight() - inset && x >= startLinkSize && x <= bounds.getWidth() - inset) {
return EDragGesture.RESIZE_V;
}
if(x > bounds.getWidth() - inset && y > bounds.getHeight() - inset) {
return EDragGesture.RESIZE_VH;
}
return EDragGesture.NONE;
}
/** Returns the visual rectangle shape. */
protected final Rectangle getVisualRectangleShape() {
// wild cast works: see constructor
......
......@@ -10,6 +10,7 @@
package org.fortiss.tooling.common.ui.javafx.lwfxef.visual.rectangular;
import static org.fortiss.tooling.common.ui.javafx.lwfxef.visual.rectangular.RectangularBorderLocation.getClosestLocationOnBounds;
import static org.fortiss.tooling.common.ui.javafx.lwfxef.visual.rectangular.RectangularContentVisualBase.getRectangularShapeDragGesture;
import org.fortiss.tooling.common.ui.javafx.lwfxef.DiagramCoordinate;
import org.fortiss.tooling.common.ui.javafx.lwfxef.DiagramLayers;
......@@ -21,7 +22,6 @@ import org.fortiss.tooling.common.ui.javafx.lwfxef.visual.IContentAnchorageVisua
import org.fortiss.tooling.common.ui.javafx.lwfxef.visual.base.ContentVisualBase;
import javafx.collections.ObservableList;
import javafx.geometry.Bounds;
import javafx.geometry.Dimension2D;
import javafx.geometry.Rectangle2D;
import javafx.geometry.Side;
......@@ -35,6 +35,11 @@ import javafx.scene.shape.PathElement;
/** Base class for {@link ContentVisualBase content visuals} depicted by a rhomboid. */
public abstract class RhomboidContentVisualBase extends ContentVisualBase {
/** The default horizontal offset multiplier. */
private static final double DEFAULT_OFFSET_MULTIPLIER = 3.0;
/** The default corner arc. */
private static final Dimension2D DEFAULT_CORNER_ARC = new Dimension2D(15, 15);
/** Constructor. */
public RhomboidContentVisualBase(IContentMVCBundle mvcb) {
super(mvcb, new Path(), new Path());
......@@ -86,8 +91,7 @@ public abstract class RhomboidContentVisualBase extends ContentVisualBase {
/** Returns the offset of the upper and lower rhomboid line (0 = rectangle). */
public double getOffset() {
// TODO (SB): Magic constant
return 3.0 * getViewer().getFeatures().getHorizontalSpacing();
return DEFAULT_OFFSET_MULTIPLIER * getViewer().getFeatures().getHorizontalSpacing();
}
/** {@inheritDoc} */
......@@ -124,39 +128,15 @@ public abstract class RhomboidContentVisualBase extends ContentVisualBase {
/** Returns the dimensions of the corner arcs. */
protected Dimension2D getCornerArcDimensions() {
// TODO (SB): Magic constant
return new Dimension2D(15, 15);
return DEFAULT_CORNER_ARC;
}
/** {@inheritDoc} */
@Override
protected EDragGesture dragGestureHitTest(Node node, DiagramCoordinate diagramLocation) {
if(node == getHitAreaShape()) {
double x = diagramLocation.getLocalX(node);
double y = diagramLocation.getLocalY(node);
double l = getHitAreaStartLinkSize();
double r = getHitAreaResizeSize();
Bounds bounds = node.getBoundsInLocal();
// check for move area
double inset = l + r;
Rectangle2D moveArea = new Rectangle2D(inset, inset, bounds.getWidth() - 2 * inset,
bounds.getHeight() - 2 * inset);
if(moveArea.contains(x, y)) {
return EDragGesture.MOVE;
}
if(x < l || y < l || x > bounds.getWidth() - l || y > bounds.getHeight() - l) {
return EDragGesture.NEW_LINK;
}
if(x > bounds.getWidth() - inset && y >= l && y <= bounds.getHeight() - inset) {
return EDragGesture.RESIZE_H;
}
if(y > bounds.getHeight() - inset && x >= l && x <= bounds.getWidth() - inset) {
return EDragGesture.RESIZE_V;
}
if(x > bounds.getWidth() - inset && y > bounds.getHeight() - inset) {
return EDragGesture.RESIZE_VH;
}
return EDragGesture.NONE;
return getRectangularShapeDragGesture(node, diagramLocation, getHitAreaStartLinkSize(),
getHitAreaResizeSize());
}
if(node == getVisualShape() || node == text) {
return EDragGesture.MOVE;
......
......@@ -46,6 +46,13 @@
name="Model Elements"
restorable="true">
</view>
<view
class="org.fortiss.tooling.kernel.ui.internal.views.ModelElementsViewFX"
icon="icons/library.png"
id="org.fortiss.tooling.kernel.model.element.view.fx"
name="Model Elements (FX)"
restorable="true">
</view>
<view
allowMultiple="false"
class="org.fortiss.tooling.kernel.ui.internal.introspection.KISSViewPart"
......
......@@ -4,7 +4,7 @@ EObjectActionBase.java 4ef9f8be59e64d4838acc9e268d418ba5d94fa1a GREEN
EReferenceListPropertySectionBase.java 7390dd7bfdc979e8ff0c5c30c67ab7b6c9d70c92 GREEN
EReferencePropertySectionBase.java 0548da6778516003257f59d0b4c2b60d458be3b6 GREEN
EditorBase.java 9c09fff92945256bb8680992ae7bb2c78f47b150 GREEN
FXEditorBase.java 545085c3270f09d69b609f328792e904ebda23ff GREEN
FXEditorBase.java 40caf638c7b4c02da5aece0d9d58883bce630e76 GREEN
IListPropertySection.java 8bb00fe7959583e794ff9437b7a77404c9a9e70f GREEN
LWFXEFEditorBase.java f6b160b700a0287021402b5702beb2bfdce3dc2e GREEN
ModelEditorBindingBase.java b9b1a1c5a48a6e677d1f57ad55a6126d9703c4b5 GREEN
......
......@@ -47,7 +47,6 @@ public abstract class FXEditorBase<T extends EObject> extends EditorBase<T>
FXCanvas canvas = new FXCanvas(parent, SWT.NONE);
Scene scene = new Scene(createSceneRoot());
canvas.setScene(scene);
getSite().setSelectionProvider(this);
}
......
......@@ -5,6 +5,7 @@ LibraryViewDragSourceAdapter.java 56ef61b214ef5d6cb5b751791a92158bda0391ec GREEN
LinkWithEditorPartListener.java c5ab74424378e7b158a805c4dd14fc03c8abeded GREEN
MarkerViewContentProvider.java 4cb1192baebe21bca951c439c163d0c171512515 GREEN
MarkerViewPart.java cbb650271b6877af205421b7cb11f930440a7ef9 GREEN
ModelElementsViewFX.java 5e1b3217eaa69c6d54c4300cdd1c744e36b3495b GREEN
NavigatorNewMenu.java a35e391960d1dacbe7f77982e53e1891e9382d5a GREEN
NavigatorTreeContentComparator.java d9f1354cfdff78b104b28887d2397e5ca0e9755b GREEN
NavigatorTreeContentProvider.java 1fbe97bebf3805cc1af190cecd784fc1cfd12306 GREEN
......
/*-------------------------------------------------------------------------+
| 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.kernel.ui.internal.views;
import static java.util.Arrays.asList;
import static java.util.Collections.emptyList;
import static org.fortiss.tooling.kernel.service.IPrototypeService.PROTOTYPE_DATA_FORMAT;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.filterOutInstanceOf;
import static org.fortiss.tooling.kernel.utils.KernelModelElementUtils.getParentElement;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import java.util.function.Predicate;
import org.conqat.ide.commons.ui.ui.EmptyPartListener;
import org.conqat.lib.commons.collections.IdentityHashSet;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.fx.ui.workbench3.FXViewPart;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPart;
import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeContentProviderBase;
import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeUIProviderBase;
import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeViewer;
import org.fortiss.tooling.kernel.extension.data.LibraryPrototype;
import org.fortiss.tooling.kernel.extension.data.Prototype;
import org.fortiss.tooling.kernel.extension.data.PrototypeCategory;
import org.fortiss.tooling.kernel.model.ILibraryElement;
import org.fortiss.tooling.kernel.service.IPrototypeService;
import org.fortiss.tooling.kernel.ui.extension.base.EditorBase;
import org.fortiss.tooling.kernel.ui.internal.editor.ExtendableMultiPageEditor;
import org.fortiss.tooling.kernel.ui.listener.ExtendableMultiPageEditorPageChangeListener;
import org.fortiss.tooling.kernel.ui.service.IModelElementHandlerService;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.TextField;
import javafx.scene.input.ClipboardContent;
import javafx.scene.layout.BorderPane;
/**
* {@link FXViewPart} for showing composable model elements with DND editing support.
*
* @author hoelzl
*/
public final class ModelElementsViewFX extends FXViewPart {
/** A dummy object serving as hidden root element of the tree view. */
private static final Object DUMMY_ROOT = new Object();
/** The tree-table viewer. */
private DynamicTreeViewer<Object> treeViewer;
/** The filter text field if filtering is enabled in content provider. */
private TextField filterWidget;
/** Current active {@link ExtendableMultiPageEditor}. */
private ExtendableMultiPageEditor activeBindingEditor = null;
/** Stores the editor activation listener. */
private EditorActivationListener editorActivationListener = new EditorActivationListener();
/** The container object used. */
private EObject containerObject = null;
/** The prototypes supported by the current editor. */
private Set<Prototype> supportedBaseClasses = new IdentityHashSet<Prototype>();
/** Listener for reacting to changes of the embedded editor. */
private final ExtendableMultiPageEditorPageChangeListener bindingEditorPageChangeListener =
new ExtendableMultiPageEditorPageChangeListener() {
@Override
public void pageChanged() {
updateEditorFilters(activeBindingEditor.getActiveModelEditor());
}
};
/** {@inheritDoc} */
@Override
protected Scene createFxScene() {
getSite().getWorkbenchWindow().getPartService().addPartListener(editorActivationListener);
BorderPane pane = new BorderPane();
ContentProvider contentProvider = new ContentProvider();
UIProvider uiProvider = new UIProvider();
filterWidget = new TextField();
filterWidget.textProperty().addListener((obs, oVal, nVal) -> {
contentProvider.setFilterExpression(nVal);
treeViewer.update();
});
treeViewer = new DynamicTreeViewer<>(DUMMY_ROOT, false, 2, contentProvider, uiProvider);
pane.setTop(filterWidget);
pane.setCenter(treeViewer.getControl());
return new Scene(pane);
}
/** {@inheritDoc} */
@Override
protected void setFxFocus() {
filterWidget.requestFocus();
}
/** Updates the filters according to the given editor. */
@SuppressWarnings("unchecked")
private void updateEditorFilters(IEditorPart editor) {
supportedBaseClasses.clear();
if(editor instanceof EditorBase &&
((EditorBase<? extends EObject>)editor).enableLibraryView()) {
EditorBase<? extends EObject> editorBase = (EditorBase<? extends EObject>)editor;
containerObject = editorBase.getEditedObject();
for(Class<? extends EObject> clazz : editorBase.getVisibleEObjectTypes()) {
List<Prototype> composablePrototypes =
IPrototypeService.getInstance().getComposablePrototypes(clazz);
if(getParentElement(containerObject, ILibraryElement.class, true) == null) {
supportedBaseClasses.addAll(composablePrototypes);
} else {
supportedBaseClasses.addAll(
filterOutInstanceOf(LibraryPrototype.class, composablePrototypes));
}
}
} else {
containerObject = null;
}
treeViewer.update();
treeViewer.expandAllItems();
}
/** Switches to the given workbench editor part. */
private void switchWorkbenchEditor(IEditorPart editor) {
if(activeBindingEditor != null) {
activeBindingEditor.removeBindingEditorListener(bindingEditorPageChangeListener);
activeBindingEditor = null;
}
if(editor instanceof ExtendableMultiPageEditor) {
activeBindingEditor = (ExtendableMultiPageEditor)editor;
activeBindingEditor.addBindingEditorListener(bindingEditorPageChangeListener);
updateEditorFilters(activeBindingEditor.getActiveModelEditor());
} else if(editor != null) {
updateEditorFilters(editor);
}
}
/** {@link DynamicTreeContentProviderBase} for the library view. */
private class ContentProvider extends DynamicTreeContentProviderBase<Object> {
/** {@inheritDoc} */
@Override
protected Collection<? extends Object> getChildren(Object parent) {
if(parent instanceof PrototypeCategory) {
PrototypeCategory protoCat = (PrototypeCategory)parent;
return asList(protoCat.getChildren());
}
if(parent == DUMMY_ROOT) {
return IPrototypeService.getInstance().getAllTopLevelPrototypesCategories();
}
return emptyList();
}
/** {@inheritDoc} */
@Override
protected boolean filter(Object element, String filterValue) {
if(containerObject == null || supportedBaseClasses.isEmpty()) {
return false;
}
if(element instanceof PrototypeCategory) {
PrototypeCategory protoCat = (PrototypeCategory)element;
for(Object child : protoCat.getChildren()) {
if(filter(child, filterValue)) {
return true;
}
}
return false;
}
if(supportedBaseClasses.contains(element)) {
if(filterValue == null || "".equals(filterValue)) {
return true;
}
if(element instanceof Prototype) {
Prototype proto = (Prototype)element;
return proto.getName().contains(filterValue);
}
}
return false;
}
/** {@inheritDoc} */
@Override
protected Predicate<Object> getFilterPredicate(String filterValue) {
// this override is needed, because super implementation does not
// call filter(Object, String) when filter value is null.
if(filterValue == null || "".equals(filterValue)) {
return (o) -> {
return filter(o, null);
};
}
return super.getFilterPredicate(filterValue);
}
}
/** {@link DynamicTreeUIProviderBase} for the library view. */
private class UIProvider extends DynamicTreeUIProviderBase<Object> {
/** {@inheritDoc} */
@Override
public String getLabel(Object element) {
if(element instanceof Prototype) {
Prototype proto = (Prototype)element;
return proto.getName();
}
if(element instanceof PrototypeCategory) {
PrototypeCategory protoCat = (PrototypeCategory)element;
return protoCat.getName();
}
return element == null ? "" : element.toString();
}
/** {@inheritDoc} */
@Override
public Node getIconNode(Object element) {
if(element instanceof Prototype) {
Prototype proto = (Prototype)element;
EObject eoPrototype = proto.getPrototype();
return IModelElementHandlerService.getInstance().getFXIcon(eoPrototype);
}
if(element instanceof PrototypeCategory) {
PrototypeCategory protoCat = (PrototypeCategory)element;
if(protoCat.getChildren().length > 0) {
return getIconNode(protoCat.getChildren()[0]);
}
}
return null;
}
/** {@inheritDoc} */
@Override
public ClipboardContent getDragClipboardContent(Object element) {
if(element instanceof Prototype) {
Prototype proto = (Prototype)element;
String uid = IPrototypeService.getInstance().getUniquePrototypeID(proto);
if(uid != null) {
ClipboardContent cbContent = new ClipboardContent();
cbContent.put(PROTOTYPE_DATA_FORMAT, uid);
return cbContent;
}
}
return null;
}
}
/** If an editor in a different Project is opened the Model is reinitialized */
private class EditorActivationListener extends EmptyPartListener {
/** Change the tree viewer content whenever workbench part changes. */
@Override
public void partActivated(IWorkbenchPart workbenchPart) {
if(!(workbenchPart instanceof IEditorPart)) {
return;
}
IEditorPart part = (IEditorPart)workbenchPart;
treeViewer.update();
switchWorkbenchEditor(part);
}
}
}
......@@ -4,6 +4,6 @@ IContextMenuService.java cfb6b8237b6cd2b0e461991a9ceb95969f330265 GREEN
IEditPartFactoryService.java c448bff63fb81f57037c9f1dc5319859c12d0c4d GREEN
IMarkerService.java d433e838e387dd2fe61b8dea7395ebb7203ae39b GREEN
IModelEditorBindingService.java ce2ae1957e2232bb0fac1d1d262103f9adfc5266 GREEN
IModelElementHandlerService.java 1ff2bda9054f6bbd4017fc0ddc118b7702196815 GREEN
IModelElementHandlerService.java 748ffd22d6836a5599f8785f023469eb58c80ece GREEN
INavigatorService.java 8d2ffeb6f075d3abea904b84d8a40090d97837fd GREEN
ITutorialUIService.java 72707c60c3d23d8ffc5c579cb9b022bb614eb094 GREEN
......@@ -31,11 +31,14 @@ import javafx.scene.Node;
* @author hoelzl
*/
public interface IModelElementHandlerService {
/** The view ID of the model element library view. */
public static final String MODEL_ELEMENT_LIBRARY_VIEW =
"org.fortiss.tooling.kernel.model.element.library";
/** The view ID of the model element library view. */
public static final String MODEL_ELEMENT_LIBRARY_VIEW_FX =
"org.fortiss.tooling.kernel.model.element.view.fx";
/** Returns the service instance. */
public static IModelElementHandlerService getInstance() {
return ModelElementHandlerService.getInstance();
......
IConnectionCompositor.java 82188750593a08df75a5f21fd91d4b41f72593fd GREEN
IConstraint.java e5e95efa8b06b30d6feffd9a2033e5caa3e710e9 GREEN
IConstraintChecker.java a6d76e332ece919adb990397dd5ef6aaa542ea7d GREEN
IEclipseResourcePostLoadProvider.java e842bb7485ef27917092ffc60af8a57e475d01d6 GREEN
IEclipseResourceStorageLocationProvider.java 0ab7f304d52a9d86f01f66e308e9a7ca420497ba GREEN
......@@ -7,7 +6,7 @@ IElementCompositor.java 5b0ab1732f71b3f8467e0276c844f0dd549e191f GREEN
ILibraryElementHandler.java 00ef5b25c63b8570006e6f6748aed0da1f33a5f1 GREEN
ILogMessageHandler.java 9ab53e836a095ef00fd84ecc0375167edf593b46 GREEN
IMigrationProvider.java 241bfd8594dfb86ce0f89dc95b43662f52d9e450 GREEN
IPrototypeProvider.java d5e3dbae19b5654caf28b81da6b1609d3c12be12 GREEN
IPrototypeProvider.java 5a135f31c5b65a9ebd3432f6d65fd790992b724b GREEN
IStorageProvider.java d9b14cdd254d0c956dc5715c1c4d4d955a705dd5 GREEN
ITransformationProvider.java a4ee2ea08720bb2fce29806062eb01499bb5071e GREEN
ITutorialProvider.java 0f649c7856fc0e13c5dd71e116ee8bf4ba372216 GREEN
......