Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormgolubev2014-11-06 02:24:15 +0000
committermgolubev2014-11-06 11:21:00 +0000
commitc40b89941ba2a5c702cae4a188a2fab837857007 (patch)
tree449bba02d179a0768d6bab245d7540748de12e5f
parentc94101419b11d4b6224f19fb2763c32ac3c553e5 (diff)
downloadorg.eclipse.papyrus-c40b89941ba2a5c702cae4a188a2fab837857007.tar.gz
org.eclipse.papyrus-c40b89941ba2a5c702cae4a188a2fab837857007.tar.xz
org.eclipse.papyrus-c40b89941ba2a5c702cae4a188a2fab837857007.zip
Bug 442156: rotate anchors when affixed item changes the side of the
parent Bug 448393: persist synthetic bendpoints created by rectilinear router before moving any of the link ends + enforce to never create centered anchors (slidable area = 100%) Change-Id: I387b35cd64c7e2e8c4267ecf909f1c0b684df2de Signed-off-by: mgolubev <golubev@montages.com>
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/linklf/LinksLFNodeFigure.java2
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/linklf/editpolicies/AdjustSyntheticBendpointsEditPolicy.java120
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/linklf/editpolicies/LinksLFConnectionBendpointEditPolicy.java2
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/linkslf/DefaultEditPolicies.java7
4 files changed, 129 insertions, 2 deletions
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/linklf/LinksLFNodeFigure.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/linklf/LinksLFNodeFigure.java
index 9098ddac577..b18cafa2a90 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/linklf/LinksLFNodeFigure.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/linklf/LinksLFNodeFigure.java
@@ -17,7 +17,7 @@ import org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure;
public class LinksLFNodeFigure extends DefaultSizeNodeFigure {
- protected static final double AVOID_DEFAULT_ANCHOR_AREA = 0.9;
+ protected static final double AVOID_DEFAULT_ANCHOR_AREA = 1.0;
private final GraphicalEditPart myHost;
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/linklf/editpolicies/AdjustSyntheticBendpointsEditPolicy.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/linklf/editpolicies/AdjustSyntheticBendpointsEditPolicy.java
new file mode 100644
index 00000000000..43cb62cd8b9
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/linklf/editpolicies/AdjustSyntheticBendpointsEditPolicy.java
@@ -0,0 +1,120 @@
+/*****************************************************************************
+ * Copyright (c) 2014 CEA LIST and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.gmfdiag.common.linklf.editpolicies;
+
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.draw2d.Connection;
+import org.eclipse.draw2d.ConnectionRouter;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.PointList;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.requests.ChangeBoundsRequest;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart;
+import org.eclipse.gmf.runtime.draw2d.ui.internal.routers.OrthogonalRouter;
+import org.eclipse.gmf.runtime.notation.Edge;
+
+/**
+ * This editpolicy persists synthetic bendpoints created by rectilinear router and not yet serialized in the model.
+ * It should be registered before other adjusting edit policies for the same node.
+ */
+public class AdjustSyntheticBendpointsEditPolicy extends AdjustAbsoluteBendpointsEditPolicyBase {
+
+ /**
+ * Default role for registering this edit policy.
+ * <p/>
+ * The value is prefixed by class FQN in order to avoid conflicts, but the literal should NOT be used anywhere.
+ */
+ public static final String ROLE = AdjustSyntheticBendpointsEditPolicy.class.getName() + ":Role";
+
+
+ @Override
+ protected Command getAdjustLinksCommand(ChangeBoundsRequest req) {
+ final Point moveDelta = req.getMoveDelta();
+ if (moveDelta.x == 0 && moveDelta.y == 0) {
+ return null;
+ }
+
+ CachedEditPartsSet allMoved = getMovedEditPartsSet(req);
+ ICommand result = null;
+ LinkedList<GraphicalEditPart> queue = new LinkedList<GraphicalEditPart>();
+ queue.add(getHost());
+
+ while (!queue.isEmpty()) {
+ GraphicalEditPart cur = queue.removeFirst();
+ // we will adjust target (incoming) links only from the ends which are not moved
+ // and all outgoing (source) links
+ // this way all links are processed only once
+ for (Object nextLink : cur.getSourceConnections()) {
+ if (nextLink instanceof ConnectionEditPart) {
+ ConnectionEditPart nextLinkEP = (ConnectionEditPart) nextLink;
+ ICommand nextAdjustment = getAdjustOneLinkCommand(nextLinkEP, req);
+ result = compose(result, nextAdjustment);
+ }
+ }
+ for (Object nextLink : cur.getTargetConnections()) {
+ if (nextLink instanceof ConnectionEditPart) {
+ ConnectionEditPart nextLinkEP = (ConnectionEditPart) nextLink;
+ EditPart target = nextLinkEP.getSource();
+ MovedNodeKind move = allMoved.isMoved(target);
+ if (move == MovedNodeKind.NO) {
+ ICommand nextAdjustment = getAdjustOneLinkCommand(nextLinkEP, req);
+ result = compose(result, nextAdjustment);
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ Collection<GraphicalEditPart> children = cur.getChildren();
+ queue.addAll(children);
+ }
+ return result == null ? null : new ICommandProxy(result.reduce());
+ }
+
+ private ICommand getAdjustOneLinkCommand(ConnectionEditPart linkEP, ChangeBoundsRequest req) {
+ Connection conn = linkEP.getConnectionFigure();
+ ConnectionRouter router = conn.getConnectionRouter();
+ if (false == router instanceof OrthogonalRouter) {
+ // only ortho-routers may produce synthetic bend points
+ return null;
+ }
+ if (false == linkEP.getNotationView() instanceof Edge) {
+ return null;
+ }
+
+ PointList points = conn.getPoints();
+ if (points.size() <= 2) { // source + target
+ return null;
+ }
+ if (false == conn.getRoutingConstraint() instanceof List<?>) {
+ return null;
+ }
+ List<?> d2dBendpoints = (List<?>) conn.getRoutingConstraint();
+ if (d2dBendpoints.size() >= points.size()) {
+ return null;
+ }
+ SetAbsoluteBendpointsCommand result = new SetAbsoluteBendpointsCommand(linkEP.getEditingDomain());
+ result.setEdge(linkEP);
+ result.setNewPointList(points);
+
+ return result;
+ }
+
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/linklf/editpolicies/LinksLFConnectionBendpointEditPolicy.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/linklf/editpolicies/LinksLFConnectionBendpointEditPolicy.java
index 632678449d5..8692ec28374 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/linklf/editpolicies/LinksLFConnectionBendpointEditPolicy.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/linklf/editpolicies/LinksLFConnectionBendpointEditPolicy.java
@@ -207,7 +207,7 @@ public class LinksLFConnectionBendpointEditPolicy extends ConnectionBendpointEdi
}
PrecisionPoint snapped = point.getPreciseCopy();
- snapper.snapPoint(new LocationRequest(), horizontally ? PositionConstants.HORIZONTAL : PositionConstants.VERTICAL, point, snapped);
+ snapper.snapPoint(new LocationRequest(REQ_MOVE_BENDPOINT), horizontally ? PositionConstants.HORIZONTAL : PositionConstants.VERTICAL, point, snapped);
point.setLocation(snapped);
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/linkslf/DefaultEditPolicies.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/linkslf/DefaultEditPolicies.java
index f8bd578a99e..ca8ad7f6344 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/linkslf/DefaultEditPolicies.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/linkslf/DefaultEditPolicies.java
@@ -1,16 +1,23 @@
package org.eclipse.papyrus.uml.diagram.common.editparts.linkslf;
import org.eclipse.gef.EditPolicy;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart;
import org.eclipse.gmf.runtime.diagram.ui.editparts.INodeEditPart;
+import org.eclipse.papyrus.infra.gmfdiag.common.linklf.editpolicies.AdjustBorderItemAnchorsEditPolicy;
import org.eclipse.papyrus.infra.gmfdiag.common.linklf.editpolicies.AdjustImplicitlyMovedLinksEditPolicy;
+import org.eclipse.papyrus.infra.gmfdiag.common.linklf.editpolicies.AdjustSyntheticBendpointsEditPolicy;
import org.eclipse.papyrus.infra.gmfdiag.common.linklf.editpolicies.LinksLFGraphicalNodeEditPolicy;
class DefaultEditPolicies {
static void installNodeEditPolicies(INodeEditPart nodeEP) {
+ nodeEP.installEditPolicy(AdjustSyntheticBendpointsEditPolicy.ROLE, new AdjustSyntheticBendpointsEditPolicy());
nodeEP.installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new LinksLFGraphicalNodeEditPolicy());
nodeEP.installEditPolicy(AdjustImplicitlyMovedLinksEditPolicy.ROLE, new AdjustImplicitlyMovedLinksEditPolicy());
+ if (nodeEP instanceof IBorderItemEditPart) {
+ nodeEP.installEditPolicy(AdjustBorderItemAnchorsEditPolicy.ROLE, new AdjustBorderItemAnchorsEditPolicy());
+ }
}
}

Back to the top