Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandra Buzila2018-09-18 09:16:19 -0400
committerCamille Letavernier2018-09-24 06:48:58 -0400
commitd9cbd1b8978a125d833ea6d3e9ebab8528fa5173 (patch)
treed98c97eb485c70e104913e4858a963584477b096
parent4d0138d52a586f07fb22cd3803d860e9b66c3ba6 (diff)
downloadorg.eclipse.papyrus-d9cbd1b8978a125d833ea6d3e9ebab8528fa5173.tar.gz
org.eclipse.papyrus-d9cbd1b8978a125d833ea6d3e9ebab8528fa5173.tar.xz
org.eclipse.papyrus-d9cbd1b8978a125d833ea6d3e9ebab8528fa5173.zip
Bug 536633 - [Sequence Diagram] EditParts based on DurationLinkFigure
should provide custom selection points - reconnection handles for the Start/Target anchors - selection handles at the intersection points between each line - horizontal/vertical move handle in the middle of the arrow line - Bug 536634 - add a DragPolicy for the move handle that moves the arrow horizontally/vertically, based on its orientation Change-Id: I2c111e4fc7fae68f45b96fa682db8ad245ad08f0 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.java70
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomDurationObservationLinkEditPart.java72
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/DurationLinkSelectionHandlesEditPolicy.java239
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/DurationLinkFigure.java37
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/locator/IntersectionPointSelectionLocator.java54
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/CustomEditPartProvider.java8
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/requests/MoveArrowRequest.java46
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/requests/MoveSeparatorRequest.java51
8 files changed, 518 insertions, 59 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
new file mode 100644
index 00000000000..cf50423a1b6
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomDurationConstraintLinkEditPart.java
@@ -0,0 +1,70 @@
+/*****************************************************************************
+ * Copyright (c) 2018 CEA LIST, EclipseSource and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * EclipseSource - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.diagram.sequence.edit.parts;
+
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gmf.runtime.notation.Connector;
+import org.eclipse.gmf.runtime.notation.IntValueStyle;
+import org.eclipse.gmf.runtime.notation.NamedStyle;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.DurationLinkSelectionHandlesEditPolicy;
+import org.eclipse.papyrus.uml.diagram.sequence.figures.DurationLinkFigure;
+
+public class CustomDurationConstraintLinkEditPart extends DurationConstraintLinkEditPart {
+
+ /**
+ * Constructor.
+ *
+ * @param view
+ */
+ public CustomDurationConstraintLinkEditPart(View view) {
+ super(view);
+ }
+
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.CONNECTION_ENDPOINTS_ROLE, new DurationLinkSelectionHandlesEditPolicy(this, getEditingDomain()));
+ }
+
+ @Override
+ protected void refreshVisuals() {
+ Connector connector = (Connector) getNotationView();
+ NamedStyle namedStyle = connector.getNamedStyle(NotationPackage.Literals.INT_VALUE_STYLE, "delta");
+ if (namedStyle instanceof IntValueStyle) {
+ refreshArrowDelta((IntValueStyle) namedStyle);
+ }
+ super.refreshVisuals();
+ }
+
+ @Override
+ protected void handleNotificationEvent(Notification event) {
+ if (event.getNotifier() instanceof IntValueStyle
+ && "delta".equals(((IntValueStyle) event.getNotifier()).getName())) {
+ refreshArrowDelta((IntValueStyle) event.getNotifier());
+ } else if (event.getNotifier() == getNotationView()
+ && event.getFeature() == NotationPackage.Literals.VIEW__STYLES) {
+ refreshVisuals();
+ }
+ super.handleNotificationEvent(event);
+ }
+
+ private void refreshArrowDelta(IntValueStyle deltaStyle) {
+ int delta = deltaStyle.getIntValue();
+ ((DurationLinkFigure) getFigure()).setArrowPositionDelta(delta);
+ }
+}
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
new file mode 100644
index 00000000000..7e9bfbfe163
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomDurationObservationLinkEditPart.java
@@ -0,0 +1,72 @@
+/*****************************************************************************
+ * Copyright (c) 2018 CEA LIST, EclipseSource and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * EclipseSource - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.sequence.edit.parts;
+
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gmf.runtime.notation.Connector;
+import org.eclipse.gmf.runtime.notation.IntValueStyle;
+import org.eclipse.gmf.runtime.notation.NamedStyle;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.DurationLinkSelectionHandlesEditPolicy;
+import org.eclipse.papyrus.uml.diagram.sequence.figures.DurationLinkFigure;
+
+public class CustomDurationObservationLinkEditPart extends DurationObservationLinkEditPart {
+
+ /**
+ * Constructor.
+ *
+ * @param view
+ */
+ public CustomDurationObservationLinkEditPart(View view) {
+ super(view);
+ }
+
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.CONNECTION_ENDPOINTS_ROLE, new DurationLinkSelectionHandlesEditPolicy(this, getEditingDomain()));
+ }
+
+ @Override
+ protected void refreshVisuals() {
+ Connector connector = (Connector) getNotationView();
+ NamedStyle namedStyle = connector.getNamedStyle(NotationPackage.Literals.INT_VALUE_STYLE, "delta");
+ if (namedStyle instanceof IntValueStyle) {
+ refreshArrowDelta((IntValueStyle) namedStyle);
+ }
+ super.refreshVisuals();
+ }
+
+ @Override
+ protected void handleNotificationEvent(Notification event) {
+ if (event.getNotifier() instanceof IntValueStyle
+ && "delta".equals(((IntValueStyle) event.getNotifier()).getName())) {
+ refreshArrowDelta((IntValueStyle) event.getNotifier());
+ } else if (event.getNotifier() == getNotationView()
+ && event.getFeature() == NotationPackage.Literals.VIEW__STYLES) {
+ refreshVisuals();
+ }
+ super.handleNotificationEvent(event);
+ }
+
+ private void refreshArrowDelta(IntValueStyle deltaStyle) {
+ int delta = deltaStyle.getIntValue();
+ ((DurationLinkFigure) getFigure()).setArrowPositionDelta(delta);
+ }
+
+}
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
new file mode 100644
index 00000000000..63aecb6e4d3
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/DurationLinkSelectionHandlesEditPolicy.java
@@ -0,0 +1,239 @@
+/*****************************************************************************
+ * Copyright (c) 2018 CEA LIST, EclipseSource and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * EclipseSource - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.sequence.edit.policies;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Optional;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.draw2d.Connection;
+import org.eclipse.draw2d.ConnectionLocator;
+import org.eclipse.draw2d.Cursors;
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.PointList;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gef.DragTracker;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.Handle;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.RequestConstants;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.handles.ConnectionHandle;
+import org.eclipse.gef.handles.SquareHandle;
+import org.eclipse.gef.tools.SelectEditPartTracker;
+import org.eclipse.gef.tools.SimpleDragTracker;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart;
+import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
+import org.eclipse.gmf.runtime.notation.Connector;
+import org.eclipse.gmf.runtime.notation.IntValueStyle;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.PapyrusConnectionEndEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.editparts.UMLConnectionNodeEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationConstraintLinkEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.figures.DurationLinkFigure;
+import org.eclipse.papyrus.uml.diagram.sequence.figures.DurationLinkFigure.Orientation;
+import org.eclipse.papyrus.uml.diagram.sequence.locator.IntersectionPointSelectionLocator;
+import org.eclipse.papyrus.uml.diagram.sequence.requests.MoveArrowRequest;
+import org.eclipse.swt.graphics.Cursor;
+
+/**
+ * Edit policy for the selection handles of a {@link DurationConstraintLinkEditPart}
+ */
+public class DurationLinkSelectionHandlesEditPolicy extends PapyrusConnectionEndEditPolicy implements PropertyChangeListener {
+ private UMLConnectionNodeEditPart durationLinkEditPart;
+ private TransactionalEditingDomain editingDomain;
+
+ public DurationLinkSelectionHandlesEditPolicy(UMLConnectionNodeEditPart durationLinkEditPart, TransactionalEditingDomain editingDomain) {
+ this.durationLinkEditPart = durationLinkEditPart;
+ this.editingDomain = editingDomain;
+ }
+
+ @Override
+ public void setHost(EditPart host) {
+ super.setHost(host);
+ if (getHost() != null) {
+ getHostFigure().addPropertyChangeListener(Connection.PROPERTY_POINTS, this);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ protected List<?> createSelectionHandles() {
+ List<Handle> handles = new ArrayList<>();
+ handles.addAll((Collection<? extends Handle>) super.createSelectionHandles());
+ addSelectionHandles(handles);
+ addMoveHandles(handles);
+ return handles;
+ }
+
+ private void addMoveHandles(List<Handle> list) {
+ // middle of the arrow line
+ DurationLinkFigure figure = ((DurationLinkFigure) getHostFigure());
+ Cursor cursor = getCursor(figure);
+ Handle moveHandle = new SquareHandle((ConnectionEditPart) getHost(), new CustomMoveHandleLocator(figure), cursor) {
+ @Override
+ protected DragTracker createDragTracker() {
+ return new ArrowLineMoveTracker();
+ }
+ };
+
+ list.add(moveHandle);
+ }
+
+ private Cursor getCursor(DurationLinkFigure figure) {
+ if (figure.getArrowOrientation() == Orientation.VERTICAL) {
+ return Cursors.SIZEWE;
+ }
+ return Cursors.SIZENS;
+ }
+
+ private void addSelectionHandles(List<Handle> list) {
+ DurationLinkFigure figure = ((DurationLinkFigure) getHostFigure());
+
+ PointList arrowLinePoints = figure.getArrowLinePoints();
+ PointList startLinePoints = figure.getStartLinePoints();
+ PointList endLinePoints = figure.getEndLinePoints();
+ // intersection between start and arrow line
+ list.add(new DurationConstraintArrowSelectionHandle(true, durationLinkEditPart, figure, startLinePoints, arrowLinePoints));
+ // intersection between end and arrow line
+ list.add(new DurationConstraintArrowSelectionHandle(true, durationLinkEditPart, figure, endLinePoints, arrowLinePoints));
+ }
+
+ protected SelectEditPartTracker getSelectTracker() {
+ return new SelectEditPartTracker(getHost());
+ }
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ // refresh selection handles when the points property changes
+ if (getHost().getSelected() != EditPart.SELECTED_NONE) {
+ addSelectionHandles();
+ }
+ }
+
+ class CustomMoveHandleLocator extends ConnectionLocator {
+
+ /**
+ * Constructor.
+ *
+ * @param connection
+ */
+ public CustomMoveHandleLocator(Connection connection) {
+ super(connection);
+ }
+
+ @Override
+ protected Point getLocation(PointList points) {
+ DurationLinkFigure figure = (DurationLinkFigure) getConnection();
+ PointList arrowLinePoints = figure.getArrowLinePoints();
+ return arrowLinePoints.getMidpoint();
+ }
+
+ }
+
+ class DurationConstraintArrowSelectionHandle extends ConnectionHandle {
+
+ DurationConstraintArrowSelectionHandle(boolean fixed, org.eclipse.gef.GraphicalEditPart owner, Connection connection, PointList pointList1, PointList pointList2) {
+ super(fixed);
+ setOwner(owner);
+ setLocator(new IntersectionPointSelectionLocator(connection, pointList1, pointList2));
+ }
+
+ @Override
+ protected DragTracker createDragTracker() {
+ return new SimpleDragTracker() {
+ @Override
+ protected String getCommandName() {
+ return RequestConstants.REQ_SELECTION;
+ }
+ };
+ }
+ }
+
+ class ArrowLineMoveTracker extends SimpleDragTracker {
+
+ @Override
+ protected String getCommandName() {
+ return MoveArrowRequest.REQ_MOVE_ARROW;
+ }
+
+ @Override
+ protected void updateSourceRequest() {
+ super.updateSourceRequest();
+ MoveArrowRequest request = (MoveArrowRequest) getSourceRequest();
+ DurationLinkFigure figure = (DurationLinkFigure) durationLinkEditPart.getPrimaryShape();
+ request.setArrowOrientation(figure.getArrowOrientation());
+ Point location = new Point(getLocation());
+ request.setLocation(location);
+ Dimension dragMoveDelta = getDragMoveDelta();
+ Point moveDelta = new Point(0, 0);
+ moveDelta.y += dragMoveDelta.height;
+ moveDelta.x += dragMoveDelta.width;
+ request.setMoveDelta(moveDelta);
+ }
+
+ @Override
+ protected Request createSourceRequest() {
+ return new MoveArrowRequest();
+ }
+
+ @Override
+ protected Command getCommand() {
+ Request request = getSourceRequest();
+
+ if (request instanceof MoveArrowRequest) {
+ ICommand moveArrowCommand = new AbstractTransactionalCommand(editingDomain, "Move arrow", null) {
+
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ 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();
+ IntValueStyle deltaStyle = deltaOptional.orElseGet(() -> {
+ IntValueStyle style = (IntValueStyle) connector.createStyle(NotationPackage.eINSTANCE.getIntValueStyle());
+ style.setName("delta");
+ return style;
+ });
+ Point moveDelta = ((MoveArrowRequest) request).getMoveDelta();
+ Orientation arrowOrientation = ((MoveArrowRequest) request).getArrowOrientation();
+ if (arrowOrientation == Orientation.VERTICAL) {
+ deltaStyle.setIntValue(deltaStyle.getIntValue() + moveDelta.x);
+ } else {
+ // horizontal
+ deltaStyle.setIntValue(deltaStyle.getIntValue() + moveDelta.y);
+ }
+ return CommandResult.newOKCommandResult();
+ }
+ };
+ return new ICommandProxy(moveArrowCommand);
+ }
+ return super.getCommand();
+ }
+
+ }
+
+} \ No newline at end of file
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 7399a2bcb3c..0ed0026e5f1 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
@@ -94,6 +94,7 @@ public class DurationLinkFigure extends UMLEdgeFigure {
protected void outlineShape(Graphics graphics) {
// Skip super; we're not drawing a polyline connection
arrowOrientation = computeOptimalOrientation();
+
paintStartLine(graphics);
paintEndLine(graphics);
paintArrow(graphics);
@@ -116,7 +117,7 @@ public class DurationLinkFigure extends UMLEdgeFigure {
}
/** Returns the points for the start line - the line connecting the start point to the arrow. */
- protected PointList getStartLinePoints() {
+ public PointList getStartLinePoints() {
if (arrowOrientation == Orientation.HORIZONTAL) {
return getStartLinePointsHorizontal();
}
@@ -133,7 +134,7 @@ public class DurationLinkFigure extends UMLEdgeFigure {
startOffsetEnd.setX(startOffsetEnd.x() + HORIZOTAL_ARROW_START_LINE_OFFSET);
points.addPoint(startOffsetEnd);
- int arrowYCoordinate = (getStart().y() + getEnd().y()) / 2;
+ int arrowYCoordinate = getArrowLineHorizontalY();
// the vertical segment
Point startLineEnd = startOffsetEnd.getCopy();
@@ -165,7 +166,7 @@ public class DurationLinkFigure extends UMLEdgeFigure {
}
private int getArrowLineVerticalX() {
- if (getPoints().size() < 2) {
+ if (super.getPoints().size() < 2) {
// The connection is not configured yet
return 0;
}
@@ -193,7 +194,7 @@ public class DurationLinkFigure extends UMLEdgeFigure {
}
/** Returns the points for the end line - the line connecting the end point to the arrow. */
- protected PointList getEndLinePoints() {
+ public PointList getEndLinePoints() {
if (arrowOrientation == Orientation.HORIZONTAL) {
return getEndLinePointsHorizontal();
}
@@ -208,7 +209,7 @@ public class DurationLinkFigure extends UMLEdgeFigure {
Point endOffsetEnd = getEnd().getCopy();
endOffsetEnd.setX(endOffsetEnd.x() - HORIZOTAL_ARROW_END_LINE_OFFSET);
points.addPoint(endOffsetEnd);
- int arrowYCoordinate = (getStart().y() + getEnd().y()) / 2;
+ int arrowYCoordinate = getArrowLineHorizontalY();
// paint the end line
Point endLineEnd = endOffsetEnd.getCopy();
if (arrowYCoordinate < getEnd().y) {
@@ -263,13 +264,13 @@ public class DurationLinkFigure extends UMLEdgeFigure {
}
/** Returns the points for the arrow line drawn between the and and start lines. */
- protected PointList getArrowLinePoints() {
+ public PointList getArrowLinePoints() {
PointList points = new PointList(2);
Point arrowStart = null, arrowEnd = null;
if (arrowOrientation == Orientation.HORIZONTAL) {
- int arrowYCoordinate = (getStart().y() + getEnd().y()) / 2;
- arrowStart = getStart().getCopy().setX(getStart().x() + ARROW_PADDING).setY(arrowYCoordinate);
- arrowEnd = getEnd().getCopy().setX(getEnd().x() - ARROW_PADDING).setY(arrowYCoordinate);
+
+ arrowStart = getStart().getCopy().setX(getStart().x() + ARROW_PADDING).setY(getArrowLineHorizontalY());
+ arrowEnd = getEnd().getCopy().setX(getEnd().x() - ARROW_PADDING).setY(getArrowLineHorizontalY());
} else {
arrowStart = getStart().getCopy().setX(getArrowLineVerticalX());
arrowEnd = arrowStart.getCopy().setY(getArrowLineVerticalY());
@@ -279,6 +280,14 @@ public class DurationLinkFigure extends UMLEdgeFigure {
return points;
}
+ private int getArrowLineHorizontalY() {
+ if (super.getPoints().size() < 2) {
+ // The connection is not configured yet
+ return 0;
+ }
+ return (getStart().y() + getEnd().y()) / 2 + arrowPositionDelta;
+ }
+
/** Adds decorations(e.g. arrow triangles) to the arrow line. */
protected void decorateArrowLine(PolylineConnection arrowLine, Point arrowStart, Point arrowEnd) {
// source
@@ -377,7 +386,14 @@ public class DurationLinkFigure extends UMLEdgeFigure {
// Skip; this figure doesn't support routers/bendpoints
}
- /* package */ static enum Orientation {
+ /**
+ * @return the arrowOrientation
+ */
+ public Orientation getArrowOrientation() {
+ return arrowOrientation;
+ }
+
+ public static enum Orientation {
VERTICAL, HORIZONTAL;
}
@@ -404,5 +420,4 @@ public class DurationLinkFigure extends UMLEdgeFigure {
list.add(this::getEnd);
return list;
}
-
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/locator/IntersectionPointSelectionLocator.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/locator/IntersectionPointSelectionLocator.java
new file mode 100644
index 00000000000..ac593325fbf
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/locator/IntersectionPointSelectionLocator.java
@@ -0,0 +1,54 @@
+/*****************************************************************************
+ * Copyright (c) 2018 CEA LIST, EclipseSource and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * EclipseSource - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.sequence.locator;
+
+import org.eclipse.draw2d.Connection;
+import org.eclipse.draw2d.ConnectionLocator;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.PointList;
+import org.eclipse.draw2d.geometry.Rectangle;
+
+/** ConnectionLocator that provides the location of the intersection point of two PointLists. */
+public class IntersectionPointSelectionLocator extends ConnectionLocator {
+
+ private PointList pointList1;
+ private PointList pointList2;
+
+ /**
+ * Constructor.
+ *
+ * @param connection
+ */
+ public IntersectionPointSelectionLocator(Connection connection, PointList pointList1, PointList pointList2) {
+ super(connection);
+ this.pointList1 = pointList1;
+ this.pointList2 = pointList2;
+ }
+
+ @Override
+ protected Point getLocation(PointList points) {
+ if (pointList1 == null || pointList2 == null) {
+ return super.getLocation(points);
+ }
+
+ Rectangle intersect = pointList1.getBounds().intersect(pointList2.getBounds());
+ if (!intersect.isEmpty()) {
+ return intersect.getLocation();
+ }
+ // fallback to default (middle point)
+ return super.getLocation(points);
+ }
+} \ No newline at end of file
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/CustomEditPartProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/CustomEditPartProvider.java
index 6bfbf12b238..e34a16ea433 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/CustomEditPartProvider.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/CustomEditPartProvider.java
@@ -29,6 +29,8 @@ import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CLifeLineEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CombinedFragmentCombinedFragmentCompartmentEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CombinedFragmentEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.ConsiderIgnoreFragmentEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CustomDurationConstraintLinkEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CustomDurationObservationLinkEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CustomGeneralOrderingEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CustomMessageName2EditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CustomMessageName3EditPart;
@@ -40,6 +42,8 @@ import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CustomMessageNameEdit
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CustomStateInvariantEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CustomStateInvariantLabelEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DestructionOccurrenceSpecificationEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationConstraintLinkEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationObservationLinkEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.GeneralOrderingEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.InteractionEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.InteractionInteractionCompartmentEditPart;
@@ -190,6 +194,10 @@ public class CustomEditPartProvider extends UMLEditPartProvider {
// return new MessageEndEditPart(view);
case StateInvariantLabelEditPart.VISUAL_ID:
return new CustomStateInvariantLabelEditPart(view);
+ case DurationConstraintLinkEditPart.VISUAL_ID:
+ return new CustomDurationConstraintLinkEditPart(view);
+ case DurationObservationLinkEditPart.VISUAL_ID:
+ return new CustomDurationObservationLinkEditPart(view);
}
return null;
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/requests/MoveArrowRequest.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/requests/MoveArrowRequest.java
new file mode 100644
index 00000000000..235ace2c1b6
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/requests/MoveArrowRequest.java
@@ -0,0 +1,46 @@
+/*****************************************************************************
+ * Copyright (c) 2018 CEA LIST, EclipseSource and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * EclipseSource - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.sequence.requests;
+
+import org.eclipse.gef.requests.ChangeBoundsRequest;
+import org.eclipse.papyrus.uml.diagram.sequence.figures.DurationLinkFigure.Orientation;
+
+/**
+ * A request for moving the position of the arrow of a DurationLinkFigure.
+ */
+public class MoveArrowRequest extends ChangeBoundsRequest {
+ public static final String REQ_MOVE_ARROW = "MoveArrowRequest";
+ private Orientation arrowOrientation;
+
+ @Override
+ public Object getType() {
+ return REQ_MOVE_ARROW;
+ }
+
+ /**
+ * @param arrowOrientation
+ */
+ public void setArrowOrientation(Orientation arrowOrientation) {
+ this.arrowOrientation = arrowOrientation;
+ }
+
+ /**
+ * @return the arrowOrientation
+ */
+ public Orientation getArrowOrientation() {
+ return arrowOrientation;
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/requests/MoveSeparatorRequest.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/requests/MoveSeparatorRequest.java
index ff8a068081f..5d052cba159 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/requests/MoveSeparatorRequest.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/requests/MoveSeparatorRequest.java
@@ -14,11 +14,7 @@
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.sequence.requests;
-import java.util.List;
-
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.Request;
+import org.eclipse.gef.requests.ChangeBoundsRequest;
/**
* <p>
@@ -26,16 +22,13 @@ import org.eclipse.gef.Request;
* This should expand one of the Operands, and shrink the other one of the same
* amount.
* </p>
- *
+ *
* @since 5.0
*/
-public class MoveSeparatorRequest extends Request {
+public class MoveSeparatorRequest extends ChangeBoundsRequest {
public static final String REQ_MOVE_SEPARATOR = "MoveSeparatorRequest";
private final int separatorIndex;
- private Point moveDelta;
- private Point location;
- private List<? extends EditPart> editParts;
public MoveSeparatorRequest(int separatorIndex) {
this.separatorIndex = separatorIndex;
@@ -54,42 +47,4 @@ public class MoveSeparatorRequest extends Request {
return separatorIndex;
}
- /**
- * @param moveDelta
- */
- public void setMoveDelta(Point moveDelta) {
- this.moveDelta = moveDelta;
- }
-
- public Point getMoveDelta() {
- return moveDelta;
- }
-
- /**
- * @param location
- */
- public void setLocation(Point location) {
- this.location = location;
- }
-
- /**
- * @return the location
- */
- public Point getLocation() {
- return location;
- }
-
- /**
- * @param editParts
- */
- public void setEditParts(List<? extends EditPart> editParts) {
- this.editParts = editParts;
- }
-
- /**
- * @return the editParts
- */
- public List<? extends EditPart> getEditParts() {
- return editParts;
- }
}

Back to the top