diff --git a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/controller/.ratings b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/controller/.ratings index bbcdbadc07f5b698c7c00e4401de496664592e4c..8d09ec9d904303d427c821bc22059a729d7e0094 100644 --- a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/controller/.ratings +++ b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/controller/.ratings @@ -1,10 +1,15 @@ -ContextMenuUtil.java 36184cc3f383d294463336a8318c61e98fd7d2d4 YELLOW -EObjectDiagramController.java 9af59e8e586c8251d174108a2ce2fcdee5e75782 YELLOW -EObjectModelChangeProvider.java f4b60cebb088a5c81ca92a41614e1a5d40030502 YELLOW -EObjectRectangularResizableContentControllerBase.java 5e5331f3c16185b3d64a87c3cba43f7155f7ae2f YELLOW -KernelServiceBasedModelChangeProviderBase.java 8d1f8ef79ecd383ff74e5a2bbcf24345aabe70af YELLOW -LayoutModelChangeProvider.java b5449d02eaf39086909720c43e21bd061005fc9e YELLOW -LayoutedContentAnchorageController.java 73b103c06edcbf1762654e71a3e524f43c0c50c0 YELLOW -LayoutedDiagramAnchorageController.java 32d7d77daf252d021458c39ebcfe502f26f29a98 YELLOW -LayoutedLinkBendPointController.java 6d5de856f513ca82eab805a0ad9cda8194be011d YELLOW -LayoutedRectangularResizableContentController.java 3232d423572924363702898cf8ba240ce7042b65 YELLOW +ContextMenuUtil.java 405387151d45b09dffb3b6ba44f980313c8edcaf GREEN +CurvedLinkLayoutedContentAnchorangeController.java 67c20e31ddb82fe2fd499117193353b0545839a0 GREEN +EObjectDiagramController.java 9af59e8e586c8251d174108a2ce2fcdee5e75782 GREEN +EObjectEllipticResizableContentControllerBase.java 3494d4f0dcdff5eb35f22f0e21d04df81b32e494 GREEN +EObjectModelChangeProvider.java f4b60cebb088a5c81ca92a41614e1a5d40030502 GREEN +EObjectRectangularResizableContentControllerBase.java f4a967591a60fadb20550ec3eaabccf240c9ec0d YELLOW +KernelServiceBasedModelChangeProviderBase.java 8d1f8ef79ecd383ff74e5a2bbcf24345aabe70af GREEN +LayoutModelChangeProvider.java b5449d02eaf39086909720c43e21bd061005fc9e GREEN +LayoutedContentAnchorageController.java 9fc513a7404277514c730f7702d45588f2d81878 GREEN +LayoutedCurveLinkBendPointController.java 54d7c294c4afaeadb6787408fbfe2ca1958c2de0 GREEN +LayoutedDiagramAnchorageController.java 32d7d77daf252d021458c39ebcfe502f26f29a98 GREEN +LayoutedEllipticResizableContentController.java 93bdeb7ecd5f7386724a9d7df5fff3174ab8ce10 GREEN +LayoutedLineLinkBendPointController.java f5fac4fe8e4b4c0259407acb6bfc80dbe9c3a1fb GREEN +LayoutedLinkBendPointController.java 3203d946de233274934dca1bcd47bbdc1d0a3b13 GREEN +LayoutedRectangularResizableContentController.java 3232d423572924363702898cf8ba240ce7042b65 GREEN diff --git a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/controller/ContextMenuUtil.java b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/controller/ContextMenuUtil.java index 36184cc3f383d294463336a8318c61e98fd7d2d4..405387151d45b09dffb3b6ba44f980313c8edcaf 100644 --- a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/controller/ContextMenuUtil.java +++ b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/controller/ContextMenuUtil.java @@ -39,7 +39,7 @@ import javafx.scene.control.MenuItem; * * @author hoelzl */ -final class ContextMenuUtil { +public final class ContextMenuUtil { /** Creates the menu populated with composable prototypes. */ public static List<MenuItem> createPrototypeMenu(EObject target, IElementCompositionContext context) { diff --git a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/controller/CurvedLinkLayoutedContentAnchorangeController.java b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/controller/CurvedLinkLayoutedContentAnchorangeController.java new file mode 100644 index 0000000000000000000000000000000000000000..67c20e31ddb82fe2fd499117193353b0545839a0 --- /dev/null +++ b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/controller/CurvedLinkLayoutedContentAnchorangeController.java @@ -0,0 +1,76 @@ +/*-------------------------------------------------------------------------+ +| 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.utils.LayoutDataUIUtils.addConnectionPoint; + +import org.fortiss.tooling.base.model.base.EntryConnectorBase; +import org.fortiss.tooling.base.model.base.ExitConnectorBase; +import org.fortiss.tooling.base.model.element.IConnection; +import org.fortiss.tooling.base.model.element.IConnector; +import org.fortiss.tooling.base.model.layout.ILayoutedModelElement; +import org.fortiss.tooling.common.ui.javafx.lwfxef.DiagramCoordinate; +import org.fortiss.tooling.common.ui.javafx.lwfxef.controller.base.DelegatingContentAnchorageController; +import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.IContentAnchorageMVCBundle; +import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.IMVCBundle; + +/** + * {@link DelegatingContentAnchorageController} for diagrams with curved links. + * + * @author munaro + */ +public class CurvedLinkLayoutedContentAnchorangeController<T extends IConnector & ILayoutedModelElement> + extends LayoutedContentAnchorageController<T> { + + /** Constructor. */ + public CurvedLinkLayoutedContentAnchorangeController(IContentAnchorageMVCBundle mvcb, + Class<T> modelType) { + super(mvcb, modelType); + } + + /** {@inheritDoc} */ + @SuppressWarnings("unchecked") + @Override + protected void link(IMVCBundle startBundle, DiagramCoordinate startLocation, + IMVCBundle endBundle, DiagramCoordinate endLocation) { + super.link(startBundle, startLocation, endBundle, endLocation); + + // Fetch newly created connection by comparing incoming and outgoing connections of the + // given connectors. As only one connection is allowed between a pair of connectors, this + // 'findFirst' is safe. + T startConnector = (T)(startBundle.getModel() instanceof ExitConnectorBase + ? startBundle.getModel() : endBundle.getModel()); + T endConnector = (T)(endBundle.getModel() instanceof EntryConnectorBase + ? endBundle.getModel() : startBundle.getModel()); + IConnection connection = startConnector.getOutgoing().stream() + .filter(segment -> endConnector.getIncoming().contains(segment)).findFirst().get(); + + // Create handles + DiagramCoordinate startPosition = + new DiagramCoordinate(startBundle.getVisual().getCurrentBounds().getMaxX(), + startBundle.getVisual().getCurrentBounds().getMaxY()); + DiagramCoordinate endPosition = + new DiagramCoordinate(endBundle.getVisual().getCurrentBounds().getMaxX(), + endBundle.getVisual().getCurrentBounds().getMaxY()); + DiagramCoordinate middle = + new DiagramCoordinate((startPosition.getX() + endPosition.getX()) / 2, + (startPosition.getY() + endPosition.getY()) / 2); + addConnectionPoint((ILayoutedModelElement)connection, 0, (int)middle.getX(), + (int)middle.getY()); + addConnectionPoint((ILayoutedModelElement)connection, 1, (int)middle.getX(), + (int)middle.getY()); + } +} diff --git a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/controller/EObjectEllipticResizableContentControllerBase.java b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/controller/EObjectEllipticResizableContentControllerBase.java new file mode 100644 index 0000000000000000000000000000000000000000..3494d4f0dcdff5eb35f22f0e21d04df81b32e494 --- /dev/null +++ b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/controller/EObjectEllipticResizableContentControllerBase.java @@ -0,0 +1,151 @@ +/******************************************************************************* + * Copyright (c) 2017, 2018 fortiss GmbH. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v2.0 which is available at + * http://www.eclipse.org/legal/epl-v20.html + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Florian Hoelzl (fortiss GmbH) - initial implementation + * + *******************************************************************************/ +package org.fortiss.tooling.base.ui.editor.fx.controller; + +import static java.lang.Math.max; +import static java.util.Objects.requireNonNull; +import static org.fortiss.tooling.base.ui.editor.fx.controller.ContextMenuUtil.createElementCompositionContext; +import static org.fortiss.tooling.base.ui.editor.fx.controller.ContextMenuUtil.createPrototypeMenu; + +import java.util.List; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.ecore.EObject; +import org.fortiss.tooling.base.model.element.ElementPackage; +import org.fortiss.tooling.base.model.layout.ILayoutedModelElement; +import org.fortiss.tooling.common.ui.javafx.lwfxef.DiagramCoordinate; +import org.fortiss.tooling.common.ui.javafx.lwfxef.DiagramViewerFeatures; +import org.fortiss.tooling.common.ui.javafx.lwfxef.change.Change; +import org.fortiss.tooling.common.ui.javafx.lwfxef.controller.IClickController; +import org.fortiss.tooling.common.ui.javafx.lwfxef.controller.base.ClickControllerBase; +import org.fortiss.tooling.common.ui.javafx.lwfxef.controller.elliptic.EllipticResizableContentControllerBase; +import org.fortiss.tooling.common.ui.javafx.lwfxef.model.IModelChangeProvider; +import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.IContentMVCBundle; +import org.fortiss.tooling.kernel.extension.data.IElementCompositionContext; +import org.fortiss.tooling.kernel.service.IElementCompositorService; +import org.fortiss.tooling.kernel.ui.extension.IModelElementHandler; +import org.fortiss.tooling.kernel.ui.service.IModelEditorBindingService; +import org.fortiss.tooling.kernel.ui.service.IModelElementHandlerService; + +import javafx.scene.Node; +import javafx.scene.control.MenuItem; +import javafx.scene.input.MouseEvent; + +/** + * {@link EllipticResizableContentControllerBase} with a listener mechanism for the layout of the + * connected {@link EObject model element}. + * + * @author hoelzl + */ +public abstract class EObjectEllipticResizableContentControllerBase<T extends EObject> + extends EllipticResizableContentControllerBase { + /** {@link IModelChangeProvider} for this controller */ + private final LayoutModelChangeProvider layoutModelChangeProvider; + /** The click controller handling double-click to open editor. */ + private final IClickController openEditorDoubleClickController = new ClickControllerBase() { + @Override + public Change singleClick(MouseEvent event, Node node, DiagramCoordinate diagramLocation) { + return EObjectEllipticResizableContentControllerBase.super.getClickController(node, + diagramLocation).singleClick(event, node, diagramLocation); + } + + @Override + public Change secondaryClick(MouseEvent event, Node node, + DiagramCoordinate diagramLocation) { + return EObjectEllipticResizableContentControllerBase.super.getClickController(node, + diagramLocation).secondaryClick(event, node, diagramLocation); + } + + @Override + public Change doubleClick(MouseEvent event, Node node, DiagramCoordinate diagramLocation) { + EObject eo = getModelElement(); + IModelElementHandler<EObject> handler = + IModelElementHandlerService.getInstance().getModelElementHandler(eo); + if(handler != null) { + eo = handler.handleOpenModelElementRequest(eo); + } + IModelEditorBindingService.getInstance().openInEditor(eo); + return null; // no changes to model + } + }; + + /** Constructor. */ + public EObjectEllipticResizableContentControllerBase(IContentMVCBundle mvcb, + Class<T> modelType) { + super(mvcb); + + Object model = requireNonNull(mvcb.getModel(), "The given model is null!"); + if(!modelType.isAssignableFrom(model.getClass())) { + throw new IllegalArgumentException("Expected model of type " + + modelType.getSimpleName() + ", but was " + model.getClass().getSimpleName()); + } + + ILayoutedModelElement lme = (ILayoutedModelElement)mvcb.getModel(); + this.layoutModelChangeProvider = new LayoutModelChangeProvider(lme) { + /** {@inheritDoc} */ + @Override + protected boolean acceptNotification(Notification notification) { + if(notification.getNotifier() != getModelElement()) { + return false; + } + return isAnchorageFeature(notification.getFeature()); + } + }; + } + + /** Returns the correctly casted model element. */ + @SuppressWarnings("unchecked") + protected T getModelElement() { + // wild cast works: see constructor check with exception + return (T)getModel(); + } + + /** {@inheritDoc} */ + @Override + public IModelChangeProvider getModelChangeProvider() { + return layoutModelChangeProvider; + } + + /** {@inheritDoc} */ + @Override + public List<MenuItem> contextMenuContributions(Node node, DiagramCoordinate diagramLocation) { + // outer-most grid areas of the diagram are inaccessible + DiagramViewerFeatures features = getViewer().getFeatures(); + double x = max(features.getHorizontalSpacing(), diagramLocation.getX()); + double y = max(features.getVerticalSpacing(), diagramLocation.getY()); + + // wild cast works: see constructor exception + EObject modelParent = (EObject)getModel(); + IElementCompositionContext edc = createElementCompositionContext(modelParent, x, y, false, + getViewer().getFeatures().getCurrentZoomFactor()); + return createPrototypeMenu(modelParent, edc); + } + + /** {@inheritDoc} */ + @Override + public void delete() { + IElementCompositorService.getInstance().decompose(getModelElement()); + } + + /** Checks whether the given feature corresponds to an anchorage model element. */ + protected boolean isAnchorageFeature(Object feature) { + return feature == ElementPackage.Literals.IHIERARCHIC_ELEMENT__CONNECTORS; + } + + /** {@inheritDoc} */ + @Override + public IClickController getClickController(Node node, DiagramCoordinate diagramLocation) { + return openEditorDoubleClickController; + } +} diff --git a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/controller/LayoutedContentAnchorageController.java b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/controller/LayoutedContentAnchorageController.java index 73b103c06edcbf1762654e71a3e524f43c0c50c0..9fc513a7404277514c730f7702d45588f2d81878 100644 --- a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/controller/LayoutedContentAnchorageController.java +++ b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/controller/LayoutedContentAnchorageController.java @@ -30,8 +30,7 @@ import org.fortiss.tooling.kernel.service.IConnectionCompositorService; import org.fortiss.tooling.kernel.service.IElementCompositorService; /** - * {@link DelegatingContentAnchorageController} for - * {@link org.fortiss.tooling.base.model.layout.ILayoutedModelElement}s. + * {@link DelegatingContentAnchorageController} for {@link ILayoutedModelElement}s. * * @author hoelzl */ diff --git a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/controller/LayoutedCurveLinkBendPointController.java b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/controller/LayoutedCurveLinkBendPointController.java new file mode 100644 index 0000000000000000000000000000000000000000..54d7c294c4afaeadb6787408fbfe2ca1958c2de0 --- /dev/null +++ b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/controller/LayoutedCurveLinkBendPointController.java @@ -0,0 +1,111 @@ +/*-------------------------------------------------------------------------+ +| 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 java.util.Arrays.asList; +import static org.fortiss.tooling.base.utils.LayoutModelElementFactory.createPoint; +import static org.fortiss.tooling.common.ui.javafx.lwfxef.FeedbackChange.locationFeedbackChange; + +import org.fortiss.tooling.base.model.layout.ILayoutedModelElement; +import org.fortiss.tooling.base.model.layout.Point; +import org.fortiss.tooling.common.ui.javafx.lwfxef.DiagramCoordinate; +import org.fortiss.tooling.common.ui.javafx.lwfxef.DiagramViewer; +import org.fortiss.tooling.common.ui.javafx.lwfxef.DiagramViewerFeatures; +import org.fortiss.tooling.common.ui.javafx.lwfxef.FeedbackChange; +import org.fortiss.tooling.common.ui.javafx.lwfxef.controller.IController; +import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.ILinkMVCBundle; +import org.fortiss.tooling.common.ui.javafx.lwfxef.visual.ILinkVisual; + +import javafx.geometry.Point2D; + +/** + * {@link IController} for {@link ILayoutedModelElement}s representing curved links and connections + * in a {@link DiagramViewer}. + * + * @author munaro + */ +public class LayoutedCurveLinkBendPointController<T extends ILayoutedModelElement> + extends LayoutedLinkBendPointController<T> { + + /** Constructor. */ + public LayoutedCurveLinkBendPointController(ILinkMVCBundle mvcb, Class<T> modelType) { + super(mvcb, modelType); + } + + /** {@inheritDoc} */ + @Override + protected final void createBendPointAt(int bpIndex, DiagramCoordinate location) { + DiagramViewerFeatures features = getViewer().getFeatures(); + Point c2 = createPoint((int)(location.getX() - 2 * features.getHorizontalSpacing()), + (int)location.getY(), null); + Point c1 = createPoint((int)(location.getX() + 2 * features.getHorizontalSpacing()), + (int)location.getY(), null); + Point bp = createPoint((int)location.getX(), (int)location.getY(), null); + getBendPointList(getModelElement()).addAll(bpIndex - 1, asList(c2, bp, c1)); + } + + /** {@inheritDoc} */ + @Override + protected final void moveBendPointVisually(int bpIndex, Point2D delta) { + super.moveBendPointVisually(bpIndex, delta); + if(bpIndex <= 0 || bpIndex >= getNumerOfBendPoints() - 1) { + // first and last bend-point move unconnected + return; + } + ILinkVisual linkVisual = getLinkVisual(); + FeedbackChange centerPointChange = getMoveDeltaFeedback(bpIndex, delta); + int indexMod3 = bpIndex % 3; + if(indexMod3 == 2) { + // bend-points between curve segments also drag the previous and next point + linkVisual.setFeedbackChangeForBendPoint(bpIndex - 1, centerPointChange); + linkVisual.setFeedbackChangeForBendPoint(bpIndex + 1, centerPointChange); + } else { + // otherwise the connected bend-point is moved in the opposite direction + FeedbackChange inv = locationFeedbackChange(-centerPointChange.getDeltaX(), + -centerPointChange.getDeltaY()); + int otherIndex = (indexMod3 == 1) ? bpIndex + 2 : bpIndex - 2; + linkVisual.setFeedbackChangeForBendPoint(otherIndex, inv); + } + // linkVisual.update(); + return; + } + + /** {@inheritDoc} */ + @Override + protected final void moveBendPointInModel(int bpIndex, Point2D delta) { + FeedbackChange chg = getMoveDeltaFeedback(bpIndex, delta); + getLinkVisual().setFeedbackChangeForBendPoint(bpIndex, null); + updateModelAfterBendPointMove(bpIndex, chg.getDeltaX(), chg.getDeltaY()); + if(bpIndex <= 0 || bpIndex >= getNumerOfBendPoints() - 1) { + // first and last bend-point move unconnected + return; + } + ILinkVisual linkVisual = getLinkVisual(); + int indexMod3 = bpIndex % 3; + if(indexMod3 == 2) { + // bend-points between curve segments also drag the previous and next point + linkVisual.setFeedbackChangeForBendPoint(bpIndex - 1, null); + updateModelAfterBendPointMove(bpIndex - 1, chg.getDeltaX(), chg.getDeltaY()); + linkVisual.setFeedbackChangeForBendPoint(bpIndex + 1, null); + updateModelAfterBendPointMove(bpIndex + 1, chg.getDeltaX(), chg.getDeltaY()); + } else { + // otherwise the connected bend-point is moved in the opposite direction + int otherIndex = (indexMod3 == 1) ? bpIndex + 2 : bpIndex - 2; + linkVisual.setFeedbackChangeForBendPoint(otherIndex, null); + updateModelAfterBendPointMove(otherIndex, -chg.getDeltaX(), -chg.getDeltaY()); + } + } +} diff --git a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/controller/LayoutedEllipticResizableContentController.java b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/controller/LayoutedEllipticResizableContentController.java new file mode 100644 index 0000000000000000000000000000000000000000..93bdeb7ecd5f7386724a9d7df5fff3174ab8ce10 --- /dev/null +++ b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/controller/LayoutedEllipticResizableContentController.java @@ -0,0 +1,84 @@ +/*-------------------------------------------------------------------------+ +| 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 java.lang.Math.toRadians; +import static java.util.Objects.requireNonNull; +import static org.fortiss.tooling.base.ui.utils.LayoutDataUIUtils.setConnectorAngle; +import static org.fortiss.tooling.base.utils.LayoutDataUtils.getNodeSize; +import static org.fortiss.tooling.base.utils.LayoutDataUtils.moveNode; +import static org.fortiss.tooling.base.utils.LayoutDataUtils.setNodeSize; + +import org.fortiss.tooling.base.model.element.IConnector; +import org.fortiss.tooling.base.model.layout.Dimension; +import org.fortiss.tooling.base.model.layout.ILayoutedModelElement; +import org.fortiss.tooling.common.ui.javafx.lwfxef.FeedbackChange; +import org.fortiss.tooling.common.ui.javafx.lwfxef.controller.IController; +import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.IContentAnchorageMVCBundle; +import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.IContentMVCBundle; + +/** + * {@link IController} for {@link ILayoutedModelElement}s that have a elliptical shape. + * + * @author munaro + */ +public class LayoutedEllipticResizableContentController<T extends ILayoutedModelElement> + extends EObjectEllipticResizableContentControllerBase<T> { + + /** Constructor */ + public LayoutedEllipticResizableContentController(IContentMVCBundle mvcb, Class<T> modelType) { + super(mvcb, modelType); + + Object model = requireNonNull(mvcb.getModel(), "The given model is null!"); + if(!modelType.isAssignableFrom(model.getClass())) { + throw new IllegalArgumentException("Expected model of type " + + modelType.getSimpleName() + ", but was " + model.getClass().getSimpleName()); + } + } + + /** {@inheritDoc} */ + @Override + protected void moveAnchorageToAngle(IContentAnchorageMVCBundle anchorage, + double angleInDegree) { + Object connObj = anchorage.getModel(); + if(connObj instanceof IConnector && connObj instanceof ILayoutedModelElement) { + ILayoutedModelElement conn = (ILayoutedModelElement)connObj; + setConnectorAngle(conn, toRadians(angleInDegree)); + } + } + + /** {@inheritDoc} */ + @Override + protected void move(FeedbackChange deltaChange) { + moveNode(getModelElement(), (int)deltaChange.getDeltaX(), (int)deltaChange.getDeltaY()); + } + + /** {@inheritDoc} */ + @Override + protected boolean allowLink() { + return false; + } + + /** {@inheritDoc} */ + @Override + protected void resize(FeedbackChange delta) { + T element = getModelElement(); + Dimension d = getNodeSize(element); + int w = d.getWidth() + (int)delta.getDeltaW(); + int h = d.getHeight() + (int)delta.getDeltaH(); + setNodeSize(element, w, h); + } +} diff --git a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/controller/LayoutedLineLinkBendPointController.java b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/controller/LayoutedLineLinkBendPointController.java new file mode 100644 index 0000000000000000000000000000000000000000..f5fac4fe8e4b4c0259407acb6bfc80dbe9c3a1fb --- /dev/null +++ b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/controller/LayoutedLineLinkBendPointController.java @@ -0,0 +1,45 @@ +/******************************************************************************* + * Copyright (c) 2017, 2018 fortiss GmbH. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v2.0 which is available at + * http://www.eclipse.org/legal/epl-v20.html + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Florian Hoelzl (fortiss GmbH) - initial implementation + * + *******************************************************************************/ +package org.fortiss.tooling.base.ui.editor.fx.controller; + +import static org.fortiss.tooling.base.ui.utils.LayoutDataUIUtils.addConnectionPoint; + +import org.fortiss.tooling.base.model.layout.ILayoutedModelElement; +import org.fortiss.tooling.common.ui.javafx.lwfxef.DiagramCoordinate; +import org.fortiss.tooling.common.ui.javafx.lwfxef.DiagramViewer; +import org.fortiss.tooling.common.ui.javafx.lwfxef.controller.IController; +import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.ILinkMVCBundle; + +/** + * {@link IController} for {@link ILayoutedModelElement}s representing straight links and + * connections in a {@link DiagramViewer}. + * + * @author hoelzl + */ +public class LayoutedLineLinkBendPointController<T extends ILayoutedModelElement> + extends LayoutedLinkBendPointController<T> { + + /** Constructor. */ + public LayoutedLineLinkBendPointController(ILinkMVCBundle mvcb, Class<T> modelType) { + super(mvcb, modelType); + } + + /** {@inheritDoc} */ + @Override + protected void createBendPointAt(int bpIndex, DiagramCoordinate location) { + int x = (int)location.getX(); + int y = (int)location.getY(); + addConnectionPoint(getModelElement(), bpIndex, x, y); + } +} diff --git a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/controller/LayoutedLinkBendPointController.java b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/controller/LayoutedLinkBendPointController.java index 6d5de856f513ca82eab805a0ad9cda8194be011d..3203d946de233274934dca1bcd47bbdc1d0a3b13 100644 --- a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/controller/LayoutedLinkBendPointController.java +++ b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/controller/LayoutedLinkBendPointController.java @@ -1,47 +1,59 @@ -/******************************************************************************* - * Copyright (c) 2017, 2018 fortiss GmbH. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v2.0 which is available at - * http://www.eclipse.org/legal/epl-v20.html - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Florian Hoelzl (fortiss GmbH) - initial implementation - * - *******************************************************************************/ +/*-------------------------------------------------------------------------+ +| 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 java.util.Objects.requireNonNull; -import static org.fortiss.tooling.base.ui.utils.LayoutDataUIUtils.addConnectionPoint; import static org.fortiss.tooling.base.ui.utils.LayoutDataUIUtils.getConnectionPoints; import static org.fortiss.tooling.base.ui.utils.LayoutDataUIUtils.removeConnectionPoint; import java.util.List; import org.eclipse.emf.common.util.EList; -import org.fortiss.tooling.common.ui.javafx.lwfxef.DiagramCoordinate; +import org.fortiss.tooling.base.model.layout.ILayoutedModelElement; +import org.fortiss.tooling.base.model.layout.Point; import org.fortiss.tooling.common.ui.javafx.lwfxef.DiagramViewer; import org.fortiss.tooling.common.ui.javafx.lwfxef.controller.IController; import org.fortiss.tooling.common.ui.javafx.lwfxef.controller.base.LinkControllerBase; import org.fortiss.tooling.common.ui.javafx.lwfxef.model.IModelChangeProvider; import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.ILinkMVCBundle; import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.IMVCBundle; -import org.fortiss.tooling.base.model.layout.ILayoutedModelElement; -import org.fortiss.tooling.base.model.layout.Point; import org.fortiss.tooling.kernel.service.IConnectionCompositorService; /** - * {@link IController} for {@link ILayoutedModelElement}s representing links and connections in a - * {@link DiagramViewer}. + * Base class for {@link IController}s for {@link ILayoutedModelElement}s representing links and + * connections in a {@link DiagramViewer}. * - * @author hoelzl + * @author munaro */ -public class LayoutedLinkBendPointController<T extends ILayoutedModelElement> +public abstract class LayoutedLinkBendPointController<T extends ILayoutedModelElement> extends LinkControllerBase { /** {@link IModelChangeProvider} for this controller */ - private final LayoutModelChangeProvider layoutModelChangeProvider; + protected final LayoutModelChangeProvider layoutModelChangeProvider; + + /** Returns the model element. */ + @SuppressWarnings("unchecked") + public T getModelElement() { + return (T)getModel(); + } + + /** {@inheritDoc} */ + @Override + public IModelChangeProvider getModelChangeProvider() { + return layoutModelChangeProvider; + } /** Constructor. */ public LayoutedLinkBendPointController(ILinkMVCBundle mvcb, Class<T> modelType) { @@ -57,10 +69,10 @@ public class LayoutedLinkBendPointController<T extends ILayoutedModelElement> this.layoutModelChangeProvider = new LayoutModelChangeProvider(lme); } - /** Returns the model element. */ - @SuppressWarnings("unchecked") - public T getModelElement() { - return (T)getModel(); + /** {@inheritDoc} */ + @Override + public void delete() { + deleteLink(); } /** {@inheritDoc} */ @@ -79,27 +91,8 @@ public class LayoutedLinkBendPointController<T extends ILayoutedModelElement> /** {@inheritDoc} */ @Override - public IModelChangeProvider getModelChangeProvider() { - return layoutModelChangeProvider; - } - - /** {@inheritDoc} */ - @Override - protected int getNumerOfBendPoints() { - return getBendPointList(getModelElement()).size(); - } - - /** Returns the list of bend-points. */ - private EList<Point> getBendPointList(ILayoutedModelElement modelElement) { - return getConnectionPoints(modelElement).getPoints(); - } - - /** {@inheritDoc} */ - @Override - protected void createBendPointAt(int bpIndex, DiagramCoordinate location) { - int x = (int)location.getX(); - int y = (int)location.getY(); - addConnectionPoint(getModelElement(), bpIndex, x, y); + protected void deleteBendPoint(int bpIndex) { + removeConnectionPoint(getModelElement(), bpIndex); } /** {@inheritDoc} */ @@ -117,8 +110,8 @@ public class LayoutedLinkBendPointController<T extends ILayoutedModelElement> /** {@inheritDoc} */ @Override - protected void deleteBendPoint(int bpIndex) { - removeConnectionPoint(getModelElement(), bpIndex); + protected void deleteLink() { + IConnectionCompositorService.getInstance().disconnect(getModelElement()); } /** {@inheritDoc} */ @@ -128,15 +121,14 @@ public class LayoutedLinkBendPointController<T extends ILayoutedModelElement> // ignored } - /** {@inheritDoc} */ - @Override - protected void deleteLink() { - IConnectionCompositorService.getInstance().disconnect(getModelElement()); + /** Returns the list of bend-points. */ + protected EList<Point> getBendPointList(ILayoutedModelElement modelElement) { + return getConnectionPoints(modelElement).getPoints(); } /** {@inheritDoc} */ @Override - public void delete() { - deleteLink(); + protected int getNumerOfBendPoints() { + return getBendPointList(getModelElement()).size(); } } diff --git a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/model/.ratings b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/model/.ratings index e486bea097082450923a8577024abfdd76030929..c383bdc481a671fd2afae32b91f7634ba932a2a2 100644 --- a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/model/.ratings +++ b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/model/.ratings @@ -1 +1 @@ -HierarchicElementModelFactoryBase.java 10741fec431df8c05038e73b6b40ba9c7c35fa57 YELLOW +HierarchicElementModelFactoryBase.java 10741fec431df8c05038e73b6b40ba9c7c35fa57 GREEN diff --git a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/visual/.ratings b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/visual/.ratings index a7dd2ab254be3d36a5e8d5b555f759f9f3f9568e..ae3ce00b4dfec253e3adc2a33e0b985e930fce56 100644 --- a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/visual/.ratings +++ b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/visual/.ratings @@ -1,9 +1,13 @@ -CoordinateCorrections.java 018bf229e5686afcb8540b61dd9d05b6e4a23e93 YELLOW -LayoutedCircularAnchorageContentVisualBase.java dba8ae04ecd5813aae9b29eaccea520caa3cf237 YELLOW -LayoutedCircularAnchorageDiagramVisualBase.java 7634416bcb88a014d985143bf00a8d29ff1e3ff5 YELLOW -LayoutedLineLinkVisual.java ff1291c57d4ce111d5543d7381a616cd2e096290 YELLOW -LayoutedRectangularContentVisualBase.java 61698ffd771ee2ad798025df8195d1bc09c2c765 YELLOW -NamedLayoutedCircularAnchorageContentVisual.java bf06ac6e93d78e98b0359e0f879dccaefc920aa0 YELLOW -NamedLayoutedCircularAnchorageDiagramVisual.java 53b9d739587d658f65dc03517257d6e29f4ba1fa YELLOW -NamedLayoutedLineLinkVisual.java 60f5d21f0723dc5d08b2ad43bc6361fca83a16aa YELLOW -NamedLayoutedRectangularContentVisual.java 8cdc55b306c1db60074fa8c5c240f95d892e1e32 YELLOW +CoordinateCorrections.java 018bf229e5686afcb8540b61dd9d05b6e4a23e93 GREEN +LayoutedCircularAnchorageContentVisualBase.java cd85ff478e9b8e6b6d6f6c75cc5bf61522a63f3e GREEN +LayoutedCircularAnchorageDiagramVisualBase.java 7634416bcb88a014d985143bf00a8d29ff1e3ff5 GREEN +LayoutedCurveLinkVisual.java 5b06cd7e80eaf7cf6af37a4769eaafe2a1e591f3 GREEN +LayoutedEllipticContentVisualBase.java 6f3daf386d5120793b90ce4569dd9bea33dd2a0f GREEN +LayoutedLineLinkVisual.java 5fc26086e2f63afee403379ba8f09f5113d4c025 GREEN +LayoutedRectangularContentVisualBase.java 61698ffd771ee2ad798025df8195d1bc09c2c765 GREEN +NamedLayoutedCircularAnchorageContentVisual.java bf06ac6e93d78e98b0359e0f879dccaefc920aa0 GREEN +NamedLayoutedCircularAnchorageDiagramVisual.java 53b9d739587d658f65dc03517257d6e29f4ba1fa GREEN +NamedLayoutedCurveLinkVisual.java 7945b2f550d5e4804f44891294ee60cc8ffcbf1e GREEN +NamedLayoutedEllipticContentVisual.java f96a956c2f71b675eee56cfc613684397545da68 GREEN +NamedLayoutedLineLinkVisual.java 4fc48616000516dc90ba22b7069ffdabadc9c377 GREEN +NamedLayoutedRectangularContentVisual.java 8cdc55b306c1db60074fa8c5c240f95d892e1e32 GREEN diff --git a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/visual/LayoutedCircularAnchorageContentVisualBase.java b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/visual/LayoutedCircularAnchorageContentVisualBase.java index dba8ae04ecd5813aae9b29eaccea520caa3cf237..cd85ff478e9b8e6b6d6f6c75cc5bf61522a63f3e 100644 --- a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/visual/LayoutedCircularAnchorageContentVisualBase.java +++ b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/visual/LayoutedCircularAnchorageContentVisualBase.java @@ -15,23 +15,26 @@ +--------------------------------------------------------------------------*/ package org.fortiss.tooling.base.ui.editor.fx.visual; +import static java.lang.Math.toDegrees; import static javafx.scene.paint.Color.BLACK; import static javafx.scene.paint.Color.rgb; -import static org.fortiss.tooling.common.ui.javafx.lwfxef.DiagramViewerDefaultTags.LINK_TARGET_ALLOWED_TAG; -import static org.fortiss.tooling.common.ui.javafx.lwfxef.DiagramViewerDefaultTags.LINK_TARGET_DENIED_TAG; import static org.fortiss.tooling.base.ui.editor.fx.visual.CoordinateCorrections.ANCHOR_DIMENSION; import static org.fortiss.tooling.base.ui.editor.fx.visual.CoordinateCorrections.ANCHOR_INSET; import static org.fortiss.tooling.base.ui.utils.LWFXEditorUtils.convertEOrientationToSide; +import static org.fortiss.tooling.base.ui.utils.LayoutDataUIUtils.getConnectorAngleAsDouble; import static org.fortiss.tooling.base.ui.utils.LayoutDataUIUtils.getConnectorOffsetOrientation; +import static org.fortiss.tooling.common.ui.javafx.lwfxef.DiagramViewerDefaultTags.LINK_TARGET_ALLOWED_TAG; +import static org.fortiss.tooling.common.ui.javafx.lwfxef.DiagramViewerDefaultTags.LINK_TARGET_DENIED_TAG; +import org.fortiss.tooling.base.model.layout.EOrientation; +import org.fortiss.tooling.base.model.layout.ILayoutedModelElement; +import org.fortiss.tooling.base.model.layout.OffsetOrientation; +import org.fortiss.tooling.common.ui.javafx.lwfxef.model.layout.IAngleLayout; import org.fortiss.tooling.common.ui.javafx.lwfxef.model.layout.ILayout; import org.fortiss.tooling.common.ui.javafx.lwfxef.model.layout.IOffsetLayout; import org.fortiss.tooling.common.ui.javafx.lwfxef.model.layout.ISideLayout; import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.IContentAnchorageMVCBundle; import org.fortiss.tooling.common.ui.javafx.lwfxef.visual.elliptic.CircularContentAnchorageVisualBase; -import org.fortiss.tooling.base.model.layout.EOrientation; -import org.fortiss.tooling.base.model.layout.ILayoutedModelElement; -import org.fortiss.tooling.base.model.layout.OffsetOrientation; import javafx.geometry.Dimension2D; import javafx.geometry.Point2D; @@ -47,7 +50,8 @@ import javafx.scene.paint.Paint; * @author munaro */ public abstract class LayoutedCircularAnchorageContentVisualBase<T extends ILayoutedModelElement> - extends CircularContentAnchorageVisualBase implements ISideLayout, IOffsetLayout { + extends CircularContentAnchorageVisualBase + implements ISideLayout, IOffsetLayout, IAngleLayout { /** Constructor. */ public LayoutedCircularAnchorageContentVisualBase(IContentAnchorageMVCBundle mvcb, @@ -149,4 +153,10 @@ public abstract class LayoutedCircularAnchorageContentVisualBase<T extends ILayo } return super.getInteractionColor(); } + + /** {@inheritDoc} */ + @Override + public double getAngleInDegree() { + return toDegrees(getConnectorAngleAsDouble(getModelElement())); + } } diff --git a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/visual/LayoutedCurveLinkVisual.java b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/visual/LayoutedCurveLinkVisual.java new file mode 100644 index 0000000000000000000000000000000000000000..5b06cd7e80eaf7cf6af37a4769eaafe2a1e591f3 --- /dev/null +++ b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/visual/LayoutedCurveLinkVisual.java @@ -0,0 +1,127 @@ +/******************************************************************************* + * Copyright (c) 2018 fortiss GmbH. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v2.0 which is available at + * http://www.eclipse.org/legal/epl-v20.html + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Florian Hoelzl (fortiss GmbH) - initial implementation + * + *******************************************************************************/ +package org.fortiss.tooling.base.ui.editor.fx.visual; + +import static java.util.Collections.emptyList; +import static org.fortiss.tooling.base.ui.utils.LWFXEditorUtils.computeLinkToCircleLocation; +import static org.fortiss.tooling.base.ui.utils.LayoutDataUIUtils.getConnectionPoints; + +import java.util.List; + +import org.fortiss.tooling.base.model.layout.ILayoutedModelElement; +import org.fortiss.tooling.base.model.layout.Point; +import org.fortiss.tooling.base.model.layout.Points; +import org.fortiss.tooling.common.ui.javafx.lwfxef.DiagramCoordinate; +import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.ILinkMVCBundle; +import org.fortiss.tooling.common.ui.javafx.lwfxef.visual.elliptic.CurveLinkVisualBase; + +import javafx.geometry.Point2D; +import javafx.geometry.Rectangle2D; + +/** + * {@link CurveLinkVisualBase} providing a default visual for wires in ellipses-and-wires diagrams + * based on {@link ILayoutedModelElement}s. + * + * @author munaro + */ +public class LayoutedCurveLinkVisual<T extends ILayoutedModelElement> extends CurveLinkVisualBase { + /** Constructor. */ + public LayoutedCurveLinkVisual(ILinkMVCBundle mvcb, Class<T> modelType) { + super(mvcb); + + // TODO(#3877): Move type checks to a common base class. + Object model = mvcb.getModel(); + if(model == null) { + throw new IllegalArgumentException("The given model is null!"); + } + if(!modelType.isAssignableFrom(model.getClass())) { + throw new IllegalArgumentException("Expected model of type " + + modelType.getSimpleName() + ", but was " + model.getClass().getSimpleName()); + } + } + + /** Returns the model element with the expected type. */ + @SuppressWarnings("unchecked") + protected T getModelElement() { + return (T)getModel(); + } + + /** {@inheritDoc} */ + @Override + public DiagramCoordinate getBendPointLocation(int bpIndex) { + Point point = getBendPointList().get(bpIndex); + return new DiagramCoordinate(point.getX(), point.getY()); + } + + /** {@inheritDoc} */ + @Override + protected DiagramCoordinate getStartAnchorLocation(Rectangle2D anchorBounds, Point2D target) { + return computeLinkToCircleLocation(anchorBounds, target); + } + + /** {@inheritDoc} */ + @Override + protected DiagramCoordinate getEndAnchorLocation(Rectangle2D anchorBounds, Point2D target) { + return computeLinkToCircleLocation(anchorBounds, target); + } + + /** {@inheritDoc} */ + @Override + protected Object getBendPointModel(int i) { + return getBendPointList().get(i); + } + + /** {@inheritDoc} */ + @Override + protected int getNumberOfBendPoints() { + return getBendPointList().size(); + } + + /** Returns the list of bend-points. */ + private List<Point> getBendPointList() { + Points connectionPoints = getConnectionPoints(getModelElement()); + if(connectionPoints == null) { + return emptyList(); + } + List<Point> pointList = connectionPoints.getPoints(); + if(pointList == null) { + return emptyList(); + } + return pointList; + } + + /** {@inheritDoc} */ + @Override + protected double getFeedbackMarkerSize() { + return 10; + } + + /** {@inheritDoc} */ + @Override + protected boolean showArrowOnLastSegment() { + return true; + } + + /** {@inheritDoc} */ + @Override + protected double getInvisibleSelectionLineWidth() { + return 7; + } + + /** {@inheritDoc} */ + @Override + protected double getArrowLength() { + return 7; + } +} diff --git a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/visual/LayoutedEllipticContentVisualBase.java b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/visual/LayoutedEllipticContentVisualBase.java new file mode 100644 index 0000000000000000000000000000000000000000..6f3daf386d5120793b90ce4569dd9bea33dd2a0f --- /dev/null +++ b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/visual/LayoutedEllipticContentVisualBase.java @@ -0,0 +1,101 @@ +/*-------------------------------------------------------------------------+ +| 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.visual; + +import static javafx.scene.paint.Color.BLACK; +import static org.fortiss.tooling.base.layout.DefaultLayoutConstants.DEFAULT_CONNECTOR_SIZE; +import static org.fortiss.tooling.base.utils.LayoutDataUtils.getNodeBounds; + +import org.fortiss.tooling.base.model.layout.ILayoutedModelElement; +import org.fortiss.tooling.base.model.layout.Rectangle; +import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.IContentMVCBundle; +import org.fortiss.tooling.common.ui.javafx.lwfxef.visual.elliptic.EllipticContentVisualBase; + +import javafx.geometry.Rectangle2D; +import javafx.scene.paint.Paint; + +/** + * {@link EllipticContentVisualBase} providing a default visual for ellipses in ellipses-and-wires + * diagrams based on {@link ILayoutedModelElement}s. + * + * @author munaro + */ +public abstract class LayoutedEllipticContentVisualBase<T extends ILayoutedModelElement> + extends EllipticContentVisualBase { + + /** Constructor. */ + public LayoutedEllipticContentVisualBase(IContentMVCBundle mvcb, Class<T> modelType) { + super(mvcb); + + // TODO(#3877): Move type checks to a common base class. + Object model = mvcb.getModel(); + if(model == null) { + throw new IllegalArgumentException("The given model is null!"); + } + if(!modelType.isAssignableFrom(model.getClass())) { + throw new IllegalArgumentException("Expected model of type " + + modelType.getSimpleName() + ", but was " + model.getClass().getSimpleName()); + } + } + + /** Returns the model element with the specified type. */ + // TODO(#3877): Move type checks to a common base class. + @SuppressWarnings("unchecked") + protected T getModelElement() { + // Safe wild cast due to type check in constructor + return (T)getModel(); + } + + /** {@inheritDoc} */ + @Override + public Rectangle2D getModelBounds() { + Rectangle r = getNodeBounds(getModelElement()); + double dc = DEFAULT_CONNECTOR_SIZE / 2 - 2; + double dc2 = 2 * dc; + return new Rectangle2D(r.getX() + dc, r.getY() + dc, r.getWidth() - dc2, + r.getHeight() - dc2); + } + + /** {@inheritDoc} */ + @Override + protected Paint getBorderColor() { + return BLACK; + } + + /** {@inheritDoc} */ + @Override + protected double getBorderWidth() { + return 1; + } + + /** {@inheritDoc} */ + @Override + protected double getOpacity() { + return 1.0; + } + + /** {@inheritDoc} */ + @Override + protected boolean requireSelectionForMoveGesture() { + return false; + } + + /** {@inheritDoc} */ + @Override + protected boolean requireSelectionForResizeGesture() { + return false; + } +} diff --git a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/visual/LayoutedLineLinkVisual.java b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/visual/LayoutedLineLinkVisual.java index ff1291c57d4ce111d5543d7381a616cd2e096290..5fc26086e2f63afee403379ba8f09f5113d4c025 100644 --- a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/visual/LayoutedLineLinkVisual.java +++ b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/visual/LayoutedLineLinkVisual.java @@ -36,11 +36,7 @@ import javafx.geometry.Rectangle2D; * * @author munaro */ -// TODO (TM): As this class already requires the generic type to implement INamedElement -// NamedLayoutedLineLinkVisual becomes useless. Remove INamedElement here and make class -// abstract (consistent with the other Layouted*VisualBase classes) -public abstract class LayoutedLineLinkVisual<T extends ILayoutedModelElement> - extends LineLinkVisualBase { +public class LayoutedLineLinkVisual<T extends ILayoutedModelElement> extends LineLinkVisualBase { /** Constructor. */ public LayoutedLineLinkVisual(ILinkMVCBundle mvcb, Class<T> modelType) { diff --git a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/visual/NamedLayoutedCurveLinkVisual.java b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/visual/NamedLayoutedCurveLinkVisual.java new file mode 100644 index 0000000000000000000000000000000000000000..7945b2f550d5e4804f44891294ee60cc8ffcbf1e --- /dev/null +++ b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/visual/NamedLayoutedCurveLinkVisual.java @@ -0,0 +1,43 @@ +/*-------------------------------------------------------------------------+ +| 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.visual; + +import org.fortiss.tooling.base.model.element.IConnection; +import org.fortiss.tooling.base.model.layout.ILayoutedModelElement; +import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.ILinkMVCBundle; +import org.fortiss.tooling.common.ui.javafx.lwfxef.visual.IVisual; +import org.fortiss.tooling.kernel.model.INamedElement; + +/** + * {@link IVisual} for layouted and named curved links within a diagram. Typically, those are + * {@link IConnection}s. + * + * @author munaro + */ +public class NamedLayoutedCurveLinkVisual<T extends INamedElement & ILayoutedModelElement> + extends LayoutedCurveLinkVisual<T> { + + /** Constructor. */ + public NamedLayoutedCurveLinkVisual(ILinkMVCBundle mvcb, Class<T> modelType) { + super(mvcb, modelType); + } + + /** {@inheritDoc} */ + @Override + protected String getLabelText(int currentSegment, int lastSegment) { + return getModelElement().getName(); + } +} diff --git a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/visual/NamedLayoutedEllipticContentVisual.java b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/visual/NamedLayoutedEllipticContentVisual.java new file mode 100644 index 0000000000000000000000000000000000000000..f96a956c2f71b675eee56cfc613684397545da68 --- /dev/null +++ b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/visual/NamedLayoutedEllipticContentVisual.java @@ -0,0 +1,40 @@ +/*-------------------------------------------------------------------------+ +| 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.visual; + +import org.fortiss.tooling.base.model.layout.ILayoutedModelElement; +import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.IContentMVCBundle; +import org.fortiss.tooling.kernel.model.INamedElement; + +/** + * {@link LayoutedEllipticContentVisualBase} that defines its name. + * + * @author munaro + */ +public class NamedLayoutedEllipticContentVisual<T extends INamedElement & ILayoutedModelElement> + extends LayoutedEllipticContentVisualBase<T> { + + /** Constructor. */ + public NamedLayoutedEllipticContentVisual(IContentMVCBundle mvcb, Class<T> modelType) { + super(mvcb, modelType); + } + + /** {@inheritDoc} */ + @Override + protected String getName() { + return getModelElement().getName(); + } +} diff --git a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/visual/NamedLayoutedLineLinkVisual.java b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/visual/NamedLayoutedLineLinkVisual.java index 60f5d21f0723dc5d08b2ad43bc6361fca83a16aa..4fc48616000516dc90ba22b7069ffdabadc9c377 100644 --- a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/visual/NamedLayoutedLineLinkVisual.java +++ b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/visual/NamedLayoutedLineLinkVisual.java @@ -15,19 +15,18 @@ +--------------------------------------------------------------------------*/ package org.fortiss.tooling.base.ui.editor.fx.visual; -import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.ILinkMVCBundle; -import org.fortiss.tooling.common.ui.javafx.lwfxef.visual.IVisual; import org.fortiss.tooling.base.model.element.IConnection; import org.fortiss.tooling.base.model.layout.ILayoutedModelElement; +import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.ILinkMVCBundle; +import org.fortiss.tooling.common.ui.javafx.lwfxef.visual.IVisual; import org.fortiss.tooling.kernel.model.INamedElement; /** - * {@link IVisual} for layouted and named links within a diagram. Typically, those are + * {@link IVisual} for layouted and named straight links within a diagram. Typically, those are * {@link IConnection}s. * * @author diewald */ -// TODO (TM): See comment in LayoutedLineLinkVisual public class NamedLayoutedLineLinkVisual<T extends INamedElement & ILayoutedModelElement> extends LayoutedLineLinkVisual<T> { diff --git a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/utils/.ratings b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/utils/.ratings index d2fc13e9d443fbc1e3005b3723a68a1c72519d3a..673e0fc6505e31b30d19bf9937d831e8cbecb282 100644 --- a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/utils/.ratings +++ b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/utils/.ratings @@ -4,7 +4,7 @@ DragAndDropBaseUtils.java d375377f9124f6113b2a295e6b0e09ac8966e564 GREEN EllipseLayoutUIUtils.java 4dd9dbd96a45e8c455c019caa19e4a50f18336af GREEN FontUtils.java a167a05bdaa8da9853705cc5134f30f6d81bc9f2 GREEN GCStateManager.java 983973a92376b5c757c1253b32e33d0666ccdf7b GREEN -LWFXEditorUtils.java c624d3f0f6487b6d426b168dad048b2c39e71114 YELLOW +LWFXEditorUtils.java c624d3f0f6487b6d426b168dad048b2c39e71114 GREEN LayoutDataUIUtils.java c85886ac313a6efb122532218eb134047ffd6631 GREEN PropertiesViewUtils.java d345b4501c4092228edf1c98e0189317d53aaf22 GREEN RectangleLayoutUIUtils.java ef4b872bb5b4a51174e9a29d9ef05e7cb3bff3a1 GREEN diff --git a/org.fortiss.tooling.base/model/.ratings b/org.fortiss.tooling.base/model/.ratings index a14484332c6f194fa6e1e2dc001bc8a240b3aa5b..176d4ad2d4b8aeb0a19dadedde7fe5ffdafe724e 100644 --- a/org.fortiss.tooling.base/model/.ratings +++ b/org.fortiss.tooling.base/model/.ratings @@ -1 +1 @@ -base.ecore 6ba521f3458eaf64fc3ee0359e236c9a1201d259 YELLOW +base.ecore 6ba521f3458eaf64fc3ee0359e236c9a1201d259 GREEN diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/control/treetableview/.ratings b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/control/treetableview/.ratings index 1d719596aadb4771c489581b90bd5a6dcde4f410..4850e6d5cc854062f8760986309dc09fbbc41974 100644 --- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/control/treetableview/.ratings +++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/control/treetableview/.ratings @@ -1,7 +1,7 @@ -DynamicTreeContentProviderBase.java dff437afeaf7486af05460fa54eca4fa61d7eae6 GREEN -DynamicTreeItem.java afc105cf5acf3d2506d89e0892555100c234ce5b GREEN -DynamicTreeTableUIProviderBase.java fd9fce19a65eb1006ceacb0d869bbe90a8c578b3 GREEN -DynamicTreeTableViewer.java 4f278387dd90542adc07bf0da12e92d4eaad79c4 GREEN +DynamicTreeContentProviderBase.java e801da995a1b6e5a1b757247c1638bafb6073e6d GREEN +DynamicTreeItem.java 75dc5534b119ffdb3c10a65810c2a0f330b7955e GREEN +DynamicTreeTableUIProviderBase.java 7bfc1395283d3dc10026aff5e2e65df88d25f3a7 GREEN +DynamicTreeTableViewer.java 43757359b3071192ae79710bcbc0e9577bb6f62d GREEN DynamicTreeUIProviderBase.java 56fe4df4577b35f1e5e6e4c4be189b706c852d52 GREEN DynamicTreeViewer.java da5e24ae57777a482d8e12c8262513d8143bfa93 GREEN DynamicTreeViewerBase.java 47124c847de322a0ae26eb7a114f85ce4bd02d7e GREEN diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/control/treetableview/DynamicTreeContentProviderBase.java b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/control/treetableview/DynamicTreeContentProviderBase.java index dff437afeaf7486af05460fa54eca4fa61d7eae6..e801da995a1b6e5a1b757247c1638bafb6073e6d 100644 --- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/control/treetableview/DynamicTreeContentProviderBase.java +++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/control/treetableview/DynamicTreeContentProviderBase.java @@ -30,13 +30,43 @@ public abstract class DynamicTreeContentProviderBase<T> { /** Returns the children of the given parent in the tree. */ protected abstract Collection<? extends T> getChildren(T parent); - /** Returns the filer predicate. */ - protected Predicate<Object> getFilterPredicate() { + /** The current filter expression. */ + private String filterExpression = null; + + /** Sets the filter expression. */ + public void setFilterExpression(String filterExpression) { + this.filterExpression = filterExpression; + } + + /** + * Returns the filter expression. Sub-classes may override or simply use + * {@link #setFilterExpression(String)} + */ + protected String getFilterExpression() { + return filterExpression; + } + + /** + * Returns the filter predicate for the given filter value. The default checks if the object's + * toString() contains the filter value. Sub-classes may override or implement + * {@link #filter(Object, String)}. + */ + protected Predicate<T> getFilterPredicate(String filterValue) { + if(filterValue != null && !"".equals(filterValue.trim())) { + return (o) -> { + return filter(o, filterValue); + }; + } return (o) -> true; } + /** Sub-classes may override to implement simple filter behavior. */ + protected boolean filter(T element, String filterValue) { + return element != null && element.toString().contains(filterValue); + } + /** Returns the sorter comparator. */ - protected Comparator<Object> getSortingComparator() { + protected Comparator<T> getSortingComparator() { return (o1, o2) -> 0; } @@ -46,7 +76,7 @@ public abstract class DynamicTreeContentProviderBase<T> { if(l == null) { return emptyList(); } - return l.stream().filter(getFilterPredicate()).sorted(getSortingComparator()) - .collect(toList()); + return l.stream().filter(getFilterPredicate(getFilterExpression())) + .sorted(getSortingComparator()).collect(toList()); } } diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/control/treetableview/DynamicTreeItem.java b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/control/treetableview/DynamicTreeItem.java index afc105cf5acf3d2506d89e0892555100c234ce5b..75dc5534b119ffdb3c10a65810c2a0f330b7955e 100644 --- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/control/treetableview/DynamicTreeItem.java +++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/control/treetableview/DynamicTreeItem.java @@ -21,8 +21,8 @@ import java.util.HashMap; import javafx.scene.control.TreeItem; /** - * {@link TreeItem} with support for dynamic children using the {@link DynamicTreeItem#update()} - * method. + * {@link TreeItem} with support for dynamic children using the + * {@link DynamicTreeItem#update()} method. */ public class DynamicTreeItem<T> extends TreeItem<T> { /** The viewer. */ @@ -45,7 +45,8 @@ public class DynamicTreeItem<T> extends TreeItem<T> { } // get list of children and create tree items getChildren().clear(); - for(T element : viewer.getContentProvider().getFilteredSortedChildren(getValue())) { + DynamicTreeContentProviderBase<T> cp = viewer.getContentProvider(); + for(T element : cp.getFilteredSortedChildren(getValue())) { DynamicTreeItem<T> dti; if(expanded.containsKey(element)) { dti = (DynamicTreeItem<T>)expanded.get(element); diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/control/treetableview/DynamicTreeTableUIProviderBase.java b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/control/treetableview/DynamicTreeTableUIProviderBase.java index fd9fce19a65eb1006ceacb0d869bbe90a8c578b3..7bfc1395283d3dc10026aff5e2e65df88d25f3a7 100644 --- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/control/treetableview/DynamicTreeTableUIProviderBase.java +++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/control/treetableview/DynamicTreeTableUIProviderBase.java @@ -13,14 +13,19 @@ *******************************************************************************/ package org.fortiss.tooling.common.ui.javafx.control.treetableview; +import static javafx.scene.control.cell.TextFieldTreeTableCell.forTreeTableColumn; + import javafx.scene.Node; import javafx.scene.control.ContextMenu; +import javafx.scene.control.TreeTableCell; +import javafx.scene.control.TreeTableColumn; +import javafx.util.Callback; /** * This UI provider is responsible to return the label, the icon, and the context menu for each cell * in the {@link DynamicTreeTableViewer} based on the data object and the column. */ -public abstract class DynamicTreeTableUIProviderBase { +public abstract class DynamicTreeTableUIProviderBase<T> { /** * @param element * the element to be displayed in the current row @@ -28,7 +33,7 @@ public abstract class DynamicTreeTableUIProviderBase { * the current column * @return the label to be displayed in the given column */ - public String getLabel(Object element, int column) { + public String getLabel(T element, int column) { return ""; } @@ -39,7 +44,7 @@ public abstract class DynamicTreeTableUIProviderBase { * the current column * @return the node to be displayed as the icon in the given column */ - public Node getIconNode(Object element, int column) { + public Node getIconNode(T element, int column) { return null; } @@ -50,7 +55,94 @@ public abstract class DynamicTreeTableUIProviderBase { * the current column * @return the context menu in the given column */ - public ContextMenu createContextMenu(Object element, int column) { + public ContextMenu createContextMenu(T element, int column) { return null; } + + /** + * Returns whether the given column is editable. + * + * @param column + * the column index + * @return whether the column is editable + */ + public boolean isEditable(int column) { + return false; + } + + /** + * Updates the value after the given column was edited for the given element. + * + * @param element + * the element to be edited in the current row + * @param column + * the currently edited column + * @param value + * the edited value + */ + public void updateValue(T element, int column, String value) { + // ignored, since not editable + } + + /** + * Notifies the provider about the selection of the given new value (and the deselection of the + * given old value. + * + * @param oldValue + * unselected value + * @param newValue + * the selected value + */ + public void select(T oldValue, T newValue) { + // ignored + } + + /** Applies the editing support to the given column. */ + /* package */ final void applyToColumn(int i, TreeTableColumn<T, String> column) { + if(!isEditable(i)) { + column.setCellFactory(createReadOnlyCellFactory(i)); + column.setEditable(false); + column.setOnEditCommit(null); + return; + } + column.setCellFactory(createEditableCellFactory()); + column.setEditable(true); + column.setOnEditCommit(event -> { + T element = event.getRowValue().getValue(); + int colIndex = event.getTreeTablePosition().getColumn(); + String value = event.getNewValue(); + updateValue(element, colIndex, value); + column.getTreeTableView().refresh(); + }); + } + + /** Creates a cell factory for editable cells. */ + private Callback<TreeTableColumn<T, String>, TreeTableCell<T, String>> + createEditableCellFactory() { + return forTreeTableColumn(); + } + + /** Creates a cell factory for read-only cells. */ + private Callback<TreeTableColumn<T, String>, TreeTableCell<T, String>> + createReadOnlyCellFactory(int colIndex) { + return param -> { + TreeTableCell<T, String> cell = new TreeTableCell<T, String>() { + @Override + protected void updateItem(String item, boolean empty) { + super.updateItem(item, empty); + ContextMenu menu = null; + Node icon = null; + if(!empty && item != null) { + T data = this.getTreeTableRow().getItem(); + menu = createContextMenu(data, colIndex); + icon = getIconNode(data, colIndex); + } + this.setContextMenu(menu); + this.setGraphic(icon); + } + }; + cell.textProperty().bind(cell.itemProperty()); + return cell; + }; + } } diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/control/treetableview/DynamicTreeTableViewer.java b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/control/treetableview/DynamicTreeTableViewer.java index 4f278387dd90542adc07bf0da12e92d4eaad79c4..43757359b3071192ae79710bcbc0e9577bb6f62d 100644 --- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/control/treetableview/DynamicTreeTableViewer.java +++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/control/treetableview/DynamicTreeTableViewer.java @@ -15,17 +15,12 @@ *******************************************************************************/ package org.fortiss.tooling.common.ui.javafx.control.treetableview; -import static javafx.scene.control.cell.TextFieldTreeTableCell.forTreeTableColumn; - import javafx.beans.property.SimpleObjectProperty; -import javafx.scene.Node; -import javafx.scene.control.ContextMenu; import javafx.scene.control.SelectionMode; import javafx.scene.control.TreeItem; -import javafx.scene.control.TreeTableCell; import javafx.scene.control.TreeTableColumn; import javafx.scene.control.TreeTableView; -import javafx.util.Callback; +import javafx.scene.control.TreeTableView.TreeTableViewSelectionModel; /** * A JavaFX {@link TreeTableView} based on an {@link DynamicTreeContentProviderBase} and @@ -42,12 +37,12 @@ public final class DynamicTreeTableViewer<T> extends DynamicTreeViewerBase<T> { /** The {@link TreeTableView} control to be managed. */ private final TreeTableView<T> view; /** The UI provider of this tree-table. */ - private final DynamicTreeTableUIProviderBase uiProvider; + private final DynamicTreeTableUIProviderBase<T> uiProvider; /** Constructor. */ public DynamicTreeTableViewer(TreeTableView<T> view, T root, boolean showRoot, int revealLevel, DynamicTreeContentProviderBase<T> contentProvider, - DynamicTreeTableUIProviderBase uiProvider) { + DynamicTreeTableUIProviderBase<T> uiProvider) { super(contentProvider); this.uiProvider = uiProvider; // construct view @@ -56,7 +51,14 @@ public final class DynamicTreeTableViewer<T> extends DynamicTreeViewerBase<T> { view.setRoot(rootItem); view.setShowRoot(showRoot); view.setEditable(true); - view.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); + TreeTableViewSelectionModel<T> selectionModel = view.getSelectionModel(); + selectionModel.setSelectionMode(SelectionMode.MULTIPLE); + selectionModel.selectedItemProperty().addListener((obs, oVal, nVal) -> { + T ov = (oVal != null) ? oVal.getValue() : null; + T nv = (nVal != null) ? nVal.getValue() : null; + uiProvider.select(ov, nv); + }); + rootItem.update(); // expand to reveal (+1 if root node is not shown expandItem(rootItem, showRoot ? revealLevel : revealLevel + 1); @@ -65,7 +67,7 @@ public final class DynamicTreeTableViewer<T> extends DynamicTreeViewerBase<T> { /** Constructor. */ public DynamicTreeTableViewer(T root, boolean showRoot, int revealLevel, DynamicTreeContentProviderBase<T> contentProvider, - DynamicTreeTableUIProviderBase uiProvider) { + DynamicTreeTableUIProviderBase<T> uiProvider) { this(new TreeTableView<T>(), root, showRoot, revealLevel, contentProvider, uiProvider); } @@ -74,6 +76,7 @@ public final class DynamicTreeTableViewer<T> extends DynamicTreeViewerBase<T> { // wild cast works: see constructor DynamicTreeItem<T> rootItem = (DynamicTreeItem<T>)view.getRoot(); rootItem.update(); + view.refresh(); } /** Expands items up to the given level. */ @@ -92,51 +95,33 @@ public final class DynamicTreeTableViewer<T> extends DynamicTreeViewerBase<T> { * Adds a column to the table part of the view. The labels, context menus and icons are shown as * defined in the {@link DynamicTreeTableUIProviderBase}. */ - public TreeTableColumn<T, String> addColumn(String headerLabel, int prefWidth, - boolean readOnly) { + public TreeTableColumn<T, String> addColumn(String headerLabel, int prefWidth) { int num = view.getColumns().size(); TreeTableColumn<T, String> column = new TreeTableColumn<>(headerLabel); column.setPrefWidth(prefWidth); column.setCellValueFactory(param -> { - Object data = param.getValue().getValue(); + T data = param.getValue().getValue(); return new SimpleObjectProperty<String>(uiProvider.getLabel(data, num)); }); - Callback<TreeTableColumn<T, String>, TreeTableCell<T, String>> cellFactory; - if(readOnly) { - // Read only cell with the icon and context menu as specified in the UI provider - cellFactory = param -> { - TreeTableCell<T, String> cell = new TreeTableCell<T, String>() { - @Override - protected void updateItem(String item, boolean empty) { - super.updateItem(item, empty); - ContextMenu menu = null; - Node icon = null; - int index = view.getColumns().size() - 1; - if(!empty && item != null) { - T data = this.getTreeTableRow().getItem(); - menu = uiProvider.createContextMenu(data, index); - icon = uiProvider.getIconNode(data, index); - } - this.setContextMenu(menu); - this.setGraphic(icon); - } - }; - cell.textProperty().bind(cell.itemProperty()); - return cell; - }; - } else { - // Editable text field - cellFactory = forTreeTableColumn(); - } - column.setCellFactory(cellFactory); - + uiProvider.applyToColumn(num, column); view.getColumns().add(column); - return column; } + /** + * Adds a column to the table part of the view. The labels, context menus and icons are shown as + * defined in the {@link DynamicTreeTableUIProviderBase}. + * + * @deprecated use {@link DynamicTreeTableUIProviderBase} + */ + @Deprecated + public TreeTableColumn<T, String> addColumn(String headerLabel, int prefWidth, + @SuppressWarnings("unused") boolean readOnly) { + return addColumn(headerLabel, prefWidth); + } + /** Returns the underlying {@link TreeTableView}. */ public TreeTableView<T> getControl() { return view; diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/.ratings b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/.ratings index 3bd75d30bb2759490c246d437ee73faf7a2b3ccf..1d69252bb5cb8618560bbb8e8ac9f491d72920f7 100644 --- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/.ratings +++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/.ratings @@ -1,12 +1,12 @@ -DiagramCoordinate.java 6b00aec99054d4cd19003a72bd4e5e774ac6a641 YELLOW -DiagramLayers.java 155cbb47a5f0aaa0025320ae607e6777f3a2d2e8 YELLOW -DiagramViewer.java d5ba3f45ddc619132434f9cbefd36f65cce18b65 YELLOW -DiagramViewerDefaultTags.java 6230763252409c60009ab8887b4ef582cf883229 YELLOW -DiagramViewerFeatures.java 31e3fb61f915b0d8695005b083c47ce1c5be0b05 YELLOW -DiagramViewerSelection.java e833f592543bc97077907d980a39b123fc4044e6 YELLOW -EDragGesture.java 5cfa098d3877db11981c2750e5e103156d62fc5e YELLOW -FeedbackChange.java b088fa89af648f1674f2f9c1f7f99d585ce801ca YELLOW -GridCanvasVisual.java 734027d56af342cd01ff445ba9347b8dbb6c83c2 YELLOW -MVCBundleManager.java 2b4ab114c55b30a3d98d7135458f8f3ddd244d58 YELLOW -MouseState.java ff90af6d1cca427ef6f3fded76367b535120a5df YELLOW +DiagramCoordinate.java 6b00aec99054d4cd19003a72bd4e5e774ac6a641 GREEN +DiagramLayers.java 155cbb47a5f0aaa0025320ae607e6777f3a2d2e8 GREEN +DiagramViewer.java e7c550be6443f798ba9399a35ab3059033a33e59 RED +DiagramViewerDefaultTags.java 6230763252409c60009ab8887b4ef582cf883229 GREEN +DiagramViewerFeatures.java 31e3fb61f915b0d8695005b083c47ce1c5be0b05 GREEN +DiagramViewerSelection.java e833f592543bc97077907d980a39b123fc4044e6 GREEN +EDragGesture.java 5cfa098d3877db11981c2750e5e103156d62fc5e GREEN +FeedbackChange.java b088fa89af648f1674f2f9c1f7f99d585ce801ca GREEN +GridCanvasVisual.java 734027d56af342cd01ff445ba9347b8dbb6c83c2 GREEN +MVCBundleManager.java 2b4ab114c55b30a3d98d7135458f8f3ddd244d58 GREEN +MouseState.java ff90af6d1cca427ef6f3fded76367b535120a5df GREEN SVGExporter.java cbbd1eceb2910fd5c1693e05c5303a193127b9db YELLOW diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/DiagramViewer.java b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/DiagramViewer.java index d5ba3f45ddc619132434f9cbefd36f65cce18b65..e7c550be6443f798ba9399a35ab3059033a33e59 100644 --- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/DiagramViewer.java +++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/DiagramViewer.java @@ -9,6 +9,7 @@ *******************************************************************************/ package org.fortiss.tooling.common.ui.javafx.lwfxef; +import static java.lang.Math.abs; import static java.lang.Math.ceil; import static java.lang.Math.max; import static java.lang.Math.min; @@ -117,6 +118,7 @@ public class DiagramViewer { // selection feedback rectangle mouseDragRectangle.setFill(Color.TRANSPARENT); mouseDragRectangle.setStroke(Color.ORANGERED); + // TODO (SB): Magic constant mouseDragRectangle.getStrokeDashArray().addAll(15.0, 5.0); mouseDragRectangle.setMouseTransparent(true); // viewer pane @@ -556,13 +558,13 @@ public class DiagramViewer { return; } Point2D location = locationInDiagram; - double x = Math.min(mouseDragRectangleStartLocation.getX(), location.getX()); + double x = min(mouseDragRectangleStartLocation.getX(), location.getX()); mouseDragRectangle.setX(x); - double w = Math.abs(mouseDragRectangleStartLocation.getX() - location.getX()); + double w = abs(mouseDragRectangleStartLocation.getX() - location.getX()); mouseDragRectangle.setWidth(w); - double y = Math.min(mouseDragRectangleStartLocation.getY(), location.getY()); + double y = min(mouseDragRectangleStartLocation.getY(), location.getY()); mouseDragRectangle.setY(y); - double h = Math.abs(mouseDragRectangleStartLocation.getY() - location.getY()); + double h = abs(mouseDragRectangleStartLocation.getY() - location.getY()); mouseDragRectangle.setHeight(h); } @@ -572,10 +574,10 @@ public class DiagramViewer { return; } Point2D location = locationInDiagram; - double x = Math.min(mouseDragRectangleStartLocation.getX(), location.getX()); - double w = Math.abs(mouseDragRectangleStartLocation.getX() - location.getX()); - double y = Math.min(mouseDragRectangleStartLocation.getY(), location.getY()); - double h = Math.abs(mouseDragRectangleStartLocation.getY() - location.getY()); + double x = min(mouseDragRectangleStartLocation.getX(), location.getX()); + double w = abs(mouseDragRectangleStartLocation.getX() - location.getX()); + double y = min(mouseDragRectangleStartLocation.getY(), location.getY()); + double h = abs(mouseDragRectangleStartLocation.getY() - location.getY()); layers.getVisualFeedbackLayer().remove(mouseDragRectangle); Rectangle2D selectionRect = new Rectangle2D(x, y, w, h); // remove old selection diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/change/.ratings b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/change/.ratings index 1758ea0a359923dd644757977226edcf4ad6064a..4dd6266d7ad3b29bc193f6055fe20be8435d5334 100644 --- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/change/.ratings +++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/change/.ratings @@ -1,3 +1,3 @@ -Change.java e907a516f1369013cbb3d5d002b1ddb69cd5cc25 YELLOW -ChangeSet.java 363c4fcdad1709e6f7ccad4205a53b22c976b50d YELLOW -DefaultModelModifier.java bfa32a76ce226ec84a173201553b87d6317b84b1 YELLOW +Change.java e907a516f1369013cbb3d5d002b1ddb69cd5cc25 GREEN +ChangeSet.java 363c4fcdad1709e6f7ccad4205a53b22c976b50d GREEN +DefaultModelModifier.java bfa32a76ce226ec84a173201553b87d6317b84b1 GREEN diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/controller/.ratings b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/controller/.ratings index b36ac7444c8875c8a6f059a120545746e2acdf95..cfa9cb5656d6c4b10625c7f4b9a179d3c7efe731 100644 --- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/controller/.ratings +++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/controller/.ratings @@ -1,5 +1,5 @@ -IClickController.java c0270e99d918aef14612d46f3e84905d3a6bdd8c YELLOW -IController.java 6ba069977e7588f97187916c23a0e37f7cb91059 YELLOW -IControllerFactory.java 85b86eda643489f2a03454eae5383915ecf27f83 YELLOW -IDragController.java c1f311d2ae9ed684c8a7cd85e9ed1f85e79658d1 YELLOW -IKeyPressController.java dc8fe2a7c441866122e8c7b3114fd12d17f0b051 YELLOW +IClickController.java c0270e99d918aef14612d46f3e84905d3a6bdd8c GREEN +IController.java 6ba069977e7588f97187916c23a0e37f7cb91059 GREEN +IControllerFactory.java 85b86eda643489f2a03454eae5383915ecf27f83 GREEN +IDragController.java c1f311d2ae9ed684c8a7cd85e9ed1f85e79658d1 GREEN +IKeyPressController.java dc8fe2a7c441866122e8c7b3114fd12d17f0b051 GREEN diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/controller/base/.ratings b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/controller/base/.ratings index 93fa9d581988497529b293afd4f2f10d1bf78f83..ddb0df3c46daa08aed60d40fafb85f3ae5239589 100644 --- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/controller/base/.ratings +++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/controller/base/.ratings @@ -1,11 +1,11 @@ -AnchorageContentControllerBase.java da56b10cbf2711b5da69f0b59f43eacbe54f4eea YELLOW -ClickControllerBase.java 8e5861ed5f9318008ad0fdd5497ed320cd5bd647 YELLOW -ContentAnchorageMoveControllerBase.java c18e7915ce23e124757f5b736086ecc46694800a YELLOW +AnchorageContentControllerBase.java da56b10cbf2711b5da69f0b59f43eacbe54f4eea GREEN +ClickControllerBase.java 8e5861ed5f9318008ad0fdd5497ed320cd5bd647 GREEN +ContentAnchorageMoveControllerBase.java c18e7915ce23e124757f5b736086ecc46694800a GREEN ControllerBase.java 6f32c252fad45327c5ece55ec81f517421d2d4a6 YELLOW -DefaultDiagramController.java 0e083b89a08f63967102a384d66ebc1d64d203af YELLOW -DelegatingContentAnchorageController.java 2e3b1b4e14402a3503233f816b21ef3e4aa09edc YELLOW -DragControllerBase.java b15ff874304f679fe494d85f57cc8cbe4d0d1d15 YELLOW -DraggingUtils.java 95117e2ea4c36b6c6a31f8088bb95b484e0e6612 YELLOW -LinkControllerBase.java 392cb79cb42e9f878c665d47053b0795c3768603 YELLOW -MoveControllerBase.java 38d632e31f5e27d112ecdd4933e3a331378180d0 YELLOW -ResizableContentControllerBase.java 898500d389b035f8138308d496d2d24be501c719 YELLOW +DefaultDiagramController.java 0e083b89a08f63967102a384d66ebc1d64d203af GREEN +DelegatingContentAnchorageController.java 2e3b1b4e14402a3503233f816b21ef3e4aa09edc GREEN +DragControllerBase.java b15ff874304f679fe494d85f57cc8cbe4d0d1d15 GREEN +DraggingUtils.java 95117e2ea4c36b6c6a31f8088bb95b484e0e6612 GREEN +LinkControllerBase.java 392cb79cb42e9f878c665d47053b0795c3768603 GREEN +MoveControllerBase.java 38d632e31f5e27d112ecdd4933e3a331378180d0 GREEN +ResizableContentControllerBase.java 898500d389b035f8138308d496d2d24be501c719 GREEN diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/controller/elliptic/.ratings b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/controller/elliptic/.ratings index ca7cd95560997655fec8af345c644cec0bccbc37..28d2587c373396106aed0e3864a7707ac1fb97f5 100644 --- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/controller/elliptic/.ratings +++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/controller/elliptic/.ratings @@ -1,3 +1,3 @@ -CircularResizableContentControllerBase.java daf05a58eac298462a5f092503e506575b31dff1 YELLOW -CurveLinkBendPointControllerBase.java 4d119cd640b864f2193ea5c1a7f816310b7a57a4 YELLOW -EllipticResizableContentControllerBase.java 42bcbdbf29c1cf2b71177e55f74358d1517d623f YELLOW +CircularResizableContentControllerBase.java daf05a58eac298462a5f092503e506575b31dff1 GREEN +CurveLinkBendPointControllerBase.java 4d119cd640b864f2193ea5c1a7f816310b7a57a4 GREEN +EllipticResizableContentControllerBase.java 42bcbdbf29c1cf2b71177e55f74358d1517d623f GREEN diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/controller/rectangular/.ratings b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/controller/rectangular/.ratings index fa26ef326bf580bcd604a022d994a5dfaa2d8888..9405c329604c289d6b479655f2a0e1786fdc8b6a 100644 --- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/controller/rectangular/.ratings +++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/controller/rectangular/.ratings @@ -1,5 +1,5 @@ -DiamondResizableContentControllerBase.java 31f227e88205bd2e131326bdddd8421991b47d79 YELLOW +DiamondResizableContentControllerBase.java 31f227e88205bd2e131326bdddd8421991b47d79 GREEN RectangularContentAnchorageMoveController.java 78b55be1a974ee1bca89a7934afb504f56bd495a YELLOW -RectangularResizableContentControllerBase.java 262b083e4e0ce842b0bb8fbb594585e9f0d2f678 YELLOW -RhomboidContentAnchorageMoveController.java fbd40ce483f99c18cfa94076374f572bb72c2646 YELLOW -RhomboidResizableContentControllerBase.java 863b9eae49bad18f71b20c8cde4b0f350348aa27 YELLOW +RectangularResizableContentControllerBase.java 262b083e4e0ce842b0bb8fbb594585e9f0d2f678 GREEN +RhomboidContentAnchorageMoveController.java fbd40ce483f99c18cfa94076374f572bb72c2646 GREEN +RhomboidResizableContentControllerBase.java 863b9eae49bad18f71b20c8cde4b0f350348aa27 GREEN diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/model/.ratings b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/model/.ratings index 64f28f835bfdcd13cc22512f260cf8d9d693a7ca..b3e49918b7fb9c33983501e717629f830a3e9146 100644 --- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/model/.ratings +++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/model/.ratings @@ -1,5 +1,5 @@ -IModelChangeListener.java 241a583a3517ad504ad0a2d5a8f4d98afee8fd8b YELLOW -IModelChangeProvider.java bc7622c4af211e3ee470d12b80d04a92880f0d38 YELLOW -IModelFactory.java 3b6a1cb2779af0215a2637c40428b42600ef4ffb YELLOW -ModelChangeProviderBase.java eb5ad0363e30f727a70c42edb3d781acb6e6add6 YELLOW -ModelFactoryBase.java 6d0e1e5658c592f3f98d3bcf68bdbb54a506c489 YELLOW +IModelChangeListener.java 241a583a3517ad504ad0a2d5a8f4d98afee8fd8b GREEN +IModelChangeProvider.java bc7622c4af211e3ee470d12b80d04a92880f0d38 GREEN +IModelFactory.java 3b6a1cb2779af0215a2637c40428b42600ef4ffb GREEN +ModelChangeProviderBase.java eb5ad0363e30f727a70c42edb3d781acb6e6add6 GREEN +ModelFactoryBase.java 6d0e1e5658c592f3f98d3bcf68bdbb54a506c489 GREEN diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/model/layout/.ratings b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/model/layout/.ratings index e16ac9b565554bdc3997e7fda8cf824f4f77e9aa..579b227ef74dde76b632ceadb6ef103bd4cc45dc 100644 --- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/model/layout/.ratings +++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/model/layout/.ratings @@ -1,6 +1,6 @@ -IAngleLayout.java 4993d53870c2a71dc63e8a99ceb47df6cfec3801 YELLOW -ILayout.java e6fd2a1ac953a18c8ea8951e594e44a1c0fc8d92 YELLOW -IOffsetLayout.java 440551f07a2af2ceb000b14177cc2351cb1b7f52 YELLOW -IPointsLayout.java be1c706ae6e782d6ac960e02e6855f8d2118914b YELLOW -ISideLayout.java 20b14640a7424a013338e6683b9f4cf6e62f01e1 YELLOW -IXYLayout.java e3e007db33846621bf6844621360b5881f7f6023 YELLOW +IAngleLayout.java 4993d53870c2a71dc63e8a99ceb47df6cfec3801 GREEN +ILayout.java e6fd2a1ac953a18c8ea8951e594e44a1c0fc8d92 GREEN +IOffsetLayout.java 440551f07a2af2ceb000b14177cc2351cb1b7f52 GREEN +IPointsLayout.java be1c706ae6e782d6ac960e02e6855f8d2118914b GREEN +ISideLayout.java 20b14640a7424a013338e6683b9f4cf6e62f01e1 GREEN +IXYLayout.java e3e007db33846621bf6844621360b5881f7f6023 GREEN diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/mvc/.ratings b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/mvc/.ratings index 2cbebcd4f0eb0c2a87624fda33091a00b464d1d6..0caf473507c9a43784b1e21e70aa1dcf8a9f66fb 100644 --- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/mvc/.ratings +++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/mvc/.ratings @@ -1,10 +1,10 @@ -IAnchorageMVCBundle.java 17671d1ef6ecc4d1b4b98cf9d83016b31455346d YELLOW -IContentAnchorageMVCBundle.java c3bd9eb5266d0f87b16cdd16aeaadbfa6eeb49de YELLOW -IContentMVCBundle.java f84f8e59af85d022c2019d271d957821c5c55d3f YELLOW -IContentMVCBundleWithParent.java 890ffcacb493fda5ead5b7f74dc7ae1637077526 YELLOW -IDiagramAnchorageMVCBundle.java c49ef7ca7457ea9d4557251263779b403f79e69c YELLOW -IDiagramMVCBundle.java 354facfc00887726a6d7553d40824b7171865330 YELLOW -ILinkMVCBundle.java a2b1527f98ed642def2346190f6a71016ca674af YELLOW -IMVCBundle.java 19a6cc6bc96c42dd98dca24288a050ff0ba04734 YELLOW -IMVCBundlePart.java 6ddc90167a6ee7410876150e1785840f6ad32912 YELLOW -MVCBundleTag.java cf428833f24caccd74945119cf906b19daa3d63b YELLOW +IAnchorageMVCBundle.java 17671d1ef6ecc4d1b4b98cf9d83016b31455346d GREEN +IContentAnchorageMVCBundle.java c3bd9eb5266d0f87b16cdd16aeaadbfa6eeb49de GREEN +IContentMVCBundle.java f84f8e59af85d022c2019d271d957821c5c55d3f GREEN +IContentMVCBundleWithParent.java 890ffcacb493fda5ead5b7f74dc7ae1637077526 GREEN +IDiagramAnchorageMVCBundle.java c49ef7ca7457ea9d4557251263779b403f79e69c GREEN +IDiagramMVCBundle.java 354facfc00887726a6d7553d40824b7171865330 GREEN +ILinkMVCBundle.java a2b1527f98ed642def2346190f6a71016ca674af GREEN +IMVCBundle.java 19a6cc6bc96c42dd98dca24288a050ff0ba04734 GREEN +IMVCBundlePart.java 6ddc90167a6ee7410876150e1785840f6ad32912 GREEN +MVCBundleTag.java cf428833f24caccd74945119cf906b19daa3d63b GREEN diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/mvc/impl/.ratings b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/mvc/impl/.ratings index 75dd39150629f014e42f0ffb5515d36228037152..f2a2a198165e2e3d12be6739bf9f96f07b6169d6 100644 --- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/mvc/impl/.ratings +++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/mvc/impl/.ratings @@ -1,8 +1,8 @@ -AnchorageMVCBundleBase.java 63dc967da3342d402603adcc005344ce89386ea8 YELLOW -ContentAnchorageMVCBundle.java 1a517903c6400203cb7850502671e01d715f2453 YELLOW -ContentMVCBundle.java ee8a2c7780b64d61cf3e196437ce5ab07ad29e7c YELLOW -DiagramAnchorageMVCBundle.java b0f12259bbb8ccbf68b0774eb76c060188f4fea2 YELLOW -DiagramMVCBundle.java 46860e820c67f985cd75704b9084948df1939ee8 YELLOW -LinkMVCBundle.java b8246cd0e6f6ff53b377a9a0c4d1c8e4aa6371c4 YELLOW -MVCBundleBase.java 0a1b561e6ed5a5b4a3d2fdf52e2e5839c770193b YELLOW -MVCBundlePartBase.java 9e56b3799f14fe63649a09130edbdef083b87fdc YELLOW +AnchorageMVCBundleBase.java 63dc967da3342d402603adcc005344ce89386ea8 GREEN +ContentAnchorageMVCBundle.java 1a517903c6400203cb7850502671e01d715f2453 GREEN +ContentMVCBundle.java ee8a2c7780b64d61cf3e196437ce5ab07ad29e7c GREEN +DiagramAnchorageMVCBundle.java b0f12259bbb8ccbf68b0774eb76c060188f4fea2 GREEN +DiagramMVCBundle.java 46860e820c67f985cd75704b9084948df1939ee8 GREEN +LinkMVCBundle.java b8246cd0e6f6ff53b377a9a0c4d1c8e4aa6371c4 GREEN +MVCBundleBase.java 0a1b561e6ed5a5b4a3d2fdf52e2e5839c770193b GREEN +MVCBundlePartBase.java 9e56b3799f14fe63649a09130edbdef083b87fdc GREEN diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/.ratings b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/.ratings index eac3ce8aa6f5915c3c45dd6ddaee84beae2392df..a84ae75a78cdc614ba48b39de4ba43f38993a892 100644 --- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/.ratings +++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/.ratings @@ -1,7 +1,7 @@ -IAnchorageVisual.java e742212c132db1e2309650f5d6e40bc79c2ff85a YELLOW -IContentAnchorageVisual.java 3a3ceb675820f151aa678b6caa0f1ae833da1b7f YELLOW -IContentVisual.java 1052ece1f6172799204b1d7524398766c3b7a12e YELLOW -IDiagramAnchorageVisual.java ae0895912fe735147ccd11b7f466a7a5b61c3ca5 YELLOW -ILinkVisual.java 8f9bd6cf7c423a78d67fab0a20ba2dad2dfbd55e YELLOW -IVisual.java 400569502788bf2efff3de84f2c53b65256b3fc4 YELLOW -IVisualFactory.java 39253dc705f7f73ddbb83d050232a19219d54e71 YELLOW +IAnchorageVisual.java e742212c132db1e2309650f5d6e40bc79c2ff85a GREEN +IContentAnchorageVisual.java 3a3ceb675820f151aa678b6caa0f1ae833da1b7f GREEN +IContentVisual.java 1052ece1f6172799204b1d7524398766c3b7a12e GREEN +IDiagramAnchorageVisual.java ae0895912fe735147ccd11b7f466a7a5b61c3ca5 GREEN +ILinkVisual.java 8f9bd6cf7c423a78d67fab0a20ba2dad2dfbd55e GREEN +IVisual.java 400569502788bf2efff3de84f2c53b65256b3fc4 GREEN +IVisualFactory.java 39253dc705f7f73ddbb83d050232a19219d54e71 GREEN diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/base/.ratings b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/base/.ratings index 46f793ff95f84ccfb94b335d55d982ac19faa129..f25afc4fc869edb72d824531a0f042e3a2f447e7 100644 --- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/base/.ratings +++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/base/.ratings @@ -1,6 +1,6 @@ -ContentAnchorageVisualBase.java 6722629a940e9f8d973d2176bc3855932d7fa35a YELLOW -ContentVisualBase.java b061d42fc27e980023980d070961d0814702237d YELLOW -DiagramAnchorageVisualBase.java 05c235152bc79187f0fc9b041435da7968654a78 YELLOW -LinkVisualBase.java 909b933b38b7651cac901d767115e173983bef26 YELLOW -MVCBundlePartWithEffectsBase.java 6f6fbbb065950ad3acd4dc1fbfdd1348874e51d2 YELLOW -VisualBase.java a2daf2d8f8450559450ddf5bbc93d3f948c189dd YELLOW +ContentAnchorageVisualBase.java 6722629a940e9f8d973d2176bc3855932d7fa35a GREEN +ContentVisualBase.java d232c6cb7bc54b2430379379eb2985f5a2e12cd3 RED +DiagramAnchorageVisualBase.java 05c235152bc79187f0fc9b041435da7968654a78 GREEN +LinkVisualBase.java 909b933b38b7651cac901d767115e173983bef26 GREEN +MVCBundlePartWithEffectsBase.java 6f6fbbb065950ad3acd4dc1fbfdd1348874e51d2 GREEN +VisualBase.java 8d6e74d5c74703dad12847cd5c913fa72707a84a RED diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/base/ContentVisualBase.java b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/base/ContentVisualBase.java index b061d42fc27e980023980d070961d0814702237d..d232c6cb7bc54b2430379379eb2985f5a2e12cd3 100644 --- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/base/ContentVisualBase.java +++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/base/ContentVisualBase.java @@ -41,6 +41,7 @@ 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); @@ -79,6 +80,7 @@ public abstract class ContentVisualBase extends VisualBase implements IContentVi /** Returns the insets of the text label. */ protected Insets getTextInsets() { + // TODO (SB): Magic constant return new Insets(10, 10, 10, 10); } @@ -250,12 +252,14 @@ public abstract class ContentVisualBase extends VisualBase implements IContentVi /** Returns the inset for the plus/minus sign of the expand/collapse widget. */ protected double getExpandCollapseWidgetInset() { + // TODO (SB): Magic constant return 3; } /** Returns the location for the expand/collapse widget. */ protected Rectangle2D getExpandCollapseWidgetRectangle() { Rectangle2D b = getCurrentBounds(); + // TODO (SB): Magic constant return new Rectangle2D(b.getWidth() - 20, 6, 14, 14); } diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/base/VisualBase.java b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/base/VisualBase.java index a2daf2d8f8450559450ddf5bbc93d3f948c189dd..8d6e74d5c74703dad12847cd5c913fa72707a84a 100644 --- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/base/VisualBase.java +++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/base/VisualBase.java @@ -85,6 +85,7 @@ 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)); } // handle hover text @@ -280,6 +281,7 @@ public abstract class VisualBase extends MVCBundlePartWithEffectsBase implements /** Returns the opacity of the content visual. */ protected double getOpacity() { + // TODO (SB): Magic constant return 0.8; } @@ -290,6 +292,7 @@ public abstract class VisualBase extends MVCBundlePartWithEffectsBase implements /** Returns the width of the border. */ protected double getBorderWidth() { + // TODO (SB): Magic constant return 2; } @@ -320,6 +323,7 @@ public abstract class VisualBase extends MVCBundlePartWithEffectsBase implements /** Returns the size of the hit area as an outset of the visible rectangle. */ protected double getHitAreaOutset() { + // TODO (SB): Magic constant return 10; } diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/elliptic/.ratings b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/elliptic/.ratings index b0919970948f955eebfde4f8f242ca98603d22aa..76c3a528f870909b4f5035694b2df546f5c05a37 100644 --- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/elliptic/.ratings +++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/elliptic/.ratings @@ -1,7 +1,7 @@ -CircularContentAnchorageVisualBase.java de227ce8a2a14eb4df7bdcf43b82d98f6ff17045 YELLOW -CircularContentVisualBase.java cc3caea328e36e90069b915e413c8e7e9522a939 YELLOW +CircularContentAnchorageVisualBase.java e1d3f982239beb38120c7eda6ecf319ab2779f9c RED +CircularContentVisualBase.java cc3caea328e36e90069b915e413c8e7e9522a939 GREEN CircularDiagramAnchorageVisualBase.java 7a3b92fb1b135c218b9a5e16506acfc74a6b5468 YELLOW -CurveLinkVisualBase.java 0b8706214320d715966c86a5242ad21c8bf5a315 YELLOW -CurveSegment.java 445bc2607cb70ae1c788c27ba9fc637dd7df4956 YELLOW +CurveLinkVisualBase.java 5ce3086769004a9eb6800d7eb58379d831ff74b1 GREEN +CurveSegment.java 0e7f70e9526a74aaec2bec4f4fc16295521cf5f2 GREEN EllipticBorderLocation.java 6775dd54c01f8d76ecf1721185b60b63f1eec6c2 YELLOW -EllipticContentVisualBase.java dc2fddc9cfe5605bc8a5d09dd862845e360b23f5 YELLOW +EllipticContentVisualBase.java dc2fddc9cfe5605bc8a5d09dd862845e360b23f5 GREEN diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/elliptic/CircularContentAnchorageVisualBase.java b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/elliptic/CircularContentAnchorageVisualBase.java index de227ce8a2a14eb4df7bdcf43b82d98f6ff17045..e1d3f982239beb38120c7eda6ecf319ab2779f9c 100644 --- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/elliptic/CircularContentAnchorageVisualBase.java +++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/elliptic/CircularContentAnchorageVisualBase.java @@ -84,6 +84,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; } diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/elliptic/CurveLinkVisualBase.java b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/elliptic/CurveLinkVisualBase.java index 0b8706214320d715966c86a5242ad21c8bf5a315..5ce3086769004a9eb6800d7eb58379d831ff74b1 100644 --- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/elliptic/CurveLinkVisualBase.java +++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/elliptic/CurveLinkVisualBase.java @@ -65,7 +65,7 @@ public abstract class CurveLinkVisualBase extends LinkVisualBase { for(int i = 2; i < pts; i += 3) { Point2D ep = getBendPointLocation(i); makeCurve(sp, cp1, cp2, ep, getInvisibleSelectionLineWidth(), markerSize, markerSize, - false, true, 0); + false, true, 0, getLabelText(i, pts + 1)); sp = ep; cp1 = getBendPointLocation(i + 1); cp2 = getBendPointLocation(i + 2); @@ -76,14 +76,16 @@ public abstract class CurveLinkVisualBase extends LinkVisualBase { .applyToPoint(getEndAnchorPoint()); // Last bend point is not selectable => set its feedback rectangle size to 0 makeCurve(sp, cp1, cp2, ep, getInvisibleSelectionLineWidth(), 0, markerSize, - showArrowOnLastSegment(), useLineArrow(), getArrowLength()); + showArrowOnLastSegment(), useLineArrow(), getArrowLength(), + getLabelText(pts, pts + 1)); endFeedbackHandle.setX(ep.getX() - ms2); endFeedbackHandle.setY(ep.getY() - ms2); endFeedbackHandle.setWidth(markerSize); endFeedbackHandle.setHeight(markerSize); for(CurveSegment cs : segments) { - cs.addLinkNodes(layers, linkBundle); + cs.addLinkNodes(layers, linkBundle, + getLabelText(segments.indexOf(cs), segments.size())); } curvesAddedToSceneGraph = true; } @@ -133,7 +135,8 @@ public abstract class CurveLinkVisualBase extends LinkVisualBase { // handle bend points for(int i = 2; i < pts; i += 3) { Point2D ep = getFeedbackChangeForBendPoint(i).applyToPoint(getBendPointLocation(i)); - segments.get(segIndex).update(sp, cp1, cp2, ep, markerSize, markerSize, 0); + segments.get(segIndex).update(sp, cp1, cp2, ep, markerSize, markerSize, 0, + getLabelText(i, pts)); sp = ep; cp1 = getFeedbackChangeForBendPoint(i + 1).applyToPoint(getBendPointLocation(i + 1)); cp2 = getFeedbackChangeForBendPoint(i + 2).applyToPoint(getBendPointLocation(i + 2)); @@ -142,7 +145,8 @@ public abstract class CurveLinkVisualBase extends LinkVisualBase { // end point Point2D ep = getFeedbackChangeForBendPoint(END_OF_LINK_BEND_POINT_INDEX) .applyToPoint(getEndAnchorPoint()); - segments.get(segIndex).update(sp, cp1, cp2, ep, 0, markerSize, getArrowLength()); + segments.get(segIndex).update(sp, cp1, cp2, ep, 0, markerSize, getArrowLength(), + getLabelText(pts, pts)); endFeedbackHandle.setX(ep.getX() - ms2); endFeedbackHandle.setY(ep.getY() - ms2); endFeedbackHandle.setWidth(markerSize); @@ -338,10 +342,10 @@ public abstract class CurveLinkVisualBase extends LinkVisualBase { /** Creates the curve segment. */ private void makeCurve(Point2D sp, Point2D cp1, Point2D cp2, Point2D ep, double selWidth, double bpMarkerSize, double cpMarkerSize, boolean showArrow, boolean useLineArrow, - double arrowLength) { + double arrowLength, String labelText) { CurveSegment segVis = new CurveSegment(sp.getX(), sp.getY(), cp1.getX(), cp1.getY(), cp2.getX(), cp2.getY(), ep.getX(), ep.getY(), selWidth, bpMarkerSize, cpMarkerSize, - showArrow, useLineArrow, arrowLength); + showArrow, useLineArrow, arrowLength, labelText); segments.add(segVis); } @@ -448,4 +452,17 @@ public abstract class CurveLinkVisualBase extends LinkVisualBase { cs.setMouseTransparent(true); } } + + /** + * Returns the label text. + * + * @param currentSegment + * the current segment + * @param lastSegment + * the last index of a segment + * @return the label text for the current segment or null for no label + */ + protected String getLabelText(int currentSegment, int lastSegment) { + return null; + } } diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/elliptic/CurveSegment.java b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/elliptic/CurveSegment.java index 445bc2607cb70ae1c788c27ba9fc637dd7df4956..0e7f70e9526a74aaec2bec4f4fc16295521cf5f2 100644 --- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/elliptic/CurveSegment.java +++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/elliptic/CurveSegment.java @@ -13,6 +13,7 @@ import static javafx.scene.paint.Color.BLACK; import static javafx.scene.paint.Color.GRAY; import static javafx.scene.paint.Color.RED; import static javafx.scene.paint.Color.TRANSPARENT; +import static javafx.scene.paint.Color.WHITE; import static javafx.scene.shape.StrokeLineCap.BUTT; import static javafx.scene.shape.StrokeLineJoin.ROUND; @@ -21,11 +22,17 @@ import org.fortiss.tooling.common.ui.javafx.lwfxef.DiagramLayers.ILayer; import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.ILinkMVCBundle; import org.fortiss.tooling.common.ui.javafx.lwfxef.visual.widgets.LinkArrowWidget; +import javafx.geometry.Insets; import javafx.geometry.Point2D; +import javafx.scene.control.Label; +import javafx.scene.layout.Background; +import javafx.scene.layout.BackgroundFill; +import javafx.scene.layout.CornerRadii; import javafx.scene.paint.Paint; import javafx.scene.shape.CubicCurve; import javafx.scene.shape.Line; import javafx.scene.shape.Rectangle; +import javafx.scene.text.TextAlignment; /** * This class encapsulates {@link CubicCurve}s usually needed for every segment: a visible one, a @@ -48,12 +55,14 @@ final class CurveSegment { private final Line helperEnd; /** The arrow widget for curved links. */ private final LinkArrowWidget arrowWidget; + /** Stores the label. */ + private Label label; /** Constructor. */ public CurveSegment(double sx, double sy, double c1x, double c1y, double c2x, double c2y, double ex, double ey, double selectionStrokeWidth, double bendPointFeedbackSize, double controlPointFeedbackSize, boolean showArrow, boolean useLineArrow, - double arrowLength) { + double arrowLength, String labelText) { visibleCurve = new CubicCurve(sx, sy, c1x, c1y, c2x, c2y, ex, ey); visibleCurve.setStroke(BLACK); visibleCurve.setFill(null); @@ -93,6 +102,12 @@ final class CurveSegment { } else { arrowWidget = null; } + if(labelText != null) { + label = new Label(labelText); + label.setTextAlignment(TextAlignment.CENTER); + } else { + label = null; + } } /** Returns the visible curve. */ @@ -145,7 +160,8 @@ final class CurveSegment { /** Updates the segment coordinates. */ public void update(Point2D sp, Point2D cp1, Point2D cp2, Point2D ep, - double bendPointFeedbackSize, double controlPointFeedbackSize, double arrowLength) { + double bendPointFeedbackSize, double controlPointFeedbackSize, double arrowLength, + String labelText) { double sx = sp.getX(); double sy = sp.getY(); visibleCurve.setStartX(sx); @@ -196,16 +212,29 @@ final class CurveSegment { if(arrowWidget != null) { arrowWidget.update(ex, ey, c2x, c2y, arrowLength); } + if(label != null) { + label.setText(labelText); + double lx = (sx + ex - label.getBoundsInLocal().getWidth()) / 2; + double ly = (sy + ey) / 2; + label.setLayoutX(lx); + label.setLayoutY(ly); + } } /** Adds the link nodes of this segment to the link layer node. */ - public void addLinkNodes(DiagramLayers layers, ILinkMVCBundle bundle) { + public void addLinkNodes(DiagramLayers layers, ILinkMVCBundle bundle, String labelText) { ILayer linkLayer = layers.getLinkLayer(); linkLayer.add(visibleCurve, bundle); linkLayer.add(clickableCurve, bundle); if(arrowWidget != null) { linkLayer.add(arrowWidget, bundle); } + if(label != null) { + label.setText(labelText); + label.setBackground( + new Background(new BackgroundFill(WHITE, new CornerRadii(0), new Insets(0)))); + layers.getTextLayer().add(label, bundle); + } } /** Removes the link nodes of this segment from the link layer node. */ @@ -216,6 +245,9 @@ final class CurveSegment { if(arrowWidget != null) { linkLayer.remove(arrowWidget); } + if(label != null) { + layers.getTextLayer().remove(label); + } } /** Adds the feedback nodes of this segment to the feedback layer node. */ @@ -246,5 +278,8 @@ final class CurveSegment { if(arrowWidget != null) { arrowWidget.setMouseTransparent(transparent); } + if(label != null) { + label.setMouseTransparent(transparent); + } } } diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/rectangular/.ratings b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/rectangular/.ratings index 1f339261e0cee18516e6bb05f07035ad012a2ef4..3c07cda2d566de786499df2e878426974facd923 100644 --- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/rectangular/.ratings +++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/rectangular/.ratings @@ -1,9 +1,9 @@ -DiamondContentVisualBase.java 214dc886dba3f26a6404db5c521715466ce85522 YELLOW -LineLinkGraph.java 85a06a553f88f7b9fb4bd9c06411725d9fb160fc YELLOW -LineLinkVisualBase.java 41cee7c8258cb65080bfce2a5d785772305a8119 YELLOW -LineSegment.java a8658ec5bcd930d417a148861831b9ebb70bb37d YELLOW -RectangularBorderLocation.java 824472c353534d1094ae4f735a30a231b885f050 YELLOW -RectangularContentAnchorageVisualBase.java 39981dc29cac42d77c6ffe855ecc8ccad1689230 YELLOW -RectangularContentVisualBase.java ccd23400a7ac47573127a39bc68c55c82baa44ad YELLOW -RectangularDiagramAnchorageVisualBase.java 1259d6d110becca9ae02c754036c6693f00de683 YELLOW -RhomboidContentVisualBase.java 7a91e401034acc629179fb1a45416cd519f617d7 YELLOW +DiamondContentVisualBase.java de349d41b84b2063f74c03ff5ad7290855e997f7 RED +LineLinkGraph.java 85a06a553f88f7b9fb4bd9c06411725d9fb160fc GREEN +LineLinkVisualBase.java 5529031f89a96ad0322f011e89dad1ece785bc03 RED +LineSegment.java a8658ec5bcd930d417a148861831b9ebb70bb37d GREEN +RectangularBorderLocation.java 824472c353534d1094ae4f735a30a231b885f050 GREEN +RectangularContentAnchorageVisualBase.java 39981dc29cac42d77c6ffe855ecc8ccad1689230 GREEN +RectangularContentVisualBase.java aee9ac3dbd53ce89539252d9984ed103d955be2f RED +RectangularDiagramAnchorageVisualBase.java 1259d6d110becca9ae02c754036c6693f00de683 GREEN +RhomboidContentVisualBase.java 0c3820cbfd3763c3cb6b1a0cba5cc71d8eecea73 RED diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/rectangular/DiamondContentVisualBase.java b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/rectangular/DiamondContentVisualBase.java index 214dc886dba3f26a6404db5c521715466ce85522..de349d41b84b2063f74c03ff5ad7290855e997f7 100644 --- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/rectangular/DiamondContentVisualBase.java +++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/rectangular/DiamondContentVisualBase.java @@ -190,6 +190,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); } } diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/rectangular/LineLinkVisualBase.java b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/rectangular/LineLinkVisualBase.java index 41cee7c8258cb65080bfce2a5d785772305a8119..5529031f89a96ad0322f011e89dad1ece785bc03 100644 --- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/rectangular/LineLinkVisualBase.java +++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/rectangular/LineLinkVisualBase.java @@ -339,6 +339,7 @@ public abstract class LineLinkVisualBase extends LinkVisualBase { /** Returns the length of the arrow. */ protected double getArrowLength() { + // TODO (SB): Magic constant return 10; } diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/rectangular/RectangularContentVisualBase.java b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/rectangular/RectangularContentVisualBase.java index ccd23400a7ac47573127a39bc68c55c82baa44ad..aee9ac3dbd53ce89539252d9984ed103d955be2f 100644 --- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/rectangular/RectangularContentVisualBase.java +++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/rectangular/RectangularContentVisualBase.java @@ -28,6 +28,7 @@ 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 { /** Constructor. */ @@ -98,6 +99,7 @@ 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); } diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/rectangular/RhomboidContentVisualBase.java b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/rectangular/RhomboidContentVisualBase.java index 7a91e401034acc629179fb1a45416cd519f617d7..0c3820cbfd3763c3cb6b1a0cba5cc71d8eecea73 100644 --- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/rectangular/RhomboidContentVisualBase.java +++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/rectangular/RhomboidContentVisualBase.java @@ -86,6 +86,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(); } @@ -123,6 +124,7 @@ 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); } diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/widgets/.ratings b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/widgets/.ratings index 23567ab4141161407f8d322123ed4eb8e732c7f4..66a576d2aea5fd43293c3c98d47c80eca5f43f3b 100644 --- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/widgets/.ratings +++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/lwfxef/visual/widgets/.ratings @@ -1,2 +1,2 @@ -ExpandCollapseWidget.java f431b6a86f3ce1794c55b90f39a15cda4f92ea06 YELLOW -LinkArrowWidget.java 5354f14ca9d53cc3df88afb1867a266dfde65199 YELLOW +ExpandCollapseWidget.java f431b6a86f3ce1794c55b90f39a15cda4f92ea06 GREEN +LinkArrowWidget.java 5354f14ca9d53cc3df88afb1867a266dfde65199 GREEN diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/util/.ratings b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/util/.ratings index 1922ed59e6f776adeb20031a9a89f3ef591ddfc5..d8aad1a695ee70a33a9224b9196e6a220822fcaf 100644 --- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/util/.ratings +++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/util/.ratings @@ -1,2 +1,2 @@ -GraphicUtils.java 4d471a310a52bda1c090f956dcdbe90775b12cb8 GREEN +GraphicUtils.java 46cfc991cd3ef787fec3f95751bc680d68479e26 GREEN JavaFXUtils.java db3cf28289109ffec64c8f96c7b2de779a977b3b GREEN diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/util/GraphicUtils.java b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/util/GraphicUtils.java index 4d471a310a52bda1c090f956dcdbe90775b12cb8..46cfc991cd3ef787fec3f95751bc680d68479e26 100644 --- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/util/GraphicUtils.java +++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/util/GraphicUtils.java @@ -28,21 +28,28 @@ import javafx.scene.paint.Color; * @author munaro */ public class GraphicUtils { - /** The image cache of loaded images. */ private static final HashMap<String, Image> imageCache = new HashMap<>(); /** Returns the plugin-local URI string for the given resource. */ public static String getURIString(String pluginId, String localPath) { + if(!pluginId.endsWith("/") && !localPath.startsWith("/")) { + localPath = "/" + localPath; + } return "platform:/plugin/" + pluginId + localPath; } - /** Returns the Java FX Image load from the local path. */ + /** Returns the Java FX Image loaded from the plugin's local path. */ public static Image getFXImage(String pluginId, String localPath) { String uri = getURIString(pluginId, localPath); if(uri == null) { return null; } + return getFXImageFromURI(uri); + } + + /** Returns the Java FX Image loaded from the given URI. */ + public static Image getFXImageFromURI(String uri) { Image cacheImage = imageCache.get(uri); if(cacheImage == null) { InputStream in = null; diff --git a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/extension/.ratings b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/extension/.ratings index 62c4ab516cd12fe289a932734684368e00f044be..e039d39f894c2359d5eec38e68a158d58f1e65fa 100644 --- a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/extension/.ratings +++ b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/extension/.ratings @@ -3,8 +3,8 @@ IContextMenuContributor.java 0f09c76662c154cf52ddab61b417e82a42854162 GREEN IContextMenuMultiSelectionContributor.java 125b31dd38009bc2095b7e6bc860e946e39f58c4 GREEN IEditPartFactory.java 5729715847f553d95a5bad4a9211c7e6f458badd GREEN IModelEditor.java 962d7f7758abc88bbc6064c8b4eb32da00abf8e8 GREEN -IModelEditorBinding.java 844865d93252b6c4a648c23ff28bb28fd42c17aa YELLOW -IModelElementHandler.java 21b4a96251e0267f156b4b8f2b95a97f6e81e646 GREEN +IModelEditorBinding.java 844865d93252b6c4a648c23ff28bb28fd42c17aa GREEN +IModelElementHandler.java 86a8ec88b9679bbe7f53cfa8d1592bd862873f80 GREEN ITutorialStepUI.java b8aee2b95857484ab6ad9ecd55b5de9f0ea158e5 GREEN ITutorialUIProvider.java aa0ff5db4d7ba0953e34edeb99f3e8279567e18f GREEN ITutorialUIWhitelistProvider.java d703c1531c6ae7677c2d94cbc95d498dfa4a7e9b GREEN diff --git a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/extension/IModelElementHandler.java b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/extension/IModelElementHandler.java index 21b4a96251e0267f156b4b8f2b95a97f6e81e646..86a8ec88b9679bbe7f53cfa8d1592bd862873f80 100644 --- a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/extension/IModelElementHandler.java +++ b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/extension/IModelElementHandler.java @@ -25,6 +25,8 @@ import org.fortiss.tooling.kernel.ui.extension.base.ModelElementHandlerBase; import org.fortiss.tooling.kernel.ui.extension.base.NamedCommentedModelElementHandlerBase; import org.fortiss.tooling.kernel.ui.service.IModelElementHandlerService; +import javafx.scene.Node; + /** * A model element handler provides information about a specific type of model * elements like name, description, icon and certain kinds of sub-elements. @@ -49,6 +51,9 @@ public interface IModelElementHandler<T extends EObject> extends IEObjectAware<T /** Returns image descriptor to be used as icon image. */ ImageDescriptor getIconImageDescriptor(T element); + /** Returns the JavaFX icon of the model element. */ + Node getFXIcon(T element); + /** * Returns all children acting as nodes, which are usually displayed as edit * parts by graphical editors and entries in the navigator tree. diff --git a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/extension/base/.ratings b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/extension/base/.ratings index 3747d405583494626be4fdece7f4d8e8214f2f49..b57e572ddef97543ad02e1f91fca7eee0f6531c2 100644 --- a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/extension/base/.ratings +++ b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/extension/base/.ratings @@ -4,11 +4,11 @@ EObjectActionBase.java 4ef9f8be59e64d4838acc9e268d418ba5d94fa1a GREEN EReferenceListPropertySectionBase.java 7390dd7bfdc979e8ff0c5c30c67ab7b6c9d70c92 GREEN EReferencePropertySectionBase.java 0548da6778516003257f59d0b4c2b60d458be3b6 GREEN EditorBase.java 9c09fff92945256bb8680992ae7bb2c78f47b150 GREEN -FXEditorBase.java 2e520be0bbae7d0aebdff70218a124dbe0896ce2 GREEN +FXEditorBase.java 545085c3270f09d69b609f328792e904ebda23ff GREEN IListPropertySection.java 8bb00fe7959583e794ff9437b7a77404c9a9e70f GREEN -LWFXEFEditorBase.java 72a0735d0a516e53f34e485039471512c8ac6577 YELLOW -ModelEditorBindingBase.java b9b1a1c5a48a6e677d1f57ad55a6126d9703c4b5 YELLOW -ModelElementHandlerBase.java 384727748f125c9d43f19d9c0eba4ba1be5a7a26 GREEN +LWFXEFEditorBase.java f6b160b700a0287021402b5702beb2bfdce3dc2e GREEN +ModelEditorBindingBase.java b9b1a1c5a48a6e677d1f57ad55a6126d9703c4b5 GREEN +ModelElementHandlerBase.java d08583ffdf78938a14caeb46124eda4ce5cac3e4 GREEN MultiEObjectActionBase.java 9e237d8ea640c4194e4877af4a9cfce88698e543 GREEN NamedCommentedModelElementHandlerBase.java 681b98b50b362f01abb7a36f108f4f11b9e51829 GREEN PropertySectionBase.java 20fb1daea544123ea941743aafeb9ac59daf5356 GREEN diff --git a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/extension/base/FXEditorBase.java b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/extension/base/FXEditorBase.java index 2e520be0bbae7d0aebdff70218a124dbe0896ce2..545085c3270f09d69b609f328792e904ebda23ff 100644 --- a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/extension/base/FXEditorBase.java +++ b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/extension/base/FXEditorBase.java @@ -15,7 +15,15 @@ +--------------------------------------------------------------------------*/ package org.fortiss.tooling.kernel.ui.extension.base; +import java.util.ArrayList; +import java.util.List; + import org.eclipse.emf.ecore.EObject; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.ISelectionProvider; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Composite; @@ -28,15 +36,50 @@ import javafx.scene.Scene; * * @author hoelzlf */ -public abstract class FXEditorBase<T extends EObject> extends EditorBase<T> { +public abstract class FXEditorBase<T extends EObject> extends EditorBase<T> + implements ISelectionProvider { + /** The list of {@link ISelectionChangedListener}s. */ + private final List<ISelectionChangedListener> selectionListeners = new ArrayList<>(); + /** {@inheritDoc} */ @Override public final void createPartControl(Composite parent) { FXCanvas canvas = new FXCanvas(parent, SWT.NONE); Scene scene = new Scene(createSceneRoot()); canvas.setScene(scene); + + getSite().setSelectionProvider(this); } /** Creates the root node of the scene. */ protected abstract Parent createSceneRoot(); + + /** {@inheritDoc} */ + @Override + public final void addSelectionChangedListener(ISelectionChangedListener listener) { + if(!selectionListeners.contains(listener)) { + selectionListeners.add(listener); + } + } + + /** {@inheritDoc} */ + @Override + public final void removeSelectionChangedListener(ISelectionChangedListener listener) { + selectionListeners.remove(listener); + } + + /** {@inheritDoc} */ + @Override + public final void setSelection(ISelection selection) { + SelectionChangedEvent evt = new SelectionChangedEvent(this, selection); + for(ISelectionChangedListener scl : selectionListeners) { + scl.selectionChanged(evt); + } + } + + /** {@inheritDoc} */ + @Override + public ISelection getSelection() { + return StructuredSelection.EMPTY; + } } diff --git a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/extension/base/LWFXEFEditorBase.java b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/extension/base/LWFXEFEditorBase.java index 72a0735d0a516e53f34e485039471512c8ac6577..f6b160b700a0287021402b5702beb2bfdce3dc2e 100644 --- a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/extension/base/LWFXEFEditorBase.java +++ b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/extension/base/LWFXEFEditorBase.java @@ -23,10 +23,7 @@ import java.util.Objects; import org.eclipse.emf.ecore.EObject; import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.ui.IEditorPart; import org.fortiss.tooling.common.ui.javafx.lwfxef.DiagramViewer; @@ -51,12 +48,9 @@ import javafx.scene.Parent; * @author hoelzl * @author diewald */ -public abstract class LWFXEFEditorBase<T extends EObject> extends FXEditorBase<T> - implements ISelectionProvider { +public abstract class LWFXEFEditorBase<T extends EObject> extends FXEditorBase<T> { /** The diagram viewer. */ protected DiagramViewer viewer; - /** The list of {@link ISelectionChangedListener}s. */ - private final List<ISelectionChangedListener> selectionListeners = new ArrayList<>(); /** References the delegating {@link IModelFactory} of this JavaFX {@link IEditorPart}. */ private IModelFactory delegatingModelFactory; @@ -75,7 +69,6 @@ public abstract class LWFXEFEditorBase<T extends EObject> extends FXEditorBase<T viewer = new DiagramViewer(delegatingModelFactory, delegatingVisualFactory, delegatingControllerFactory, cb -> modelSelected(), chg -> applyModelChange(chg)); customizeViewer(); - getSite().setSelectionProvider(this); return viewer.getVisualNode(); } @@ -117,29 +110,6 @@ public abstract class LWFXEFEditorBase<T extends EObject> extends FXEditorBase<T ICommandStackService.getInstance().runAsCommand(editedObject, () -> chg.applyChange()); } - /** {@inheritDoc} */ - @Override - public void addSelectionChangedListener(ISelectionChangedListener listener) { - if(!selectionListeners.contains(listener)) { - selectionListeners.add(listener); - } - } - - /** {@inheritDoc} */ - @Override - public void removeSelectionChangedListener(ISelectionChangedListener listener) { - selectionListeners.remove(listener); - } - - /** {@inheritDoc} */ - @Override - public void setSelection(ISelection selection) { - SelectionChangedEvent evt = new SelectionChangedEvent(this, selection); - for(ISelectionChangedListener scl : selectionListeners) { - scl.selectionChanged(evt); - } - } - /** {@inheritDoc} */ @Override public ISelection getSelection() { diff --git a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/extension/base/ModelElementHandlerBase.java b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/extension/base/ModelElementHandlerBase.java index 384727748f125c9d43f19d9c0eba4ba1be5a7a26..d08583ffdf78938a14caeb46124eda4ce5cac3e4 100644 --- a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/extension/base/ModelElementHandlerBase.java +++ b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/extension/base/ModelElementHandlerBase.java @@ -16,6 +16,7 @@ package org.fortiss.tooling.kernel.ui.extension.base; import static java.util.Collections.emptyList; +import static org.fortiss.tooling.common.ui.javafx.util.GraphicUtils.getFXImageFromURI; import java.util.HashMap; import java.util.List; @@ -28,6 +29,9 @@ import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Point; import org.fortiss.tooling.kernel.ui.extension.IModelElementHandler; +import javafx.scene.Node; +import javafx.scene.image.ImageView; + /** * Base implementation for {@link IModelElementHandler}s. * @@ -40,7 +44,6 @@ import org.fortiss.tooling.kernel.ui.extension.IModelElementHandler; */ public abstract class ModelElementHandlerBase<T extends EObject> implements IModelElementHandler<T> { - /** Stores the icon image. */ private Map<ImageDescriptor, Image> iconImages = new HashMap<ImageDescriptor, Image>(); @@ -76,6 +79,28 @@ public abstract class ModelElementHandlerBase<T extends EObject> return iconImage; } + /** + * Returns the URL to the JavaFX icon image. + * + * @param element + * the model element + * @return the URL of the icon + */ + protected String getFXIconURL(T element) { + return "platform:/plugin/org.fortiss.tooling.kernel.ui/icons/fix.png"; + } + + /** {@inheritDoc} */ + @Override + public Node getFXIcon(T element) { + String uri = getFXIconURL(element); + if(uri == null) { + return null; + } + javafx.scene.image.Image img = getFXImageFromURI(uri); + return new ImageView(img); + } + /** The default implementation forwards the request by ignoring the model element. */ @Override public ImageDescriptor getIconImageDescriptor(T element) { diff --git a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/extension/base/factory/.ratings b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/extension/base/factory/.ratings index 5d72fbf78d3b4ebb888b9c985348f093a1e4bc05..913a709138d79300d853f3471bc404d1aaea3571 100644 --- a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/extension/base/factory/.ratings +++ b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/extension/base/factory/.ratings @@ -1,4 +1,4 @@ -DelegatingControllerFactory.java be19395684645d79d892e5caed079d4b7f5cb5b0 YELLOW +DelegatingControllerFactory.java 50b2a5057794d6df22649e267d282ca3aa16797c GREEN DelegatingFactoryBase.java f421742267610f41bb6196346026d2f239d90ed0 GREEN -DelegatingModelFactory.java f94ca989a5b97ad3f073040bb46b9c0a87e35d6d YELLOW -DelegatingVisualFactory.java 8bb82e9d48b2577655e577e7e807629c6fd6f2db YELLOW +DelegatingModelFactory.java 2b5b22137d875ff7676990fb148034ab42e912da GREEN +DelegatingVisualFactory.java 17bd4a6bbd3b9f9f8f9104d8cd9b239ef4bac759 GREEN diff --git a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/extension/base/factory/DelegatingControllerFactory.java b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/extension/base/factory/DelegatingControllerFactory.java index be19395684645d79d892e5caed079d4b7f5cb5b0..50b2a5057794d6df22649e267d282ca3aa16797c 100644 --- a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/extension/base/factory/DelegatingControllerFactory.java +++ b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/extension/base/factory/DelegatingControllerFactory.java @@ -28,9 +28,10 @@ import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.ILinkMVCBundle; import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.IMVCBundle; /** - * Delegates the creational calls to concrete {@link IControllerFactory}s. The first non-null - * element returned by the factories of the initially given list is returned. If no element is - * created (all delegates returned null), this factory throws a {@link RuntimeException}. + * Delegates the creational calls to concrete {@link IControllerFactory}s. The first + * non-{@code null} element returned by the factories of the initially given list is returned. If no + * element is created (all delegates returned {@code null}), this factory throws a + * {@link RuntimeException}. * * @author hoelzl * @author diewald diff --git a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/extension/base/factory/DelegatingModelFactory.java b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/extension/base/factory/DelegatingModelFactory.java index f94ca989a5b97ad3f073040bb46b9c0a87e35d6d..2b5b22137d875ff7676990fb148034ab42e912da 100644 --- a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/extension/base/factory/DelegatingModelFactory.java +++ b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/extension/base/factory/DelegatingModelFactory.java @@ -15,6 +15,7 @@ +--------------------------------------------------------------------------*/ package org.fortiss.tooling.kernel.ui.extension.base.factory; +import static java.util.Optional.empty; import static java.util.stream.Collectors.toList; import static org.apache.commons.lang3.reflect.ConstructorUtils.getMatchingAccessibleConstructor; import static org.conqat.lib.commons.collections.CollectionUtils.isNullOrEmpty; @@ -32,9 +33,9 @@ import org.fortiss.tooling.common.ui.javafx.lwfxef.model.IModelFactory; import org.fortiss.tooling.kernel.ui.ToolingKernelUIActivator; /** - * Delegates the creational and getter calls to concrete {@link IModelFactory}s. The first non-null - * element returned by the factories of the initially given list is returned. If no element is - * created (all delegates returned null), this factory also returns null. + * Delegates the creational and getter calls to concrete {@link IModelFactory}s. The first + * non-{@code null} element returned by the factories of the initially given list is returned. If no + * element is created (all delegates returned {@code null}), this factory also returns {@code null}. * <p> * Only the root model must be identical for all delegate factories. Hence, the root element of the * first delegate is returned. @@ -65,7 +66,7 @@ public class DelegatingModelFactory extends DelegatingFactoryBase<IModelFactory> InvocationTargetException e) { error(ToolingKernelUIActivator.getDefault(), "Failed to instantiate the factory " + delegateFactory.getSimpleName() + "."); - return Optional.empty(); + return empty(); } } catch(NullPointerException | SecurityException e1) { error(ToolingKernelUIActivator.getDefault(), "The factory " + @@ -73,7 +74,7 @@ public class DelegatingModelFactory extends DelegatingFactoryBase<IModelFactory> " is missing a single argument Constructor accepting the edited model." + " Only such constructors are allowed for " + IModelFactory.class.getSimpleName() + "s."); - return Optional.empty(); + return empty(); } } @@ -109,7 +110,8 @@ public class DelegatingModelFactory extends DelegatingFactoryBase<IModelFactory> /** {@inheritDoc} */ @Override public Object getRootModel() { - return editedObject; + return getDelegateFactories().stream().map(f -> f.getRootModel()).filter(cc -> cc != null) + .findFirst().orElse(null); } /** {@inheritDoc} */ diff --git a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/extension/base/factory/DelegatingVisualFactory.java b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/extension/base/factory/DelegatingVisualFactory.java index 8bb82e9d48b2577655e577e7e807629c6fd6f2db..17bd4a6bbd3b9f9f8f9104d8cd9b239ef4bac759 100644 --- a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/extension/base/factory/DelegatingVisualFactory.java +++ b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/extension/base/factory/DelegatingVisualFactory.java @@ -32,9 +32,9 @@ import org.fortiss.tooling.kernel.ui.extension.base.LWFXEFEditorBase; /** * Base class for {@link IVisualFactory}s of extendable {@link LWFXEFEditorBase} - * {@link IEditorPart}s.The first non-null element returned by the factories of the initially given - * list is returned. If no element is - * created (all delegates returned null), this factory also returns null. + * {@link IEditorPart}s.The first non-{@code null} element returned by the factories of the + * initially given list is returned. If no element is created (all delegates returned null), this + * factory also returns {@code null}. * <P> * This class uses the {@link ITransformationService} to find a delegate visual factory for the * model elements in question. diff --git a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/.ratings b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/.ratings index 4fe5ae19062526bb33cd7efe44bd12d9d85587b6..47d763c0b8c828c45fb79c3acb051e06400a72bd 100644 --- a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/.ratings +++ b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/.ratings @@ -3,8 +3,8 @@ AllocationEditPartFactoryService.java 81bd227736013f1157ba9d0f79a9f3deefe10064 G ContextMenuService.java ca3c899293f25b70ce8e5f0d86ca2f9683329d81 GREEN EditPartFactoryService.java e9180c0020f1769d9e24ef3c08f9ca5599dbc5c3 GREEN MarkerService.java 208f97f3ccabf0947702a17ddca23d8766a268f4 GREEN -ModelEditorBindingService.java 948fcdc298a74e366351ad8835a145af6cd238be GREEN -ModelElementHandlerService.java 07a30545ad687ff0fe13bf7a9348c41fb03e0b2c GREEN +ModelEditorBindingService.java 577f5db41abf240291434dbad6bc6b0fde1eeb2b GREEN +ModelElementHandlerService.java eeb07f6926012aa98256d452d1e554a5486dc657 GREEN NavigatorService.java 2b1361eac805996e22e5409dafff9707fbac3376 GREEN ToolingKernelUIInternal.java a70d19883dfb315d860233156d8524cf1ac2952f GREEN TutorialUIService.java b1d632eca91b4feb583f3930cd6ee4722dd9bfed GREEN diff --git a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/ModelElementHandlerService.java b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/ModelElementHandlerService.java index 07a30545ad687ff0fe13bf7a9348c41fb03e0b2c..eeb07f6926012aa98256d452d1e554a5486dc657 100644 --- a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/ModelElementHandlerService.java +++ b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/ModelElementHandlerService.java @@ -33,6 +33,8 @@ import org.fortiss.tooling.kernel.ui.extension.IModelElementHandler; import org.fortiss.tooling.kernel.ui.internal.introspection.items.ModelElementHandlerServiceIntrospectionDetailsItem; import org.fortiss.tooling.kernel.ui.service.IModelElementHandlerService; +import javafx.scene.Node; + /** * This class implements the {@link IModelElementHandlerService} interface. It * requires a unique and singleton model element handler per model element @@ -145,6 +147,13 @@ public class ModelElementHandlerService return handler == null ? null : handler.getIcon(modelElement); } + /** {@inheritDoc} */ + @Override + public Node getFXIcon(EObject modelElement) { + IModelElementHandler<EObject> handler = getModelElementHandler(modelElement); + return handler == null ? null : handler.getFXIcon(modelElement); + } + /** {@inheritDoc} */ @Override public String getWrappedNameDescription(EObject modelElement) { diff --git a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/service/.ratings b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/service/.ratings index ac88577cf756cac95c8f570ad76c78098a9ea3ba..86599ae4e07d82e60443af868fe84e8d057ae40e 100644 --- a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/service/.ratings +++ b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/service/.ratings @@ -4,6 +4,6 @@ IContextMenuService.java cfb6b8237b6cd2b0e461991a9ceb95969f330265 GREEN IEditPartFactoryService.java c448bff63fb81f57037c9f1dc5319859c12d0c4d GREEN IMarkerService.java d433e838e387dd2fe61b8dea7395ebb7203ae39b GREEN IModelEditorBindingService.java ce2ae1957e2232bb0fac1d1d262103f9adfc5266 GREEN -IModelElementHandlerService.java c04c2876ccb8b3f8597c8e443f9c7c3db0945430 GREEN +IModelElementHandlerService.java 1ff2bda9054f6bbd4017fc0ddc118b7702196815 GREEN INavigatorService.java 8d2ffeb6f075d3abea904b84d8a40090d97837fd GREEN ITutorialUIService.java 72707c60c3d23d8ffc5c579cb9b022bb614eb094 GREEN diff --git a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/service/IModelElementHandlerService.java b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/service/IModelElementHandlerService.java index c04c2876ccb8b3f8597c8e443f9c7c3db0945430..1ff2bda9054f6bbd4017fc0ddc118b7702196815 100644 --- a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/service/IModelElementHandlerService.java +++ b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/service/IModelElementHandlerService.java @@ -20,6 +20,8 @@ import org.eclipse.swt.graphics.Image; import org.fortiss.tooling.kernel.ui.extension.IModelElementHandler; import org.fortiss.tooling.kernel.ui.internal.ModelElementHandlerService; +import javafx.scene.Node; + /** * The model element handler service provides access to registered model element * handlers. @@ -63,6 +65,12 @@ public interface IModelElementHandlerService { */ Image getIcon(EObject modelElement); + /** + * Returns the (JavaFX) icon of the model element (or <code>null</code> if no handler + * was found). + */ + Node getFXIcon(EObject modelElement); + /** * Returns a wrapped string built from the name and description returned by * the underlying handler. diff --git a/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/utils/.ratings b/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/utils/.ratings index 8fb040ffbf08c91fe3c8dea473975346c23c28b3..87159f5430ed08dd71e893efd81e7542dab16d2a 100644 --- a/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/utils/.ratings +++ b/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/utils/.ratings @@ -7,6 +7,7 @@ HierarchicalNameComparator.java 6face1b673126701a0721af48ead2f9766c17d46 GREEN IdentifierUtils.java fff43dc4e84cdd89c3ece4f5d9d89aec4b0749c2 GREEN JavaUtils.java 65cdadfb9137a240ad59992eacf53a15b7f20804 GREEN KernelModelElementUtils.java fded09befe7e543fc04ea5184ffc1c8a309d7a66 GREEN +KernelServiceBasedModelListenerBase.java 8d916509ae75f7118ce72564ee715c46556fb709 GREEN LoggingUtils.java 0e0aa5d466d80ea29cfc7e91178b23a5cdd4ddf7 GREEN PrototypesUtils.java ec75bed75cfc5103f1f38e3a29df86f729428775 GREEN ResourceUtils.java 7f4941a83115dfbed75eb58b79c0a372fe1cbb94 GREEN diff --git a/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/utils/KernelServiceBasedModelListenerBase.java b/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/utils/KernelServiceBasedModelListenerBase.java new file mode 100644 index 0000000000000000000000000000000000000000..8d916509ae75f7118ce72564ee715c46556fb709 --- /dev/null +++ b/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/utils/KernelServiceBasedModelListenerBase.java @@ -0,0 +1,116 @@ +/*-------------------------------------------------------------------------+ +| Copyright 2019 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.utils; + +import java.util.ArrayList; +import java.util.EventObject; +import java.util.List; + +import org.eclipse.emf.common.command.CommandStackListener; +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.util.EContentAdapter; +import org.fortiss.tooling.kernel.extension.data.ITopLevelElement; +import org.fortiss.tooling.kernel.service.ICommandStackService; +import org.fortiss.tooling.kernel.service.IPersistencyService; + +/** + * Base class for listeners using EMF {@link Adapter}s and {@link ICommandStackService}. + * <P> + * Sub-classes should override {@link #updateComplete(List)} in order to be notified when an + * update cycle has completed (one or more EMF notifications followed by a command stack + * change). + * <P> + * Sub-classes may also provide their custom EMF {@link Adapter}, but must call + * {@link #addNotification(Notification)} whenever a relevant EMF notification occurs. + * + * @author hoelzl + */ +public abstract class KernelServiceBasedModelListenerBase<T extends EObject> + implements CommandStackListener { + /** The persistency service reference. */ + private static final IPersistencyService persistencyService = IPersistencyService.getInstance(); + /** The command stack service. */ + private static final ICommandStackService commandStackService = + ICommandStackService.getInstance(); + /** List of relevant {@link Notification}s recorded during a change transaction. */ + private final List<Notification> notifications = new ArrayList<>(); + + /** The model element. */ + private final T modelElement; + /** The EMF notification listener. */ + private Adapter emfAdapter = new EContentAdapter() { + /** {@inheritDoc} */ + @Override + public void notifyChanged(Notification notification) { + super.notifyChanged(notification); + addNotification(notification); + } + }; + + /** Constructor. */ + public KernelServiceBasedModelListenerBase(T modelElement, Adapter emfAdapter) { + this.modelElement = modelElement; + this.emfAdapter = emfAdapter; + } + + /** Constructor. */ + public KernelServiceBasedModelListenerBase(T modelElement) { + this.modelElement = modelElement; + } + + /** + * Called when the update cycle is completed. + * + * @param notifications + * the list of notifications of the completed cycle + */ + public void updateComplete(List<Notification> notifications) { + // default does nothing. + } + + /** Adds the given {@link Notification} to list of notifications. */ + protected final void addNotification(Notification event) { + notifications.add(event); + } + + /** Registers the listener with the model and the command stack service. */ + public final void register() { + notifications.clear(); + ITopLevelElement root = persistencyService.getTopLevelElementFor(modelElement); + commandStackService.addCommandStackListener(root, this); + modelElement.eAdapters().add(emfAdapter); + } + + /** Unregisters the listener from the model and the command stack service. */ + public final void unregister() { + modelElement.eAdapters().remove(emfAdapter); + ITopLevelElement root = persistencyService.getTopLevelElementFor(modelElement); + commandStackService.removeCommandStackListener(root, this); + notifications.clear(); + } + + /** {@inheritDoc} */ + @Override + public void commandStackChanged(EventObject event) { + if(notifications.isEmpty()) { + return; + } + updateComplete(notifications); + notifications.clear(); + } +}