Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandra Buzila2018-09-27 08:43:29 -0400
committerAlexandra Buzila2018-09-27 09:35:25 -0400
commit31a4aa59cdfcee172444c719944dda80c2e10b94 (patch)
tree2d51dc19bf31f6c0479421b7558c050c7df12ed4
parentbb4b836de63a06830f21b5e8c9c088405276ae3f (diff)
downloadorg.eclipse.papyrus-31a4aa59cdfcee172444c719944dda80c2e10b94.tar.gz
org.eclipse.papyrus-31a4aa59cdfcee172444c719944dda80c2e10b94.tar.xz
org.eclipse.papyrus-31a4aa59cdfcee172444c719944dda80c2e10b94.zip
Bug 539370 - [Sequence Diagram] Add feedback when moving a DurationLink
(Constraint or Observation) Change-Id: Ib01888c99ae13219b1265bca4dbffc1fb952440c Signed-off-by: Alexandra Buzila <abuzila@eclipsesource.com>
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/DurationLinkSelectionHandlesEditPolicy.java45
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/DurationLinkFigure.java10
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();

Back to the top