diff options
| author | Laurent Redor | 2015-05-05 09:32:52 +0000 |
|---|---|---|
| committer | Laurent Redor | 2015-05-07 06:52:11 +0000 |
| commit | 8bddcd9682ac7d30fa294cb6c4ca1ff8bd2df47e (patch) | |
| tree | dffafcecda186b24bbc45fe8d70a1d0e5baa5109 | |
| parent | 2b4c0049f5507af0c0c15f3ef90205390c74f476 (diff) | |
| download | org.eclipse.sirius-8bddcd9682ac7d30fa294cb6c4ca1ff8bd2df47e.tar.gz org.eclipse.sirius-8bddcd9682ac7d30fa294cb6c4ca1ff8bd2df47e.tar.xz org.eclipse.sirius-8bddcd9682ac7d30fa294cb6c4ca1ff8bd2df47e.zip | |
[448739] The zoom is not correctly handled for centered edge feature
The new size of the resized node is not correctly done in
CenterEditPartEdgesCommand and it is used to compute all new bendpoints.
This explains that all bendpoints move.
Bug: 448739
Change-Id: I094aa376e40fea70474369dcffc30d12da1ed06e
Signed-off-by: Laurent Redor <laurent.redor@obeo.fr>
2 files changed, 42 insertions, 5 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/commands/CenterEditPartEdgesCommand.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/commands/CenterEditPartEdgesCommand.java index c2324235e3..800345d61e 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/commands/CenterEditPartEdgesCommand.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/commands/CenterEditPartEdgesCommand.java @@ -37,7 +37,7 @@ import com.google.common.collect.Iterables; * given graphicalEditPart. * * @author Florian Barbin - * + * */ public class CenterEditPartEdgesCommand extends AbstractTransactionalCommand { @@ -93,13 +93,15 @@ public class CenterEditPartEdgesCommand extends AbstractTransactionalCommand { private Dimension getNewSize(EditPart edgeEnd) { if (edgeEnd instanceof GraphicalEditPart) { IFigure figure = ((GraphicalEditPart) edgeEnd).getFigure(); - Dimension newSize = figure.getSize().getCopy(); + Rectangle newBounds = figure.getBounds().getCopy(); + figure.translateToAbsolute(newBounds); + List editPartRequesting = request.getEditParts(); if (editPartRequesting.contains(edgeEnd)) { - Rectangle newBounds = request.getTransformedRectangle(figure.getBounds()); - newSize = newBounds.getSize(); + newBounds = request.getTransformedRectangle(newBounds); } - return newSize; + figure.translateToRelative(newBounds); + return newBounds.getSize(); } return null; } 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 f0447fb7c7..a15cae5f48 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 @@ -41,6 +41,7 @@ import org.eclipse.sirius.diagram.ui.internal.edit.parts.DNodeEditPart; import org.eclipse.sirius.ext.base.Option; import org.eclipse.sirius.ext.gmf.runtime.editparts.GraphicalHelper; import org.eclipse.sirius.tests.swtbot.support.api.AbstractSiriusSwtBotGefTestCase; +import org.eclipse.sirius.tests.swtbot.support.api.business.UIDiagramRepresentation.ZoomLevel; import org.eclipse.sirius.tests.swtbot.support.api.business.UIResource; import org.eclipse.sirius.tests.swtbot.support.api.condition.CheckEditPartMoved; import org.eclipse.sirius.tests.swtbot.support.api.editor.SWTBotSiriusDiagramEditor; @@ -497,6 +498,39 @@ public class CenteredEdgesTest extends AbstractSiriusSwtBotGefTestCase { } /** + * Test that when resizing a border node, the bendpoints of the centered + * edge are fix and the edge is still centered. See <a + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=448739#c18">Bug + * 448739#c18</a>. + */ + public void testResizingCenteredTargetBorderNodeWithZoom() { + openDiagram(REPRESENTATION_NAME_RESIZE_BORDER_NODE); + editor.zoom(ZoomLevel.ZOOM_200); + try { + SWTBotGefEditPart borderNodeBotGefEditPart = editor.getEditPart("border1", AbstractDiagramBorderNodeEditPart.class); + borderNodeBotGefEditPart.select(); + + SWTBotGefConnectionEditPart edgeSwtBotGefEditPart = (SWTBotGefConnectionEditPart) editor.getEditPart("edge2", DEdgeEditPart.class); + PointList edge2PointListBefore = getEdgePointList(edgeSwtBotGefEditPart); + + IFigure figure = ((GraphicalEditPart) borderNodeBotGefEditPart.part()).getFigure(); + Rectangle boundsBefore = figure.getBounds().getCopy(); + borderNodeBotGefEditPart.resize(PositionConstants.SOUTH, 0, 400); + + // we make sure the figure has been resized + bot.waitUntil(new WaitFigureResizedCondition(boundsBefore, figure)); + + assertEdgeHasExpectedTgtAnchor(edgeSwtBotGefEditPart, new PrecisionPoint(0.5, 0.5)); + + // Bendpoints of edges must no be changed (bug 441424), except the + // last point as it is centered. + checkPointsListAfterResizing(edgeSwtBotGefEditPart, edge2PointListBefore, true); + } finally { + editor.zoom(ZoomLevel.ZOOM_100); + } + } + + /** * Test that when resizing a shape over edge bendpoints, the edge is still * centered. See <a * href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=448739#c8">Bug @@ -704,6 +738,7 @@ public class CenteredEdgesTest extends AbstractSiriusSwtBotGefTestCase { Point realTargetConnection = pointList.getPoint(pointList.size() - 1); Point expectedLineTerminus = getProportionalPoint(getAbsoluteBounds((IGraphicalEditPart) targetSwtBotGefEditPart.part()), expectedAnchor); + connection.translateToRelative(expectedLineTerminus); Option<Point> option = GraphicalHelper.getIntersection(lineOrigin, expectedLineTerminus, (IGraphicalEditPart) targetSwtBotGefEditPart.part(), false); if (option.some()) { |
