Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Redor2015-05-05 11:50:37 +0000
committerLaurent Redor2015-05-07 06:53:36 +0000
commit9067bd9865c39b219ef17c43b4452cd0199486d8 (patch)
tree197f56ae1c46c794723cba1803bc2734a5a1db68
parent8bddcd9682ac7d30fa294cb6c4ca1ff8bd2df47e (diff)
downloadorg.eclipse.sirius-9067bd9865c39b219ef17c43b4452cd0199486d8.tar.gz
org.eclipse.sirius-9067bd9865c39b219ef17c43b4452cd0199486d8.tar.xz
org.eclipse.sirius-9067bd9865c39b219ef17c43b4452cd0199486d8.zip
[466422] Resize of border node with overlap and fixed bendpoints
The resize of border node overlaping another one was not correctly handled by bug 441424. Bug: 466422 Bug: 441424 Change-Id: Ibbb59c614774bebdede14a70b8df2a5ad4ae3fe5 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/graphical/edit/policies/SpecificBorderItemSelectionEditPolicy.java12
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/operation/ShiftEdgeIdentityAnchorOperation.java52
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/CenteredEdgesTest.java29
3 files changed, 86 insertions, 7 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/SpecificBorderItemSelectionEditPolicy.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/SpecificBorderItemSelectionEditPolicy.java
index 63ae120c6b..ca6f1bca13 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/SpecificBorderItemSelectionEditPolicy.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/SpecificBorderItemSelectionEditPolicy.java
@@ -642,7 +642,17 @@ public class SpecificBorderItemSelectionEditPolicy extends ResizableEditPolicyEx
CompositeTransactionalCommand ctc = new CompositeTransactionalCommand(editingDomain, setBoundsCommand.getLabel());
ctc.add(setBoundsCommand);
- ShiftEdgeIdentityAnchorOperation operation = new ShiftEdgeIdentityAnchorOperation(request);
+ // Compute the shift delta according to the real future bounds.
+ PrecisionPoint delta = new PrecisionPoint();
+ if (newBounds != null) {
+ if (getHost() instanceof IGraphicalEditPart) {
+ final Point parentOrigin = borderItemEP.getFigure().getParent().getBounds().getTopLeft();
+ Point oldRelativeBounds = borderItemEP.getFigure().getBounds().getTopLeft().translate(parentOrigin.getNegated());
+ delta = new PrecisionPoint(newBounds.getLocation().translate(oldRelativeBounds.getNegated()));
+ }
+ }
+
+ ShiftEdgeIdentityAnchorOperation operation = new ShiftEdgeIdentityAnchorOperation(request, newBounds.getSize(), delta);
ICommand command = CommandFactory.createICommand(editingDomain, operation);
ctc.add(command);
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 b46802e7ed..e6bfe45e5b 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
@@ -15,6 +15,7 @@ import java.util.List;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.PositionConstants;
+import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.PrecisionPoint;
import org.eclipse.draw2d.geometry.Rectangle;
@@ -48,12 +49,43 @@ import com.google.common.collect.Iterables;
*/
public class ShiftEdgeIdentityAnchorOperation extends AbstractModelChangeOperation<Void> {
+ /** The request to compute the new anchor. */
private ChangeBoundsRequest request;
+ /** The future size of the border node. */
+ private Dimension futureSize;
+
+ /** The real delta whose the border node will be shift. */
+ private PrecisionPoint delta;
+
+ /**
+ * Default constructor.
+ *
+ * @param request
+ * Request to compute the new anchor location.
+ */
public ShiftEdgeIdentityAnchorOperation(ChangeBoundsRequest request) {
this.request = request;
}
+ /**
+ * Constructor to use for border node. The request is not enough in case of
+ * border node because its real location, depends on other border nodes and
+ * not only on the request data.
+ *
+ * @param request
+ * Request to compute the new anchor location.
+ * @param futureSize
+ * The future size of the border node.
+ * @param delta
+ * The delta whose the border node will be shift
+ */
+ public ShiftEdgeIdentityAnchorOperation(ChangeBoundsRequest request, Dimension futureSize, PrecisionPoint delta) {
+ this(request);
+ this.futureSize = futureSize;
+ this.delta = delta;
+ }
+
@Override
public Void execute() {
List<?> editParts = request.getEditParts();
@@ -127,15 +159,23 @@ public class ShiftEdgeIdentityAnchorOperation extends AbstractModelChangeOperati
Point currentRelativePoint = getAnchorRelativePoint(currentAnchorPoint, bounds);
- double logicalWidthDelta = request.getSizeDelta().width / scale;
- double logicalHeightDelta = request.getSizeDelta().height / scale;
+ if (futureSize != null && delta != null) {
+ // In case of border node, the real location is computed earlier
+ // (according to BorderItemLocator). The corresponding futureSize
+ // and delta are used instead of the request data.
+ return new PrecisionPoint(((double) (currentRelativePoint.x - delta.x)) / futureSize.width, ((double) (currentRelativePoint.y - delta.y)) / futureSize.height);
+ } else {
+
+ double logicalWidthDelta = request.getSizeDelta().width / scale;
+ double logicalHeightDelta = request.getSizeDelta().height / scale;
- int direction = request.getResizeDirection();
+ int direction = request.getResizeDirection();
- double newRelativeX = computeNewXRelativeLocation(direction, currentRelativePoint, logicalWidthDelta);
- double newRelativeY = computeNewYRelativeLocation(direction, currentRelativePoint, logicalHeightDelta);
+ double newRelativeX = computeNewXRelativeLocation(direction, currentRelativePoint, logicalWidthDelta);
+ double newRelativeY = computeNewYRelativeLocation(direction, currentRelativePoint, logicalHeightDelta);
- return new PrecisionPoint(newRelativeX / (bounds.width() + logicalWidthDelta), newRelativeY / (bounds.height() + logicalHeightDelta));
+ return new PrecisionPoint(newRelativeX / (bounds.width() + logicalWidthDelta), newRelativeY / (bounds.height() + logicalHeightDelta));
+ }
}
private Point getAnchorRelativePoint(PrecisionPoint currentAnchorPoint, Rectangle bounds) {
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 a15cae5f48..22930d90df 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
@@ -531,6 +531,35 @@ public class CenteredEdgesTest extends AbstractSiriusSwtBotGefTestCase {
}
/**
+ * Test that when resizing a border node over another 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=466422">Bug
+ * 466422</a>.
+ */
+ public void testResizingCenteredTargetBorderNodeOverAnotherNode() {
+ openDiagram(REPRESENTATION_NAME_RESIZE_BORDER_NODE);
+ SWTBotGefEditPart border1NodeBotGefEditPart = editor.getEditPart("border1", AbstractDiagramBorderNodeEditPart.class);
+ border1NodeBotGefEditPart.select();
+
+ SWTBotGefConnectionEditPart edgeSwtBotGefEditPart = (SWTBotGefConnectionEditPart) editor.getEditPart("edge2", DEdgeEditPart.class);
+ PointList edge2PointListBefore = getEdgePointList(edgeSwtBotGefEditPart);
+
+ IFigure figure = ((GraphicalEditPart) border1NodeBotGefEditPart.part()).getFigure();
+ Rectangle boundsBefore = figure.getBounds().getCopy();
+ // Resize border1 over border2
+ border1NodeBotGefEditPart.resize(PositionConstants.NORTH, 0, 160);
+
+ // we make sure the figure has been resized (and moved)
+ 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);
+ }
+
+ /**
* 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

Back to the top