diff options
author | Laurent Redor | 2017-05-31 13:10:42 +0000 |
---|---|---|
committer | Laurent Redor | 2017-06-16 14:23:21 +0000 |
commit | b194889dac3fdbcbd49f16c0d9457403774939f3 (patch) | |
tree | 7a56c8d0ead0ad0ff4ae2cac24e6140db5a59e6a | |
parent | 0f3bb475971352c3d9efa1f7c34c5cdf92cb8728 (diff) | |
download | org.eclipse.sirius-b194889dac3fdbcbd49f16c0d9457403774939f3.tar.gz org.eclipse.sirius-b194889dac3fdbcbd49f16c0d9457403774939f3.tar.xz org.eclipse.sirius-b194889dac3fdbcbd49f16c0d9457403774939f3.zip |
[517437] Fix bug when both source note and target node are moved
This commit fixes the second scenario of the initial description of this
issue.
Technical changes:
* When both source and target of an edge are moved, the relative
location of the labels of this edge must not be recomputed.
* The setNewPointList and setLabelsToUpdate methods of
SetConnectionBendpointsAccordingToDraw2DCommand have been decorrelated,
to allow to not update label in above case.
Bug: 517437
Change-Id: I4cda42c9de42a754c3e543b8974cc2f7b91f70d1
Signed-off-by: Laurent Redor <laurent.redor@obeo.fr>
3 files changed, 38 insertions, 21 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/SetConnectionBendpointsAccordingToDraw2DCommand.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/SetConnectionBendpointsAccordingToDraw2DCommand.java index 88ba1bbba3..b27f37cdf5 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/SetConnectionBendpointsAccordingToDraw2DCommand.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/SetConnectionBendpointsAccordingToDraw2DCommand.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012 THALES GLOBAL SERVICES. + * Copyright (c) 2012, 2017 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 @@ -40,13 +40,19 @@ public class SetConnectionBendpointsAccordingToDraw2DCommand extends SetConnecti super(editingDomain); } - @Override - public void setLabelsToUpdate(ConnectionEditPart connectionEditPart) { - ConnectionEditPart gmfConnectionEditPart = (ConnectionEditPart) connectionEditPart; + /** + * Compute the new PointList, source reference point and target reference + * point according to given <code>connectionEditPart</code>, + * <code>sourceMove</code> value and the <code>modeDelta</code>. + * + * @param connectionEditPart + * The connection from which to compute the new PointList + */ + public void setNewPointList(ConnectionEditPart connectionEditPart) { // Apply inverse zoom on moveDelta, because moveDelta is only // element in relative value - GraphicalHelper.applyInverseZoomOnPoint(gmfConnectionEditPart, moveDelta); - Connection connection = gmfConnectionEditPart.getConnectionFigure(); + GraphicalHelper.applyInverseZoomOnPoint(connectionEditPart, moveDelta); + Connection connection = connectionEditPart.getConnectionFigure(); Point tempSourceRefPoint = connection.getSourceAnchor().getReferencePoint(); connection.translateToRelative(tempSourceRefPoint); @@ -148,7 +154,6 @@ public class SetConnectionBendpointsAccordingToDraw2DCommand extends SetConnecti } } setNewPointList(connectionPointList, tempSourceRefPoint, tempTargetRefPoint); - super.setLabelsToUpdate(connectionEditPart); } /** diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/commands/ChangeBendpointsOfEdgesCommand.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/commands/ChangeBendpointsOfEdgesCommand.java index 70518bfa3e..2339d531b3 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/commands/ChangeBendpointsOfEdgesCommand.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/commands/ChangeBendpointsOfEdgesCommand.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2014, 2016 THALES GLOBAL SERVICES and others. + * Copyright (c) 2014, 2017 THALES GLOBAL SERVICES and others. * 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 @@ -270,12 +270,15 @@ public class ChangeBendpointsOfEdgesCommand extends AbstractTransactionalCommand setConnectionBendpointsCommand.setSourceMove(sourceMove); setConnectionBendpointsCommand.setMoveDelta(new PrecisionPoint(moveDelta)); setConnectionBendpointsCommand.setEdgeAdapter(connectionEditPart); - setConnectionBendpointsCommand.setLabelsToUpdate(connectionEditPart); + setConnectionBendpointsCommand.setNewPointList(connectionEditPart); + if (isBothSourceAndTargetMoved(connectionEditPart, allMovedEditParts, sourceMove)) { + setConnectionBendpointsCommand.setLabelsToUpdate(connectionEditPart); + } command.add(setConnectionBendpointsCommand); result = Options.newSome(command); } else if (connectionEditPartQuery.isEdgeWithObliqueRoutingStyle() || connectionEditPartQuery.isEdgeWithRectilinearRoutingStyle()) { if (!allMovedEditParts.isEmpty()) { - if ((sourceMove && !allMovedEditParts.contains(connectionEditPart.getTarget())) || (!sourceMove && !allMovedEditParts.contains(connectionEditPart.getSource()))) { + if (isBothSourceAndTargetMoved(connectionEditPart, allMovedEditParts, sourceMove)) { CompositeTransactionalCommand command = new CompositeTransactionalCommand(transactionalEditingDomain, Messages.ChangeBendpointsOfEdgesCommand_mapGmfToDraw2dCommandLabel); // Reset the connection anchor source and target // considering @@ -302,7 +305,7 @@ public class ChangeBendpointsOfEdgesCommand extends AbstractTransactionalCommand } } else if (connectionEditPart instanceof BracketEdgeEditPart) { if (!allMovedEditParts.isEmpty()) { - if ((sourceMove && !allMovedEditParts.contains(connectionEditPart.getTarget())) || (!sourceMove && !allMovedEditParts.contains(connectionEditPart.getSource()))) { + if (isBothSourceAndTargetMoved(connectionEditPart, allMovedEditParts, sourceMove)) { // Just update the label offset CompositeTransactionalCommand command = new CompositeTransactionalCommand(transactionalEditingDomain, Messages.ChangeBendpointsOfEdgesCommand_updateLabelsOffsetCmdLabel); PointList currentPointList = connectionEditPart.getConnectionFigure().getPoints(); @@ -319,6 +322,10 @@ public class ChangeBendpointsOfEdgesCommand extends AbstractTransactionalCommand return result; } + private boolean isBothSourceAndTargetMoved(ConnectionEditPart connectionEditPart, List<AbstractGraphicalEditPart> allMovedEditParts, boolean sourceMove) { + return (sourceMove && !allMovedEditParts.contains(connectionEditPart.getTarget())) || (!sourceMove && !allMovedEditParts.contains(connectionEditPart.getSource())); + } + private List<AbstractGraphicalEditPart> getMovedChildren(Iterable<AbstractGraphicalEditPart> parentEditParts, boolean addSelf) { List<AbstractGraphicalEditPart> result = Lists.newArrayList(); for (AbstractGraphicalEditPart abstractGraphicalEditPart : parentEditParts) { diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/commands/SetLabelsOffsetOperation.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/commands/SetLabelsOffsetOperation.java index ce5e7a150a..2947a1e7b6 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/commands/SetLabelsOffsetOperation.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/commands/SetLabelsOffsetOperation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2015 THALES GLOBAL SERVICES. + * Copyright (c) 2015, 2017 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 @@ -159,17 +159,22 @@ public class SetLabelsOffsetOperation { /** * Update the offset ({@link Bounds}) of the labels {@link Node}. This * method must be called after setting the newPointList and the - * labelToUpdate. + * labelToUpdate. If the methods + * {@link #setLabelsToUpdate(ConnectionEditPart)} or + * {@link #setLabelsToUpdate(ConnectionEditPart, PointList)} are not called, + * this method has no effect. */ public void updateGMFLabelsOffset() { - // Update Bounds of the three labels Node (Center, Begin and End) - Set<Entry<Node, Point>> entries = labelsWithNewOffset.entrySet(); - for (Entry<Node, Point> entry : entries) { - LayoutConstraint layoutConstraint = entry.getKey().getLayoutConstraint(); - if (layoutConstraint instanceof Bounds) { - Bounds bounds = (Bounds) layoutConstraint; - bounds.setX(entry.getValue().x); - bounds.setY(entry.getValue().y); + if (labelsWithNewOffset != null) { + // Update Bounds of the three labels Node (Center, Begin and End) + Set<Entry<Node, Point>> entries = labelsWithNewOffset.entrySet(); + for (Entry<Node, Point> entry : entries) { + LayoutConstraint layoutConstraint = entry.getKey().getLayoutConstraint(); + if (layoutConstraint instanceof Bounds) { + Bounds bounds = (Bounds) layoutConstraint; + bounds.setX(entry.getValue().x); + bounds.setY(entry.getValue().y); + } } } } |