diff options
author | Florian Barbin | 2014-10-31 15:37:34 +0000 |
---|---|---|
committer | Florian Barbin | 2014-10-31 16:07:12 +0000 |
commit | 220c31aa503c821bb482632f90c004d4e11081e1 (patch) | |
tree | be6b2ba362efe2e368f8b570bc49905a38e26ad1 | |
parent | cdd61560c9a69ce96f52d65879860997fb26f9c4 (diff) | |
download | org.eclipse.sirius-220c31aa503c821bb482632f90c004d4e11081e1.tar.gz org.eclipse.sirius-220c31aa503c821bb482632f90c004d4e11081e1.tar.xz org.eclipse.sirius-220c31aa503c821bb482632f90c004d4e11081e1.zip |
[448739] Center edges after the reconnect.
* With the new SetReconnectingConnectionBendpointsCommand, the edge
centering is broken since this command is executed after the centering.
* Add two new tests that check the reconnection on rectilinear edges.
Bug: 448739
Change-Id: Ia45596b1e395700270c975d840f157dd9fac8e28
Signed-off-by: Florian Barbin <florian.barbin@obeo.fr>
2 files changed, 35 insertions, 1 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 7a852d1107..b96f49c633 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 @@ -29,6 +29,7 @@ import org.eclipse.gmf.runtime.notation.View; import org.eclipse.gmf.runtime.notation.datatype.RelativeBendpoint; import org.eclipse.sirius.diagram.description.tool.ReconnectionKind; import org.eclipse.sirius.diagram.ui.business.internal.edit.helpers.EdgeReconnectionHelper; +import org.eclipse.sirius.diagram.ui.internal.operation.CenterEdgeEndModelChangeOperation; import org.eclipse.sirius.diagram.ui.internal.refresh.GMFHelper; /** @@ -121,7 +122,8 @@ public class SetReconnectingConnectionBendpointsCommand extends SetConnectionBen List newBendpoints = new ArrayList(); int numOfPoints = getNewPointList().size(); for (short i = 0; i < numOfPoints; i++) { - // The sourceRefPoint and targetRefPoint will be recovered from the reconnected edge + // 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()); newBendpoints.add(new RelativeBendpoint(s.width, s.height, t.width, t.height)); @@ -129,6 +131,10 @@ public class SetReconnectingConnectionBendpointsCommand extends SetConnectionBen RelativeBendpoints points = (RelativeBendpoints) edge.getBendpoints(); points.setPoints(newBendpoints); + + CenterEdgeEndModelChangeOperation centerEdgeEndModelChangeOperation = new CenterEdgeEndModelChangeOperation(edge, false); + centerEdgeEndModelChangeOperation.execute(); + return CommandResult.newOKCommandResult(); } } diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/CenteredEdgesTest.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/CenteredEdgesTest.java index 56ff22d4fa..e65e2d6f5b 100644 --- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/CenteredEdgesTest.java +++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/CenteredEdgesTest.java @@ -204,6 +204,34 @@ public class CenteredEdgesTest extends AbstractSiriusSwtBotGefTestCase { } /** + * Test that the Rectilinear edge is correctly centered on the target border + * node when using the reconnect tool. + */ + public void testRectilinearEdgeReconnectionOnCenteredBorderNode() { + openDiagram(REPRESENTATION_NAME_RECONNECT); + SWTBotGefEditPart toBotGefEditPart = editor.getEditPart("border1", DNode4EditPart.class); + SWTBotGefEditPart botGefEditPart = editor.getEditPart("edge1", DEdgeEditPart.class); + changeRoutingStyle((SWTBotGefConnectionEditPart) botGefEditPart, RECTILINEAR_STYLE_ROUTING); + reconnectEdge("edge1", toBotGefEditPart, false); + SWTBotGefConnectionEditPart swtBotGefEditPart = (SWTBotGefConnectionEditPart) editor.getEditPart("edge1", DEdgeEditPart.class); + assertEdgeHasExpectedTgtAnchor(swtBotGefEditPart, new PrecisionPoint(0.5, 0.5)); + } + + /** + * Test that the Rectilinear edge is correctly centered on the target + * container when using the reconnect tool. + */ + public void testRectilinearEdgeReconnectionOnCenteredContainer() { + openDiagram(REPRESENTATION_NAME_RECONNECT); + SWTBotGefEditPart toBotGefEditPart = editor.getEditPart("container1", DNodeContainerEditPart.class); + SWTBotGefEditPart botGefEditPart = editor.getEditPart("edge2", DEdgeEditPart.class); + changeRoutingStyle((SWTBotGefConnectionEditPart) botGefEditPart, RECTILINEAR_STYLE_ROUTING); + reconnectEdge("edge2", toBotGefEditPart, false); + SWTBotGefConnectionEditPart swtBotGefEditPart = (SWTBotGefConnectionEditPart) editor.getEditPart("edge2", DEdgeEditPart.class); + assertEdgeHasExpectedTgtAnchor(swtBotGefEditPart, new PrecisionPoint(0.5, 0.5)); + } + + /** * Test that when changing the edge routing style to rectilinear, the edge * is still centered toward its source. */ |