Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/AbstractExecutionSpecificationEditPart.java80
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/ExecutionSpecificationGraphicalNodeEditPolicy.java152
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/ExecutionSpecificationNodePlate.java10
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/ActionExecutionSpecificationEditPart.java7
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/BehaviorExecutionSpecificationEditPart.java7
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/DurationConstraintEditHelper.java59
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/DurationObservationEditHelper.java54
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/AbstractDurationEditHelperAdvice.java230
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/DurationConstraintEditHelperAdvice.java33
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/DurationObservationEditHelperAdvice.java31
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/utils/SequenceRequestConstant.java35
11 files changed, 539 insertions, 159 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 34f48364451..43109a13113 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
@@ -30,6 +30,7 @@ import org.eclipse.gef.EditPolicy;
import org.eclipse.gef.GraphicalViewer;
import org.eclipse.gef.Request;
import org.eclipse.gef.requests.ChangeBoundsRequest;
+import org.eclipse.gef.requests.CreateRequest;
import org.eclipse.gef.requests.ReconnectRequest;
import org.eclipse.gmf.runtime.common.core.util.Log;
import org.eclipse.gmf.runtime.common.core.util.Trace;
@@ -55,6 +56,8 @@ import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.gmf.runtime.notation.datatype.GradientData;
import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure;
import org.eclipse.papyrus.uml.diagram.common.editparts.RoundedCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.anchors.NodeBottomAnchor;
+import org.eclipse.papyrus.uml.diagram.sequence.anchors.NodeTopAnchor;
import org.eclipse.papyrus.uml.diagram.sequence.edit.helpers.AnchorHelper;
import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.AppliedStereotypeCommentCreationEditPolicyEx;
import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.SequenceReferenceEditPolicy;
@@ -76,6 +79,10 @@ import org.eclipse.swt.graphics.Color;
*/
public abstract class AbstractExecutionSpecificationEditPart extends RoundedCompartmentEditPart {
+ /**
+ * @deprecated since 5.1 this constant is not used anymore.
+ */
+ @Deprecated
public static final String EXECUTION_FIX_ANCHOR_POSITION = "Execution Fix Anchor Position";
public static int DEFAUT_HEIGHT = 100;
public static int DEFAUT_WIDTH = 20;
@@ -232,15 +239,15 @@ public abstract class AbstractExecutionSpecificationEditPart extends RoundedComp
protected void moveExecutionSpecificationFeedback(ChangeBoundsRequest request, AbstractExecutionSpecificationEditPart movedPart, PrecisionRectangle rect, Rectangle originalBounds) {
// If this is a move to the top, the execution specification cannot be moved upper than the life line y position
- if(request.getMoveDelta().y < 0) {
+ if (request.getMoveDelta().y < 0) {
EditPart parent = getParent();
- if(parent instanceof CLifeLineEditPart) {
-
+ if (parent instanceof CLifeLineEditPart) {
+
Point locationOnDiagram = CoordinateReferentialUtils.transformPointFromScreenToDiagramReferential(originalBounds.getCopy().getLocation(), (GraphicalViewer) movedPart.getViewer());
- Bounds parentBounds = BoundForEditPart.getBounds((Node)((CLifeLineEditPart)parent).getModel());
-
+ Bounds parentBounds = BoundForEditPart.getBounds((Node) ((CLifeLineEditPart) parent).getModel());
+
// This magic delta is needed to be at the bottom of the life line name
- if((locationOnDiagram.y + request.getMoveDelta().y) < (parentBounds.getY() + 50)) {
+ if ((locationOnDiagram.y + request.getMoveDelta().y) < (parentBounds.getY() + 50)) {
Point loc = locationOnDiagram.getCopy();
loc.y = parentBounds.getY() + 50;
rect.setLocation(loc);
@@ -304,20 +311,18 @@ public abstract class AbstractExecutionSpecificationEditPart extends RoundedComp
*/
@Override
public ConnectionAnchor getTargetConnectionAnchor(Request request) {
- Object fixPos = request.getExtendedData().get(EXECUTION_FIX_ANCHOR_POSITION);
- if (fixPos != null && (fixPos.equals(PositionConstants.TOP) || fixPos.equals(PositionConstants.BOTTOM))) {
- return new AnchorHelper.FixedAnchorEx(getFigure(), (Integer) fixPos);
- }
if (request instanceof CreateUnspecifiedTypeConnectionRequest) {
CreateUnspecifiedTypeConnectionRequest createRequest = (CreateUnspecifiedTypeConnectionRequest) request;
List<?> relationshipTypes = createRequest.getElementTypes();
- for (Object obj : relationshipTypes) {
- if (UMLElementTypes.Message_SynchEdge.equals(obj)) {
+ for (Object type : relationshipTypes) {
+ if (UMLElementTypes.Message_SynchEdge.equals(type)) {
// Sync Message
if (!createRequest.getTargetEditPart().equals(createRequest.getSourceEditPart())) {
return new AnchorHelper.FixedAnchorEx(getFigure(), PositionConstants.TOP);
}
// otherwise, this is a recursive call, let destination free
+ } else if (UMLElementTypes.DurationConstraint_Edge.equals(type) || UMLElementTypes.DurationObservation_Edge.equals(type)) {
+ return isStart(createRequest) ? new NodeTopAnchor(getFigure()) : new NodeBottomAnchor(getFigure());
}
}
} else if (request instanceof ReconnectRequest) {
@@ -338,11 +343,32 @@ public abstract class AbstractExecutionSpecificationEditPart extends RoundedComp
return new AnchorHelper.FixedAnchorEx(getFigure(), PositionConstants.TOP);
}
}
+ if (isDurationLink(createRequest)) {
+ return isStart(createRequest) ? new NodeTopAnchor(getFigure()) : new NodeBottomAnchor(getFigure());
+ }
}
return super.getTargetConnectionAnchor(request);
}
/**
+ * Test whether the given request is closer to the start (top) or to the finish (bottom) point of the execution specification
+ *
+ * @param createRequest
+ * The create request
+ * @return
+ * <code>true</code> if the given request is closer to the top of the figure; false if it is closer to the bottom
+ */
+ private boolean isStart(CreateRequest createRequest) {
+ Point location = createRequest.getLocation();
+ Rectangle bounds = getFigure().getBounds().getCopy();
+ getFigure().translateToAbsolute(bounds);
+
+ double distanceToTop = location.getDistance(bounds.getTop());
+ double distanceToBottom = location.getDistance(bounds.getBottom());
+ return distanceToTop < distanceToBottom;
+ }
+
+ /**
* @see org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart#getTargetConnectionAnchor(org.eclipse.gef.ConnectionEditPart)
*
* @param connEditPart
@@ -392,17 +418,15 @@ public abstract class AbstractExecutionSpecificationEditPart extends RoundedComp
*/
@Override
public ConnectionAnchor getSourceConnectionAnchor(Request request) {
- Object fixPos = request.getExtendedData().get(EXECUTION_FIX_ANCHOR_POSITION);
- if (fixPos != null && (fixPos.equals(PositionConstants.TOP) || fixPos.equals(PositionConstants.BOTTOM))) {
- return new AnchorHelper.FixedAnchorEx(getFigure(), (Integer) fixPos);
- }
if (request instanceof CreateUnspecifiedTypeConnectionRequest) {
CreateUnspecifiedTypeConnectionRequest createRequest = (CreateUnspecifiedTypeConnectionRequest) request;
List<?> relationshipTypes = createRequest.getElementTypes();
- for (Object obj : relationshipTypes) {
- if (UMLElementTypes.Message_ReplyEdge.equals(obj)) {
+ for (Object type : relationshipTypes) {
+ if (UMLElementTypes.Message_ReplyEdge.equals(type)) {
// Reply Message
return new AnchorHelper.FixedAnchorEx(getFigure(), PositionConstants.BOTTOM);
+ } else if (UMLElementTypes.DurationConstraint_Edge.equals(type) || UMLElementTypes.DurationObservation_Edge.equals(type)) {
+ return isStart(createRequest) ? new NodeTopAnchor(getFigure()) : new NodeBottomAnchor(getFigure());
}
}
} else if (request instanceof ReconnectRequest) {
@@ -412,11 +436,30 @@ public abstract class AbstractExecutionSpecificationEditPart extends RoundedComp
// Reply Message
return new AnchorHelper.FixedAnchorEx(getFigure(), PositionConstants.BOTTOM);
}
+ } else if (request instanceof CreateConnectionViewRequest) {
+ CreateConnectionViewRequest createRequest = (CreateConnectionViewRequest) request;
+ if (isDurationLink(createRequest)) {
+ return isStart(createRequest) ? new NodeTopAnchor(getFigure()) : new NodeBottomAnchor(getFigure());
+ }
}
return super.getSourceConnectionAnchor(request);
}
/**
+ * @param createRequest
+ * @return
+ */
+ private boolean isDurationLink(CreateConnectionViewRequest createRequest) {
+ String semanticHint = createRequest.getConnectionViewDescriptor().getSemanticHint();
+ switch (semanticHint) {
+ case DurationConstraintLinkEditPart.VISUAL_ID:
+ case DurationObservationLinkEditPart.VISUAL_ID:
+ return true;
+ }
+ return false;
+ }
+
+ /**
* @see org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart#getSourceConnectionAnchor(org.eclipse.gef.ConnectionEditPart)
*
* @param connEditPart
@@ -518,4 +561,5 @@ public abstract class AbstractExecutionSpecificationEditPart extends RoundedComp
}
super.showTargetFeedback(request);
}
+
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/ExecutionSpecificationGraphicalNodeEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/ExecutionSpecificationGraphicalNodeEditPolicy.java
new file mode 100644
index 00000000000..541df0f2538
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/ExecutionSpecificationGraphicalNodeEditPolicy.java
@@ -0,0 +1,152 @@
+/*****************************************************************************
+ * 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 java.util.List;
+
+import org.eclipse.draw2d.Connection;
+import org.eclipse.draw2d.PolylineConnection;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.editpolicies.GraphicalNodeEditPolicy;
+import org.eclipse.gef.requests.CreateConnectionRequest;
+import org.eclipse.gef.requests.CreateRequest;
+import org.eclipse.gmf.runtime.diagram.core.edithelpers.CreateElementRequestAdapter;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewAndElementRequest;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.gmfdiag.common.service.palette.AspectUnspecifiedTypeConnectionTool.CreateAspectUnspecifiedTypeConnectionRequest;
+import org.eclipse.papyrus.uml.diagram.sequence.figures.DurationLinkFigure;
+import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.service.types.utils.SequenceRequestConstant;
+import org.eclipse.uml2.uml.ExecutionSpecification;
+import org.eclipse.uml2.uml.OccurrenceSpecification;
+
+/**
+ * <p>
+ * A specialized {@link GraphicalNodeEditPolicy} for {@link ExecutionSpecification ExecutionSpecifications}, to handle
+ * connection of DurationLinks to the Start/Finish Occurrences of the {@link ExecutionSpecification}
+ * </p>
+ */
+public class ExecutionSpecificationGraphicalNodeEditPolicy extends ElementCreationWithMessageEditPolicy {
+
+ // Source (First half of the request)
+ @Override
+ protected Command getConnectionCreateCommand(CreateConnectionRequest request) {
+ if (isCreateDurationLink(request)) {
+ CreateRelationshipRequest createRequest = getCreateRelationshipRequest(request);
+ if (createRequest != null) {
+ OccurrenceSpecification sourceOccurrence;
+ ExecutionSpecification execSpec = getExecutionSpecification();
+ if (execSpec != null) {
+ if (isStart(request)) {
+ sourceOccurrence = execSpec.getStart();
+ } else {
+ sourceOccurrence = execSpec.getFinish();
+ }
+ request.getExtendedData().put(SequenceRequestConstant.SOURCE_OCCURRENCE, sourceOccurrence);
+ createRequest.setParameter(SequenceRequestConstant.SOURCE_OCCURRENCE, sourceOccurrence);
+ }
+ }
+ }
+ return super.getConnectionCreateCommand(request);
+ }
+
+ private ExecutionSpecification getExecutionSpecification() {
+ Object model = getHost().getModel();
+ if (model instanceof View && ((View) model).getElement() instanceof ExecutionSpecification) {
+ return (ExecutionSpecification) ((View) model).getElement();
+ }
+ return null;
+ }
+
+ /**
+ * Test whether the given request is closer to the start (top) or to the finish (bottom) point of the execution specification
+ *
+ * @param createRequest
+ * The create request
+ * @return
+ * <code>true</code> if the given request is closer to the top of the figure; false if it is closer to the bottom
+ */
+ private boolean isStart(CreateRequest createRequest) {
+ Point location = createRequest.getLocation();
+ Rectangle bounds = getHostFigure().getBounds();
+
+ double distanceToTop = location.getDistance(bounds.getTop());
+ double distanceToBottom = location.getDistance(bounds.getBottom());
+ return distanceToTop < distanceToBottom;
+ }
+
+ // Target (Second half of the request)
+ @Override
+ protected Command getConnectionAndRelationshipCompleteCommand(CreateConnectionViewAndElementRequest request) {
+ if (isCreateDurationLink(request)) {
+ CreateRelationshipRequest createRequest = getCreateRelationshipRequest(request);
+ if (createRequest != null) {
+ OccurrenceSpecification targetOccurrence;
+ ExecutionSpecification execSpec = getExecutionSpecification();
+ if (execSpec != null) {
+ if (isStart(request)) {
+ targetOccurrence = execSpec.getStart();
+ } else {
+ targetOccurrence = execSpec.getFinish();
+ }
+ request.getExtendedData().put(SequenceRequestConstant.TARGET_OCCURRENCE, targetOccurrence);
+ createRequest.setParameter(SequenceRequestConstant.TARGET_OCCURRENCE, targetOccurrence);
+ }
+ }
+ }
+ return super.getConnectionAndRelationshipCompleteCommand(request);
+ }
+
+ private boolean isCreateDurationLink(CreateConnectionRequest request) {
+ CreateRelationshipRequest createElementRequest = getCreateRelationshipRequest(request);
+ if (createElementRequest == null) {
+ if (request instanceof CreateAspectUnspecifiedTypeConnectionRequest) {
+ CreateAspectUnspecifiedTypeConnectionRequest createRequest = (CreateAspectUnspecifiedTypeConnectionRequest) request;
+ List<?> types = createRequest.getElementTypes();
+ if (types.stream().allMatch(
+ type -> type == UMLElementTypes.DurationConstraint_Edge ||
+ type == UMLElementTypes.DurationObservation_Edge)) {
+ return true;
+ }
+ }
+ }
+ IElementType type = createElementRequest.getElementType();
+ return type == UMLElementTypes.DurationConstraint_Edge || type == UMLElementTypes.DurationObservation_Edge;
+ }
+
+ private CreateRelationshipRequest getCreateRelationshipRequest(CreateConnectionRequest request) {
+ if (false == request instanceof CreateConnectionViewAndElementRequest) {
+ return null;
+ }
+ CreateElementRequestAdapter requestAdapter = ((CreateConnectionViewAndElementRequest) request).getConnectionViewAndElementDescriptor().getCreateElementRequestAdapter();
+ if (requestAdapter == null) {
+ return null;
+ }
+ CreateRelationshipRequest createElementRequest = (CreateRelationshipRequest) requestAdapter.getAdapter(CreateRelationshipRequest.class);
+ return createElementRequest;
+ }
+
+ @Override
+ protected Connection createDummyConnection(Request req) {
+ if (req instanceof CreateConnectionRequest && isCreateDurationLink((CreateConnectionRequest) req)) {
+ return new DurationLinkFigure();
+ }
+ return new PolylineConnection();
+ }
+
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/ExecutionSpecificationNodePlate.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/ExecutionSpecificationNodePlate.java
index 3a6c01fd127..2dcf0510f93 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/ExecutionSpecificationNodePlate.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/ExecutionSpecificationNodePlate.java
@@ -64,4 +64,14 @@ public class ExecutionSpecificationNodePlate extends LinkLFSVGNodePlateFigure im
}
return super.getConnectionAnchor(terminal);
}
+
+ @Override
+ public String getConnectionAnchorTerminal(ConnectionAnchor c) {
+ if (c instanceof NodeTopAnchor) {
+ return AnchorConstants.START_TERMINAL;
+ } else if (c instanceof NodeBottomAnchor) {
+ return AnchorConstants.END_TERMINAL;
+ }
+ return super.getConnectionAnchorTerminal(c);
+ }
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/ActionExecutionSpecificationEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/ActionExecutionSpecificationEditPart.java
index 74585f55f66..116fffb9469 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/ActionExecutionSpecificationEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/ActionExecutionSpecificationEditPart.java
@@ -26,13 +26,12 @@ import org.eclipse.gef.requests.CreateRequest;
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure;
import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultGraphicalNodeEditPolicy;
import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultSemanticEditPolicy;
import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure;
import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.RoundedRectangleNodePlateFigure;
import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SelectableBorderedNodeFigure;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.ElementCreationWithMessageEditPolicy;
import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.ExecutionSpecificationComponentEditPolicy;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.ExecutionSpecificationGraphicalNodeEditPolicy;
import org.eclipse.swt.graphics.Color;
/**
@@ -70,10 +69,8 @@ public class ActionExecutionSpecificationEditPart extends AbstractExecutionSpeci
super.createDefaultEditPolicies();
installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy());
- installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DefaultGraphicalNodeEditPolicy());
-
installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
- installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new ElementCreationWithMessageEditPolicy());
+ installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new ExecutionSpecificationGraphicalNodeEditPolicy());
installEditPolicy(EditPolicy.COMPONENT_ROLE, new ExecutionSpecificationComponentEditPolicy());
// XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies
// removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE);
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/BehaviorExecutionSpecificationEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/BehaviorExecutionSpecificationEditPart.java
index cc9576691b3..34564bc0c3a 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/BehaviorExecutionSpecificationEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/BehaviorExecutionSpecificationEditPart.java
@@ -26,13 +26,12 @@ import org.eclipse.gef.requests.CreateRequest;
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure;
import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultGraphicalNodeEditPolicy;
import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultSemanticEditPolicy;
import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure;
import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.RoundedRectangleNodePlateFigure;
import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SelectableBorderedNodeFigure;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.ElementCreationWithMessageEditPolicy;
import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.ExecutionSpecificationComponentEditPolicy;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.ExecutionSpecificationGraphicalNodeEditPolicy;
import org.eclipse.swt.graphics.Color;
/**
@@ -70,10 +69,8 @@ public class BehaviorExecutionSpecificationEditPart extends AbstractExecutionSpe
super.createDefaultEditPolicies();
installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy());
- installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DefaultGraphicalNodeEditPolicy());
-
installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
- installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new ElementCreationWithMessageEditPolicy());
+ installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new ExecutionSpecificationGraphicalNodeEditPolicy());
installEditPolicy(EditPolicy.COMPONENT_ROLE, new ExecutionSpecificationComponentEditPolicy());
// XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies
// removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE);
diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/DurationConstraintEditHelper.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/DurationConstraintEditHelper.java
index d9c3fc93da1..6e3758d4c18 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/DurationConstraintEditHelper.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/DurationConstraintEditHelper.java
@@ -17,11 +17,7 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
import org.eclipse.gmf.runtime.common.core.command.IdentityCommand;
import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
-import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest;
import org.eclipse.papyrus.infra.gmfdiag.common.commands.CreateRelationshipCommandEx;
-import org.eclipse.uml2.uml.DurationConstraint;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.Interaction;
import org.eclipse.uml2.uml.UMLFactory;
import org.eclipse.uml2.uml.ValueSpecification;
@@ -34,45 +30,6 @@ public class DurationConstraintEditHelper extends ConstraintEditHelper {
/**
* <p>
- * If the request is a {@link CreateRelationshipRequest}, configure it to indicate that
- * the {@link DurationConstraint} should be created as an {@link Interaction#getOwnedRules() ownedRule} in the {@link Interaction}.
- * </p>
- */
- @Override
- public void configureRequest(IEditCommandRequest request) {
- super.configureRequest(request);
-
- if (request instanceof CreateRelationshipRequest) {
- CreateRelationshipRequest req = (CreateRelationshipRequest) request;
- EObject container = req.getContainer();
- if (req.getSource() != null && req.getTarget() != null) {
- // Create in the interaction#ownedRules
- Interaction interaction = findInteraction(req.getSource());
- if (interaction != null) {
- container = interaction;
- }
- req.setContainer(container);
- }
-
- }
- super.configureRequest(request);
- }
-
- private Interaction findInteraction(EObject source) {
- if (source instanceof Element) {
- Element element = (Element) source;
- while (element != null) {
- if (element instanceof Interaction) {
- return (Interaction) element;
- }
- element = element.getOwner();
- }
- }
- return null;
- }
-
- /**
- * <p>
* Unlike other constraints, a DurationConstraint is a Constraint between two elements; so we support
* creation as a Link. In the sequence diagram, this is currently (2018/07) the only supported way.
* In the future, we may add support for DurationConstraints targetting a single element (The UML
@@ -82,16 +39,16 @@ public class DurationConstraintEditHelper extends ConstraintEditHelper {
@Override
protected ICommand getCreateRelationshipCommand(CreateRelationshipRequest req) {
EObject source = req.getSource();
- EObject target = req.getTarget();
+ EObject target = req.getTarget();
- boolean noSourceOrTarget = (source == null || target == null);
- boolean noSourceAndTarget = (source == null && target == null);
+ boolean noSourceOrTarget = (source == null || target == null);
+ boolean noSourceAndTarget = (source == null && target == null);
- if (noSourceOrTarget && !noSourceAndTarget) {
- // The request isn't complete yet. Return the identity command so
- // that the create relationship gesture is enabled.
- return IdentityCommand.INSTANCE;
- }
+ if (noSourceOrTarget && !noSourceAndTarget) {
+ // The request isn't complete yet. Return the identity command so
+ // that the create relationship gesture is enabled.
+ return IdentityCommand.INSTANCE;
+ }
return new CreateRelationshipCommandEx(req);
}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/DurationObservationEditHelper.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/DurationObservationEditHelper.java
index e26033722b3..acbd1124c00 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/DurationObservationEditHelper.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/DurationObservationEditHelper.java
@@ -17,50 +17,12 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
import org.eclipse.gmf.runtime.common.core.command.IdentityCommand;
import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
-import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest;
import org.eclipse.papyrus.infra.gmfdiag.common.commands.CreateRelationshipCommandEx;
-import org.eclipse.uml2.uml.DurationObservation;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.Package;
public class DurationObservationEditHelper extends ElementEditHelper {
/**
* <p>
- * If the request is a {@link CreateRelationshipRequest}, configure it to indicate that
- * the {@link DurationObservation} should be created as a {@link Package#getPackagedElements() packagedElement} in the nearest {@link Package}.
- * </p>
- */
- @Override
- public void configureRequest(IEditCommandRequest request) {
- super.configureRequest(request);
-
- if (request instanceof CreateRelationshipRequest) {
- CreateRelationshipRequest req = (CreateRelationshipRequest) request;
- EObject container = req.getContainer();
- if (req.getSource() != null && req.getTarget() != null) {
- // Create in the package#packagedElement
- Package pkg = findPackage(req.getSource());
- if (pkg != null) {
- container = pkg;
- }
- req.setContainer(container);
- }
-
- }
- super.configureRequest(request);
- }
-
- private Package findPackage(EObject source) {
- if (source instanceof Element) {
- Element element = (Element) source;
- return element.getNearestPackage();
- }
- return null;
- }
-
- /**
- * <p>
* A DurationObservation is an Observation between two named elements; so we support
* creation as a Link. In the sequence diagram, this is currently (2018/07) the only supported way.
* In the future, we may add support for DurationObservations targetting a single named element (The UML
@@ -70,16 +32,16 @@ public class DurationObservationEditHelper extends ElementEditHelper {
@Override
protected ICommand getCreateRelationshipCommand(CreateRelationshipRequest req) {
EObject source = req.getSource();
- EObject target = req.getTarget();
+ EObject target = req.getTarget();
- boolean noSourceOrTarget = (source == null || target == null);
- boolean noSourceAndTarget = (source == null && target == null);
+ boolean noSourceOrTarget = (source == null || target == null);
+ boolean noSourceAndTarget = (source == null && target == null);
- if (noSourceOrTarget && !noSourceAndTarget) {
- // The request isn't complete yet. Return the identity command so
- // that the create relationship gesture is enabled.
- return IdentityCommand.INSTANCE;
- }
+ if (noSourceOrTarget && !noSourceAndTarget) {
+ // The request isn't complete yet. Return the identity command so
+ // that the create relationship gesture is enabled.
+ return IdentityCommand.INSTANCE;
+ }
return new CreateRelationshipCommandEx(req);
}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/AbstractDurationEditHelperAdvice.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/AbstractDurationEditHelperAdvice.java
new file mode 100644
index 00000000000..9e69b4bfded
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/AbstractDurationEditHelperAdvice.java
@@ -0,0 +1,230 @@
+/*****************************************************************************
+ * 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.service.types.helper.advice;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand;
+import org.eclipse.gmf.runtime.emf.type.core.commands.GetEditContextCommand;
+import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice;
+import org.eclipse.gmf.runtime.emf.type.core.requests.AbstractEditCommandRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.GetEditContextRequest;
+import org.eclipse.papyrus.uml.service.types.utils.SequenceRequestConstant;
+import org.eclipse.uml2.uml.DurationConstraint;
+import org.eclipse.uml2.uml.DurationObservation;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.ExecutionSpecification;
+import org.eclipse.uml2.uml.Message;
+import org.eclipse.uml2.uml.OccurrenceSpecification;
+
+/**
+ * <p>
+ * Abstract advice for Durations ({@link DurationConstraint} or {@link DurationObservation})
+ * </p>
+ */
+public abstract class AbstractDurationEditHelperAdvice extends AbstractEditHelperAdvice {
+
+ /**
+ * <p>
+ * Retrieve the Source Element from a request (Either a {@link CreateRelationshipRequest}, or a
+ * related request, e.g. a {@link ConfigureRequest} occurring after a {@link CreateRelationshipRequest}).
+ * </p>
+ *
+ * <p>
+ * The source element may correspond to the element on which the relationship is created,
+ * or a specific occurrence specification (For example, when creating a Duration link on an {@link ExecutionSpecification},
+ * this method may return the specific start or finish {@link OccurrenceSpecification} instead of the {@link ExecutionSpecification}).
+ * </p>
+ *
+ * @param request
+ * The Edit Request (Typically a {@link CreateRelationshipRequest} or {@link ConfigureRequest})
+ * @return
+ * The source element for this request, or <code>null</code> if no such element can be found
+ */
+ protected Element getSourceElement(AbstractEditCommandRequest request) {
+ if (request instanceof CreateRelationshipRequest) {
+ return getSourceElement((CreateRelationshipRequest) request);
+ }
+ return getSourceOrTarget(request.getParameter(CreateRelationshipRequest.SOURCE), request.getParameter(SequenceRequestConstant.SOURCE_OCCURRENCE));
+ }
+
+ /**
+ * <p>
+ * Retrieve the Target Element from a request (Either a {@link CreateRelationshipRequest}, or a
+ * related request, e.g. a {@link ConfigureRequest} occurring after a {@link CreateRelationshipRequest}).
+ * </p>
+ *
+ * <p>
+ * The target element may correspond to the element on which the relationship is created,
+ * or a specific occurrence specification (For example, when creating a Duration link on an {@link ExecutionSpecification},
+ * this method may return the specific start or finish {@link OccurrenceSpecification} instead of the {@link ExecutionSpecification}).
+ * </p>
+ *
+ * @param request
+ * The Edit Request (Typically a {@link CreateRelationshipRequest} or {@link ConfigureRequest})
+ * @return
+ * The target element for this request, or <code>null</code> if no such element can be found
+ */
+ protected Element getTargetElement(AbstractEditCommandRequest request) {
+ if (request instanceof CreateRelationshipRequest) {
+ return getTargetElement((CreateRelationshipRequest) request);
+ }
+ return getSourceOrTarget(request.getParameter(CreateRelationshipRequest.TARGET), request.getParameter(SequenceRequestConstant.TARGET_OCCURRENCE));
+ }
+
+ /**
+ * <p>
+ * Retrieve the Source Element from a {@link CreateRelationshipRequest}
+ * </p>
+ *
+ * <p>
+ * The source element may correspond to the element on which the relationship is created,
+ * or a specific occurrence specification (For example, when creating a Duration link on an {@link ExecutionSpecification},
+ * this method may return the specific start or finish {@link OccurrenceSpecification} instead of the {@link ExecutionSpecification}).
+ * </p>
+ *
+ * @param request
+ * The Edit Request (Typically a {@link CreateRelationshipRequest} or {@link ConfigureRequest})
+ * @return
+ * The source element for this request, or <code>null</code> if no such element can be found
+ */
+ protected Element getSourceElement(CreateRelationshipRequest request) {
+ return getSourceOrTarget(request.getSource(), request.getParameter(SequenceRequestConstant.SOURCE_OCCURRENCE));
+ }
+
+ /**
+ * <p>
+ * Retrieve the Target Element from a {@link CreateRelationshipRequest}
+ * </p>
+ *
+ * <p>
+ * The target element may correspond to the element on which the relationship is created,
+ * or a specific occurrence specification (For example, when creating a Duration link on an {@link ExecutionSpecification},
+ * this method may return the specific start or finish {@link OccurrenceSpecification} instead of the {@link ExecutionSpecification}).
+ * </p>
+ *
+ * @param request
+ * The Edit Request (Typically a {@link CreateRelationshipRequest} or {@link ConfigureRequest})
+ * @return
+ * The source element for this request, or <code>null</code> if no such element can be found
+ */
+ protected Element getTargetElement(CreateRelationshipRequest request) {
+ return getSourceOrTarget(request.getTarget(), request.getParameter(SequenceRequestConstant.TARGET_OCCURRENCE));
+ }
+
+ /**
+ * <p>
+ * For Duration Links, the {@link CreateRelationshipRequest} will typically contain two distinct parameters
+ * for their source, and two for their target. The first one will represent the source/target visual element,
+ * and the second will represent the real event ({@link OccurrenceSpecification}); typically the start/finish
+ * {@link OccurrenceSpecification} of the graphical element.
+ * </p>
+ * <p>
+ * This method will take these two values (Which may or may not be valid {@link Element} or {@link OccurrenceSpecification},
+ * thus the {@link Object} type), and will return the one that should be used as the source/target of the new Duration Link
+ * </p>
+ *
+ * @param rawElement
+ * The element that is the source or target of a {@link CreateRelationshipRequest}. (Typically the UML Element
+ * represented in a Diagram, i.e. an {@link ExecutionSpecification} or a {@link Message}. It may also be
+ * an {@link OccurrenceSpecification}, e.g. if the Duration Link is created directly from the Model Explorer).
+ * @param occurrenceParam
+ * The specific {@link OccurrenceSpecification} referenced by the {@link CreateRelationshipRequest}. Typical values
+ * may be <code>null</code> (The request doesn't specify which event should be used), an {@link OccurrenceSpecification}
+ * referenced by the <code>rawElement</code> (Start/Finish occurrence, or Send/Receive event), or the same object as
+ * <code>rawElement</code>.
+ * @return
+ * The source or target semantic element for a DurationLink (Which may be different from
+ * the graphical element, since {@link OccurrenceSpecification} are not displayed on diagrams)
+ *
+ * @see CreateRelationshipRequest#getSource()
+ * @see CreateRelationshipRequest#getTarget()
+ * @see SequenceRequestConstant#SOURCE_OCCURRENCE
+ * @see SequenceRequestConstant#TARGET_OCCURRENCE
+ * @see CreateRelationshipRequest#SOURCE
+ * @see CreateRelationshipRequest#TARGET
+ */
+ protected Element getSourceOrTarget(Object rawElement, Object occurrenceParam) {
+ OccurrenceSpecification occurrence;
+ if (occurrenceParam instanceof OccurrenceSpecification) {
+ occurrence = (OccurrenceSpecification) occurrenceParam;
+ } else if (rawElement instanceof Element) {
+ return (Element) rawElement;
+ } else {
+ return null;
+ }
+
+ Element element;
+ if (rawElement instanceof Element) {
+ element = (Element) rawElement;
+ } else {
+ element = null;
+ }
+
+ // If both the element and occurrence are set, make sure the occurrence belongs to the element
+ // That's required, because the occurrence parameter might have been added to the request
+ // when its owner was hovered, and then it wasn't removed when we hovered a different element.
+ if (element instanceof ExecutionSpecification) {
+ ExecutionSpecification execSpec = (ExecutionSpecification) element;
+ if (execSpec.getStart() == occurrence || execSpec.getFinish() == occurrence) {
+ return occurrence;
+ }
+ } else if (element instanceof Message) {
+ Message message = (Message) element;
+ if (message.getSendEvent() == occurrence || message.getReceiveEvent() == occurrence) {
+ return occurrence;
+ }
+ } else if (element == occurrence) {
+ return occurrence;
+ }
+
+ return element;
+ }
+
+ @Override
+ protected ICommand getBeforeEditContextCommand(GetEditContextRequest request) {
+ if (request.getEditCommandRequest() instanceof CreateRelationshipRequest) {
+ CreateRelationshipRequest createRequest = (CreateRelationshipRequest) request.getEditCommandRequest();
+ EObject source = getSourceElement(createRequest);
+ EObject target = getTargetElement(createRequest);
+ if (createRequest.getSource() != null && !isValid(source)) {
+ return UnexecutableCommand.INSTANCE;
+ }
+ if (createRequest.getTarget() != null && !isValid(target)) {
+ return UnexecutableCommand.INSTANCE;
+ }
+ if (source != null && target != null) {
+ // Always create DurationConstraints in the Interaction
+ Object editContext = request.getEditContext();
+ if (editContext instanceof Element) {
+ Element durationCreationContainer = getDurationCreationContainer((Element) editContext);
+ if (durationCreationContainer != null) {
+ GetEditContextCommand command = new GetEditContextCommand(request);
+ command.setEditContext(durationCreationContainer);
+ return command;
+ }
+ }
+ }
+ }
+ return super.getBeforeEditContextCommand(request);
+ }
+
+ protected boolean isValid(EObject sourceOrTarget) {
+ return sourceOrTarget instanceof OccurrenceSpecification;
+ }
+
+ protected abstract Element getDurationCreationContainer(Element targetElement);
+
+}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/DurationConstraintEditHelperAdvice.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/DurationConstraintEditHelperAdvice.java
index d02eae6ed37..0635266720d 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/DurationConstraintEditHelperAdvice.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/DurationConstraintEditHelperAdvice.java
@@ -21,21 +21,20 @@ 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.edithelper.AbstractEditHelperAdvice;
import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest;
-import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
import org.eclipse.papyrus.uml.tools.utils.NamedElementUtil;
import org.eclipse.uml2.uml.Duration;
import org.eclipse.uml2.uml.DurationConstraint;
import org.eclipse.uml2.uml.DurationInterval;
import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Interaction;
import org.eclipse.uml2.uml.UMLFactory;
/**
* @since 3.0
*
*/
-public class DurationConstraintEditHelperAdvice extends AbstractEditHelperAdvice {
+public class DurationConstraintEditHelperAdvice extends AbstractDurationEditHelperAdvice {
/**
@@ -122,21 +121,25 @@ public class DurationConstraintEditHelperAdvice extends AbstractEditHelperAdvice
return composite;
}
- protected Element getSourceElement(ConfigureRequest request) {
- Object paramObject = request.getParameter(CreateRelationshipRequest.SOURCE);
- if (paramObject instanceof Element) {
- return (Element) paramObject;
- }
-
- return null;
+ /**
+ * @see org.eclipse.papyrus.uml.service.types.helper.advice.AbstractDurationEditHelperAdvice#getDurationCreationContainer(org.eclipse.uml2.uml.Element)
+ *
+ * @param targetElement
+ * @return
+ */
+ @Override
+ protected Element getDurationCreationContainer(Element targetElement) {
+ return findInteraction(targetElement);
}
- protected Element getTargetElement(ConfigureRequest request) {
- Object paramObject = request.getParameter(CreateRelationshipRequest.TARGET);
- if (paramObject instanceof Element) {
- return (Element) paramObject;
+ protected Interaction findInteraction(Element source) {
+ Element element = source;
+ while (element != null) {
+ if (element instanceof Interaction) {
+ return (Interaction) element;
+ }
+ element = element.getOwner();
}
-
return null;
}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/DurationObservationEditHelperAdvice.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/DurationObservationEditHelperAdvice.java
index d47c0bde87d..2f93b6b7f97 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/DurationObservationEditHelperAdvice.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/DurationObservationEditHelperAdvice.java
@@ -19,13 +19,13 @@ 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.edithelper.AbstractEditHelperAdvice;
+import org.eclipse.gmf.runtime.emf.type.core.requests.AbstractEditCommandRequest;
import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest;
-import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
import org.eclipse.uml2.uml.DurationObservation;
+import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.NamedElement;
-public class DurationObservationEditHelperAdvice extends AbstractEditHelperAdvice {
+public class DurationObservationEditHelperAdvice extends AbstractDurationEditHelperAdvice {
@Override
protected ICommand getAfterConfigureCommand(ConfigureRequest request) {
@@ -63,22 +63,21 @@ public class DurationObservationEditHelperAdvice extends AbstractEditHelperAdvic
return composite;
}
- protected NamedElement getSourceElement(ConfigureRequest request) {
- Object paramObject = request.getParameter(CreateRelationshipRequest.SOURCE);
- if (paramObject instanceof NamedElement) {
- return (NamedElement) paramObject;
- }
-
- return null;
+ @Override
+ protected NamedElement getSourceElement(AbstractEditCommandRequest request) {
+ Element source = super.getSourceElement(request);
+ return source instanceof NamedElement ? (NamedElement) source : null;
}
- protected NamedElement getTargetElement(ConfigureRequest request) {
- Object paramObject = request.getParameter(CreateRelationshipRequest.TARGET);
- if (paramObject instanceof NamedElement) {
- return (NamedElement) paramObject;
- }
+ @Override
+ protected NamedElement getTargetElement(AbstractEditCommandRequest request) {
+ Element target = super.getTargetElement(request);
+ return target instanceof NamedElement ? (NamedElement) target : null;
+ }
- return null;
+ @Override
+ protected Element getDurationCreationContainer(Element targetElement) {
+ return targetElement.getNearestPackage();
}
}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/utils/SequenceRequestConstant.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/utils/SequenceRequestConstant.java
index 9a584d1de12..321c2c02a1e 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/utils/SequenceRequestConstant.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/utils/SequenceRequestConstant.java
@@ -15,10 +15,13 @@
package org.eclipse.papyrus.uml.service.types.utils;
import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest;
+import org.eclipse.uml2.uml.ExecutionSpecification;
+import org.eclipse.uml2.uml.Message;
+import org.eclipse.uml2.uml.OccurrenceSpecification;
/**
* Constants used in the sequence diagram
- *
+ *
* @since 3.0
*/
public interface SequenceRequestConstant {
@@ -31,7 +34,7 @@ public interface SequenceRequestConstant {
/**
* Add in the request that a element cover another element.
- *
+ *
* @deprecated Since version 3.1, use the {@link #COVERED_LIFELINES}, instead.
* @see RequestParameterUtils#getCoveredLifelines(IEditCommandRequest)
* @see RequestParameterUtils#setCoveredLifelines(IEditCommandRequest, Iterable)
@@ -41,7 +44,7 @@ public interface SequenceRequestConstant {
/**
* Hint providing a collection of covered lifelines ({@code {@literal Collection<Lifeline>}}).
- *
+ *
* @since 4.0
* @see RequestParameterUtils#getCoveredLifelines(IEditCommandRequest)
* @see RequestParameterUtils#setCoveredLifelines(IEditCommandRequest, Iterable)
@@ -61,4 +64,30 @@ public interface SequenceRequestConstant {
/** the finish of Execution specification can be replace by an event of a message */
public static final String REPLACE_EXECUTION_SPECIFICATION_FINISH = "REPLACE_EXECUTION_SPECIFICATION_FINISH"; //$NON-NLS-1$
+ /**
+ * <p>
+ * When creating a Relationship to an {@link ExecutionSpecification} or a {@link Message},
+ * this parameter represents the target {@link OccurrenceSpecification}. It may be the start or finish
+ * occurrence of an {@link ExecutionSpecification}, or the send or receive event of a {@link Message}.
+ * </p>
+ *
+ * <p>
+ * If this parameter is set, the source of the relationship should reference the {@link OccurrenceSpecification} rather than the original {@link Message} or {@link ExecutionSpecification}.
+ * </p>
+ */
+ public static final String SOURCE_OCCURRENCE = "Source Occurrence";
+
+ /**
+ * <p>
+ * When creating a Relationship to an {@link ExecutionSpecification} or a {@link Message},
+ * this parameter represents the source {@link OccurrenceSpecification}. It may be the start or finish
+ * occurrence of an {@link ExecutionSpecification}, or the send or receive event of a {@link Message}.
+ * </p>
+ *
+ * <p>
+ * If this parameter is set, the target of the relationship should reference the {@link OccurrenceSpecification} rather than the original {@link Message} or {@link ExecutionSpecification}.
+ * </p>
+ */
+ public static final String TARGET_OCCURRENCE = "Target Occurrence";
+
}

Back to the top