Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamille Letavernier2018-08-06 07:32:25 -0400
committerCamille Letavernier2018-09-24 06:48:39 -0400
commit08c6860edce7dd0decb923d92208ebdfe05a329a (patch)
treebfbcd3758793ed920b73cb35cd5da297ed4da126
parent9d4b21535734e307582c3229d5f38c3bc4561921 (diff)
downloadorg.eclipse.papyrus-08c6860edce7dd0decb923d92208ebdfe05a329a.tar.gz
org.eclipse.papyrus-08c6860edce7dd0decb923d92208ebdfe05a329a.tar.xz
org.eclipse.papyrus-08c6860edce7dd0decb923d92208ebdfe05a329a.zip
Bug 537724: [Sequence Diagram] Support ReconnectRequests for
GeneralOrdering Change-Id: I7199af44fec105e54d7b9e1fc295a5198e686b76 Signed-off-by: Camille Letavernier <cletavernier@eclipsesource.com>
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/AbstractExecutionSpecificationEditPart.java4
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/AbstractMessageEditPart.java10
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CDestructionOccurrenceSpecificationEditPart.java6
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/OccurenceSemanticEditPolicy.java179
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/LifeLineGraphicalNodeEditPolicy.java2
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/OccurrenceSpecificationMoveHelper.java80
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/OccurrenceSpecificationUtil.java38
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/GeneralOrderingHelperAdvice.java24
8 files changed, 255 insertions, 88 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/AbstractExecutionSpecificationEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/AbstractExecutionSpecificationEditPart.java
index 1bccffeb26f..f2c32ec6a46 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/AbstractExecutionSpecificationEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/AbstractExecutionSpecificationEditPart.java
@@ -336,6 +336,8 @@ public abstract class AbstractExecutionSpecificationEditPart extends RoundedComp
if (connectionEditPart instanceof MessageSyncEditPart) {
// Sync Message
return new AnchorHelper.FixedAnchorEx(getFigure(), PositionConstants.TOP);
+ } else if (DurationLinkUtil.isDurationLink(reconnectRequest) || GeneralOrderingUtil.isGeneralOrderingLink(reconnectRequest)) {
+ return OccurrenceSpecificationUtil.isStart(getFigure(), reconnectRequest.getLocation()) ? new NodeTopAnchor(getFigure()) : new NodeBottomAnchor(getFigure());
}
}
// Fixed bug about computing target anchor when creating message sync.
@@ -422,6 +424,8 @@ public abstract class AbstractExecutionSpecificationEditPart extends RoundedComp
if (connectionEditPart instanceof MessageReplyEditPart) {
// Reply Message
return new AnchorHelper.FixedAnchorEx(getFigure(), PositionConstants.BOTTOM);
+ } else if (DurationLinkUtil.isDurationLink(reconnectRequest) || GeneralOrderingUtil.isGeneralOrderingLink(reconnectRequest)) {
+ return OccurrenceSpecificationUtil.isStart(getFigure(), reconnectRequest.getLocation()) ? new NodeTopAnchor(getFigure()) : new NodeBottomAnchor(getFigure());
}
} else if (request instanceof CreateConnectionViewRequest) {
CreateConnectionViewRequest createRequest = (CreateConnectionViewRequest) request;
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/AbstractMessageEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/AbstractMessageEditPart.java
index 33e5891bb1a..2d82fef3fdd 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/AbstractMessageEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/AbstractMessageEditPart.java
@@ -419,6 +419,11 @@ public abstract class AbstractMessageEditPart extends UMLConnectionNodeEditPart
if (DurationLinkUtil.isDurationLink(createRequest) || GeneralOrderingUtil.isGeneralOrderingLink(createRequest)) {
return OccurrenceSpecificationUtil.isSource(getConnectionFigure(), createRequest) ? new ConnectionSourceAnchor(getPrimaryShape()) : new ConnectionTargetAnchor(getPrimaryShape());
}
+ } else if (request instanceof ReconnectRequest) {
+ ReconnectRequest reconnectRequest = (ReconnectRequest) request;
+ if (DurationLinkUtil.isDurationLink(reconnectRequest) || GeneralOrderingUtil.isGeneralOrderingLink(reconnectRequest)) {
+ return OccurrenceSpecificationUtil.isSource(getConnectionFigure(), reconnectRequest.getLocation()) ? new ConnectionSourceAnchor(getPrimaryShape()) : new ConnectionTargetAnchor(getPrimaryShape());
+ }
}
return super.getSourceConnectionAnchor(request);
}
@@ -438,6 +443,11 @@ public abstract class AbstractMessageEditPart extends UMLConnectionNodeEditPart
if (DurationLinkUtil.isDurationLink(createRequest) || GeneralOrderingUtil.isGeneralOrderingLink(createRequest)) {
return OccurrenceSpecificationUtil.isSource(getConnectionFigure(), createRequest) ? new ConnectionSourceAnchor(getPrimaryShape()) : new ConnectionTargetAnchor(getPrimaryShape());
}
+ } else if (request instanceof ReconnectRequest) {
+ ReconnectRequest reconnectRequest = (ReconnectRequest) request;
+ if (DurationLinkUtil.isDurationLink(reconnectRequest) || GeneralOrderingUtil.isGeneralOrderingLink(reconnectRequest)) {
+ return OccurrenceSpecificationUtil.isSource(getConnectionFigure(), reconnectRequest.getLocation()) ? new ConnectionSourceAnchor(getPrimaryShape()) : new ConnectionTargetAnchor(getPrimaryShape());
+ }
}
return super.getTargetConnectionAnchor(request);
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CDestructionOccurrenceSpecificationEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CDestructionOccurrenceSpecificationEditPart.java
index fe1368e481f..05cbf46e2fc 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CDestructionOccurrenceSpecificationEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CDestructionOccurrenceSpecificationEditPart.java
@@ -17,6 +17,7 @@ import java.util.List;
import org.eclipse.draw2d.ConnectionAnchor;
import org.eclipse.gef.EditPolicy;
import org.eclipse.gef.Request;
+import org.eclipse.gef.requests.ReconnectRequest;
import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewRequest;
import org.eclipse.gmf.runtime.diagram.ui.requests.CreateUnspecifiedTypeConnectionRequest;
import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure;
@@ -55,6 +56,11 @@ public class CDestructionOccurrenceSpecificationEditPart extends DestructionOccu
if (DurationLinkUtil.isDurationLink(createRequest) || GeneralOrderingUtil.isGeneralOrderingLink(createRequest)) {
return new CenterAnchor(getFigure());
}
+ } else if (request instanceof ReconnectRequest) {
+ ReconnectRequest reconnectRequest = (ReconnectRequest) request;
+ if (DurationLinkUtil.isDurationLink(reconnectRequest) || GeneralOrderingUtil.isGeneralOrderingLink(reconnectRequest)) {
+ return new CenterAnchor(getFigure());
+ }
}
return super.getTargetConnectionAnchor(request);
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/OccurenceSemanticEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/OccurenceSemanticEditPolicy.java
new file mode 100644
index 00000000000..d66ae19ab8e
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/OccurenceSemanticEditPolicy.java
@@ -0,0 +1,179 @@
+/*****************************************************************************
+ * 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 v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * EclipseSource - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.sequence.edit.policies;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.requests.ReconnectRequest;
+import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.SemanticEditPolicy;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
+import org.eclipse.gmf.runtime.notation.Anchor;
+import org.eclipse.gmf.runtime.notation.Edge;
+import org.eclipse.gmf.runtime.notation.IdentityAnchor;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultSemanticEditPolicy;
+import org.eclipse.papyrus.uml.diagram.sequence.anchors.AnchorConstants;
+import org.eclipse.papyrus.uml.diagram.sequence.util.GeneralOrderingUtil;
+import org.eclipse.papyrus.uml.diagram.sequence.util.OccurrenceSpecificationUtil;
+import org.eclipse.uml2.uml.ExecutionSpecification;
+import org.eclipse.uml2.uml.Message;
+import org.eclipse.uml2.uml.OccurrenceSpecification;
+
+/**
+ * A {@link SemanticEditPolicy} that is able to target specific {@link OccurrenceSpecification}s
+ * from a request (Typically for {@link Message#getSendEvent()},{@link Message#getReceiveEvent()},
+ * {@link ExecutionSpecification#getStart()} and {@link ExecutionSpecification#getFinish()})
+ */
+public class OccurenceSemanticEditPolicy extends DefaultSemanticEditPolicy {
+
+ /**
+ * {@inheritDoc}
+ *
+ * <p>
+ * Overridden to support {@link ReconnectRequest}, when only the anchor changes, referencing
+ * a different {@link OccurrenceSpecification} on the same edit part.
+ * </p>
+ *
+ * @param request
+ * @return
+ */
+ @Override
+ public Command getCommand(Request request) {
+ if (REQ_RECONNECT_SOURCE.equals(request.getType())
+ && relationshipSourceHasChanged((ReconnectRequest) request)) {
+ EditPart connectionEP = ((ReconnectRequest) request)
+ .getConnectionEditPart();
+ if (ViewUtil.resolveSemanticElement((View) connectionEP.getModel()) == null) {
+ return getReorientRefRelationshipSourceCommand((ReconnectRequest) request);
+ } else {
+ return getReorientRelationshipSourceCommand((ReconnectRequest) request);
+ }
+ } else if (REQ_RECONNECT_TARGET.equals(request.getType())
+ && relationshipTargetHasChanged((ReconnectRequest) request)) {
+ EditPart connectionEP = ((ReconnectRequest) request)
+ .getConnectionEditPart();
+ if (ViewUtil.resolveSemanticElement((View) connectionEP.getModel()) == null) {
+ return getReorientRefRelationshipTargetCommand((ReconnectRequest) request);
+ } else {
+ return getReorientRelationshipTargetCommand((ReconnectRequest) request);
+ }
+ }
+ return super.getCommand(request);
+ }
+
+ protected boolean relationshipSourceHasChanged(ReconnectRequest request) {
+ return getSourceOccurrence((Edge) request.getConnectionEditPart().getModel()) != getOccurrence(request);
+ }
+
+ protected boolean relationshipTargetHasChanged(ReconnectRequest request) {
+ return getTargetOccurrence((Edge) request.getConnectionEditPart().getModel()) != getOccurrence(request);
+ }
+
+ @Override
+ protected Command getReorientRelationshipSourceCommand(ReconnectRequest request) {
+ if (GeneralOrderingUtil.isGeneralOrderingLink(request)) {
+ EObject connectionSemElement = ViewUtil.resolveSemanticElement(((View) request.getConnectionEditPart()
+ .getModel()));
+ EObject targetSemElement = getOccurrence(request);
+ EObject oldSemElement = getSourceOccurrence((Edge) request.getConnectionEditPart().getModel());
+
+ TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost())
+ .getEditingDomain();
+ ReorientRelationshipRequest semRequest = new ReorientRelationshipRequest(
+ editingDomain, connectionSemElement, targetSemElement,
+ oldSemElement, ReorientRelationshipRequest.REORIENT_SOURCE);
+
+ semRequest.addParameters(request.getExtendedData());
+
+ return getSemanticCommand(semRequest);
+ }
+
+ return super.getReorientRefRelationshipSourceCommand(request);
+ }
+
+ @Override
+ protected Command getReorientRelationshipTargetCommand(ReconnectRequest request) {
+ if (GeneralOrderingUtil.isGeneralOrderingLink(request)) {
+ EObject connectionSemElement = ViewUtil.resolveSemanticElement((View) request.getConnectionEditPart().getModel());
+ EObject targetSemElement = getOccurrence(request);
+ EObject oldSemElement = getTargetOccurrence((Edge) request.getConnectionEditPart().getModel());
+
+ TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost())
+ .getEditingDomain();
+ ReorientRelationshipRequest semRequest = new ReorientRelationshipRequest(
+ editingDomain, connectionSemElement, targetSemElement,
+ oldSemElement, ReorientRelationshipRequest.REORIENT_TARGET);
+
+ semRequest.addParameters(request.getExtendedData());
+
+ return getSemanticCommand(semRequest);
+ }
+
+ return super.getReorientRelationshipTargetCommand(request);
+ }
+
+ private EObject getOccurrence(ReconnectRequest request) {
+ EObject element = EMFHelper.getEObject(request.getTarget());
+ IFigure targetFigure = ((IGraphicalEditPart) request.getTarget()).getFigure();
+ if (element instanceof Message) {
+ if (OccurrenceSpecificationUtil.isSource(targetFigure, request.getLocation())) {
+ return ((Message) element).getSendEvent();
+ } else {
+ return ((Message) element).getReceiveEvent();
+ }
+ } else if (element instanceof ExecutionSpecification) {
+ if (OccurrenceSpecificationUtil.isStart(targetFigure, request.getLocation())) {
+ return ((ExecutionSpecification) element).getStart();
+ } else {
+ return ((ExecutionSpecification) element).getFinish();
+ }
+ }
+ return element;
+ }
+
+ private EObject getTargetOccurrence(Edge connection) {
+ return getOccurrence(connection.getTargetAnchor(), connection.getTarget());
+ }
+
+ private EObject getSourceOccurrence(Edge connection) {
+ return getOccurrence(connection.getSourceAnchor(), connection.getSource());
+ }
+
+ private EObject getOccurrence(Anchor anchor, View targetElement) {
+ String anchorId = ((IdentityAnchor) anchor).getId();
+ EObject element = targetElement.getElement();
+ if (AnchorConstants.END_TERMINAL.equals(anchorId)) {
+ if (element instanceof Message) {
+ return ((Message) element).getReceiveEvent();
+ } else if (element instanceof ExecutionSpecification) {
+ return ((ExecutionSpecification) element).getFinish();
+ }
+ } else if (AnchorConstants.START_TERMINAL.equals(anchorId)) {
+ if (element instanceof Message) {
+ return ((Message) element).getSendEvent();
+ } else if (element instanceof ExecutionSpecification) {
+ return ((ExecutionSpecification) element).getStart();
+ }
+ }
+ return null;
+ }
+
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/LifeLineGraphicalNodeEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/LifeLineGraphicalNodeEditPolicy.java
index 35c932164d8..40a47ae6d23 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/LifeLineGraphicalNodeEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/LifeLineGraphicalNodeEditPolicy.java
@@ -701,7 +701,7 @@ public class LifeLineGraphicalNodeEditPolicy extends DefaultGraphicalNodeEditPol
// Check if the target is lower than the source
Point sourceLocation = SequenceUtil.getAbsoluteEdgeExtremity((ConnectionNodeEditPart) request.getConnectionEditPart(), true);
- if (!isTargetLowerThanSource(sourceLocation, request.getLocation().getCopy())) {
+ if (sourceLocation != null && !isTargetLowerThanSource(sourceLocation, request.getLocation().getCopy())) {
Object object = request.getExtendedData().get(SequenceUtil.DO_NOT_CHECK_HORIZONTALITY);
if (!(object instanceof Boolean) || ((object instanceof Boolean) && !((Boolean) object))) {// If not HorizontalMove parameter true
return UnexecutableCommand.INSTANCE;
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/OccurrenceSpecificationMoveHelper.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/OccurrenceSpecificationMoveHelper.java
index 064a0d2dacc..2fd7d82d01b 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/OccurrenceSpecificationMoveHelper.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/OccurrenceSpecificationMoveHelper.java
@@ -129,17 +129,6 @@ public class OccurrenceSpecificationMoveHelper {
if (command != null) {
globalCmd.add(command);
}
- // reconnect the corresponding general ordering(s) if necessary
- command = getReconnectGeneralOrderingCommand(movedOccurrenceSpecification1, yLocation1, lifelinePart, notToMoveEditParts);
- if (command != null) {
- globalCmd.add(command);
- }
- if (movedOccurrenceSpecification2 != null) {
- command = getReconnectGeneralOrderingCommand(movedOccurrenceSpecification2, yLocation2, lifelinePart, notToMoveEditParts);
- if (command != null) {
- globalCmd.add(command);
- }
- }
// return null rather than an empty non executable command
if (globalCmd.isEmpty()) {
return null;
@@ -148,75 +137,6 @@ public class OccurrenceSpecificationMoveHelper {
}
/**
- * Get the command to reconnect general ordering attached to a moved occurrence specification
- *
- * @param movedOccurrenceSpecification
- * moving occurrence specification
- * @param yLocation
- * y location where occurrence specification is moved
- * @param lifelinePart
- * lifeline edit part containing the moved element
- * @param notToMoveEditParts
- * list of edit parts which must not be moved in the created command
- * @return command to reconnect general ordering edit parts linked to the occurrence specification or null
- */
- private static Command getReconnectGeneralOrderingCommand(OccurrenceSpecification movedOccurrenceSpecification, int yLocation, LifelineEditPart lifelinePart, List<EditPart> notToMoveEditParts) {
- // the global command which shall be completed and returned
- CompoundCommand command = new CompoundCommand();
- Point referencePoint = getReferencePoint(lifelinePart, movedOccurrenceSpecification, yLocation);
- EditPart childToReconnectTo = SequenceUtil.findPartToReconnectTo(lifelinePart, referencePoint);
- // if referencePoint is on a moved part, it must be translated with the location delta of this part
- if (!notToMoveEditParts.isEmpty() && childToReconnectTo != lifelinePart) {
- Point oldLoc = SequenceUtil.findLocationOfEvent(lifelinePart, movedOccurrenceSpecification);
- if (oldLoc == null) {
- return null;
- }
- referencePoint.y = oldLoc.y;
- }
- // reconnect general ordering from the event
- for (GeneralOrdering go : movedOccurrenceSpecification.getToAfters()) {
- Collection<Setting> settings = CacheAdapter.getInstance().getNonNavigableInverseReferences(go);
- for (Setting ref : settings) {
- if (NotationPackage.eINSTANCE.getView_Element().equals(ref.getEStructuralFeature())) {
- View view = (View) ref.getEObject();
- EditPart part = DiagramEditPartsUtil.getEditPartFromView(view, lifelinePart);
- // the general ordering part must start or finish on the lifeline (with the event)
- if (part instanceof ConnectionEditPart && !notToMoveEditParts.contains(part)) {
- Request reconnectRequest = makeReconnectRequest((ConnectionEditPart) part, true, referencePoint, childToReconnectTo);
- Command reconnect = childToReconnectTo.getCommand(reconnectRequest);
- if (reconnect.canExecute()) {
- command.add(reconnect);
- }
- }
- }
- }
- }
- // reconnect general ordering to the event
- for (GeneralOrdering go : movedOccurrenceSpecification.getToBefores()) {
- Collection<Setting> settings = CacheAdapter.getInstance().getNonNavigableInverseReferences(go);
- for (Setting ref : settings) {
- if (NotationPackage.eINSTANCE.getView_Element().equals(ref.getEStructuralFeature())) {
- View view = (View) ref.getEObject();
- EditPart part = DiagramEditPartsUtil.getEditPartFromView(view, lifelinePart);
- // the general ordering part must start or finish on the lifeline (with the event)
- if (part instanceof ConnectionEditPart && !notToMoveEditParts.contains(part)) {
- Request reconnectRequest = makeReconnectRequest((ConnectionEditPart) part, false, referencePoint, childToReconnectTo);
- Command reconnect = childToReconnectTo.getCommand(reconnectRequest);
- if (reconnect.canExecute()) {
- command.add(reconnect);
- }
- }
- }
- }
- }
- // return null rather than an empty non executable command
- if (command.isEmpty()) {
- return null;
- }
- return command;
- }
-
- /**
* Get the command to reconnect message attached to a moved occurrence specification
*
* @param movedOccurrenceSpecification
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/OccurrenceSpecificationUtil.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/OccurrenceSpecificationUtil.java
index 46c9bb2f8fb..64e288b16e5 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/OccurrenceSpecificationUtil.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/OccurrenceSpecificationUtil.java
@@ -20,6 +20,7 @@ import org.eclipse.draw2d.geometry.PointList;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gef.EditPart;
+import org.eclipse.gef.Request;
import org.eclipse.gef.requests.CreateConnectionRequest;
import org.eclipse.gef.requests.CreateRequest;
import org.eclipse.gmf.runtime.diagram.core.edithelpers.CreateElementRequestAdapter;
@@ -73,12 +74,23 @@ public class OccurrenceSpecificationUtil {
* <code>true</code> if the given request is closer to the top of the figure; false if it is closer to the bottom
*/
public static boolean isStart(IFigure targetFigure, CreateRequest createRequest) {
- Point location = createRequest.getLocation();
+ return isStart(targetFigure, createRequest.getLocation());
+ }
+
+ /**
+ * Test whether the given request is closer to the start (top) or to the finish (bottom) point of the execution specification
+ *
+ * @param Point
+ * The current request location
+ * @return
+ * <code>true</code> if the given request is closer to the top of the figure; false if it is closer to the bottom
+ */
+ public static boolean isStart(IFigure targetFigure, Point requestLocation) {
Rectangle bounds = targetFigure.getBounds().getCopy();
targetFigure.translateToAbsolute(bounds);
- double distanceToTop = location.getDistance(bounds.getTop());
- double distanceToBottom = location.getDistance(bounds.getBottom());
+ double distanceToTop = requestLocation.getDistance(bounds.getTop());
+ double distanceToBottom = requestLocation.getDistance(bounds.getBottom());
return distanceToTop < distanceToBottom;
}
@@ -93,15 +105,28 @@ public class OccurrenceSpecificationUtil {
* <code>true</code> if the given request is closer to the source of the connection; false if it is closer to the target
*/
public static boolean isSource(IFigure targetFigure, CreateRequest createRequest) {
- Point location = createRequest.getLocation();
+ return isSource(targetFigure, createRequest.getLocation());
+ }
+
+ /**
+ * Test whether the given request is closer to the source or to the target point of the message
+ *
+ * @param targetFigure
+ * The connection figure representing the message
+ * @param requestLocation
+ * The mouse location for the current {@link Request}
+ * @return
+ * <code>true</code> if the given request is closer to the source of the connection; false if it is closer to the target
+ */
+ public static boolean isSource(IFigure targetFigure, Point requestLocation) {
IFigure connection = targetFigure;
if (connection instanceof Connection) {
PointList points = ((Connection) connection).getPoints();
if (points.size() >= 2) {
Point source = points.getFirstPoint();
Point target = points.getLastPoint();
- double distanceToSource = location.getDistance(source);
- double distanceToTarget = location.getDistance(target);
+ double distanceToSource = requestLocation.getDistance(source);
+ double distanceToTarget = requestLocation.getDistance(target);
return distanceToSource < distanceToTarget;
}
}
@@ -112,7 +137,6 @@ public class OccurrenceSpecificationUtil {
}
-
/**
* Find the semantic {@link OccurrenceSpecification} represented by the given <code>connectorEnd</code>.
* The connector should be the source or target of a DurationLink connector.
diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/GeneralOrderingHelperAdvice.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/GeneralOrderingHelperAdvice.java
index b2089e0c760..059ccef0a45 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/GeneralOrderingHelperAdvice.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/GeneralOrderingHelperAdvice.java
@@ -24,11 +24,15 @@ import org.eclipse.gmf.runtime.common.core.command.CommandResult;
import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.type.core.commands.SetValueCommand;
import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.GeneralOrdering;
import org.eclipse.uml2.uml.Interaction;
import org.eclipse.uml2.uml.OccurrenceSpecification;
+import org.eclipse.uml2.uml.UMLPackage.Literals;
/**
* @since 3.0
@@ -76,6 +80,26 @@ public class GeneralOrderingHelperAdvice extends AbstractOccurrenceLinkEditHelpe
return findInteraction(targetElement);
}
+ @Override
+ protected ICommand getAfterReorientRelationshipCommand(ReorientRelationshipRequest request) {
+ EObject relationship = request.getRelationship();
+ if (relationship instanceof GeneralOrdering) {
+ GeneralOrdering ordering = (GeneralOrdering) relationship;
+ EObject newEnd = request.getNewRelationshipEnd();
+ if (newEnd instanceof OccurrenceSpecification) {
+ SetRequest setRequest;
+ if (request.getDirection() == ReorientRelationshipRequest.REORIENT_SOURCE) {
+ setRequest = new SetRequest(ordering, Literals.GENERAL_ORDERING__BEFORE, newEnd);
+ } else {
+ setRequest = new SetRequest(ordering, Literals.GENERAL_ORDERING__AFTER, newEnd);
+ }
+
+ return new SetValueCommand(setRequest);
+ }
+ }
+ return super.getAfterReorientRelationshipCommand(request);
+ }
+
protected Interaction findInteraction(Element source) {
Element element = source;
while (element != null) {

Back to the top