Skip to content
Snippets Groups Projects
Commit 966f98da authored by Johannes Eder's avatar Johannes Eder
Browse files

fixed master merge conflict

parents 8559fbe8 85c92880
No related branches found
No related tags found
1 merge request!1083969
Showing
with 305 additions and 83 deletions
ContextMenuUtil.java 405387151d45b09dffb3b6ba44f980313c8edcaf GREEN
CurvedLinkLayoutedContentAnchorangeController.java 6d2b64c3d6c813ac001b1500ed0529ad6e561aaf GREEN
EObjectDiagramController.java 2b253941592ee25ead95223470f983f23ef9776f GREEN
EObjectEllipticResizableContentControllerBase.java 7c862a03b97d2f2cfdcc2fcee7434de2e1e257d2 GREEN
CurvedLinkLayoutedContentAnchorangeController.java e22faedbe98c3dab660b5d2df8ebd004e116c5ba GREEN
CurvedLinkLayoutedDiagramAnchorangeController.java f2e5e2a7cc9b6a070871e200e57371286bb15222 GREEN
EObjectDiagramController.java 019e37a9016e895a720374f31667972744080e3b GREEN
EObjectEllipticResizableContentControllerBase.java 958d3856daf5337cd75d0a6f163a27dcc8717160 GREEN
EObjectModelChangeProvider.java f4b60cebb088a5c81ca92a41614e1a5d40030502 GREEN
EObjectRectangularResizableContentControllerBase.java e73cda8f54318f8b785a208215d9e31eaa46eff7 GREEN
EObjectRectangularResizableContentControllerBase.java 7cbc3e89b7b74106d56b8b4f845087e96e13d109 GREEN
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
LayoutedContentAnchorageController.java 83f066a151dd2984c4bef64daf8165a0cd53b00f GREEN
LayoutedCurveLinkBendPointController.java d963a5e227de7bd8ba910c733df2ac7acf4fa1fa GREEN
LayoutedDiagramAnchorageController.java 89ee56e8e71a5fa635cfac81e84bbfe1d50e5776 GREEN
LayoutedEllipticResizableContentController.java 1c50e80121512de7ae1f2ba09e0e1f4d0e3f3104 GREEN
LayoutedLineLinkBendPointController.java f49c994a0c90612c44ec83d42cf858e476662e1f GREEN
LayoutedLinkBendPointController.java d06736b49b6ac9a073237b989895469891500e7f GREEN
LayoutedRectangularResizableContentController.java 341f4a7da0d69360d7026af6d9b3d44dfd7d9bb1 GREEN
ModelElementFXEditorUIProviderBase.java b81bf7fc945d40f1f842876f07ba70799ab65f6d GREEN
NamedCommentedLayoutModelChangeProvider.java 223e82c1b1cba842f6fae115182f5d0c6acb44b0 GREEN
......@@ -17,8 +17,9 @@ 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.eclipse.emf.common.util.BasicEList;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.tooling.base.model.base.HierarchicElementBase;
import org.fortiss.tooling.base.model.element.IConnection;
import org.fortiss.tooling.base.model.element.IConnector;
......@@ -27,13 +28,14 @@ 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;
import org.fortiss.tooling.kernel.model.INamedCommentedElement;
/**
* {@link DelegatingContentAnchorageController} for diagrams with curved links.
*
* @author munaro
*/
public class CurvedLinkLayoutedContentAnchorangeController<T extends IConnector & ILayoutedModelElement>
public class CurvedLinkLayoutedContentAnchorangeController<T extends IConnector & INamedCommentedElement & ILayoutedModelElement>
extends LayoutedContentAnchorageController<T> {
/** Constructor. */
......@@ -43,7 +45,7 @@ public class CurvedLinkLayoutedContentAnchorangeController<T extends IConnector
}
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
// TODO(3978): Resolve code duplication in the link-method of link visuals
@Override
protected void link(IMVCBundle startBundle, DiagramCoordinate startLocation,
IMVCBundle endBundle, DiagramCoordinate endLocation) {
......@@ -53,18 +55,22 @@ public class CurvedLinkLayoutedContentAnchorangeController<T extends IConnector
return;
}
// Create the connection
// The call to `super.link` (see next lines) does not return a reference to the
// newly created connection. However, as it is needed in order to add the handles
// we get it by comparing the root element's connections before and after the
// creation of the new link:
// 1) Here we get the list of existing connections
EList<IConnection> connectionsBefore = new BasicEList<IConnection>(
((HierarchicElementBase)(EObject)getViewer().getRootElement()).getConnections());
// 2) Here we create the new connection
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();
// 3) Here we get the updated list of connections
EList<IConnection> connectionsAfter = new BasicEList<IConnection>(
((HierarchicElementBase)(EObject)getViewer().getRootElement()).getConnections());
// 4) We remove all existing ones
connectionsAfter.removeAll(connectionsBefore);
// 5) And we are left with the newly added one.
IConnection connection = connectionsAfter.stream().findFirst().get();
// Create handles
DiagramCoordinate startPosition =
......
/*-------------------------------------------------------------------------+
| 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.eclipse.emf.common.util.BasicEList;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.tooling.base.model.base.HierarchicElementBase;
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.mvc.IMVCBundle;
import org.fortiss.tooling.kernel.model.INamedCommentedElement;
/**
* {@link LayoutedDiagramAnchorageController} for diagrams with curved links.
*
* @author munaro
*/
public class CurvedLinkLayoutedDiagramAnchorangeController<T extends IConnector & INamedCommentedElement & ILayoutedModelElement>
extends LayoutedDiagramAnchorageController<T> {
/** Constructor. */
public CurvedLinkLayoutedDiagramAnchorangeController(IMVCBundle mvcb, Class<T> modelType) {
super(mvcb, modelType);
}
/** {@inheritDoc} */
// TODO(3978): Resolve code duplication in the link-method of link visuals
@Override
protected void link(IMVCBundle startBundle, DiagramCoordinate startLocation,
IMVCBundle endBundle, DiagramCoordinate endLocation) {
// Disable direct links between hierarchic element bases
if(startBundle.getModel() instanceof HierarchicElementBase ||
endBundle.getModel() instanceof HierarchicElementBase) {
return;
}
// The call to `super.link` (see next lines) does not return a reference to the
// newly created connection. However, as it is needed in order to add the handles
// we get it by comparing the root element's connections before and after the
// creation of the new link:
// 1) Here we get the list of existing connections
EList<IConnection> connectionsBefore = new BasicEList<IConnection>(
((HierarchicElementBase)(EObject)getViewer().getRootElement()).getConnections());
// 2) Here we create the new connection
super.link(startBundle, startLocation, endBundle, endLocation);
// 3) Here we get the updated list of connections
EList<IConnection> connectionsAfter = new BasicEList<IConnection>(
((HierarchicElementBase)(EObject)getViewer().getRootElement()).getConnections());
// 4) We remove all existing ones
connectionsAfter.removeAll(connectionsBefore);
// 5) And we are left with the newly added one.
IConnection connection = connectionsAfter.stream().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());
}
}
......@@ -26,7 +26,7 @@ import java.util.List;
import org.eclipse.emf.ecore.EObject;
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.controller.base.ControllerBase;
import org.fortiss.tooling.common.ui.javafx.lwfxef.controller.base.DefaultDiagramController;
import org.fortiss.tooling.common.ui.javafx.lwfxef.model.IModelChangeProvider;
import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.IMVCBundle;
import org.fortiss.tooling.kernel.extension.data.IElementCompositionContext;
......@@ -43,7 +43,7 @@ import javafx.scene.input.Dragboard;
*
* @author hoelzl
*/
public class EObjectDiagramController<T extends EObject> extends ControllerBase {
public class EObjectDiagramController<T extends EObject> extends DefaultDiagramController {
/** The model change provider. */
private final EObjectModelChangeProvider modelChangeProvider;
......
......@@ -35,6 +35,7 @@ import org.fortiss.tooling.common.ui.javafx.lwfxef.controller.elliptic.EllipticR
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.model.INamedCommentedElement;
import org.fortiss.tooling.kernel.service.IElementCompositorService;
import org.fortiss.tooling.kernel.ui.extension.IModelElementHandler;
import org.fortiss.tooling.kernel.ui.service.IModelEditorBindingService;
......@@ -51,10 +52,10 @@ import javafx.scene.input.MouseEvent;
*
* @author hoelzl
*/
public abstract class EObjectEllipticResizableContentControllerBase<T extends EObject>
public abstract class EObjectEllipticResizableContentControllerBase<T extends INamedCommentedElement & ILayoutedModelElement>
extends EllipticResizableContentControllerBase {
/** {@link IModelChangeProvider} for this controller */
private final LayoutModelChangeProvider layoutModelChangeProvider;
private final NamedCommentedLayoutModelChangeProvider<T> layoutModelChangeProvider;
/** The click controller handling double-click to open editor. */
private final IClickController openEditorDoubleClickController = new ClickControllerBase() {
@Override
......@@ -94,8 +95,8 @@ public abstract class EObjectEllipticResizableContentControllerBase<T extends EO
modelType.getSimpleName() + ", but was " + model.getClass().getSimpleName());
}
ILayoutedModelElement lme = (ILayoutedModelElement)mvcb.getModel();
this.layoutModelChangeProvider = new LayoutModelChangeProvider(lme) {
@SuppressWarnings("unchecked") T lme = (T)mvcb.getModel();
this.layoutModelChangeProvider = new NamedCommentedLayoutModelChangeProvider<T>(lme) {
/** {@inheritDoc} */
@Override
protected boolean acceptNotification(Notification notification) {
......
......@@ -41,6 +41,7 @@ import org.fortiss.tooling.common.ui.javafx.lwfxef.model.IModelChangeProvider;
import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.IContentAnchorageMVCBundle;
import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.IContentMVCBundle;
import org.fortiss.tooling.kernel.extension.data.IElementCompositionContext;
import org.fortiss.tooling.kernel.model.INamedCommentedElement;
import org.fortiss.tooling.kernel.service.IElementCompositorService;
import org.fortiss.tooling.kernel.ui.extension.IModelElementHandler;
import org.fortiss.tooling.kernel.ui.service.IModelEditorBindingService;
......@@ -58,11 +59,11 @@ import javafx.scene.input.MouseEvent;
*
* @author hoelzl
*/
public abstract class EObjectRectangularResizableContentControllerBase<T extends EObject>
public abstract class EObjectRectangularResizableContentControllerBase<T extends INamedCommentedElement & ILayoutedModelElement>
extends RectangularResizableContentControllerBase {
/** {@link IModelChangeProvider} for this controller */
private final LayoutModelChangeProvider layoutModelChangeProvider;
private final NamedCommentedLayoutModelChangeProvider<T> layoutModelChangeProvider;
/** The click controller handling double-click to open editor. */
private final IClickController openEditorDoubleClickController = new ClickControllerBase() {
@Override
......@@ -102,8 +103,8 @@ public abstract class EObjectRectangularResizableContentControllerBase<T extends
modelType.getSimpleName() + ", but was " + model.getClass().getSimpleName());
}
ILayoutedModelElement lme = (ILayoutedModelElement)mvcb.getModel();
this.layoutModelChangeProvider = new LayoutModelChangeProvider(lme) {
@SuppressWarnings("unchecked") T lme = (T)mvcb.getModel();
this.layoutModelChangeProvider = new NamedCommentedLayoutModelChangeProvider<T>(lme) {
/** {@inheritDoc} */
@Override
protected boolean acceptNotification(Notification notification) {
......
......@@ -18,14 +18,15 @@ import static org.fortiss.tooling.common.ui.javafx.lwfxef.DiagramViewerDefaultTa
import static org.fortiss.tooling.common.ui.javafx.lwfxef.DiagramViewerDefaultTags.LINK_TARGET_DENIED_TAG;
import org.eclipse.emf.ecore.EObject;
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.model.IModelChangeProvider;
import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.IContentAnchorageMVCBundle;
import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.IMVCBundle;
import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.MVCBundleTag;
import org.fortiss.tooling.base.model.element.IConnector;
import org.fortiss.tooling.base.model.layout.ILayoutedModelElement;
import org.fortiss.tooling.kernel.model.INamedCommentedElement;
import org.fortiss.tooling.kernel.service.IConnectionCompositorService;
import org.fortiss.tooling.kernel.service.IElementCompositorService;
......@@ -34,10 +35,10 @@ import org.fortiss.tooling.kernel.service.IElementCompositorService;
*
* @author hoelzl
*/
public class LayoutedContentAnchorageController<T extends ILayoutedModelElement>
public class LayoutedContentAnchorageController<T extends INamedCommentedElement & ILayoutedModelElement>
extends DelegatingContentAnchorageController {
/** {@link IModelChangeProvider} for this controller */
private final LayoutModelChangeProvider layoutModelChangeProvider;
private final NamedCommentedLayoutModelChangeProvider<T> layoutModelChangeProvider;
/** Constructor. */
public LayoutedContentAnchorageController(IContentAnchorageMVCBundle mvcb, Class<T> modelType) {
......@@ -49,8 +50,8 @@ public class LayoutedContentAnchorageController<T extends ILayoutedModelElement>
modelType.getSimpleName() + ", but was " + model.getClass().getSimpleName());
}
ILayoutedModelElement lme = (ILayoutedModelElement)mvcb.getModel();
this.layoutModelChangeProvider = new LayoutModelChangeProvider(lme);
@SuppressWarnings("unchecked") T lme = (T)mvcb.getModel();
this.layoutModelChangeProvider = new NamedCommentedLayoutModelChangeProvider<T>(lme);
}
/** Returns the model element. */
......
......@@ -28,6 +28,7 @@ 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 org.fortiss.tooling.kernel.model.INamedCommentedElement;
import javafx.geometry.Point2D;
......@@ -37,7 +38,7 @@ import javafx.geometry.Point2D;
*
* @author munaro
*/
public class LayoutedCurveLinkBendPointController<T extends ILayoutedModelElement>
public class LayoutedCurveLinkBendPointController<T extends INamedCommentedElement & ILayoutedModelElement>
extends LayoutedLinkBendPointController<T> {
/** Constructor. */
......
......@@ -14,19 +14,20 @@
package org.fortiss.tooling.base.ui.editor.fx.controller;
import static java.util.Objects.requireNonNull;
import static org.fortiss.tooling.base.utils.LayoutDataUtils.moveNode;
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.utils.LayoutDataUtils.moveNode;
import org.eclipse.emf.ecore.EObject;
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.FeedbackChange;
import org.fortiss.tooling.common.ui.javafx.lwfxef.controller.base.MoveControllerBase;
import org.fortiss.tooling.common.ui.javafx.lwfxef.model.IModelChangeProvider;
import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.IMVCBundle;
import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.MVCBundleTag;
import org.fortiss.tooling.base.model.element.IConnector;
import org.fortiss.tooling.base.model.layout.ILayoutedModelElement;
import org.fortiss.tooling.kernel.model.INamedCommentedElement;
import org.fortiss.tooling.kernel.service.IConnectionCompositorService;
import org.fortiss.tooling.kernel.service.IElementCompositorService;
......@@ -35,10 +36,10 @@ import org.fortiss.tooling.kernel.service.IElementCompositorService;
*
* @author hoelzl
*/
public class LayoutedDiagramAnchorageController<T extends ILayoutedModelElement>
public class LayoutedDiagramAnchorageController<T extends INamedCommentedElement & ILayoutedModelElement>
extends MoveControllerBase {
/** {@link IModelChangeProvider} for this controller */
private final LayoutModelChangeProvider layoutModelChangeProvider;
private final NamedCommentedLayoutModelChangeProvider<T> layoutModelChangeProvider;
/** Constructor. */
public LayoutedDiagramAnchorageController(IMVCBundle mvcb, Class<T> modelType) {
......@@ -50,8 +51,8 @@ public class LayoutedDiagramAnchorageController<T extends ILayoutedModelElement>
modelType.getSimpleName() + ", but was " + model.getClass().getSimpleName());
}
ILayoutedModelElement lme = (ILayoutedModelElement)mvcb.getModel();
this.layoutModelChangeProvider = new LayoutModelChangeProvider(lme);
@SuppressWarnings("unchecked") T lme = (T)mvcb.getModel();
this.layoutModelChangeProvider = new NamedCommentedLayoutModelChangeProvider<T>(lme);
}
/** Returns the model element. */
......
......@@ -29,13 +29,14 @@ 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;
import org.fortiss.tooling.kernel.model.INamedCommentedElement;
/**
* {@link IController} for {@link ILayoutedModelElement}s that have a elliptical shape.
*
* @author munaro
*/
public class LayoutedEllipticResizableContentController<T extends ILayoutedModelElement>
public class LayoutedEllipticResizableContentController<T extends ILayoutedModelElement & INamedCommentedElement>
extends EObjectEllipticResizableContentControllerBase<T> {
/** Constructor */
......
......@@ -20,6 +20,7 @@ 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;
import org.fortiss.tooling.kernel.model.INamedCommentedElement;
/**
* {@link IController} for {@link ILayoutedModelElement}s representing straight links and
......@@ -27,7 +28,7 @@ import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.ILinkMVCBundle;
*
* @author hoelzl
*/
public class LayoutedLineLinkBendPointController<T extends ILayoutedModelElement>
public class LayoutedLineLinkBendPointController<T extends INamedCommentedElement & ILayoutedModelElement>
extends LayoutedLinkBendPointController<T> {
/** Constructor. */
......
......@@ -30,6 +30,7 @@ import org.fortiss.tooling.common.ui.javafx.lwfxef.controller.base.LinkControlle
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.kernel.model.INamedCommentedElement;
import org.fortiss.tooling.kernel.service.IConnectionCompositorService;
/**
......@@ -38,10 +39,10 @@ import org.fortiss.tooling.kernel.service.IConnectionCompositorService;
*
* @author munaro
*/
public abstract class LayoutedLinkBendPointController<T extends ILayoutedModelElement>
public abstract class LayoutedLinkBendPointController<T extends INamedCommentedElement & ILayoutedModelElement>
extends LinkControllerBase {
/** {@link IModelChangeProvider} for this controller */
protected final LayoutModelChangeProvider layoutModelChangeProvider;
protected final NamedCommentedLayoutModelChangeProvider<T> layoutModelChangeProvider;
/** Returns the model element. */
@SuppressWarnings("unchecked")
......@@ -65,8 +66,8 @@ public abstract class LayoutedLinkBendPointController<T extends ILayoutedModelEl
modelType.getSimpleName() + ", but was " + model.getClass().getSimpleName());
}
ILayoutedModelElement lme = (ILayoutedModelElement)mvcb.getModel();
this.layoutModelChangeProvider = new LayoutModelChangeProvider(lme);
@SuppressWarnings("unchecked") T lme = (T)mvcb.getModel();
this.layoutModelChangeProvider = new NamedCommentedLayoutModelChangeProvider<T>(lme);
}
/** {@inheritDoc} */
......
......@@ -22,13 +22,14 @@ import static org.fortiss.tooling.base.utils.LayoutDataUtils.moveNode;
import static org.fortiss.tooling.base.utils.LayoutDataUtils.setNodeSize;
import static org.fortiss.tooling.base.utils.LayoutDataUtils.setStickyConnectorLayoutData;
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;
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.kernel.model.INamedCommentedElement;
import javafx.geometry.Dimension2D;
import javafx.geometry.Side;
......@@ -38,7 +39,7 @@ import javafx.geometry.Side;
*
* @author diewald
*/
public class LayoutedRectangularResizableContentController<T extends ILayoutedModelElement>
public class LayoutedRectangularResizableContentController<T extends INamedCommentedElement & ILayoutedModelElement>
extends EObjectRectangularResizableContentControllerBase<T> {
/** Constructor. */
public LayoutedRectangularResizableContentController(IContentMVCBundle mvcb,
......
......@@ -24,28 +24,30 @@ import org.eclipse.emf.ecore.util.EContentAdapter;
import org.fortiss.tooling.base.model.layout.ILayoutData;
import org.fortiss.tooling.base.model.layout.ILayoutedModelElement;
import org.fortiss.tooling.base.model.layout.LayoutPackage;
import org.fortiss.tooling.kernel.model.FortissToolingKernelPackage;
import org.fortiss.tooling.kernel.model.INamedCommentedElement;
/**
* A {@link KernelServiceBasedModelChangeProviderBase} for {@link ILayoutedModelElement}s.
*
* @author hoelzl
*/
class LayoutModelChangeProvider
extends KernelServiceBasedModelChangeProviderBase<ILayoutedModelElement> {
class NamedCommentedLayoutModelChangeProvider<T extends INamedCommentedElement & ILayoutedModelElement>
extends KernelServiceBasedModelChangeProviderBase<T> {
/** The layouted model element. */
private final ILayoutedModelElement modelElement;
private final T modelElement;
/** The layout EMF notification listener. */
private final LayoutModelElementAdapter notificationListener;
/** Constructor. */
public LayoutModelChangeProvider(ILayoutedModelElement modelElement) {
public NamedCommentedLayoutModelChangeProvider(T modelElement) {
this.modelElement = modelElement;
this.notificationListener = new LayoutModelElementAdapter();
}
/** {@inheritDoc} */
@Override
protected ILayoutedModelElement getModelElement() {
protected T getModelElement() {
return modelElement;
}
......@@ -78,7 +80,11 @@ class LayoutModelChangeProvider
Object notifier = notification.getNotifier();
if(notifier == modelElement) {
Object feature = notification.getFeature();
if(feature == LayoutPackage.Literals.ILAYOUTED_MODEL_ELEMENT__LAYOUT_DATA) {
if(feature == FortissToolingKernelPackage.Literals.INAMED_ELEMENT__NAME ||
feature == FortissToolingKernelPackage.Literals.INAMED_COMMENTED_ELEMENT__COMMENT) {
addNotification(notification);
return;
} else if(feature == LayoutPackage.Literals.ILAYOUTED_MODEL_ELEMENT__LAYOUT_DATA) {
// self adapt to layout data
super.notifyChanged(notification);
addNotification(notification);
......
CoordinateCorrections.java 018bf229e5686afcb8540b61dd9d05b6e4a23e93 GREEN
LayoutedCircularAnchorageContentVisualBase.java cd85ff478e9b8e6b6d6f6c75cc5bf61522a63f3e GREEN
LayoutedCircularAnchorageContentVisualBase.java bf71e5e84ede0c26bd0632e4218aae55ab915ade 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
NamedLayoutedCircularAnchorageContentVisual.java 5ba0b5d133998eac47425696ef0a02b575418c2d GREEN
NamedLayoutedCircularAnchorageDiagramVisual.java 94eccb7bb03c5518ae875e9972f062ddd0e1f62d GREEN
NamedLayoutedCurveLinkVisual.java 7945b2f550d5e4804f44891294ee60cc8ffcbf1e GREEN
NamedLayoutedEllipticContentVisual.java f96a956c2f71b675eee56cfc613684397545da68 GREEN
NamedLayoutedLineLinkVisual.java 4fc48616000516dc90ba22b7069ffdabadc9c377 GREEN
......
......@@ -157,6 +157,6 @@ public abstract class LayoutedCircularAnchorageContentVisualBase<T extends ILayo
/** {@inheritDoc} */
@Override
public double getAngleInDegree() {
return toDegrees(getConnectorAngleAsDouble(getModelElement()));
return 360 - toDegrees(getConnectorAngleAsDouble(getModelElement()));
}
}
......@@ -15,29 +15,64 @@
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.ui.editor.fx.visual;
import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.IContentAnchorageMVCBundle;
import org.fortiss.tooling.common.ui.javafx.lwfxef.visual.IVisual;
import static org.fortiss.tooling.base.ui.utils.LWFXEditorUtils.stickyConnectorHasVisibleConnections;
import org.fortiss.tooling.base.model.element.IConnector;
import org.fortiss.tooling.base.model.layout.ILayoutedModelElement;
import org.fortiss.tooling.common.ui.javafx.lwfxef.DiagramLayers;
import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.IContentAnchorageMVCBundle;
import org.fortiss.tooling.common.ui.javafx.lwfxef.visual.IVisual;
import org.fortiss.tooling.kernel.model.INamedElement;
import javafx.geometry.Rectangle2D;
import javafx.geometry.VPos;
import javafx.scene.text.Text;
import javafx.scene.text.TextAlignment;
/**
* {@link IVisual} for layouted and named {@link IConnector}s of some content element within a
* diagram (sticky connectors).
*
* @author diewald
*/
public class NamedLayoutedCircularAnchorageContentVisual<T extends ILayoutedModelElement & INamedElement>
public class NamedLayoutedCircularAnchorageContentVisual<T extends ILayoutedModelElement & INamedElement & IConnector>
extends LayoutedCircularAnchorageContentVisualBase<T> {
/** The name text label. */
private final Text nameText = new Text("");
/** Constructor. */
public NamedLayoutedCircularAnchorageContentVisual(IContentAnchorageMVCBundle mvcb, Class<T> modelType) {
public NamedLayoutedCircularAnchorageContentVisual(IContentAnchorageMVCBundle mvcb,
Class<T> modelType) {
super(mvcb, modelType);
nameText.setMouseTransparent(true);
nameText.setTextAlignment(TextAlignment.LEFT);
nameText.setTextOrigin(VPos.CENTER);
}
/** {@inheritDoc} */
@Override
protected String getHoverText() {
public void updateNodes(DiagramLayers layers) {
super.updateNodes(layers);
if(enableName()) {
Rectangle2D bounds = getCurrentBounds();
nameText.setX(bounds.getMaxX());
nameText.setY(bounds.getMinY() + bounds.getHeight() / 2);
nameText.setText(getName());
if(nameText.getParent() == null) {
layers.getVisualFeedbackLayer().add(nameText, getMVCBundle());
}
} else if(nameText.getParent() != null) {
layers.getVisualFeedbackLayer().remove(nameText);
}
}
/** Returns whether the name label should be enabled. */
public boolean enableName() {
return !stickyConnectorHasVisibleConnections(getModelElement());
}
/** Returns the name. */
public String getName() {
return getModelElement().getName();
}
}
......@@ -15,28 +15,63 @@
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.ui.editor.fx.visual;
import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.IDiagramAnchorageMVCBundle;
import org.fortiss.tooling.common.ui.javafx.lwfxef.visual.IVisual;
import static org.fortiss.tooling.base.ui.utils.LWFXEditorUtils.freeConnectorHasVisibleConnections;
import org.fortiss.tooling.base.model.element.IConnector;
import org.fortiss.tooling.base.model.layout.ILayoutedModelElement;
import org.fortiss.tooling.common.ui.javafx.lwfxef.DiagramLayers;
import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.IDiagramAnchorageMVCBundle;
import org.fortiss.tooling.common.ui.javafx.lwfxef.visual.IVisual;
import org.fortiss.tooling.kernel.model.INamedElement;
import javafx.geometry.Rectangle2D;
import javafx.geometry.VPos;
import javafx.scene.text.Text;
import javafx.scene.text.TextAlignment;
/**
* {@link IVisual} for layouted and named {@link IConnector}s within a diagram (free connectors).
*
* @author diewald
*/
public class NamedLayoutedCircularAnchorageDiagramVisual<T extends ILayoutedModelElement & INamedElement>
public class NamedLayoutedCircularAnchorageDiagramVisual<T extends ILayoutedModelElement & INamedElement & IConnector>
extends LayoutedCircularAnchorageDiagramVisualBase<T> {
/** The name text label. */
private final Text nameText = new Text("");
/** Constructor. */
public NamedLayoutedCircularAnchorageDiagramVisual(IDiagramAnchorageMVCBundle mvcb, Class<T> modelType) {
public NamedLayoutedCircularAnchorageDiagramVisual(IDiagramAnchorageMVCBundle mvcb,
Class<T> modelType) {
super(mvcb, modelType);
nameText.setMouseTransparent(true);
nameText.setTextAlignment(TextAlignment.LEFT);
nameText.setTextOrigin(VPos.CENTER);
}
/** {@inheritDoc} */
@Override
protected String getHoverText() {
public void updateNodes(DiagramLayers layers) {
super.updateNodes(layers);
if(enableName()) {
Rectangle2D bounds = getCurrentBounds();
nameText.setX(bounds.getMaxX());
nameText.setY(bounds.getMinY() + bounds.getHeight() / 2);
nameText.setText(getName());
if(nameText.getParent() == null) {
layers.getVisualFeedbackLayer().add(nameText, getMVCBundle());
}
} else if(nameText.getParent() != null) {
layers.getVisualFeedbackLayer().remove(nameText);
}
}
/** Returns whether the name label should be enabled. */
public boolean enableName() {
return !freeConnectorHasVisibleConnections(getModelElement());
}
/** Returns the name. */
public String getName() {
return getModelElement().getName();
}
}
......@@ -5,7 +5,7 @@ EllipseLayoutUIUtils.java 4dd9dbd96a45e8c455c019caa19e4a50f18336af GREEN
FXDNDUtils.java 6ce94e239e68f9e2b3cc0524b072606f4a120076 GREEN
FontUtils.java a167a05bdaa8da9853705cc5134f30f6d81bc9f2 GREEN
GCStateManager.java 983973a92376b5c757c1253b32e33d0666ccdf7b GREEN
LWFXEditorUtils.java c624d3f0f6487b6d426b168dad048b2c39e71114 GREEN
LWFXEditorUtils.java 24ec0e23dc4b4e768ede8209335985867bdf0e35 GREEN
LayoutDataUIUtils.java c85886ac313a6efb122532218eb134047ffd6631 GREEN
PropertiesViewUtils.java d345b4501c4092228edf1c98e0189317d53aaf22 GREEN
RectangleLayoutUIUtils.java ef4b872bb5b4a51174e9a29d9ef05e7cb3bff3a1 GREEN
......
......@@ -19,8 +19,12 @@ import static java.lang.Math.atan2;
import static java.lang.Math.cos;
import static java.lang.Math.sin;
import org.fortiss.tooling.common.ui.javafx.lwfxef.DiagramCoordinate;
import org.fortiss.tooling.base.model.element.IConnection;
import org.fortiss.tooling.base.model.element.IConnector;
import org.fortiss.tooling.base.model.element.IHierarchicElement;
import org.fortiss.tooling.base.model.element.IHierarchicElementContainer;
import org.fortiss.tooling.base.model.layout.EOrientation;
import org.fortiss.tooling.common.ui.javafx.lwfxef.DiagramCoordinate;
import javafx.geometry.Point2D;
import javafx.geometry.Rectangle2D;
......@@ -99,6 +103,45 @@ public final class LWFXEditorUtils {
return new DiagramCoordinate(nx, ny);
}
/**
* Returns whether any connections of the given sticky connector are visible on the current
* level of hierarchy.
*/
public static boolean stickyConnectorHasVisibleConnections(IConnector connector) {
IHierarchicElement elem = connector.getOwner();
IHierarchicElementContainer diagram = elem.getContainer();
for(IConnection conn : connector.getIncoming()) {
if(conn.getOwner() == diagram) {
return true;
}
}
for(IConnection conn : connector.getOutgoing()) {
if(conn.getOwner() == diagram) {
return true;
}
}
return false;
}
/**
* Returns whether any connections of the given free connector are visible on the current level
* of hierarchy.
*/
public static boolean freeConnectorHasVisibleConnections(IConnector connector) {
IHierarchicElement diagram = connector.getOwner();
for(IConnection conn : connector.getIncoming()) {
if(conn.getOwner() == diagram) {
return true;
}
}
for(IConnection conn : connector.getOutgoing()) {
if(conn.getOwner() == diagram) {
return true;
}
}
return false;
}
/** Constructor. */
private LWFXEditorUtils() {
// prevent instantiation
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment