Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Redor2014-09-25 08:42:06 +0000
committerLaurent Redor2014-09-26 15:23:44 +0000
commitb27d3eb84b5dff91deec8e4890a84d246debfebd (patch)
tree619b5f0a4f147c6320035bb2de2be2a5e2d2c5ce
parentebf15097cb33376039cf765606ac47b326b86c55 (diff)
downloadorg.eclipse.sirius-b27d3eb84b5dff91deec8e4890a84d246debfebd.tar.gz
org.eclipse.sirius-b27d3eb84b5dff91deec8e4890a84d246debfebd.tar.xz
org.eclipse.sirius-b27d3eb84b5dff91deec8e4890a84d246debfebd.zip
[437528] Since bug 441424, the centering style of edges is not respected
If the centering style is "enabled" for an edge, this overrides the fact that the edge keeps its location. This commit fix the problem of https://bugs.eclipse.org/bugs/show_bug.cgi?id=437528#c12 Bug: 437528 Bug: 441424 Change-Id: Icdef14b9c698f5865569baefc8726a0edba9abf1 Signed-off-by: Laurent Redor <laurent.redor@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/operation/ShiftEdgeIdentityAnchorOperation.java34
1 files changed, 22 insertions, 12 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/operation/ShiftEdgeIdentityAnchorOperation.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/operation/ShiftEdgeIdentityAnchorOperation.java
index 0dfc60a4a3..d314b0355a 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/operation/ShiftEdgeIdentityAnchorOperation.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/operation/ShiftEdgeIdentityAnchorOperation.java
@@ -18,6 +18,7 @@ import org.eclipse.draw2d.PositionConstants;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.PrecisionPoint;
import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.emf.ecore.EObject;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.handles.HandleBounds;
import org.eclipse.gef.requests.ChangeBoundsRequest;
@@ -28,6 +29,9 @@ import org.eclipse.gmf.runtime.notation.Anchor;
import org.eclipse.gmf.runtime.notation.Edge;
import org.eclipse.gmf.runtime.notation.IdentityAnchor;
import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.sirius.diagram.DEdge;
+import org.eclipse.sirius.diagram.EdgeStyle;
+import org.eclipse.sirius.diagram.description.CenteringStyle;
import org.eclipse.sirius.diagram.ui.business.internal.operation.AbstractModelChangeOperation;
import org.eclipse.sirius.ext.base.Option;
import org.eclipse.sirius.ext.base.Options;
@@ -37,7 +41,8 @@ import com.google.common.collect.Iterables;
/**
* This operation updates edges anchors to make sure their connection points
- * keep the same location when the shape is resized.
+ * keep the same location when the shape is resized. Except when the edge forces
+ * direction toward the center of the source node or target node.
*
* @author Florian Barbin
*
@@ -67,27 +72,32 @@ public class ShiftEdgeIdentityAnchorOperation extends AbstractModelChangeOperati
private void handleSourceEdges(View view, EditPart editPart) {
List<?> sourceEdges = view.getSourceEdges();
for (Edge edge : Iterables.filter(sourceEdges, Edge.class)) {
- Anchor sourceAnchor = edge.getSourceAnchor();
- if (sourceAnchor instanceof IdentityAnchor) {
- PrecisionPoint anchorPoint = BaseSlidableAnchor.parseTerminalString(((IdentityAnchor) sourceAnchor).getId());
- PrecisionPoint newPoint = computeNewAnchor(anchorPoint, editPart);
- ((IdentityAnchor) sourceAnchor).setId(new SlidableAnchor(null, newPoint).getTerminal());
+ EObject eObj = edge.getElement();
+ if (eObj instanceof DEdge) {
+ handleEdge((DEdge) eObj, edge.getSourceAnchor(), editPart, CenteringStyle.SOURCE);
}
}
}
private void handleTargetEdges(View view, EditPart editPart) {
-
List<?> targetEdges = view.getTargetEdges();
for (Edge edge : Iterables.filter(targetEdges, Edge.class)) {
- Anchor targetAnchor = edge.getTargetAnchor();
- if (targetAnchor instanceof IdentityAnchor) {
- PrecisionPoint anchorPoint = BaseSlidableAnchor.parseTerminalString(((IdentityAnchor) targetAnchor).getId());
- PrecisionPoint newPoint = computeNewAnchor(anchorPoint, editPart);
- ((IdentityAnchor) targetAnchor).setId(new SlidableAnchor(null, newPoint).getTerminal());
+ EObject eObj = edge.getElement();
+ if (eObj instanceof DEdge) {
+ handleEdge((DEdge) eObj, edge.getTargetAnchor(), editPart, CenteringStyle.TARGET);
}
}
+ }
+ private void handleEdge(DEdge dEdge, Anchor anchorToModify, EditPart editPart, CenteringStyle forbiddenCenteringStyle) {
+ EdgeStyle edgeStyle = dEdge.getOwnedStyle();
+ if (!CenteringStyle.BOTH.equals(edgeStyle.getCentered()) && !forbiddenCenteringStyle.equals(edgeStyle.getCentered())) {
+ if (anchorToModify instanceof IdentityAnchor) {
+ PrecisionPoint anchorPoint = BaseSlidableAnchor.parseTerminalString(((IdentityAnchor) anchorToModify).getId());
+ PrecisionPoint newPoint = computeNewAnchor(anchorPoint, editPart);
+ ((IdentityAnchor) anchorToModify).setId(new SlidableAnchor(null, newPoint).getTerminal());
+ }
+ }
}
private PrecisionPoint computeNewAnchor(PrecisionPoint currentAnchorPoint, EditPart editPart) {

Back to the top