diff options
| author | Steve Monnier | 2014-09-10 16:33:59 +0000 |
|---|---|---|
| committer | Steve Monnier | 2014-09-11 15:40:32 +0000 |
| commit | 4033181353a99eda5cddd7a471fafc88990ec369 (patch) | |
| tree | 4cfb202608c573bea9f10f993de31159c307ea36 | |
| parent | dc50b65c5df2c8ea13a211c20f4fa98a27ae9910 (diff) | |
| download | org.eclipse.sirius-4033181353a99eda5cddd7a471fafc88990ec369.tar.gz org.eclipse.sirius-4033181353a99eda5cddd7a471fafc88990ec369.tar.xz org.eclipse.sirius-4033181353a99eda5cddd7a471fafc88990ec369.zip | |
[437095] Reset feedback to default on reconnection
On reconnection the feedback was also calculated in order to move only
the closest segment. However, reconnection is out of scope and the final
command was creating a connection with the default routing. Therefore
the feedback recalculation has been ignored for the reconnection cases.
Bug: 437095
Change-Id: I0eb295bfdf44e311efb21c23e9c629f18c5cfa0a
Signed-off-by: Steve Monnier <steve.monnier@obeo.fr>
| -rw-r--r-- | plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/graphical/edit/policies/SiriusConnectionEndPointEditPolicy.java | 53 |
1 files changed, 49 insertions, 4 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/graphical/edit/policies/SiriusConnectionEndPointEditPolicy.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/graphical/edit/policies/SiriusConnectionEndPointEditPolicy.java index 7ebe5676c5..a5146f1f6f 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/graphical/edit/policies/SiriusConnectionEndPointEditPolicy.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/graphical/edit/policies/SiriusConnectionEndPointEditPolicy.java @@ -25,6 +25,8 @@ import org.eclipse.draw2d.geometry.PrecisionPoint; import org.eclipse.gef.editpolicies.ConnectionEndpointEditPolicy; import org.eclipse.gef.requests.ReconnectRequest; import org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editparts.LabelEditPart; import org.eclipse.gmf.runtime.draw2d.ui.geometry.LineSeg; import org.eclipse.sirius.diagram.ui.business.api.query.ConnectionEditPartQuery; import org.eclipse.sirius.diagram.ui.business.api.query.ConnectionQuery; @@ -101,12 +103,55 @@ public class SiriusConnectionEndPointEditPolicy extends ConnectionEndpointEditPo getConnection().setRoutingConstraint(originalConstraint); } super.showConnectionMoveFeedback(request); - if (isOrthogonalTreeBranch) { - postShowConnectionMoveFeedbackForOrthogonalTreeBranch(request); - } else if (isEdgeWithObliqueRoutingStyle || isEdgeWithRectilinearRoutingStyle) { - postShowConnectionMoveFeedbackForObliqueOrRectilinearConnection(request); + if (!isReconnectingToDifferentEnd(request, (ConnectionEditPart) getHost())) { + if (isOrthogonalTreeBranch) { + postShowConnectionMoveFeedbackForOrthogonalTreeBranch(request); + } else if (isEdgeWithObliqueRoutingStyle || isEdgeWithRectilinearRoutingStyle) { + postShowConnectionMoveFeedbackForObliqueOrRectilinearConnection(request); + } + } else { + resetConnectionMoveFeedbackToDefault(); } + } + /** + * In case of reconnection to a different diagram element, the source + * feedback of the connection to this new element will be the default + * routing. The bendpoints created manually on the former connection will + * disappear. + */ + private void resetConnectionMoveFeedbackToDefault() { + Point newSourceRefPoint = getConnection().getSourceAnchor().getReferencePoint(); + getConnection().translateToRelative(newSourceRefPoint); + Point newTargetRefPoint = getConnection().getTargetAnchor().getReferencePoint(); + getConnection().translateToRelative(newTargetRefPoint); + List<Point> points = Lists.newArrayList(); + points.add(newSourceRefPoint); + points.add(newTargetRefPoint); + changeRoutingConstraint(points, newSourceRefPoint, newTargetRefPoint); + } + + /** + * Checks if the request is reconnecting to a new diagram element. + * + * @param request + * the current {@link ReconnectRequest} + * @param connectionEditPart + * the {@link ConnectionEditPart} that is under mouse during + * reconnection + * @return if the request is reconnecting to a new diagram element + */ + private boolean isReconnectingToDifferentEnd(ReconnectRequest request, ConnectionEditPart connectionEditPart) { + // The target is not the diagram itself nor a label (no reconnection on + // a diagram or a label) + boolean hasAcceptableReconnectionTarget = !(request.getTarget() instanceof DiagramEditPart) && !(request.getTarget() instanceof LabelEditPart); + // The connection target anchor is moving and the request target is + // different to the connection target + boolean isReconnectingTarget = !request.isMovingStartAnchor() && !connectionEditPart.getTarget().equals(request.getTarget()); + // The connection source anchor is moving and the request target is + // different to the connection source + boolean isReconnectingSource = request.isMovingStartAnchor() && !connectionEditPart.getSource().equals(request.getTarget()); + return hasAcceptableReconnectionTarget && (isReconnectingTarget || isReconnectingSource); } /** |
