Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandra Buzila2018-09-25 06:49:09 -0400
committerAlexandra Buzila2018-09-26 11:44:39 -0400
commitbb4b836de63a06830f21b5e8c9c088405276ae3f (patch)
treed1006cb82b038102fa2c3e4bc9875ee86585a358
parentc429f4ce717a5a7ade85f68affdeae4a8c70e8b7 (diff)
downloadorg.eclipse.papyrus-bb4b836de63a06830f21b5e8c9c088405276ae3f.tar.gz
org.eclipse.papyrus-bb4b836de63a06830f21b5e8c9c088405276ae3f.tar.xz
org.eclipse.papyrus-bb4b836de63a06830f21b5e8c9c088405276ae3f.zip
Bug 539372 - [Sequence Diagram] Resize/Move DurationLink doesn't take
zoom into account - take zoom and scroll into account - code style fixes Change-Id: I60ac9cbb02ba1a3b8bbf3d4e07de632cc16498fc 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/parts/CustomDurationConstraintLinkEditPart.java8
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomDurationObservationLinkEditPart.java8
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/DurationLinkSelectionHandlesEditPolicy.java20
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/DurationLinkFigure.java2
4 files changed, 25 insertions, 13 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomDurationConstraintLinkEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomDurationConstraintLinkEditPart.java
index 8f2d81ff47d..4673b8acbbf 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomDurationConstraintLinkEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomDurationConstraintLinkEditPart.java
@@ -49,13 +49,13 @@ public class CustomDurationConstraintLinkEditPart extends DurationConstraintLink
protected void refreshArrowDelta() {
Connector connector = (Connector) getNotationView();
- NamedStyle namedStyle = connector.getNamedStyle(NotationPackage.Literals.INT_VALUE_STYLE, "delta");
+ NamedStyle namedStyle = connector.getNamedStyle(NotationPackage.Literals.INT_VALUE_STYLE, DurationLinkFigure.DELTA_VIEW_STYLE);
if (namedStyle instanceof IntValueStyle) {
int delta = ((IntValueStyle) namedStyle).getIntValue();
- ((DurationLinkFigure) getFigure()).setArrowPositionDelta(delta);
+ getPrimaryShape().setArrowPositionDelta(delta);
} else {
// no style - reset value
- ((DurationLinkFigure) getFigure()).setArrowPositionDelta(0);
+ getPrimaryShape().setArrowPositionDelta(0);
}
}
@@ -72,6 +72,6 @@ public class CustomDurationConstraintLinkEditPart extends DurationConstraintLink
}
private boolean isDeltaIntValueStyle(Object object) {
- return object instanceof IntValueStyle && "delta".equals(((IntValueStyle) object).getName());
+ return object instanceof IntValueStyle && DurationLinkFigure.DELTA_VIEW_STYLE.equals(((IntValueStyle) object).getName());
}
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomDurationObservationLinkEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomDurationObservationLinkEditPart.java
index ef16c48dc27..a87bf7d3439 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomDurationObservationLinkEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomDurationObservationLinkEditPart.java
@@ -50,13 +50,13 @@ public class CustomDurationObservationLinkEditPart extends DurationObservationLi
protected void refreshArrowDelta() {
Connector connector = (Connector) getNotationView();
- NamedStyle namedStyle = connector.getNamedStyle(NotationPackage.Literals.INT_VALUE_STYLE, "delta");
+ NamedStyle namedStyle = connector.getNamedStyle(NotationPackage.Literals.INT_VALUE_STYLE, DurationLinkFigure.DELTA_VIEW_STYLE);
if (namedStyle instanceof IntValueStyle) {
int delta = ((IntValueStyle) namedStyle).getIntValue();
- ((DurationLinkFigure) getFigure()).setArrowPositionDelta(delta);
+ getPrimaryShape().setArrowPositionDelta(delta);
} else {
// no style - reset value
- ((DurationLinkFigure) getFigure()).setArrowPositionDelta(0);
+ getPrimaryShape().setArrowPositionDelta(0);
}
}
@@ -73,6 +73,6 @@ public class CustomDurationObservationLinkEditPart extends DurationObservationLi
}
private boolean isDeltaIntValueStyle(Object object) {
- return object instanceof IntValueStyle && "delta".equals(((IntValueStyle) object).getName());
+ return object instanceof IntValueStyle && DurationLinkFigure.DELTA_VIEW_STYLE.equals(((IntValueStyle) object).getName());
}
}
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 63aecb6e4d3..072531b0c81 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
@@ -212,19 +212,29 @@ public class DurationLinkSelectionHandlesEditPolicy extends PapyrusConnectionEnd
Connector connector = (Connector) durationLinkEditPart.getNotationView();
@SuppressWarnings("unchecked")
- Optional<IntValueStyle> deltaOptional = connector.getStyles().stream().filter(IntValueStyle.class::isInstance).filter(style -> "delta".equals(((IntValueStyle) style).getName())).findFirst();
+ Optional<IntValueStyle> deltaOptional = connector.getStyles().stream().filter(IntValueStyle.class::isInstance).filter(style -> DurationLinkFigure.DELTA_VIEW_STYLE.equals(((IntValueStyle) style).getName())).findFirst();
IntValueStyle deltaStyle = deltaOptional.orElseGet(() -> {
IntValueStyle style = (IntValueStyle) connector.createStyle(NotationPackage.eINSTANCE.getIntValueStyle());
- style.setName("delta");
+ style.setName(DurationLinkFigure.DELTA_VIEW_STYLE);
return style;
});
- Point moveDelta = ((MoveArrowRequest) request).getMoveDelta();
+
+ DurationLinkFigure figure = ((DurationLinkFigure) durationLinkEditPart.getFigure());
+ PointList arrowLinePoints = figure.getArrowLinePoints();
+ Point arrowPoint = arrowLinePoints.getMidpoint().getCopy();
+
+ figure.translateToAbsolute(arrowPoint);
+ arrowPoint.translate(((MoveArrowRequest) request).getMoveDelta());
+ figure.translateToRelative(arrowPoint);
+
+ Dimension moveDelta = arrowPoint.getDifference(arrowLinePoints.getMidpoint());
+
Orientation arrowOrientation = ((MoveArrowRequest) request).getArrowOrientation();
if (arrowOrientation == Orientation.VERTICAL) {
- deltaStyle.setIntValue(deltaStyle.getIntValue() + moveDelta.x);
+ deltaStyle.setIntValue(deltaStyle.getIntValue() + moveDelta.width);
} else {
// horizontal
- deltaStyle.setIntValue(deltaStyle.getIntValue() + moveDelta.y);
+ deltaStyle.setIntValue(deltaStyle.getIntValue() + moveDelta.height);
}
return CommandResult.newOKCommandResult();
}
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 0ed0026e5f1..8d20e0d6f4f 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
@@ -90,6 +90,8 @@ public class DurationLinkFigure extends UMLEdgeFigure {
*/
private static final int SELECTION_TOLERANCE = 3;
+ public static final String DELTA_VIEW_STYLE = "delta"; //$NON-NLS-1$
+
@Override
protected void outlineShape(Graphics graphics) {
// Skip super; we're not drawing a polyline connection

Back to the top