Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/uml/diagram')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/helpers/advice/GeneralOrderingLinkHelperAdvice.java79
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/AbstractExecutionSpecificationEditPart.java18
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/AbstractMessageEditPart.java26
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CDestructionOccurrenceSpecificationEditPart.java9
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomGeneralOrderingEditPart.java51
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/DestructionOccurrenceGraphicalNodeEditPolicy.java3
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/ExecutionSpecificationGraphicalNodeEditPolicy.java15
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/MessageGraphicalNodeEditPolicy.java14
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/CustomGeneralOrderingDescriptor.java4
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/DurationLinkUtil.java122
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/GeneralOrderingUtil.java146
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/OccurrenceSpecificationUtil.java155
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/model/SequenceDiagram.elementtypesconfigurations3
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/DurationObservationLinkEditPart.java2
14 files changed, 435 insertions, 212 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/helpers/advice/GeneralOrderingLinkHelperAdvice.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/helpers/advice/GeneralOrderingLinkHelperAdvice.java
new file mode 100644
index 00000000000..2715aa7715a
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/helpers/advice/GeneralOrderingLinkHelperAdvice.java
@@ -0,0 +1,79 @@
+/*****************************************************************************
+ * 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 - Bug 537562
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.diagram.sequence.edit.helpers.advice;
+
+
+import java.util.Collection;
+
+import org.eclipse.emf.ecore.EStructuralFeature.Setting;
+import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
+import org.eclipse.gmf.runtime.notation.Connector;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
+import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.GeneralOrderingEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.SequenceDiagramEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.util.GeneralOrderingUtil;
+import org.eclipse.uml2.uml.GeneralOrdering;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * <p>
+ * A sequence diagram advice to clear {@link GeneralOrderingEditPart GeneralOrdering links} when the
+ * orderings's before or after events are changed.
+ * </p>
+ */
+public class GeneralOrderingLinkHelperAdvice extends AbstractEditHelperAdvice {
+
+ @Override
+ protected ICommand getAfterSetCommand(SetRequest request) {
+ if ((request.getFeature() == UMLPackage.Literals.GENERAL_ORDERING__AFTER
+ || request.getFeature() == UMLPackage.Literals.GENERAL_ORDERING__BEFORE)
+ && request.getElementToEdit() instanceof GeneralOrdering) {
+ Collection<Setting> usages = EMFHelper.getUsages(request.getElementToEdit());
+
+ // We need to delegate to the command provider; otherwise the view is not correctly destroyed,
+ // and the diagram may still display a ghost connection (referencing a view that is no longer
+ // attached to the notation model)
+ IElementEditService provider = ElementEditServiceUtils.getCommandProvider(request.getElementToEdit());
+ if (provider == null) {
+ return null;
+ }
+
+ CompositeCommand deletions = new CompositeCommand("Delete inconsistent GeneralOrdering views");
+ for (Setting usage : usages) {
+ if (usage.getEObject() instanceof Connector && usage.getEStructuralFeature() == NotationPackage.Literals.VIEW__ELEMENT) {
+ Connector connector = (Connector) usage.getEObject();
+ if (GeneralOrderingEditPart.VISUAL_ID.equals(connector.getType()) //
+ && connector.getDiagram() != null //
+ && SequenceDiagramEditPart.MODEL_ID.equals(connector.getDiagram().getType())) {
+ if (!GeneralOrderingUtil.isConsistent(connector, request)) {
+ // Retrieve delete command from the Element Edit service
+ DestroyElementRequest destroyRequest = new DestroyElementRequest(request.getEditingDomain(), connector, false);
+ ICommand deleteCommand = provider.getEditCommand(destroyRequest);
+ deletions.add(deleteCommand);
+ }
+ }
+ }
+ }
+ return deletions.isEmpty() ? null : deletions.reduce();
+ }
+ return super.getAfterSetCommand(request);
+ }
+
+}
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 8544575137b..1bccffeb26f 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
@@ -71,6 +71,8 @@ import org.eclipse.papyrus.uml.diagram.sequence.referencialgrilling.ConnectExecu
import org.eclipse.papyrus.uml.diagram.sequence.referencialgrilling.ConnectYCoordinateToGrillingEditPolicy;
import org.eclipse.papyrus.uml.diagram.sequence.util.CoordinateReferentialUtils;
import org.eclipse.papyrus.uml.diagram.sequence.util.DurationLinkUtil;
+import org.eclipse.papyrus.uml.diagram.sequence.util.GeneralOrderingUtil;
+import org.eclipse.papyrus.uml.diagram.sequence.util.OccurrenceSpecificationUtil;
import org.eclipse.papyrus.uml.diagram.stereotype.edition.editpolicies.AppliedStereotypeCommentEditPolicy;
import org.eclipse.swt.graphics.Color;
@@ -324,8 +326,8 @@ public abstract class AbstractExecutionSpecificationEditPart extends RoundedComp
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 DurationLinkUtil.isStart(getFigure(), createRequest) ? new NodeTopAnchor(getFigure()) : new NodeBottomAnchor(getFigure());
+ } else if (UMLElementTypes.DurationConstraint_Edge.equals(type) || UMLElementTypes.DurationObservation_Edge.equals(type) || UMLElementTypes.GeneralOrdering_Edge.equals(type)) {
+ return OccurrenceSpecificationUtil.isStart(getFigure(), createRequest) ? new NodeTopAnchor(getFigure()) : new NodeBottomAnchor(getFigure());
}
}
} else if (request instanceof ReconnectRequest) {
@@ -346,8 +348,8 @@ public abstract class AbstractExecutionSpecificationEditPart extends RoundedComp
return new AnchorHelper.FixedAnchorEx(getFigure(), PositionConstants.TOP);
}
}
- if (DurationLinkUtil.isDurationLink(createRequest)) {
- return DurationLinkUtil.isStart(getFigure(), createRequest) ? new NodeTopAnchor(getFigure()) : new NodeBottomAnchor(getFigure());
+ if (DurationLinkUtil.isDurationLink(createRequest) || GeneralOrderingUtil.isGeneralOrderingLink(createRequest)) {
+ return OccurrenceSpecificationUtil.isStart(getFigure(), createRequest) ? new NodeTopAnchor(getFigure()) : new NodeBottomAnchor(getFigure());
}
}
return super.getTargetConnectionAnchor(request);
@@ -410,8 +412,8 @@ public abstract class AbstractExecutionSpecificationEditPart extends RoundedComp
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 DurationLinkUtil.isStart(getFigure(), createRequest) ? new NodeTopAnchor(getFigure()) : new NodeBottomAnchor(getFigure());
+ } else if (UMLElementTypes.DurationConstraint_Edge.equals(type) || UMLElementTypes.DurationObservation_Edge.equals(type) || UMLElementTypes.GeneralOrdering_Edge.equals(type)) {
+ return OccurrenceSpecificationUtil.isStart(getFigure(), createRequest) ? new NodeTopAnchor(getFigure()) : new NodeBottomAnchor(getFigure());
}
}
} else if (request instanceof ReconnectRequest) {
@@ -423,8 +425,8 @@ public abstract class AbstractExecutionSpecificationEditPart extends RoundedComp
}
} else if (request instanceof CreateConnectionViewRequest) {
CreateConnectionViewRequest createRequest = (CreateConnectionViewRequest) request;
- if (DurationLinkUtil.isDurationLink(createRequest)) {
- return DurationLinkUtil.isStart(getFigure(), createRequest) ? new NodeTopAnchor(getFigure()) : new NodeBottomAnchor(getFigure());
+ if (DurationLinkUtil.isDurationLink(createRequest) || GeneralOrderingUtil.isGeneralOrderingLink(createRequest)) {
+ return OccurrenceSpecificationUtil.isStart(getFigure(), createRequest) ? new NodeTopAnchor(getFigure()) : new NodeBottomAnchor(getFigure());
}
}
return super.getSourceConnectionAnchor(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 93f52d6b307..33e5891bb1a 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
@@ -57,6 +57,8 @@ import org.eclipse.papyrus.uml.diagram.sequence.referencialgrilling.ConnectMessa
import org.eclipse.papyrus.uml.diagram.sequence.referencialgrilling.ConnectRectangleToGridEditPolicy;
import org.eclipse.papyrus.uml.diagram.sequence.referencialgrilling.LifeLineGraphicalNodeEditPolicy;
import org.eclipse.papyrus.uml.diagram.sequence.util.DurationLinkUtil;
+import org.eclipse.papyrus.uml.diagram.sequence.util.GeneralOrderingUtil;
+import org.eclipse.papyrus.uml.diagram.sequence.util.OccurrenceSpecificationUtil;
import org.eclipse.papyrus.uml.diagram.sequence.util.SelectMessagesEditPartTracker;
import org.eclipse.papyrus.uml.diagram.sequence.util.SelfMessageHelper;
import org.eclipse.swt.SWT;
@@ -66,8 +68,6 @@ import org.eclipse.ui.PlatformUI;
public abstract class AbstractMessageEditPart extends UMLConnectionNodeEditPart implements IKeyPressState {
- private List messageEventParts;
-
private boolean reorderMessages = false;
/**
@@ -199,7 +199,7 @@ public abstract class AbstractMessageEditPart extends UMLConnectionNodeEditPart
if (points.size() <= 1) {
return;
}
- List lineSegments = PointListUtilities.getLineSegments(points);
+ List<?> lineSegments = PointListUtilities.getLineSegments(points);
LineSeg nearestSegment = PointListUtilities.getNearestSegment(lineSegments, p.x, p.y);
if (points.size() > 3 && (p.getDistance(points.getPoint(1)) < 5 || p.getDistance(points.getPoint(2)) < 5)) {
myCursor = Cursors.SIZEALL;
@@ -258,7 +258,7 @@ public abstract class AbstractMessageEditPart extends UMLConnectionNodeEditPart
}
public View findChildByModel(EObject model) {
- List list = getModelChildren();
+ List<?> list = getModelChildren();
if (list != null && list.size() > 0) {
for (Object o : list) {
if (!(o instanceof View)) {
@@ -287,7 +287,7 @@ public abstract class AbstractMessageEditPart extends UMLConnectionNodeEditPart
@Override
public EditPart getTargetEditPart(Request request) {
if (request instanceof CreateUnspecifiedTypeConnectionRequest) {
- List types = ((CreateUnspecifiedTypeConnectionRequest) request).getElementTypes();
+ List<?> types = ((CreateUnspecifiedTypeConnectionRequest) request).getElementTypes();
if (types.contains(UMLElementTypes.Message_FoundEdge) || types.contains(UMLElementTypes.Message_LostEdge)) {
return null;
}
@@ -410,14 +410,14 @@ public abstract class AbstractMessageEditPart extends UMLConnectionNodeEditPart
CreateUnspecifiedTypeConnectionRequest createRequest = (CreateUnspecifiedTypeConnectionRequest) request;
List<?> relationshipTypes = createRequest.getElementTypes();
for (Object type : relationshipTypes) {
- if (UMLElementTypes.DurationConstraint_Edge.equals(type) || UMLElementTypes.DurationObservation_Edge.equals(type)) {
- return DurationLinkUtil.isSource(getConnectionFigure(), createRequest) ? new ConnectionSourceAnchor(getPrimaryShape()) : new ConnectionTargetAnchor(getPrimaryShape());
+ if (UMLElementTypes.DurationConstraint_Edge.equals(type) || UMLElementTypes.DurationObservation_Edge.equals(type) || UMLElementTypes.GeneralOrdering_Edge.equals(type)) {
+ return OccurrenceSpecificationUtil.isSource(getConnectionFigure(), createRequest) ? new ConnectionSourceAnchor(getPrimaryShape()) : new ConnectionTargetAnchor(getPrimaryShape());
}
}
} else if (request instanceof CreateConnectionViewRequest) {
CreateConnectionViewRequest createRequest = (CreateConnectionViewRequest) request;
- if (DurationLinkUtil.isDurationLink(createRequest)) {
- return DurationLinkUtil.isSource(getConnectionFigure(), createRequest) ? new ConnectionSourceAnchor(getPrimaryShape()) : new ConnectionTargetAnchor(getPrimaryShape());
+ if (DurationLinkUtil.isDurationLink(createRequest) || GeneralOrderingUtil.isGeneralOrderingLink(createRequest)) {
+ return OccurrenceSpecificationUtil.isSource(getConnectionFigure(), createRequest) ? new ConnectionSourceAnchor(getPrimaryShape()) : new ConnectionTargetAnchor(getPrimaryShape());
}
}
return super.getSourceConnectionAnchor(request);
@@ -429,14 +429,14 @@ public abstract class AbstractMessageEditPart extends UMLConnectionNodeEditPart
CreateUnspecifiedTypeConnectionRequest createRequest = (CreateUnspecifiedTypeConnectionRequest) request;
List<?> relationshipTypes = createRequest.getElementTypes();
for (Object type : relationshipTypes) {
- if (UMLElementTypes.DurationConstraint_Edge.equals(type) || UMLElementTypes.DurationObservation_Edge.equals(type)) {
- return DurationLinkUtil.isSource(getConnectionFigure(), createRequest) ? new ConnectionSourceAnchor(getPrimaryShape()) : new ConnectionTargetAnchor(getPrimaryShape());
+ if (UMLElementTypes.DurationConstraint_Edge.equals(type) || UMLElementTypes.DurationObservation_Edge.equals(type) || UMLElementTypes.GeneralOrdering_Edge.equals(type)) {
+ return OccurrenceSpecificationUtil.isSource(getConnectionFigure(), createRequest) ? new ConnectionSourceAnchor(getPrimaryShape()) : new ConnectionTargetAnchor(getPrimaryShape());
}
}
} else if (request instanceof CreateConnectionViewRequest) {
CreateConnectionViewRequest createRequest = (CreateConnectionViewRequest) request;
- if (DurationLinkUtil.isDurationLink(createRequest)) {
- return DurationLinkUtil.isSource(getConnectionFigure(), createRequest) ? new ConnectionSourceAnchor(getPrimaryShape()) : new ConnectionTargetAnchor(getPrimaryShape());
+ if (DurationLinkUtil.isDurationLink(createRequest) || GeneralOrderingUtil.isGeneralOrderingLink(createRequest)) {
+ return OccurrenceSpecificationUtil.isSource(getConnectionFigure(), createRequest) ? 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 f2e3c642a4e..fe1368e481f 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
@@ -26,6 +26,7 @@ import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.DestructionOccurre
import org.eclipse.papyrus.uml.diagram.sequence.figures.DestructionEventNodePlate;
import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
import org.eclipse.papyrus.uml.diagram.sequence.util.DurationLinkUtil;
+import org.eclipse.papyrus.uml.diagram.sequence.util.GeneralOrderingUtil;
public class CDestructionOccurrenceSpecificationEditPart extends DestructionOccurrenceSpecificationEditPart {
@@ -45,13 +46,13 @@ public class CDestructionOccurrenceSpecificationEditPart extends DestructionOccu
CreateUnspecifiedTypeConnectionRequest createRequest = (CreateUnspecifiedTypeConnectionRequest) request;
List<?> relationshipTypes = createRequest.getElementTypes();
for (Object type : relationshipTypes) {
- if (UMLElementTypes.DurationConstraint_Edge.equals(type) || UMLElementTypes.DurationObservation_Edge.equals(type)) {
+ if (UMLElementTypes.DurationConstraint_Edge.equals(type) || UMLElementTypes.DurationObservation_Edge.equals(type) || UMLElementTypes.GeneralOrdering_Edge.equals(type)) {
return new CenterAnchor(getFigure());
}
}
} else if (request instanceof CreateConnectionViewRequest) {
CreateConnectionViewRequest createRequest = (CreateConnectionViewRequest) request;
- if (DurationLinkUtil.isDurationLink(createRequest)) {
+ if (DurationLinkUtil.isDurationLink(createRequest) || GeneralOrderingUtil.isGeneralOrderingLink(createRequest)) {
return new CenterAnchor(getFigure());
}
}
@@ -64,13 +65,13 @@ public class CDestructionOccurrenceSpecificationEditPart extends DestructionOccu
CreateUnspecifiedTypeConnectionRequest createRequest = (CreateUnspecifiedTypeConnectionRequest) request;
List<?> relationshipTypes = createRequest.getElementTypes();
for (Object type : relationshipTypes) {
- if (UMLElementTypes.DurationConstraint_Edge.equals(type) || UMLElementTypes.DurationObservation_Edge.equals(type)) {
+ if (UMLElementTypes.DurationConstraint_Edge.equals(type) || UMLElementTypes.DurationObservation_Edge.equals(type) || UMLElementTypes.GeneralOrdering_Edge.equals(type)) {
return new CenterAnchor(getFigure());
}
}
} else if (request instanceof CreateConnectionViewRequest) {
CreateConnectionViewRequest createRequest = (CreateConnectionViewRequest) request;
- if (DurationLinkUtil.isDurationLink(createRequest)) {
+ if (DurationLinkUtil.isDurationLink(createRequest) || GeneralOrderingUtil.isGeneralOrderingLink(createRequest)) {
return new CenterAnchor(getFigure());
}
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomGeneralOrderingEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomGeneralOrderingEditPart.java
index 164cb9de86e..3050045fe64 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomGeneralOrderingEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomGeneralOrderingEditPart.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2010 CEA
+ * Copyright (c) 2010, 2018 CEA List, EclipseSource and others
*
*
* All rights reserved. This program and the accompanying materials
@@ -11,16 +11,13 @@
*
* Contributors:
* Soyatec - Initial API and implementation
+ * EclipseSource - Bug 537561
*
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.sequence.edit.parts;
import org.eclipse.draw2d.Connection;
import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.gef.ConnectionEditPart;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.requests.ReconnectRequest;
import org.eclipse.gmf.runtime.notation.NotationPackage;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IPapyrusEditPart;
@@ -68,48 +65,4 @@ public class CustomGeneralOrderingEditPart extends GeneralOrderingEditPart imple
getPrimaryShape().setLineWidth(width < 0 ? 1 : 0);
}
- @Override
- public EditPart getTargetEditPart(Request request) {
- EditPart ep = super.getTargetEditPart(request);
- if (ep != null && ep instanceof org.eclipse.gef.ConnectionEditPart) {
- if (request instanceof ReconnectRequest) {
- ReconnectRequest rRequest = (ReconnectRequest) request;
-
- // If source anchor is moved, the connection's source edit part
- // should not be taken into account for a cyclic dependency
- // check so as to avoid false checks. Same goes for the target
- // anchor. See bugzilla# 417373 -- we do not want to target a
- // connection that is already connected to us so that we do not
- // introduce a cyclic connection
- if (isCyclicConnectionRequest((org.eclipse.gef.ConnectionEditPart) ep, rRequest.getConnectionEditPart())) {
- return null;
- }
- }
- }
-
- return ep;
- }
-
- /**
- * Fixed bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=417373
- *
- * The ends of GeneralOrderingEditPart are MessageEndEditParts which parent are Message*EditParts, once we move the ends of the messages, we
- * should IGNORE to move current GeneralOrdering, otherwise cyclic dependency occur.
- *
- */
- private boolean isCyclicConnectionRequest(ConnectionEditPart currentConn, ConnectionEditPart reqConn) {
- if (currentConn == null || reqConn == null) {
- return false;
- }
- EditPart source = currentConn.getSource();
- EditPart target = currentConn.getTarget();
- if (reqConn == source || reqConn == target) {
- return true;
- }
- if (reqConn == source.getParent() || reqConn == target.getParent()) {
- return true;
- }
- return false;
- }
-
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/DestructionOccurrenceGraphicalNodeEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/DestructionOccurrenceGraphicalNodeEditPolicy.java
index b7db8caeb91..9280a3e9eda 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/DestructionOccurrenceGraphicalNodeEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/DestructionOccurrenceGraphicalNodeEditPolicy.java
@@ -26,6 +26,7 @@ import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewAndElemen
import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultGraphicalNodeEditPolicy;
import org.eclipse.papyrus.uml.diagram.sequence.figures.DurationLinkFigure;
import org.eclipse.papyrus.uml.diagram.sequence.util.DurationLinkUtil;
+import org.eclipse.papyrus.uml.diagram.sequence.util.GeneralOrderingUtil;
/**
* An extended {@link DefaultGraphicalNodeEditPolicy} which supports creation of DurationLinks
@@ -34,7 +35,7 @@ public class DestructionOccurrenceGraphicalNodeEditPolicy extends DefaultGraphic
@Override
protected ICommand getAfterConnectionCompleteCommand(CreateConnectionViewAndElementRequest request, final TransactionalEditingDomain editingDomain) {
- if (DurationLinkUtil.isCreateDurationLink(request)) {
+ if (DurationLinkUtil.isCreateDurationLink(request) || GeneralOrderingUtil.isCreateGeneralOrderingLink(request)) {
return null; // Prevent the superclass from "Fixing" the anchors
}
return super.getAfterConnectionCompleteCommand(request, editingDomain);
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
index cf5c53a774b..d0b00458df0 100644
--- 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
@@ -27,14 +27,17 @@ import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.uml.diagram.sequence.figures.DurationLinkFigure;
import org.eclipse.papyrus.uml.diagram.sequence.util.DurationLinkUtil;
+import org.eclipse.papyrus.uml.diagram.sequence.util.GeneralOrderingUtil;
+import org.eclipse.papyrus.uml.diagram.sequence.util.OccurrenceSpecificationUtil;
import org.eclipse.papyrus.uml.service.types.utils.SequenceRequestConstant;
import org.eclipse.uml2.uml.ExecutionSpecification;
+import org.eclipse.uml2.uml.GeneralOrdering;
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}
+ * connection of DurationLinks or {@link GeneralOrdering} links to the Start/Finish Occurrences of the {@link ExecutionSpecification}
* </p>
*/
public class ExecutionSpecificationGraphicalNodeEditPolicy extends ElementCreationWithMessageEditPolicy {
@@ -42,13 +45,13 @@ public class ExecutionSpecificationGraphicalNodeEditPolicy extends ElementCreati
// Source (First half of the request)
@Override
protected Command getConnectionCreateCommand(CreateConnectionRequest request) {
- if (DurationLinkUtil.isCreateDurationLink(request)) {
+ if (DurationLinkUtil.isCreateDurationLink(request) || GeneralOrderingUtil.isCreateGeneralOrderingLink(request)) {
CreateRelationshipRequest createRequest = DurationLinkUtil.getCreateRelationshipRequest(request);
if (createRequest != null) {
OccurrenceSpecification sourceOccurrence;
ExecutionSpecification execSpec = getExecutionSpecification();
if (execSpec != null) {
- if (DurationLinkUtil.isStart(getHostFigure(), request)) {
+ if (OccurrenceSpecificationUtil.isStart(getHostFigure(), request)) {
sourceOccurrence = execSpec.getStart();
} else {
sourceOccurrence = execSpec.getFinish();
@@ -74,13 +77,13 @@ public class ExecutionSpecificationGraphicalNodeEditPolicy extends ElementCreati
// Target (Second half of the request)
@Override
protected Command getConnectionAndRelationshipCompleteCommand(CreateConnectionViewAndElementRequest request) {
- if (DurationLinkUtil.isCreateDurationLink(request)) {
- CreateRelationshipRequest createRequest = DurationLinkUtil.getCreateRelationshipRequest(request);
+ if (DurationLinkUtil.isCreateDurationLink(request) || GeneralOrderingUtil.isCreateGeneralOrderingLink(request)) {
+ CreateRelationshipRequest createRequest = OccurrenceSpecificationUtil.getCreateRelationshipRequest(request);
if (createRequest != null) {
OccurrenceSpecification targetOccurrence;
ExecutionSpecification execSpec = getExecutionSpecification();
if (execSpec != null) {
- if (DurationLinkUtil.isStart(getHostFigure(), request)) {
+ if (OccurrenceSpecificationUtil.isStart(getHostFigure(), request)) {
targetOccurrence = execSpec.getStart();
} else {
targetOccurrence = execSpec.getFinish();
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/MessageGraphicalNodeEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/MessageGraphicalNodeEditPolicy.java
index 2a7a2f0b09d..3c424928eeb 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/MessageGraphicalNodeEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/MessageGraphicalNodeEditPolicy.java
@@ -28,6 +28,8 @@ import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
import org.eclipse.papyrus.uml.diagram.sequence.figures.DurationLinkFigure;
import org.eclipse.papyrus.uml.diagram.sequence.util.DurationLinkUtil;
+import org.eclipse.papyrus.uml.diagram.sequence.util.GeneralOrderingUtil;
+import org.eclipse.papyrus.uml.diagram.sequence.util.OccurrenceSpecificationUtil;
import org.eclipse.papyrus.uml.service.types.utils.SequenceRequestConstant;
import org.eclipse.uml2.uml.Message;
import org.eclipse.uml2.uml.MessageEnd;
@@ -37,13 +39,13 @@ public class MessageGraphicalNodeEditPolicy extends GraphicalNodeEditPolicy {
// Source (First half of the request)
@Override
protected Command getConnectionCreateCommand(CreateConnectionRequest request) {
- if (DurationLinkUtil.isCreateDurationLink(request)) {
- CreateRelationshipRequest createRequest = DurationLinkUtil.getCreateRelationshipRequest(request);
+ if (DurationLinkUtil.isCreateDurationLink(request) || GeneralOrderingUtil.isCreateGeneralOrderingLink(request)) {
+ CreateRelationshipRequest createRequest = OccurrenceSpecificationUtil.getCreateRelationshipRequest(request);
if (createRequest != null) {
MessageEnd sourceOccurrence;
Message message = getMessage();
if (message != null) {
- sourceOccurrence = DurationLinkUtil.isSource(getHostFigure(), request) ? message.getSendEvent() : message.getReceiveEvent();
+ sourceOccurrence = OccurrenceSpecificationUtil.isSource(getHostFigure(), request) ? message.getSendEvent() : message.getReceiveEvent();
if (sourceOccurrence instanceof OccurrenceSpecification) {
@SuppressWarnings("unchecked")
Map<Object, Object> extendedData = request.getExtendedData();
@@ -59,13 +61,13 @@ public class MessageGraphicalNodeEditPolicy extends GraphicalNodeEditPolicy {
// Target (Second half of the request)
@Override
protected Command getConnectionAndRelationshipCompleteCommand(CreateConnectionViewAndElementRequest request) {
- if (DurationLinkUtil.isCreateDurationLink(request)) {
- CreateRelationshipRequest createRequest = DurationLinkUtil.getCreateRelationshipRequest(request);
+ if (DurationLinkUtil.isCreateDurationLink(request) || GeneralOrderingUtil.isCreateGeneralOrderingLink(request)) {
+ CreateRelationshipRequest createRequest = OccurrenceSpecificationUtil.getCreateRelationshipRequest(request);
if (createRequest != null) {
MessageEnd targetOccurrence;
Message message = getMessage();
if (message != null) {
- targetOccurrence = DurationLinkUtil.isSource(getHostFigure(), request) ? message.getSendEvent() : message.getReceiveEvent();
+ targetOccurrence = OccurrenceSpecificationUtil.isSource(getHostFigure(), request) ? message.getSendEvent() : message.getReceiveEvent();
if (targetOccurrence instanceof OccurrenceSpecification) {
@SuppressWarnings("unchecked")
Map<Object, Object> extendedData = request.getExtendedData();
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/CustomGeneralOrderingDescriptor.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/CustomGeneralOrderingDescriptor.java
index e19631c7c98..92b7a0241c8 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/CustomGeneralOrderingDescriptor.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/CustomGeneralOrderingDescriptor.java
@@ -91,9 +91,6 @@ public class CustomGeneralOrderingDescriptor extends GeneralOrderingDescriptor i
add(fAppliedStereotypeLabel);
}
- /**
- * @generated
- */
private RotatableDecoration createTargetDecoration() {
PolygonDecoration df = new PolygonDecoration();
df.setFill(true);
@@ -153,7 +150,6 @@ public class CustomGeneralOrderingDescriptor extends GeneralOrderingDescriptor i
* Set the middle decoration
*
* @see org.eclipse.draw2d.PolylineConnection#setTargetDecoration(org.eclipse.draw2d.RotatableDecoration)
- * @generated NOT
*/
public void setMiddleDecoration(RotatableDecoration dec) {
if (getMiddleDecoration() != null) {
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/DurationLinkUtil.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/DurationLinkUtil.java
index 600773dab24..fc688d87501 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/DurationLinkUtil.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/DurationLinkUtil.java
@@ -15,19 +15,10 @@ package org.eclipse.papyrus.uml.diagram.sequence.util;
import java.util.List;
-import org.eclipse.draw2d.Connection;
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.geometry.Point;
-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.requests.CreateConnectionRequest;
-import org.eclipse.gef.requests.CreateRequest;
import org.eclipse.gef.requests.ReconnectRequest;
-import org.eclipse.gmf.runtime.diagram.core.edithelpers.CreateElementRequestAdapter;
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.GraphicalNodeEditPolicy;
-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewAndElementRequest;
import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewRequest;
import org.eclipse.gmf.runtime.emf.type.core.IElementType;
import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
@@ -36,16 +27,11 @@ import org.eclipse.gmf.runtime.notation.Connector;
import org.eclipse.gmf.runtime.notation.IdentityAnchor;
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.anchors.AnchorConstants;
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.providers.UMLElementTypes;
import org.eclipse.uml2.uml.DurationConstraint;
import org.eclipse.uml2.uml.DurationObservation;
-import org.eclipse.uml2.uml.ExecutionSpecification;
-import org.eclipse.uml2.uml.Message;
-import org.eclipse.uml2.uml.MessageEnd;
-import org.eclipse.uml2.uml.OccurrenceSpecification;
/**
* <p>
@@ -53,7 +39,7 @@ import org.eclipse.uml2.uml.OccurrenceSpecification;
* {@link GraphicalNodeEditPolicy} or {@link EditPart}
* </p>
*/
-public class DurationLinkUtil {
+public class DurationLinkUtil extends OccurrenceSpecificationUtil {
/**
* Test if the given {@link CreateConnectionRequest} is creating a DurationLink
@@ -97,72 +83,6 @@ public class DurationLinkUtil {
return false;
}
- /**
- * Retrieve the semantic {@link CreateRelationshipRequest} from the given GEF {@link CreateConnectionRequest},
- * or <code>null</code>.
- *
- * @param request
- * @return
- */
- public static 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;
- }
-
- /**
- * 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
- */
- public static boolean isStart(IFigure targetFigure, CreateRequest createRequest) {
- Point location = createRequest.getLocation();
- Rectangle bounds = targetFigure.getBounds().getCopy();
- targetFigure.translateToAbsolute(bounds);
-
- double distanceToTop = location.getDistance(bounds.getTop());
- double distanceToBottom = location.getDistance(bounds.getBottom());
- return distanceToTop < distanceToBottom;
- }
-
- /**
- * 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 createRequest
- * The create 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, CreateRequest createRequest) {
- Point location = createRequest.getLocation();
- 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);
- return distanceToSource < distanceToTarget;
- }
- }
-
- // Default; shouldn't happen, unless the Message figure is invalid,
- // in which case we can't determine the source/target).
- return true;
- }
-
/**
* <p>
@@ -240,44 +160,4 @@ public class DurationLinkUtil {
}
}
- /**
- * Find the semantic {@link OccurrenceSpecification} represented by the given <code>connectorEnd</code>.
- * The connector should be the source or target of a DurationLink connector.
- *
- * @param connectorEnd
- * the source or target of a DurationLink connector
- * @param anchorTerminal
- * The connection anchor corresponding to the given connector end.
- * @return
- * The semantic occurrence specification represented by the given connector end (View), or null
- * if the view doesn't represent a valid {@link OccurrenceSpecification}.
- */
- public static OccurrenceSpecification findSemanticOccurrence(View connectorEnd, String anchorTerminal) {
- EObject semantic = connectorEnd.getElement();
- if (semantic instanceof OccurrenceSpecification) {
- return (OccurrenceSpecification) semantic;
- } else if (semantic instanceof ExecutionSpecification) {
- switch (anchorTerminal) {
- case AnchorConstants.START_TERMINAL:
- return ((ExecutionSpecification) semantic).getStart();
- case AnchorConstants.END_TERMINAL:
- return ((ExecutionSpecification) semantic).getFinish();
- default:
- return null;
- }
- } else if (semantic instanceof Message) {
- switch (anchorTerminal) {
- case AnchorConstants.START_TERMINAL:
- MessageEnd sendEvent = ((Message) semantic).getSendEvent();
- return sendEvent instanceof OccurrenceSpecification ? (OccurrenceSpecification) sendEvent : null;
- case AnchorConstants.END_TERMINAL:
- MessageEnd receiveEvent = ((Message) semantic).getReceiveEvent();
- return receiveEvent instanceof OccurrenceSpecification ? (OccurrenceSpecification) receiveEvent : null;
- default:
- return null;
- }
- }
- return null;
- }
-
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/GeneralOrderingUtil.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/GeneralOrderingUtil.java
new file mode 100644
index 00000000000..14dc93a014d
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/GeneralOrderingUtil.java
@@ -0,0 +1,146 @@
+/*****************************************************************************
+ * Copyright (c) 2018 CEA LIST 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.util;
+
+import java.util.List;
+import java.util.function.Predicate;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.requests.CreateConnectionRequest;
+import org.eclipse.gef.requests.ReconnectRequest;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.GraphicalNodeEditPolicy;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewRequest;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
+import org.eclipse.gmf.runtime.notation.Connector;
+import org.eclipse.gmf.runtime.notation.IdentityAnchor;
+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.edit.parts.GeneralOrderingEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
+import org.eclipse.uml2.uml.GeneralOrdering;
+import org.eclipse.uml2.uml.UMLPackage.Literals;
+
+/**
+ * <p>
+ * Util class related to the manipulation of GeneralOrdering Links, typically used by
+ * {@link GraphicalNodeEditPolicy} or {@link EditPart}
+ * </p>
+ */
+public class GeneralOrderingUtil extends OccurrenceSpecificationUtil {
+
+ /**
+ * Test if the given {@link CreateConnectionRequest} is creating a GeneralOrdering link
+ *
+ * @param request
+ * @return
+ */
+ public static boolean isCreateGeneralOrderingLink(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(Predicate.isEqual(UMLElementTypes.GeneralOrdering_Edge))) {
+ return true;
+ }
+ }
+ } else {
+ IElementType type = createElementRequest.getElementType();
+ return type == UMLElementTypes.GeneralOrdering_Edge;
+ }
+ return false;
+ }
+
+
+ /**
+ * Test if the given {@link CreateConnectionViewRequest} is creating a GeneralOrdering
+ *
+ * @param createRequest
+ * @return
+ */
+ public static boolean isGeneralOrderingLink(CreateConnectionViewRequest createRequest) {
+ String semanticHint = createRequest.getConnectionViewDescriptor().getSemanticHint();
+ return GeneralOrderingEditPart.VISUAL_ID.equals(semanticHint);
+ }
+
+ /**
+ * <p>
+ * Test if this request is trying to reconnect a GeneralOrderingLink edit part
+ * </p>
+ *
+ * @param request
+ * @return
+ *
+ * @see GeneralOrderingEditPart
+ */
+ public static boolean isGeneralOrderingLink(ReconnectRequest request) {
+ return request.getConnectionEditPart() instanceof GeneralOrderingEditPart;
+ }
+
+ /**
+ * <p>
+ * Test if the connector view is consistent with a new value.
+ * </p>
+ *
+ * @param connector
+ * A connector representing a GeneralOrdering Link in the Sequence Diagram
+ * @param setRequest
+ * A {@link SetRequest} modifying a GeneralOrdering 'before' or 'after' reference
+ * @return
+ * <code>true</code> if the Connector is consistent with the new proposed value, <code>false</code> if the connector
+ * is no longer consistent. If the result is <code>false</code>, actions should be taken to preserve the diagram
+ * consistency.
+ *
+ * @see GeneralOrdering#getBefore()
+ * @see GeneralOrdering#getAfter()
+ */
+ public static boolean isConsistent(Connector connector, SetRequest setRequest) {
+ Object newValue = setRequest.getValue();
+ EStructuralFeature feature = setRequest.getFeature();
+ if (feature != Literals.GENERAL_ORDERING__BEFORE && feature != Literals.GENERAL_ORDERING__AFTER) {
+ return true; // The set request doesn't affect that link; do nothing
+ }
+
+ if (newValue == null) { // Before or After was unset; the link is no longer consistent
+ return false;
+ }
+
+ View sourceView = connector.getSource();
+ String sourceAnchor = connector.getSourceAnchor() instanceof IdentityAnchor ? ((IdentityAnchor) connector.getSourceAnchor()).getId() : "";
+
+ View targetView = connector.getTarget();
+ String targetAnchor = connector.getSourceAnchor() instanceof IdentityAnchor ? ((IdentityAnchor) connector.getTargetAnchor()).getId() : "";
+
+ if (sourceView == null || targetView == null) {
+ return false;
+ }
+
+ if (feature == Literals.GENERAL_ORDERING__BEFORE) {
+ if (newValue != DurationLinkUtil.findSemanticOccurrence(sourceView, sourceAnchor)) {
+ return false;
+ }
+ } else if (feature == Literals.GENERAL_ORDERING__AFTER) {
+ if (newValue != DurationLinkUtil.findSemanticOccurrence(targetView, targetAnchor)) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+
+}
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
new file mode 100644
index 00000000000..46c9bb2f8fb
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/OccurrenceSpecificationUtil.java
@@ -0,0 +1,155 @@
+/*****************************************************************************
+ * Copyright (c) 2018 CEA LIST 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.util;
+
+import org.eclipse.draw2d.Connection;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.geometry.Point;
+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.requests.CreateConnectionRequest;
+import org.eclipse.gef.requests.CreateRequest;
+import org.eclipse.gmf.runtime.diagram.core.edithelpers.CreateElementRequestAdapter;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.GraphicalNodeEditPolicy;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewAndElementRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.uml.diagram.sequence.anchors.AnchorConstants;
+import org.eclipse.uml2.uml.ExecutionSpecification;
+import org.eclipse.uml2.uml.Message;
+import org.eclipse.uml2.uml.MessageEnd;
+import org.eclipse.uml2.uml.OccurrenceSpecification;
+
+/**
+ * <p>
+ * Util class related to the manipulation of Links targetting {@link OccurrenceSpecification}s,
+ * typically used by {@link GraphicalNodeEditPolicy} or {@link EditPart}.
+ * </p>
+ *
+ * @see DurationLinkUtil
+ * @see GeneralOrderingUtil
+ */
+public class OccurrenceSpecificationUtil {
+
+
+ /**
+ * Retrieve the semantic {@link CreateRelationshipRequest} from the given GEF {@link CreateConnectionRequest},
+ * or <code>null</code>.
+ *
+ * @param request
+ * @return
+ */
+ public static 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;
+ }
+
+ /**
+ * 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
+ */
+ public static boolean isStart(IFigure targetFigure, CreateRequest createRequest) {
+ Point location = createRequest.getLocation();
+ Rectangle bounds = targetFigure.getBounds().getCopy();
+ targetFigure.translateToAbsolute(bounds);
+
+ double distanceToTop = location.getDistance(bounds.getTop());
+ double distanceToBottom = location.getDistance(bounds.getBottom());
+ return distanceToTop < distanceToBottom;
+ }
+
+ /**
+ * 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 createRequest
+ * The create 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, CreateRequest createRequest) {
+ Point location = createRequest.getLocation();
+ 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);
+ return distanceToSource < distanceToTarget;
+ }
+ }
+
+ // Default; shouldn't happen, unless the Message figure is invalid,
+ // in which case we can't determine the source/target).
+ return true;
+ }
+
+
+
+ /**
+ * Find the semantic {@link OccurrenceSpecification} represented by the given <code>connectorEnd</code>.
+ * The connector should be the source or target of a DurationLink connector.
+ *
+ * @param connectorEnd
+ * the source or target of a DurationLink connector
+ * @param anchorTerminal
+ * The connection anchor corresponding to the given connector end.
+ * @return
+ * The semantic occurrence specification represented by the given connector end (View), or null
+ * if the view doesn't represent a valid {@link OccurrenceSpecification}.
+ */
+ public static OccurrenceSpecification findSemanticOccurrence(View connectorEnd, String anchorTerminal) {
+ EObject semantic = connectorEnd.getElement();
+ if (semantic instanceof OccurrenceSpecification) {
+ return (OccurrenceSpecification) semantic;
+ } else if (semantic instanceof ExecutionSpecification) {
+ switch (anchorTerminal) {
+ case AnchorConstants.START_TERMINAL:
+ return ((ExecutionSpecification) semantic).getStart();
+ case AnchorConstants.END_TERMINAL:
+ return ((ExecutionSpecification) semantic).getFinish();
+ default:
+ return null;
+ }
+ } else if (semantic instanceof Message) {
+ switch (anchorTerminal) {
+ case AnchorConstants.START_TERMINAL:
+ MessageEnd sendEvent = ((Message) semantic).getSendEvent();
+ return sendEvent instanceof OccurrenceSpecification ? (OccurrenceSpecification) sendEvent : null;
+ case AnchorConstants.END_TERMINAL:
+ MessageEnd receiveEvent = ((Message) semantic).getReceiveEvent();
+ return receiveEvent instanceof OccurrenceSpecification ? (OccurrenceSpecification) receiveEvent : null;
+ default:
+ return null;
+ }
+ }
+ return null;
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/model/SequenceDiagram.elementtypesconfigurations b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/model/SequenceDiagram.elementtypesconfigurations
index 8fb60f354be..2f2a8db69b0 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/model/SequenceDiagram.elementtypesconfigurations
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/model/SequenceDiagram.elementtypesconfigurations
@@ -13,4 +13,7 @@
<adviceBindingsConfigurations xmi:type="elementtypesconfigurations:AdviceBindingConfiguration" xmi:id="_fhVRcJP_EeiUfLwbDmLfuw" description="Graphical advice for preserving DurationObservationLink consistency" identifier="org.eclipse.papyrus.uml.diagram.sequence.edit.helpers.advice.DurationObservationLinkAdvice" editHelperAdviceClassName="org.eclipse.papyrus.uml.diagram.sequence.edit.helpers.advice.DurationObservationLinkAdvice">
<target xmi:type="elementtypesconfigurations:MetamodelTypeConfiguration" href="platform:/plugin/org.eclipse.papyrus.uml.service.types/model/uml.elementtypesconfigurations#org.eclipse.papyrus.uml.DurationObservation"/>
</adviceBindingsConfigurations>
+ <adviceBindingsConfigurations xmi:type="elementtypesconfigurations:AdviceBindingConfiguration" xmi:id="_oW2fQJYxEeies4N3OENAgQ" description="Graphical advice for preserving GeneralOrdering link consistency" identifier="org.eclipse.papyrus.uml.diagram.sequence.edit.helpers.advice.GeneralOrderingLinkHelperAdvice" editHelperAdviceClassName="org.eclipse.papyrus.uml.diagram.sequence.edit.helpers.advice.GeneralOrderingLinkHelperAdvice">
+ <target xmi:type="elementtypesconfigurations:MetamodelTypeConfiguration" href="platform:/plugin/org.eclipse.papyrus.uml.service.types/model/uml.elementtypesconfigurations#org.eclipse.papyrus.uml.GeneralOrdering"/>
+ </adviceBindingsConfigurations>
</elementtypesconfigurations:ElementTypeSetConfiguration>
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/DurationObservationLinkEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/DurationObservationLinkEditPart.java
index f31e4c98218..284ba86be78 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/DurationObservationLinkEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/DurationObservationLinkEditPart.java
@@ -13,6 +13,7 @@ package org.eclipse.papyrus.uml.diagram.sequence.edit.parts;
import org.eclipse.draw2d.Connection;
import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPolicy;
import org.eclipse.gmf.runtime.diagram.ui.editparts.ITreeBranchEditPart;
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
import org.eclipse.gmf.runtime.notation.View;
@@ -48,6 +49,7 @@ public class DurationObservationLinkEditPart extends UMLConnectionNodeEditPart i
installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy());
installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY,
new AppliedStereotypeLinkLabelDisplayEditPolicy());
+ removeEditPolicy(EditPolicy.CONNECTION_BENDPOINTS_ROLE);
}
/**

Back to the top