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 6c8379b82851a06d22fd330385c63fae0e4d7f00..ed8de38bfe169ba4f2a27c543c5aae0e06378cba 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 @@ -6,8 +6,9 @@ EObjectRectangularResizableContentControllerBase.java 787a540213f29e8daaecd9afe9 KernelServiceBasedModelChangeProviderBase.java 18e48f17ea8dfba90de024a8959fc5a4b0d05d45 GREEN LayoutModelChangeProvider.java b5449d02eaf39086909720c43e21bd061005fc9e GREEN LayoutedContentAnchorageController.java 851a957839af8a22ea41d312e21b7a4a29b882e5 YELLOW -LayoutedCurveLinkBendPointController.java 76e510cbaa39538ac3314cd909a62885b625486d RED +LayoutedCurveLinkBendPointController.java 592c1e4f6dae466e38cc67b372a910b8a1f4b67e YELLOW LayoutedDiagramAnchorageController.java 1e1ac7c5fa26c632736f5023e90f05d09bc0710d GREEN LayoutedEllipticResizableContentController.java b2c9c48190b9ff69a175bbe5f89761c1b08621ab YELLOW -LayoutedLineLinkBendPointController.java e2dac36334191c39d54b4f95fa8482a6392ce82c RED +LayoutedLineLinkBendPointController.java 6ea31e09f98b5e64890d4811e9c56b1abea39158 YELLOW +LayoutedLinkBendPointController.java e93683330e57725915e5040d9d2b23f6c7835e6c YELLOW LayoutedRectangularResizableContentController.java 1e18af3ee10dd3754325ed389fed664da65a0b61 GREEN 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 index 76e510cbaa39538ac3314cd909a62885b625486d..592c1e4f6dae466e38cc67b372a910b8a1f4b67e 100644 --- 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 @@ -16,28 +16,18 @@ package org.fortiss.tooling.base.ui.editor.fx.controller; import static java.util.Arrays.asList; -import static java.util.Objects.requireNonNull; import static org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.FeedbackChange.locationFeedbackChange; -import static org.fortiss.tooling.base.ui.utils.LayoutDataUIUtils.getConnectionPoints; -import static org.fortiss.tooling.base.ui.utils.LayoutDataUIUtils.removeConnectionPoint; import static org.fortiss.tooling.base.utils.LayoutModelElementFactory.createPoint; -import java.util.List; - -import org.eclipse.emf.common.util.EList; import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.DiagramCoordinate; import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.DiagramViewer; import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.DiagramViewerFeatures; import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.FeedbackChange; import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.controller.IController; -import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.controller.base.LinkControllerBase; -import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.model.IModelChangeProvider; import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.mvc.ILinkMVCBundle; -import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.mvc.IMVCBundle; import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.visual.ILinkVisual; import org.fortiss.tooling.base.model.layout.ILayoutedModelElement; import org.fortiss.tooling.base.model.layout.Point; -import org.fortiss.tooling.kernel.service.IConnectionCompositorService; import javafx.geometry.Point2D; @@ -48,59 +38,11 @@ import javafx.geometry.Point2D; * @author munaro */ public class LayoutedCurveLinkBendPointController<T extends ILayoutedModelElement> - extends LinkControllerBase { - /** {@link IModelChangeProvider} for this controller */ - private final LayoutModelChangeProvider layoutModelChangeProvider; + extends LayoutedLinkBendPointController<T> { /** Constructor. */ public LayoutedCurveLinkBendPointController(ILinkMVCBundle 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); - } - - /** Returns the model element. */ - @SuppressWarnings("unchecked") - public T getModelElement() { - return (T)getModel(); - } - - /** {@inheritDoc} */ - @Override - protected boolean clampAndSnapBendPointToGridCenter() { - // disable default mode - return false; - } - - /** {@inheritDoc} */ - @Override - protected boolean clampAndSnapBendPointToGrid() { - // enable clamping mode - return true; - } - - /** {@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(); + super(mvcb, modelType); } /** {@inheritDoc} */ @@ -166,42 +108,4 @@ public class LayoutedCurveLinkBendPointController<T extends ILayoutedModelElemen updateModelAfterBendPointMove(otherIndex, -chg.getDeltaX(), -chg.getDeltaY()); } } - - /** {@inheritDoc} */ - @Override - protected void deleteBendPoint(int bpIndex) { - removeConnectionPoint(getModelElement(), bpIndex); - } - - /** {@inheritDoc} */ - @Override - protected void updateModelAfterLinkMove(ILinkMVCBundle linkBundle, IMVCBundle startBundle, - IMVCBundle endBundle) { - // ignored - } - - /** {@inheritDoc} */ - @Override - protected void deleteLink() { - IConnectionCompositorService.getInstance().disconnect(getModelElement()); - } - - /** {@inheritDoc} */ - @Override - public void delete() { - deleteLink(); - } - - /** {@inheritDoc} */ - @Override - protected void updateModelAfterBendPointMove(int bpIndex, double dx, double dy) { - List<Point> oldPoints = getBendPointList(getModelElement()); - Point point = oldPoints.get(bpIndex); - int oldX = point.getX(); - int oldY = point.getY(); - int newX = oldX + (int)dx; - int newY = oldY + (int)dy; - point.setX(newX); - point.setY(newY); - } } 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 index e2dac36334191c39d54b4f95fa8482a6392ce82c..6ea31e09f98b5e64890d4811e9c56b1abea39158 100644 --- 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 @@ -13,85 +13,26 @@ *******************************************************************************/ 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.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.DiagramCoordinate; import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.DiagramViewer; import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.controller.IController; -import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.controller.base.LinkControllerBase; -import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.model.IModelChangeProvider; import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.mvc.ILinkMVCBundle; -import org.eclipse.systemfocus.kernel.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}. + * {@link IController} for {@link ILayoutedModelElement}s representing straight links and + * connections in a {@link DiagramViewer}. * * @author hoelzl */ public class LayoutedLineLinkBendPointController<T extends ILayoutedModelElement> - extends LinkControllerBase { - /** {@link IModelChangeProvider} for this controller */ - private final LayoutModelChangeProvider layoutModelChangeProvider; + extends LayoutedLinkBendPointController<T> { /** Constructor. */ public LayoutedLineLinkBendPointController(ILinkMVCBundle 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); - } - - /** Returns the model element. */ - @SuppressWarnings("unchecked") - public T getModelElement() { - return (T)getModel(); - } - - /** {@inheritDoc} */ - @Override - protected boolean clampAndSnapBendPointToGridCenter() { - // disable default mode - return false; - } - - /** {@inheritDoc} */ - @Override - protected boolean clampAndSnapBendPointToGrid() { - // enable clamping mode - return true; - } - - /** {@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(); + super(mvcb, modelType); } /** {@inheritDoc} */ @@ -101,42 +42,4 @@ public class LayoutedLineLinkBendPointController<T extends ILayoutedModelElement int y = (int)location.getY(); addConnectionPoint(getModelElement(), bpIndex, x, y); } - - /** {@inheritDoc} */ - @Override - protected void updateModelAfterBendPointMove(int bpIndex, double dx, double dy) { - List<Point> oldPoints = getBendPointList(getModelElement()); - Point point = oldPoints.get(bpIndex); - int oldX = point.getX(); - int oldY = point.getY(); - int newX = oldX + (int)dx; - int newY = oldY + (int)dy; - point.setX(newX); - point.setY(newY); - } - - /** {@inheritDoc} */ - @Override - protected void deleteBendPoint(int bpIndex) { - removeConnectionPoint(getModelElement(), bpIndex); - } - - /** {@inheritDoc} */ - @Override - protected void updateModelAfterLinkMove(ILinkMVCBundle linkBundle, IMVCBundle startBundle, - IMVCBundle endBundle) { - // ignored - } - - /** {@inheritDoc} */ - @Override - protected void deleteLink() { - IConnectionCompositorService.getInstance().disconnect(getModelElement()); - } - - /** {@inheritDoc} */ - @Override - public void delete() { - deleteLink(); - } } 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 new file mode 100644 index 0000000000000000000000000000000000000000..e93683330e57725915e5040d9d2b23f6c7835e6c --- /dev/null +++ b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/editor/fx/controller/LayoutedLinkBendPointController.java @@ -0,0 +1,134 @@ +/*-------------------------------------------------------------------------+ +| 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.getConnectionPoints; +import static org.fortiss.tooling.base.ui.utils.LayoutDataUIUtils.removeConnectionPoint; + +import java.util.List; + +import org.eclipse.emf.common.util.EList; +import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.DiagramViewer; +import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.controller.IController; +import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.controller.base.LinkControllerBase; +import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.model.IModelChangeProvider; +import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.mvc.ILinkMVCBundle; +import org.eclipse.systemfocus.kernel.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; + +/** + * Base class for {@link IController}s for {@link ILayoutedModelElement}s representing links and + * connections in a {@link DiagramViewer}. + * + * @author munaro + */ +public abstract class LayoutedLinkBendPointController<T extends ILayoutedModelElement> + extends LinkControllerBase { + /** {@link IModelChangeProvider} for this controller */ + 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) { + 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 + public void delete() { + deleteLink(); + } + + /** {@inheritDoc} */ + @Override + protected boolean clampAndSnapBendPointToGridCenter() { + // disable default mode + return false; + } + + /** {@inheritDoc} */ + @Override + protected boolean clampAndSnapBendPointToGrid() { + // enable clamping mode + return true; + } + + /** {@inheritDoc} */ + @Override + protected void deleteBendPoint(int bpIndex) { + removeConnectionPoint(getModelElement(), bpIndex); + } + + /** {@inheritDoc} */ + @Override + protected void updateModelAfterBendPointMove(int bpIndex, double dx, double dy) { + List<Point> oldPoints = getBendPointList(getModelElement()); + Point point = oldPoints.get(bpIndex); + int oldX = point.getX(); + int oldY = point.getY(); + int newX = oldX + (int)dx; + int newY = oldY + (int)dy; + point.setX(newX); + point.setY(newY); + } + + /** {@inheritDoc} */ + @Override + protected void deleteLink() { + IConnectionCompositorService.getInstance().disconnect(getModelElement()); + } + + /** {@inheritDoc} */ + @Override + protected void updateModelAfterLinkMove(ILinkMVCBundle linkBundle, IMVCBundle startBundle, + IMVCBundle endBundle) { + // ignored + } + + /** Returns the list of bend-points. */ + protected EList<Point> getBendPointList(ILayoutedModelElement modelElement) { + return getConnectionPoints(modelElement).getPoints(); + } + + /** {@inheritDoc} */ + @Override + protected int getNumerOfBendPoints() { + return getBendPointList(getModelElement()).size(); + } +} 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 2ad706334f0a8bf89a5cf2b1930f4dd1fbfc104d..122b01f3f546b866b429b53dead7684e6e6f90e7 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,9 @@ CoordinateCorrections.java c5cc475b45de38c56fc2e888a2d3093cd2efb52a GREEN LayoutedCircularAnchorageContentVisualBase.java 2aa292444671bf644e37bc923b877c92de0235b1 GREEN LayoutedCircularAnchorageDiagramVisualBase.java f06e3b908020408e3cd268a3c63edcd75ef74f8b GREEN -LayoutedCurveLinkVisual.java 7344139cd451f8d9d3b57e9cc32482753e8e53ed RED +LayoutedCurveLinkVisual.java 7344139cd451f8d9d3b57e9cc32482753e8e53ed YELLOW LayoutedEllipticContentVisualBase.java a06403f2c2245e017dc76e902a2b71ed124fedd1 YELLOW -LayoutedLineLinkVisual.java feea85e0bd288590fbe06c152a8a8b138ea85ca2 RED +LayoutedLineLinkVisual.java 3f6fa536b3e767590e95faeaf07b72df16e5e718 YELLOW LayoutedRectangularContentVisualBase.java c2a3937b99284713e0bbcd3ce458874567b25ac5 GREEN NamedLayoutedCircularAnchorageContentVisual.java c680002469ce897679fa5a3f4af51d1b19cb53d6 GREEN NamedLayoutedCircularAnchorageDiagramVisual.java 714a176a0569a2049efb4009f710ca66bf3a57fb GREEN 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 feea85e0bd288590fbe06c152a8a8b138ea85ca2..3f6fa536b3e767590e95faeaf07b72df16e5e718 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,9 +36,6 @@ 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 {