diff options
2 files changed, 54 insertions, 1 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/DurationLinkSelectionHandlesEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/DurationLinkSelectionHandlesEditPolicy.java index 072531b0c81..ee9aaea8f3d 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/DurationLinkSelectionHandlesEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/DurationLinkSelectionHandlesEditPolicy.java @@ -65,6 +65,7 @@ import org.eclipse.swt.graphics.Cursor; public class DurationLinkSelectionHandlesEditPolicy extends PapyrusConnectionEndEditPolicy implements PropertyChangeListener { private UMLConnectionNodeEditPart durationLinkEditPart; private TransactionalEditingDomain editingDomain; + private Integer arrowPositionDelta; public DurationLinkSelectionHandlesEditPolicy(UMLConnectionNodeEditPart durationLinkEditPart, TransactionalEditingDomain editingDomain) { this.durationLinkEditPart = durationLinkEditPart; @@ -103,6 +104,50 @@ public class DurationLinkSelectionHandlesEditPolicy extends PapyrusConnectionEnd list.add(moveHandle); } + @Override + public void showSourceFeedback(Request request) { + if (MoveArrowRequest.REQ_MOVE_ARROW.equals(request.getType())) { + showArrowMoveFeedback((MoveArrowRequest) request); + } + super.showSourceFeedback(request); + } + + @Override + public void eraseSourceFeedback(Request request) { + if (MoveArrowRequest.REQ_MOVE_ARROW.equals(request.getType())) { + eraseArrowMoveFeedback((MoveArrowRequest) request); + } + super.eraseSourceFeedback(request); + } + + private void eraseArrowMoveFeedback(MoveArrowRequest request) { + arrowPositionDelta = null; + getHost().refresh(); + } + + protected void showArrowMoveFeedback(MoveArrowRequest request) { + DurationLinkFigure figure = (DurationLinkFigure) durationLinkEditPart.getFigure(); + if (arrowPositionDelta == null) { + arrowPositionDelta = figure.getArrowPositionDelta(); + } + PointList arrowLinePoints = figure.getArrowLinePoints(); + Point arrowPoint = arrowLinePoints.getMidpoint().getCopy(); + + figure.translateToAbsolute(arrowPoint); + arrowPoint.translate(request.getMoveDelta()); + figure.translateToRelative(arrowPoint); + + Dimension moveDelta = arrowPoint.getDifference(arrowLinePoints.getMidpoint()); + + Orientation arrowOrientation = request.getArrowOrientation(); + if (arrowOrientation == Orientation.VERTICAL) { + figure.setArrowPositionDelta(arrowPositionDelta + moveDelta.width); + } else { + // horizontal + figure.setArrowPositionDelta(arrowPositionDelta + moveDelta.height); + } + } + private Cursor getCursor(DurationLinkFigure figure) { if (figure.getArrowOrientation() == Orientation.VERTICAL) { return Cursors.SIZEWE; diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/DurationLinkFigure.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/DurationLinkFigure.java index 8d20e0d6f4f..bea6013cca1 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/DurationLinkFigure.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/DurationLinkFigure.java @@ -270,7 +270,6 @@ public class DurationLinkFigure extends UMLEdgeFigure { PointList points = new PointList(2); Point arrowStart = null, arrowEnd = null; if (arrowOrientation == Orientation.HORIZONTAL) { - arrowStart = getStart().getCopy().setX(getStart().x() + ARROW_PADDING).setY(getArrowLineHorizontalY()); arrowEnd = getEnd().getCopy().setX(getEnd().x() - ARROW_PADDING).setY(getArrowLineHorizontalY()); } else { @@ -366,6 +365,15 @@ public class DurationLinkFigure extends UMLEdgeFigure { } } + /** Returns the arrow position delta. + * <p> + * By default, the arrow is centered between its start and end point (delta = 0). The position + * delta can be used to move it to the right (delta > 0) or to the left (delta < 0). + * </p>*/ + public int getArrowPositionDelta() { + return arrowPositionDelta; + } + @Override public Rectangle getBounds() { Rectangle bounds = super.getBounds(); |