Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Barbin2015-09-08 13:50:14 +0000
committerFlorian Barbin2015-09-10 07:12:55 +0000
commitf7332b46d093fb6b109450662c84cd0657882c55 (patch)
tree8a3c95c9ed3e603fcb9151a7cd81cc1fce2c7ac7
parente85adf6457e45c6c2f2a759c78bba4903ff19f49 (diff)
downloadorg.eclipse.sirius-f7332b46d093fb6b109450662c84cd0657882c55.tar.gz
org.eclipse.sirius-f7332b46d093fb6b109450662c84cd0657882c55.tar.xz
org.eclipse.sirius-f7332b46d093fb6b109450662c84cd0657882c55.zip
[471814] Keep edge end anchor when reconnecting the other end.
* When reconnecting an edge end, a new edge is created and the other end anchor was losted. * The test testSimpleEdgeSourceReconnectionWithObliqueStyleRouting has been completed to check the reconnect behavior. Bug: 471814 Change-Id: Iceb8da3ea947cae364b299414c375ecd64032097 Signed-off-by: Florian Barbin <florian.barbin@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/command/SetReconnectingConnectionBendpointsCommand.java39
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/edit/helpers/EdgeReconnectionHelper.java15
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/SiriusGraphicalNodeEditPolicy.java27
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/data/unit/edgeReconnection/Bug467663.aird28
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/EdgeReconnectionTests.java247
5 files changed, 216 insertions, 140 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/command/SetReconnectingConnectionBendpointsCommand.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/command/SetReconnectingConnectionBendpointsCommand.java
index 1dfce17cf6..9315fdaa25 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/command/SetReconnectingConnectionBendpointsCommand.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/command/SetReconnectingConnectionBendpointsCommand.java
@@ -77,13 +77,15 @@ public class SetReconnectingConnectionBendpointsCommand extends SetConnectionBen
*/
@Override
public Point getSourceRefPoint() {
- Edge edge = reconnectingEdgeHelper.getReconnectedEdge();
- if (edge != null) {
- Connection connection = (Connection) GMFHelper.getGraphicalEditPart(edge).get().getFigure();
+ if (reconnectingEdgeHelper.isReconnectingSource()) {
+ Edge edge = reconnectingEdgeHelper.getReconnectedEdge();
+ if (edge != null) {
+ Connection connection = (Connection) GMFHelper.getGraphicalEditPart(edge).get().getFigure();
- Point sourceRefPoint = connection.getSourceAnchor().getReferencePoint();
- connection.translateToRelative(sourceRefPoint);
- return sourceRefPoint;
+ Point sourceRefPoint = connection.getSourceAnchor().getReferencePoint();
+ connection.translateToRelative(sourceRefPoint);
+ return sourceRefPoint;
+ }
}
return super.getSourceRefPoint();
}
@@ -97,23 +99,26 @@ public class SetReconnectingConnectionBendpointsCommand extends SetConnectionBen
*/
@Override
public Point getTargetRefPoint() {
- Edge edge = reconnectingEdgeHelper.getReconnectedEdge();
- if (edge != null) {
- Connection connection = (Connection) GMFHelper.getGraphicalEditPart(edge).get().getFigure();
+ if (reconnectingEdgeHelper.isReconnectingTarget()) {
+ Edge edge = reconnectingEdgeHelper.getReconnectedEdge();
+ if (edge != null) {
+ Connection connection = (Connection) GMFHelper.getGraphicalEditPart(edge).get().getFigure();
- Point targetRefPoint = connection.getTargetAnchor().getReferencePoint();
- connection.translateToRelative(targetRefPoint);
- return targetRefPoint;
+ Point targetRefPoint = connection.getTargetAnchor().getReferencePoint();
+ connection.translateToRelative(targetRefPoint);
+ return targetRefPoint;
+ }
}
return super.getTargetRefPoint();
}
@Override
protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
-
Assert.isNotNull(getNewPointList());
- Assert.isNotNull(getSourceRefPoint());
- Assert.isNotNull(getTargetRefPoint());
+ Point sourceRefPoint = getSourceRefPoint();
+ Assert.isNotNull(sourceRefPoint);
+ Point targetRefPoint = getTargetRefPoint();
+ Assert.isNotNull(targetRefPoint);
// The edge recovery is the difference with the parent command
Edge edge = reconnectingEdgeHelper.getReconnectedEdge();
@@ -126,8 +131,8 @@ public class SetReconnectingConnectionBendpointsCommand extends SetConnectionBen
// The sourceRefPoint and targetRefPoint will be recovered from
// the
// reconnected edge
- Dimension s = getNewPointList().getPoint(i).getDifference(getSourceRefPoint());
- Dimension t = getNewPointList().getPoint(i).getDifference(getTargetRefPoint());
+ Dimension s = getNewPointList().getPoint(i).getDifference(sourceRefPoint);
+ Dimension t = getNewPointList().getPoint(i).getDifference(targetRefPoint);
newBendpoints.add(new RelativeBendpoint(s.width, s.height, t.width, t.height));
}
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/edit/helpers/EdgeReconnectionHelper.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/edit/helpers/EdgeReconnectionHelper.java
index c3d271473b..ad6120f011 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/edit/helpers/EdgeReconnectionHelper.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/edit/helpers/EdgeReconnectionHelper.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2014 THALES GLOBAL SERVICES.
+ * Copyright (c) 2014, 2015 THALES GLOBAL SERVICES.
* 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
@@ -66,7 +66,8 @@ public class EdgeReconnectionHelper {
public EdgeReconnectionHelper(View reconnectionTarget, List<Edge> reconnectionTargetEdges, ReconnectionKind reconnectionKind) {
this.reconnectionTarget = reconnectionTarget;
this.reconnectionTargetEdges = new ArrayList<Edge>(reconnectionTargetEdges);
- assert reconnectionKind == ReconnectionKind.RECONNECT_SOURCE_LITERAL || reconnectionKind == ReconnectionKind.RECONNECT_TARGET_LITERAL : "reconnectionKind must be ReconnectionKind.RECONNECT_SOURCE or ReconnectionKind.RECONNECT_TARGET";
+ assert reconnectionKind == ReconnectionKind.RECONNECT_SOURCE_LITERAL
+ || reconnectionKind == ReconnectionKind.RECONNECT_TARGET_LITERAL : "reconnectionKind must be ReconnectionKind.RECONNECT_SOURCE or ReconnectionKind.RECONNECT_TARGET";
this.reconnectionKind = reconnectionKind;
}
@@ -82,6 +83,7 @@ public class EdgeReconnectionHelper {
Iterables.removeAll(sourceEdges, reconnectionTargetEdges);
Predicate<Edge> notToReconnectingEdge = new Predicate<Edge>() {
+ @Override
public boolean apply(Edge input) {
return !sourceEdges.contains(input.getTarget());
}
@@ -107,6 +109,7 @@ public class EdgeReconnectionHelper {
Iterables.removeAll(targetEdges, reconnectionTargetEdges);
Predicate<Edge> notFromReconnectingEdge = new Predicate<Edge>() {
+ @Override
public boolean apply(Edge input) {
return !targetEdges.contains(input.getSource());
}
@@ -131,4 +134,12 @@ public class EdgeReconnectionHelper {
return edge;
}
+ public boolean isReconnectingSource() {
+ return reconnectionKind.equals(ReconnectionKind.RECONNECT_SOURCE_LITERAL);
+ }
+
+ public boolean isReconnectingTarget() {
+ return reconnectionKind.equals(ReconnectionKind.RECONNECT_TARGET_LITERAL);
+ }
+
}
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/SiriusGraphicalNodeEditPolicy.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/SiriusGraphicalNodeEditPolicy.java
index 9cb566b814..48e13635fa 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/SiriusGraphicalNodeEditPolicy.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/SiriusGraphicalNodeEditPolicy.java
@@ -246,6 +246,17 @@ public class SiriusGraphicalNodeEditPolicy extends TreeGraphicalNodeEditPolicy {
SiriusSetConnectionAnchorsCommand scaCommand = new SiriusSetConnectionAnchorsCommand(editingDomain, DiagramUIMessages.Commands_SetConnectionEndsCommand_Source, sourceView,
sourceView.getSourceEdges(), ReconnectionKind.RECONNECT_SOURCE_LITERAL);
scaCommand.setNewSourceTerminal(node.mapConnectionAnchorToTerminal(sourceAnchor));
+
+ // We retrieve the current target anchor and set it in the
+ // SiriusSetConnectionAnchorsCommand. when reconnecting the edge, a new
+ // edge is created and the anchor is lost, we need to set it back.
+ Connection connection = (Connection) ((GraphicalEditPart) request.getConnectionEditPart()).getFigure();
+ ConnectionAnchor connectionAnchor = connection.getTargetAnchor();
+ if (connectionAnchor instanceof BaseSlidableAnchor) {
+ String targetTerminal = ((BaseSlidableAnchor) connectionAnchor).getTerminal();
+ scaCommand.setNewTargetTerminal(targetTerminal);
+ }
+
CompositeCommand cc = new CompositeCommand(DiagramUIMessages.Commands_SetConnectionEndsCommand_Source);
cc.compose(scaCommand);
@@ -254,7 +265,6 @@ public class SiriusGraphicalNodeEditPolicy extends TreeGraphicalNodeEditPolicy {
// previous edge under reconnection
// Set points of Edge as they are graphically
- Connection connection = (Connection) ((GraphicalEditPart) request.getConnectionEditPart()).getFigure();
Point tempSourceRefPoint = connection.getSourceAnchor().getReferencePoint();
connection.translateToRelative(tempSourceRefPoint);
@@ -418,8 +428,20 @@ public class SiriusGraphicalNodeEditPolicy extends TreeGraphicalNodeEditPolicy {
SiriusSetConnectionAnchorsCommand scaCommand = new SiriusSetConnectionAnchorsCommand(editingDomain, DiagramUIMessages.Commands_SetConnectionEndsCommand_Target, targetView,
targetView.getTargetEdges(), ReconnectionKind.RECONNECT_TARGET_LITERAL);
scaCommand.setNewTargetTerminal(targetEP.mapConnectionAnchorToTerminal(targetAnchor));
+
+ // We retrieve the current source anchor and set it in the
+ // SiriusSetConnectionAnchorsCommand. when reconnecting the edge, a new
+ // edge is created and the anchor is lost, we need to set it back.
+ ConnectionEditPart cep = request.getConnectionEditPart();
+ Connection connection = (Connection) cep.getFigure();
+ ConnectionAnchor connectionAnchor = connection.getSourceAnchor();
+ if (connectionAnchor instanceof BaseSlidableAnchor) {
+ String sourceTerminal = ((BaseSlidableAnchor) connectionAnchor).getTerminal();
+ scaCommand.setNewSourceTerminal(sourceTerminal);
+ }
+
Command cmd = new ICommandProxy(scaCommand);
- EditPart cep = request.getConnectionEditPart();
+
RoutingStyle style = (RoutingStyle) ((View) cep.getModel()).getStyle(NotationPackage.eINSTANCE.getRoutingStyle());
Routing currentRouter = Routing.MANUAL_LITERAL;
if (style != null) {
@@ -451,7 +473,6 @@ public class SiriusGraphicalNodeEditPolicy extends TreeGraphicalNodeEditPolicy {
// previous edge under reconnection
// Set points of Edge as they are graphically
- Connection connection = (Connection) ((GraphicalEditPart) request.getConnectionEditPart()).getFigure();
Point tempSourceRefPoint = connection.getSourceAnchor().getReferencePoint();
connection.translateToRelative(tempSourceRefPoint);
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/data/unit/edgeReconnection/Bug467663.aird b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/edgeReconnection/Bug467663.aird
index 5a95930f53..babe0c6fcc 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot/data/unit/edgeReconnection/Bug467663.aird
+++ b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/edgeReconnection/Bug467663.aird
@@ -348,7 +348,7 @@
<styles xmi:type="notation:FilteringStyle" xmi:id="_smbKkxXQEeWwcbvMkwT-CQ"/>
</children>
<styles xmi:type="notation:ShapeStyle" xmi:id="_smajgxXQEeWwcbvMkwT-CQ" fontName="Cantarell" fontHeight="8"/>
- <layoutConstraint xmi:type="notation:Bounds" xmi:id="_smajhBXQEeWwcbvMkwT-CQ" x="65" y="45" width="388" height="248"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_smajhBXQEeWwcbvMkwT-CQ" x="20" y="80" width="388" height="248"/>
</children>
<children xmi:type="notation:Node" xmi:id="_smbKlBXQEeWwcbvMkwT-CQ" type="2002" element="_smZ8eRXQEeWwcbvMkwT-CQ">
<children xmi:type="notation:Node" xmi:id="_smbxoBXQEeWwcbvMkwT-CQ" type="5006"/>
@@ -375,40 +375,40 @@
<styles xmi:type="notation:FilteringStyle" xmi:id="_smbxoxXQEeWwcbvMkwT-CQ"/>
</children>
<styles xmi:type="notation:ShapeStyle" xmi:id="_smbKlRXQEeWwcbvMkwT-CQ" fontName="Cantarell" fontHeight="8"/>
- <layoutConstraint xmi:type="notation:Bounds" xmi:id="_smbKlhXQEeWwcbvMkwT-CQ" x="485" y="45" width="288" height="248"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_smbKlhXQEeWwcbvMkwT-CQ" x="440" y="80" width="288" height="248"/>
</children>
<styles xmi:type="notation:DiagramStyle" xmi:id="_smajgRXQEeWwcbvMkwT-CQ"/>
<edges xmi:type="notation:Edge" xmi:id="_smeN4BXQEeWwcbvMkwT-CQ" type="4001" element="_smZ8exXQEeWwcbvMkwT-CQ" source="_smcYsBXQEeWwcbvMkwT-CQ" target="_smajghXQEeWwcbvMkwT-CQ">
<children xmi:type="notation:Node" xmi:id="_sme08BXQEeWwcbvMkwT-CQ" type="6001">
- <layoutConstraint xmi:type="notation:Bounds" xmi:id="_sme08RXQEeWwcbvMkwT-CQ" y="-10"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_sme08RXQEeWwcbvMkwT-CQ" x="1" y="-6"/>
</children>
<children xmi:type="notation:Node" xmi:id="_sme08hXQEeWwcbvMkwT-CQ" type="6002">
- <layoutConstraint xmi:type="notation:Bounds" xmi:id="_sme08xXQEeWwcbvMkwT-CQ" y="10"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_sme08xXQEeWwcbvMkwT-CQ" x="-16" y="4"/>
</children>
<children xmi:type="notation:Node" xmi:id="_sme09BXQEeWwcbvMkwT-CQ" type="6003">
- <layoutConstraint xmi:type="notation:Bounds" xmi:id="_sme09RXQEeWwcbvMkwT-CQ" y="10"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_sme09RXQEeWwcbvMkwT-CQ" x="12" y="16"/>
</children>
<styles xmi:type="notation:ConnectorStyle" xmi:id="_smeN4RXQEeWwcbvMkwT-CQ"/>
<styles xmi:type="notation:FontStyle" xmi:id="_smeN4hXQEeWwcbvMkwT-CQ" fontName="Cantarell" fontHeight="8"/>
- <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_smeN4xXQEeWwcbvMkwT-CQ" points="[1, 3, -140, 0]$[144, 3, 3, 0]"/>
- <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_sme09hXQEeWwcbvMkwT-CQ" id="(0.9933333333333333,0.5428571428571428)"/>
- <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_sme09xXQEeWwcbvMkwT-CQ" id="(0.9922680412371134,0.28225806451612906)"/>
+ <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_smeN4xXQEeWwcbvMkwT-CQ" points="[3, -4, -127, 88]$[128, -140, -2, -48]$[128, -95, -2, -3]"/>
+ <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_sme09hXQEeWwcbvMkwT-CQ" id="(0.98,0.9714285714285714)"/>
+ <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_sme09xXQEeWwcbvMkwT-CQ" id="(0.9561855670103093,0.016129032258064516)"/>
</edges>
<edges xmi:type="notation:Edge" xmi:id="_x9n4wBXQEeWwcbvMkwT-CQ" type="4001" element="_smZ8fhXQEeWwcbvMkwT-CQ" source="_smc_xBXQEeWwcbvMkwT-CQ" target="_smajghXQEeWwcbvMkwT-CQ">
<children xmi:type="notation:Node" xmi:id="_x9of0BXQEeWwcbvMkwT-CQ" type="6001">
- <layoutConstraint xmi:type="notation:Bounds" xmi:id="_x9of0RXQEeWwcbvMkwT-CQ" y="-10"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_x9of0RXQEeWwcbvMkwT-CQ" x="-17" y="-6"/>
</children>
<children xmi:type="notation:Node" xmi:id="_x9of0hXQEeWwcbvMkwT-CQ" type="6002">
- <layoutConstraint xmi:type="notation:Bounds" xmi:id="_x9of0xXQEeWwcbvMkwT-CQ" y="10"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_x9of0xXQEeWwcbvMkwT-CQ" x="8" y="7"/>
</children>
<children xmi:type="notation:Node" xmi:id="_x9of1BXQEeWwcbvMkwT-CQ" type="6003">
- <layoutConstraint xmi:type="notation:Bounds" xmi:id="_x9of1RXQEeWwcbvMkwT-CQ" y="10"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_x9of1RXQEeWwcbvMkwT-CQ" x="-23" y="3"/>
</children>
<styles xmi:type="notation:ConnectorStyle" xmi:id="_x9n4wRXQEeWwcbvMkwT-CQ"/>
<styles xmi:type="notation:FontStyle" xmi:id="_x9n4whXQEeWwcbvMkwT-CQ" fontName="Cantarell" fontHeight="8"/>
- <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_x9n4wxXQEeWwcbvMkwT-CQ" points="[74, 2, -132, 1]$[217, 2, 11, 1]"/>
- <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_x9pG4BXQEeWwcbvMkwT-CQ" id="(0.5,0.5)"/>
- <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_x9pG4RXQEeWwcbvMkwT-CQ" id="(0.9716494845360825,0.6733870967741935)"/>
+ <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_x9n4wxXQEeWwcbvMkwT-CQ" points="[2, 2, -141, 27]$[127, 120, -16, 145]$[134, 51, -9, 76]"/>
+ <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_x9pG4BXQEeWwcbvMkwT-CQ" id="(0.9866666666666667,0.9714285714285714)"/>
+ <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_x9pG4RXQEeWwcbvMkwT-CQ" id="(0.9922680412371134,0.6935483870967742)"/>
</edges>
</data>
</ownedAnnotationEntries>
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/EdgeReconnectionTests.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/EdgeReconnectionTests.java
index 2c8f6b0b01..aeeb5ef282 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/EdgeReconnectionTests.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/EdgeReconnectionTests.java
@@ -59,119 +59,158 @@ public class EdgeReconnectionTests extends AbstractSiriusSwtBotGefTestCase {
}
/**
- * Test reconnection of target edge end point from a container to another
- * with oblique style routing.
+ * Test reconnection of source and target edge end point from a container to
+ * another with oblique style routing.
*/
public void testSimpleEdgeSourceReconnectionWithObliqueStyleRouting() {
editor = (SWTBotSiriusDiagramEditor) openRepresentation(localSession.getOpenedSession(), REPRESENTATION1_NAME, "new " + REPRESENTATION1_NAME, DDiagram.class, true);
- SWTBotGefEditPart eClass1EditPartBot = editor.getEditPart("EClass1", AbstractDiagramContainerEditPart.class);
- SWTBotGefEditPart eClass2EditPartBot = editor.getEditPart("EClass2", AbstractDiagramContainerEditPart.class);
- SWTBotGefEditPart ref1EditPartBot = editor.getEditPart("ref1", AbstractDiagramContainerEditPart.class);
- SWTBotGefEditPart ref2EditPartBot = editor.getEditPart("ref2", AbstractDiagramContainerEditPart.class);
- SWTBotGefEditPart ref3EditPartBot = editor.getEditPart("ref3", AbstractDiagramContainerEditPart.class);
- SWTBotGefEditPart ref4EditPartBot = editor.getEditPart("ref4", AbstractDiagramContainerEditPart.class);
- SWTBotGefConnectionEditPart connection1EditPartBot = editor.getConnectionEditPart(ref1EditPartBot, eClass1EditPartBot).get(0);
- SWTBotGefConnectionEditPart connection2EditPartBot = editor.getConnectionEditPart(ref2EditPartBot, eClass1EditPartBot).get(0);
+ editor.maximize();
+ try {
+ SWTBotGefEditPart eClass1EditPartBot = editor.getEditPart("EClass1", AbstractDiagramContainerEditPart.class);
+ SWTBotGefEditPart eClass2EditPartBot = editor.getEditPart("EClass2", AbstractDiagramContainerEditPart.class);
+ SWTBotGefEditPart ref1EditPartBot = editor.getEditPart("ref1", AbstractDiagramContainerEditPart.class);
+ SWTBotGefEditPart ref2EditPartBot = editor.getEditPart("ref2", AbstractDiagramContainerEditPart.class);
+ SWTBotGefEditPart ref3EditPartBot = editor.getEditPart("ref3", AbstractDiagramContainerEditPart.class);
+ SWTBotGefEditPart ref4EditPartBot = editor.getEditPart("ref4", AbstractDiagramContainerEditPart.class);
+ SWTBotGefConnectionEditPart connection1EditPartBot = editor.getConnectionEditPart(ref1EditPartBot, eClass1EditPartBot).get(0);
+ SWTBotGefConnectionEditPart connection2EditPartBot = editor.getConnectionEditPart(ref2EditPartBot, eClass1EditPartBot).get(0);
- // Reconnect target of first connection
- PointList connection1Points = ((AbstractConnectionEditPart) connection1EditPartBot.part()).getConnectionFigure().getPoints().getCopy();
- Point from = connection1Points.getLastPoint();
- Point to = from.getCopy().setX(editor.getBounds(eClass2EditPartBot).x);
- connection1EditPartBot.select();
- editor.drag(from, to);
- // Check that reconnection is correct
- assertEquals(0, editor.getConnectionEditPart(ref1EditPartBot, eClass1EditPartBot).size());
- List<SWTBotGefConnectionEditPart> newConnection1EditPartBotList = editor.getConnectionEditPart(ref1EditPartBot, eClass2EditPartBot);
- assertEquals(1, newConnection1EditPartBotList.size());
- SWTBotGefConnectionEditPart newConnection1EditPartBot = newConnection1EditPartBotList.get(0);
- PointList newConnection1Points = ((AbstractConnectionEditPart) newConnection1EditPartBot.part()).getConnectionFigure().getPoints();
- assertEquals(2, newConnection1Points.size());
- GraphicTestsSupportHelp.assertEquals("After reconnection source end point is not at the correct position.", connection1Points.getFirstPoint(), newConnection1Points.getFirstPoint(), 0, 1);
- GraphicTestsSupportHelp.assertEquals("After reconnection target end point is not at the correct position.", to, newConnection1Points.getLastPoint(), 0, 1);
- connection1EditPartBot = newConnection1EditPartBot;
+ // Reconnect target of first connection
+ PointList connection1Points = ((AbstractConnectionEditPart) connection1EditPartBot.part()).getConnectionFigure().getPoints().getCopy();
+ Point from = connection1Points.getLastPoint();
+ Point to = from.getCopy().setX(editor.getBounds(eClass2EditPartBot).x);
+ connection1EditPartBot.select();
+ editor.drag(from, to);
+ // Check that reconnection is correct
+ assertEquals(0, editor.getConnectionEditPart(ref1EditPartBot, eClass1EditPartBot).size());
+ List<SWTBotGefConnectionEditPart> newConnection1EditPartBotList = editor.getConnectionEditPart(ref1EditPartBot, eClass2EditPartBot);
+ assertEquals(1, newConnection1EditPartBotList.size());
+ SWTBotGefConnectionEditPart newConnection1EditPartBot = newConnection1EditPartBotList.get(0);
+ PointList newConnection1Points = ((AbstractConnectionEditPart) newConnection1EditPartBot.part()).getConnectionFigure().getPoints();
+ assertEquals(3, newConnection1Points.size());
+ GraphicTestsSupportHelp.assertEquals("After reconnection source end point is not at the correct position.", connection1Points.getFirstPoint(), newConnection1Points.getFirstPoint(), 0, 1);
+ GraphicTestsSupportHelp.assertEquals("After reconnection target end point is not at the correct position.", to, newConnection1Points.getLastPoint(), 0, 1);
+ connection1EditPartBot = newConnection1EditPartBot;
- // Reconnect target of second connection
- PointList connection2Points = ((AbstractConnectionEditPart) connection2EditPartBot.part()).getConnectionFigure().getPoints().getCopy();
- from = connection2Points.getLastPoint();
- to = from.getCopy().setX(editor.getBounds(eClass2EditPartBot).x);
- connection2EditPartBot.select();
- editor.drag(from, to);
- // Check that reconnection is correct
- assertEquals(0, editor.getConnectionEditPart(ref2EditPartBot, eClass1EditPartBot).size());
- List<SWTBotGefConnectionEditPart> newConnection2EditPartBotList = editor.getConnectionEditPart(ref2EditPartBot, eClass2EditPartBot);
- assertEquals(1, newConnection2EditPartBotList.size());
- SWTBotGefConnectionEditPart newConnection2EditPartBot = newConnection2EditPartBotList.get(0);
- PointList newConnection2Points = ((AbstractConnectionEditPart) newConnection2EditPartBot.part()).getConnectionFigure().getPoints();
- assertEquals(2, newConnection2Points.size());
- GraphicTestsSupportHelp.assertEquals("After reconnection source end point is not at the correct position.", connection2Points.getFirstPoint(), newConnection2Points.getFirstPoint(), 0, 2);
- GraphicTestsSupportHelp.assertEquals("After reconnection target end point is not at the correct position.", to, newConnection2Points.getLastPoint(), 0, 2);
- connection2EditPartBot = newConnection2EditPartBot;
+ // Reconnect target of second connection
+ PointList connection2Points = ((AbstractConnectionEditPart) connection2EditPartBot.part()).getConnectionFigure().getPoints().getCopy();
+ from = connection2Points.getLastPoint();
+ to = from.getCopy().setX(editor.getBounds(eClass2EditPartBot).x);
+ connection2EditPartBot.select();
+ editor.drag(from, to);
+ // Check that reconnection is correct
+ assertEquals(0, editor.getConnectionEditPart(ref2EditPartBot, eClass1EditPartBot).size());
+ List<SWTBotGefConnectionEditPart> newConnection2EditPartBotList = editor.getConnectionEditPart(ref2EditPartBot, eClass2EditPartBot);
+ assertEquals(1, newConnection2EditPartBotList.size());
+ SWTBotGefConnectionEditPart newConnection2EditPartBot = newConnection2EditPartBotList.get(0);
+ PointList newConnection2Points = ((AbstractConnectionEditPart) newConnection2EditPartBot.part()).getConnectionFigure().getPoints();
+ assertEquals(3, newConnection2Points.size());
+ GraphicTestsSupportHelp.assertEquals("After reconnection source end point is not at the correct position.", connection2Points.getFirstPoint(), newConnection2Points.getFirstPoint(), 0, 2);
+ GraphicTestsSupportHelp.assertEquals("After reconnection target end point is not at the correct position.", to, newConnection2Points.getLastPoint(), 0, 2);
+ connection2EditPartBot = newConnection2EditPartBot;
- // Reconnect target of first connection as initially
- connection1Points = ((AbstractConnectionEditPart) connection1EditPartBot.part()).getConnectionFigure().getPoints().getCopy();
- from = connection1Points.getLastPoint();
- to = from.getCopy().setX(editor.getBounds(eClass1EditPartBot).getRight().x - 2);
- connection1EditPartBot.select();
- editor.drag(from, to);
- // Check that reconnection is correct
- assertEquals(0, editor.getConnectionEditPart(ref1EditPartBot, eClass2EditPartBot).size());
- newConnection1EditPartBotList = editor.getConnectionEditPart(ref1EditPartBot, eClass1EditPartBot);
- assertEquals(1, newConnection1EditPartBotList.size());
- newConnection1EditPartBot = newConnection1EditPartBotList.get(0);
- newConnection1Points = ((AbstractConnectionEditPart) newConnection1EditPartBot.part()).getConnectionFigure().getPoints();
- assertEquals(2, newConnection1Points.size());
- GraphicTestsSupportHelp.assertEquals("After reconnection source end point is not at the correct position.", connection1Points.getFirstPoint(), newConnection1Points.getFirstPoint(), 0, 1);
- GraphicTestsSupportHelp.assertEquals("After reconnection target end point is not at the correct position.", to, newConnection1Points.getLastPoint(), 0, 1);
- connection1EditPartBot = newConnection1EditPartBot;
+ // Reconnect target of first connection as initially
+ connection1Points = ((AbstractConnectionEditPart) connection1EditPartBot.part()).getConnectionFigure().getPoints().getCopy();
+ from = connection1Points.getLastPoint();
+ to = from.getCopy().setX(editor.getBounds(eClass1EditPartBot).getRight().x - 20);
+ connection1EditPartBot.select();
+ editor.drag(from, to);
+ // Check that reconnection is correct
+ assertEquals(0, editor.getConnectionEditPart(ref1EditPartBot, eClass2EditPartBot).size());
+ newConnection1EditPartBotList = editor.getConnectionEditPart(ref1EditPartBot, eClass1EditPartBot);
+ assertEquals(1, newConnection1EditPartBotList.size());
+ newConnection1EditPartBot = newConnection1EditPartBotList.get(0);
+ newConnection1Points = ((AbstractConnectionEditPart) newConnection1EditPartBot.part()).getConnectionFigure().getPoints();
+ assertEquals(3, newConnection1Points.size());
+ GraphicTestsSupportHelp.assertEquals("After reconnection source end point is not at the correct position.", connection1Points.getFirstPoint(), newConnection1Points.getFirstPoint(), 1, 1);
+ GraphicTestsSupportHelp.assertEquals("After reconnection target end point is not at the correct position.", to, newConnection1Points.getLastPoint(), 1, 1);
+ connection1EditPartBot = newConnection1EditPartBot;
- // Reconnect target of second connection as initially
- connection2Points = ((AbstractConnectionEditPart) connection2EditPartBot.part()).getConnectionFigure().getPoints().getCopy();
- from = connection2Points.getLastPoint();
- to = from.getCopy().setX(editor.getBounds(eClass1EditPartBot).getRight().x - 2);
- connection2EditPartBot.select();
- editor.drag(from, to);
- // Check that reconnection is correct
- assertEquals(0, editor.getConnectionEditPart(ref2EditPartBot, eClass2EditPartBot).size());
- newConnection2EditPartBotList = editor.getConnectionEditPart(ref2EditPartBot, eClass1EditPartBot);
- assertEquals(1, newConnection2EditPartBotList.size());
- newConnection2EditPartBot = newConnection2EditPartBotList.get(0);
- newConnection2Points = ((AbstractConnectionEditPart) newConnection2EditPartBot.part()).getConnectionFigure().getPoints();
- assertEquals(2, newConnection2Points.size());
- GraphicTestsSupportHelp.assertEquals("After reconnection source end point is not at the correct position.", connection2Points.getFirstPoint(), newConnection2Points.getFirstPoint(), 0, 2);
- GraphicTestsSupportHelp.assertEquals("After reconnection target end point is not at the correct position.", to, newConnection2Points.getLastPoint(), 0, 2);
- connection2EditPartBot = newConnection2EditPartBot;
+ // Reconnect target of second connection as initially
+ connection2Points = ((AbstractConnectionEditPart) connection2EditPartBot.part()).getConnectionFigure().getPoints().getCopy();
+ from = connection2Points.getLastPoint();
+ to = from.getCopy().setX(editor.getBounds(eClass1EditPartBot).getRight().x - 20);
+ connection2EditPartBot.select();
+ editor.drag(from, to);
+ // Check that reconnection is correct
+ assertEquals(0, editor.getConnectionEditPart(ref2EditPartBot, eClass2EditPartBot).size());
+ newConnection2EditPartBotList = editor.getConnectionEditPart(ref2EditPartBot, eClass1EditPartBot);
+ assertEquals(1, newConnection2EditPartBotList.size());
+ newConnection2EditPartBot = newConnection2EditPartBotList.get(0);
+ newConnection2Points = ((AbstractConnectionEditPart) newConnection2EditPartBot.part()).getConnectionFigure().getPoints();
+ assertEquals(3, newConnection2Points.size());
+ GraphicTestsSupportHelp.assertEquals("After reconnection source end point is not at the correct position.", connection2Points.getFirstPoint(), newConnection2Points.getFirstPoint(), 1, 2);
+ GraphicTestsSupportHelp.assertEquals("After reconnection target end point is not at the correct position.", to, newConnection2Points.getLastPoint(), 1, 2);
+ connection2EditPartBot = newConnection2EditPartBot;
- // Reconnect source of first connection
- connection1Points = ((AbstractConnectionEditPart) connection1EditPartBot.part()).getConnectionFigure().getPoints().getCopy();
- from = connection1Points.getFirstPoint();
- to = from.getCopy().setX(editor.getBounds(ref3EditPartBot).x);
- connection1EditPartBot.select();
- editor.drag(from, to);
- // Check that reconnection is correct
- assertEquals(0, editor.getConnectionEditPart(ref1EditPartBot, eClass1EditPartBot).size());
- newConnection1EditPartBotList = editor.getConnectionEditPart(ref3EditPartBot, eClass1EditPartBot);
- assertEquals(1, newConnection1EditPartBotList.size());
- newConnection1EditPartBot = newConnection1EditPartBotList.get(0);
- newConnection1Points = ((AbstractConnectionEditPart) newConnection1EditPartBot.part()).getConnectionFigure().getPoints();
- assertEquals(2, newConnection1Points.size());
- GraphicTestsSupportHelp.assertEquals("After reconnection source end point is not at the correct position.", to, newConnection1Points.getFirstPoint(), 0, 2);
- connection1EditPartBot = newConnection1EditPartBot;
+ // Reconnect source of first connection
+ connection1Points = ((AbstractConnectionEditPart) connection1EditPartBot.part()).getConnectionFigure().getPoints().getCopy();
+ from = connection1Points.getFirstPoint();
+ to = from.getCopy().setX(editor.getBounds(ref3EditPartBot).x);
+ connection1EditPartBot.select();
+ editor.drag(from, to);
+ // Check that reconnection is correct
+ assertEquals(0, editor.getConnectionEditPart(ref1EditPartBot, eClass1EditPartBot).size());
+ newConnection1EditPartBotList = editor.getConnectionEditPart(ref3EditPartBot, eClass1EditPartBot);
+ assertEquals(1, newConnection1EditPartBotList.size());
+ newConnection1EditPartBot = newConnection1EditPartBotList.get(0);
+ newConnection1Points = ((AbstractConnectionEditPart) newConnection1EditPartBot.part()).getConnectionFigure().getPoints();
+ assertEquals(3, newConnection1Points.size());
+ GraphicTestsSupportHelp.assertEquals("After reconnection source end point is not at the correct position.", to, newConnection1Points.getFirstPoint(), 0, 2);
+ GraphicTestsSupportHelp.assertEquals("After reconnection target end point is not at the correct position.", connection1Points.getLastPoint(), newConnection1Points.getLastPoint(), 0, 2);
+ connection1EditPartBot = newConnection1EditPartBot;
- // Reconnect source of second connection
- connection2Points = ((AbstractConnectionEditPart) connection2EditPartBot.part()).getConnectionFigure().getPoints().getCopy();
- from = connection2Points.getFirstPoint();
- to = from.getCopy().setX(editor.getBounds(ref4EditPartBot).x);
- connection2EditPartBot.select();
- editor.drag(from, to);
- // Check that reconnection is correct
- assertEquals(0, editor.getConnectionEditPart(ref2EditPartBot, eClass1EditPartBot).size());
- newConnection2EditPartBotList = editor.getConnectionEditPart(ref4EditPartBot, eClass1EditPartBot);
- assertEquals(1, newConnection2EditPartBotList.size());
- newConnection2EditPartBot = newConnection2EditPartBotList.get(0);
- newConnection2Points = ((AbstractConnectionEditPart) newConnection2EditPartBot.part()).getConnectionFigure().getPoints();
- assertEquals(2, newConnection2Points.size());
- GraphicTestsSupportHelp.assertEquals("After reconnection source end point is not at the correct position.", to, newConnection2Points.getFirstPoint(), 0, 1);
- connection2EditPartBot = newConnection2EditPartBot;
+ // Reconnect source of second connection
+ connection2Points = ((AbstractConnectionEditPart) connection2EditPartBot.part()).getConnectionFigure().getPoints().getCopy();
+ from = connection2Points.getFirstPoint();
+ to = from.getCopy().setX(editor.getBounds(ref4EditPartBot).x);
+ connection2EditPartBot.select();
+ editor.drag(from, to);
+ // Check that reconnection is correct
+ assertEquals(0, editor.getConnectionEditPart(ref2EditPartBot, eClass1EditPartBot).size());
+ newConnection2EditPartBotList = editor.getConnectionEditPart(ref4EditPartBot, eClass1EditPartBot);
+ assertEquals(1, newConnection2EditPartBotList.size());
+ newConnection2EditPartBot = newConnection2EditPartBotList.get(0);
+ newConnection2Points = ((AbstractConnectionEditPart) newConnection2EditPartBot.part()).getConnectionFigure().getPoints();
+ assertEquals(3, newConnection2Points.size());
+ GraphicTestsSupportHelp.assertEquals("After reconnection source end point is not at the correct position.", to, newConnection2Points.getFirstPoint(), 0, 2);
+ GraphicTestsSupportHelp.assertEquals("After reconnection target end point is not at the correct position.", connection2Points.getLastPoint(), newConnection2Points.getLastPoint(), 0, 1);
+ connection2EditPartBot = newConnection2EditPartBot;
+
+ // Reconnect source of first connection as initially
+ connection1Points = ((AbstractConnectionEditPart) connection1EditPartBot.part()).getConnectionFigure().getPoints().getCopy();
+ from = connection1Points.getFirstPoint();
+ to = from.getCopy().setX(editor.getBounds(ref1EditPartBot).getRight().x - 2);
+ connection1EditPartBot.select();
+ editor.drag(from, to);
+ // Check that reconnection is correct
+ assertEquals(0, editor.getConnectionEditPart(ref3EditPartBot, eClass1EditPartBot).size());
+ newConnection1EditPartBotList = editor.getConnectionEditPart(ref1EditPartBot, eClass1EditPartBot);
+ assertEquals(1, newConnection1EditPartBotList.size());
+ newConnection1EditPartBot = newConnection1EditPartBotList.get(0);
+ newConnection1Points = ((AbstractConnectionEditPart) newConnection1EditPartBot.part()).getConnectionFigure().getPoints();
+ assertEquals(3, newConnection1Points.size());
+ GraphicTestsSupportHelp.assertEquals("After reconnection source end point is not at the correct position.", to, newConnection1Points.getFirstPoint(), 0, 4);
+ GraphicTestsSupportHelp.assertEquals("After reconnection target end point is not at the correct position.", connection1Points.getLastPoint(), newConnection1Points.getLastPoint(), 0, 1);
+
+ // Reconnect source of second connection as initially
+ connection2Points = ((AbstractConnectionEditPart) connection2EditPartBot.part()).getConnectionFigure().getPoints().getCopy();
+ from = connection2Points.getFirstPoint();
+ to = from.getCopy().setX(editor.getBounds(ref2EditPartBot).getRight().x - 2);
+ connection2EditPartBot.select();
+ editor.drag(from, to);
+ // Check that reconnection is correct
+ assertEquals(0, editor.getConnectionEditPart(ref4EditPartBot, eClass2EditPartBot).size());
+ newConnection2EditPartBotList = editor.getConnectionEditPart(ref2EditPartBot, eClass1EditPartBot);
+ assertEquals(1, newConnection2EditPartBotList.size());
+ newConnection2EditPartBot = newConnection2EditPartBotList.get(0);
+ newConnection2Points = ((AbstractConnectionEditPart) newConnection2EditPartBot.part()).getConnectionFigure().getPoints();
+ assertEquals(3, newConnection2Points.size());
+ GraphicTestsSupportHelp.assertEquals("After reconnection source end point is not at the correct position.", to, newConnection2Points.getFirstPoint(), 0, 2);
+ GraphicTestsSupportHelp.assertEquals("After reconnection target end point is not at the correct position.", connection1Points.getLastPoint(), newConnection1Points.getLastPoint(), 0, 2);
+ } finally {
+ editor.restore();
+ }
}
/**

Back to the top