Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamille Letavernier2018-08-02 09:21:15 +0000
committerCamille Letavernier2018-08-02 09:22:02 +0000
commitb7078d24ac5ae5cfbf19509e359cfa7ef8f51093 (patch)
treea93709fc080b703131957042af70bce1ac35d657
parent77644f5e55fa51f5e192719b4590fd8629c6b9cb (diff)
downloadorg.eclipse.papyrus-b7078d24ac5ae5cfbf19509e359cfa7ef8f51093.tar.gz
org.eclipse.papyrus-b7078d24ac5ae5cfbf19509e359cfa7ef8f51093.tar.xz
org.eclipse.papyrus-b7078d24ac5ae5cfbf19509e359cfa7ef8f51093.zip
Bug 537561: [Sequence Diagram] Support GeneralOrdering as a Connection
between two events https://bugs.eclipse.org/bugs/show_bug.cgi?id=537561 - Generalize the behavior for connecting links to OccurrenceSpecifications (Initially done in Bug 536631 for DurationLinks) - Apply to GeneralOrdering - Add #before and #after references in the GeneralOrdering properties view Change-Id: I6ad54d2670073543257c22f954264a1e01bd6a94 Signed-off-by: Camille Letavernier <cletavernier@eclipsesource.com>
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/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
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/AbstractOccurrenceLinkEditHelperAdvice.java (renamed from plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/AbstractDurationEditHelperAdvice.java)31
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/DurationConstraintEditHelperAdvice.java6
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/DurationObservationEditHelperAdvice.java4
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/GeneralOrderingHelperAdvice.java150
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/Model/UML/ui/MultipleGeneralOrdering.xwt19
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/Model/UML/ui/SingleGeneralOrdering.xwt25
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/UMLModelElement.java8
21 files changed, 537 insertions, 353 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 794cfe688c7..dd1d541f41e 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
@@ -69,6 +69,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;
@@ -322,8 +324,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) {
@@ -344,8 +346,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);
@@ -408,8 +410,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) {
@@ -421,8 +423,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 003581ef642..6d5650c2887 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
@@ -55,6 +55,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;
@@ -64,8 +66,6 @@ import org.eclipse.ui.PlatformUI;
public abstract class AbstractMessageEditPart extends UMLConnectionNodeEditPart implements IKeyPressState {
- private List messageEventParts;
-
private boolean reorderMessages = false;
/**
@@ -197,7 +197,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;
@@ -256,7 +256,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)) {
@@ -285,7 +285,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;
}
@@ -408,14 +408,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);
@@ -427,14 +427,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 8b51a9795f4..2f839f387de 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
@@ -9,16 +9,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;
@@ -66,48 +63,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 235ca99823a..1b8798eded8 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
@@ -89,9 +89,6 @@ public class CustomGeneralOrderingDescriptor extends GeneralOrderingDescriptor i
add(fAppliedStereotypeLabel);
}
- /**
- * @generated
- */
private RotatableDecoration createTargetDecoration() {
PolygonDecoration df = new PolygonDecoration();
df.setFill(true);
@@ -151,7 +148,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);
}
/**
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/AbstractOccurrenceLinkEditHelperAdvice.java
index 9e69b4bfded..89de0b2ef90 100644
--- 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/AbstractOccurrenceLinkEditHelperAdvice.java
@@ -26,15 +26,17 @@ 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.GeneralOrdering;
import org.eclipse.uml2.uml.Message;
import org.eclipse.uml2.uml.OccurrenceSpecification;
/**
* <p>
- * Abstract advice for Durations ({@link DurationConstraint} or {@link DurationObservation})
+ * Abstract advice for links connecting {@link OccurrenceSpecification}
+ * ({@link DurationConstraint}, {@link DurationObservation}, {@link GeneralOrdering})
* </p>
*/
-public abstract class AbstractDurationEditHelperAdvice extends AbstractEditHelperAdvice {
+public abstract class AbstractOccurrenceLinkEditHelperAdvice extends AbstractEditHelperAdvice {
/**
* <p>
@@ -44,7 +46,7 @@ public abstract class AbstractDurationEditHelperAdvice extends AbstractEditHelpe
*
* <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},
+ * or a specific occurrence specification (For example, when creating a link on an {@link ExecutionSpecification},
* this method may return the specific start or finish {@link OccurrenceSpecification} instead of the {@link ExecutionSpecification}).
* </p>
*
@@ -68,7 +70,7 @@ public abstract class AbstractDurationEditHelperAdvice extends AbstractEditHelpe
*
* <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},
+ * or a specific occurrence specification (For example, when creating a link on an {@link ExecutionSpecification},
* this method may return the specific start or finish {@link OccurrenceSpecification} instead of the {@link ExecutionSpecification}).
* </p>
*
@@ -91,7 +93,7 @@ public abstract class AbstractDurationEditHelperAdvice extends AbstractEditHelpe
*
* <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},
+ * or a specific occurrence specification (For example, when creating a link on an {@link ExecutionSpecification},
* this method may return the specific start or finish {@link OccurrenceSpecification} instead of the {@link ExecutionSpecification}).
* </p>
*
@@ -111,7 +113,7 @@ public abstract class AbstractDurationEditHelperAdvice extends AbstractEditHelpe
*
* <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},
+ * or a specific occurrence specification (For example, when creating a link on an {@link ExecutionSpecification},
* this method may return the specific start or finish {@link OccurrenceSpecification} instead of the {@link ExecutionSpecification}).
* </p>
*
@@ -126,27 +128,27 @@ public abstract class AbstractDurationEditHelperAdvice extends AbstractEditHelpe
/**
* <p>
- * For Duration Links, the {@link CreateRelationshipRequest} will typically contain two distinct parameters
+ * For Links connecting {@link OccurrenceSpecification}s, 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
+ * thus the {@link Object} type), and will return the one that should be used as the source/target of the new 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).
+ * an {@link OccurrenceSpecification}, e.g. if the 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 source or target semantic element for a Link (Which may be different from
* the graphical element, since {@link OccurrenceSpecification} are not displayed on diagrams)
*
* @see CreateRelationshipRequest#getSource()
@@ -206,13 +208,12 @@ public abstract class AbstractDurationEditHelperAdvice extends AbstractEditHelpe
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) {
+ Element creationContainer = getCreationContainer((Element) editContext);
+ if (creationContainer != null) {
GetEditContextCommand command = new GetEditContextCommand(request);
- command.setEditContext(durationCreationContainer);
+ command.setEditContext(creationContainer);
return command;
}
}
@@ -225,6 +226,6 @@ public abstract class AbstractDurationEditHelperAdvice extends AbstractEditHelpe
return sourceOrTarget instanceof OccurrenceSpecification;
}
- protected abstract Element getDurationCreationContainer(Element targetElement);
+ protected abstract Element getCreationContainer(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 ab66612e12f..b952f34faed 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
@@ -34,7 +34,7 @@ import org.eclipse.uml2.uml.UMLFactory;
* @since 3.0
*
*/
-public class DurationConstraintEditHelperAdvice extends AbstractDurationEditHelperAdvice {
+public class DurationConstraintEditHelperAdvice extends AbstractOccurrenceLinkEditHelperAdvice {
/**
@@ -124,13 +124,13 @@ public class DurationConstraintEditHelperAdvice extends AbstractDurationEditHelp
}
/**
- * @see org.eclipse.papyrus.uml.service.types.helper.advice.AbstractDurationEditHelperAdvice#getDurationCreationContainer(org.eclipse.uml2.uml.Element)
+ * @see org.eclipse.papyrus.uml.service.types.helper.advice.AbstractDurationEditHelperAdvice#getCreationContainer(org.eclipse.uml2.uml.Element)
*
* @param targetElement
* @return
*/
@Override
- protected Element getDurationCreationContainer(Element targetElement) {
+ protected Element getCreationContainer(Element targetElement) {
return findInteraction(targetElement);
}
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 03f293c0d1c..1a7c94bba4e 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
@@ -25,7 +25,7 @@ import org.eclipse.uml2.uml.DurationObservation;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.NamedElement;
-public class DurationObservationEditHelperAdvice extends AbstractDurationEditHelperAdvice {
+public class DurationObservationEditHelperAdvice extends AbstractOccurrenceLinkEditHelperAdvice {
@Override
protected ICommand getAfterConfigureCommand(ConfigureRequest request) {
@@ -78,7 +78,7 @@ public class DurationObservationEditHelperAdvice extends AbstractDurationEditHel
}
@Override
- protected Element getDurationCreationContainer(Element targetElement) {
+ protected Element getCreationContainer(Element targetElement) {
return targetElement.getNearestPackage();
}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/GeneralOrderingHelperAdvice.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/GeneralOrderingHelperAdvice.java
index 361122073a9..6b0ae9211a9 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/GeneralOrderingHelperAdvice.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/GeneralOrderingHelperAdvice.java
@@ -1,15 +1,14 @@
/*****************************************************************************
- * Copyright (c) 2010 CEA LIST.
+ * Copyright (c) 2010, 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:
- *
* Yann Tanguy (CEA LIST) yann.tanguy@cea.fr - Initial API and implementation
+ * EclipseSource - Bug 537562
*
*****************************************************************************/
package org.eclipse.papyrus.uml.service.types.helper.advice;
@@ -18,132 +17,73 @@ package org.eclipse.papyrus.uml.service.types.helper.advice;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.ecore.EObject;
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.common.core.command.UnexecutableCommand;
-import org.eclipse.gmf.runtime.emf.type.core.commands.ConfigureElementCommand;
-import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice;
+import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
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.gmf.runtime.emf.type.core.requests.IEditCommandRequest;
-import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
-import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
-import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
-import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
+import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.GeneralOrdering;
+import org.eclipse.uml2.uml.Interaction;
import org.eclipse.uml2.uml.OccurrenceSpecification;
-import org.eclipse.uml2.uml.UMLPackage;
/**
- * This advice add automatically the constrained element (occurrence specification) for a time constraint
* @since 3.0
*/
-public class GeneralOrderingHelperAdvice extends AbstractEditHelperAdvice {
+public class GeneralOrderingHelperAdvice extends AbstractOccurrenceLinkEditHelperAdvice {
- /**
- * {@inheritDoc}
- */
@Override
- protected ICommand getBeforeConfigureCommand(final ConfigureRequest request) {
- return new ConfigureElementCommand(request) {
+ protected ICommand getAfterConfigureCommand(ConfigureRequest request) {
+ ICommand composite = new CompositeCommand("After Configure Command of GeneralOrdering");// $NON-NLS-0$
+ ICommand afterConfigureCommand = super.getAfterConfigureCommand(request);
+ if (null != afterConfigureCommand && afterConfigureCommand.canExecute()) {
+ composite.compose(afterConfigureCommand);
+ }
+
+ EObject toConfigure = request.getElementToConfigure();
+ if (false == toConfigure instanceof GeneralOrdering) {
+ return composite;
+ }
- protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
+ GeneralOrdering generalOrdering = (GeneralOrdering) toConfigure;
+ // Create the command to initialize the Before and After values
+ Element source = getSourceElement(request);
+ Element target = getTargetElement(request);
- final GeneralOrdering generalOrdering = (GeneralOrdering) request.getElementToConfigure();
- {//set Before
- Object paramObject = this.getRequest().getParameter(CreateRelationshipRequest.SOURCE);
- if (paramObject instanceof OccurrenceSpecification) {
- generalOrdering.setBefore((OccurrenceSpecification)paramObject);
- }
- }
- {//set After
+ if (source instanceof OccurrenceSpecification && target instanceof OccurrenceSpecification) {
+ final ICommand initOrderedElements = new AbstractTransactionalCommand(request.getEditingDomain(), "Init GeneralOrdering ordered elements", null) {
- Object paramObject = this.getRequest().getParameter(CreateRelationshipRequest.TARGET);
- if (paramObject instanceof OccurrenceSpecification) {
- generalOrdering.setAfter((OccurrenceSpecification)paramObject);
- }
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ generalOrdering.setBefore((OccurrenceSpecification) source);
+ generalOrdering.setAfter((OccurrenceSpecification) target);
+ return CommandResult.newOKCommandResult();
}
+ };
- return CommandResult.newOKCommandResult(generalOrdering);
- }
- };
+ composite.compose(initOrderedElements);
+ }
+
+ return composite;
}
- /**
- * <pre>
- * {@inheritDoc}
- *
- * Add a command to related association end during re-orient.
- *
- * </pre>
- */
@Override
- protected ICommand getBeforeReorientRelationshipCommand(ReorientRelationshipRequest request) {
-
- ICommand gmfCommand = super.getBeforeReorientRelationshipCommand(request);
- final GeneralOrdering generalOrdering = (GeneralOrdering) request.getRelationship();
-
- SetRequest setTypeRequest = null;
+ protected Element getCreationContainer(Element targetElement) {
+ return findInteraction(targetElement);
+ }
- if (request.getDirection() == ReorientRelationshipRequest.REORIENT_SOURCE) {
- Object paramObject =request.getNewRelationshipEnd();
- System.out.println(paramObject);
- if (paramObject instanceof OccurrenceSpecification) {
- setTypeRequest = new SetRequest((OccurrenceSpecification)paramObject, UMLPackage.eINSTANCE.getGeneralOrdering_Before(), generalOrdering);
- }
- else{
- return UnexecutableCommand.INSTANCE;
+ protected Interaction findInteraction(Element source) {
+ Element element = source;
+ while (element != null) {
+ if (element instanceof Interaction) {
+ return (Interaction) element;
}
+ element = element.getOwner();
}
- else{
- Object paramObject =request.getNewRelationshipEnd();
- if (paramObject instanceof OccurrenceSpecification) {
- setTypeRequest = new SetRequest((OccurrenceSpecification)paramObject, UMLPackage.eINSTANCE.getGeneralOrdering_After(), generalOrdering);
- }
- else{
- return UnexecutableCommand.INSTANCE;
- }
+ return null;
+ }
- if (setTypeRequest != null) {
- // Propagate parameters to the set request
- //setTypeRequest.addParameters(request.getParameters());
- IElementEditService provider = ElementEditServiceUtils.getCommandProvider(generalOrdering);
- if (provider != null) {
- ICommand setTypeCommand = provider.getEditCommand(setTypeRequest);
- gmfCommand = CompositeCommand.compose(gmfCommand, setTypeCommand);
- }
- }
- }
- return gmfCommand;
- }
- /**
- * @see org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice#approveRequest(org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest)
- *
- * @param request
- * @return
- */
- @Override
- public boolean approveRequest(IEditCommandRequest request) {
- if (request instanceof GetEditContextRequest){
- GetEditContextRequest contextRequest= (GetEditContextRequest)request;
- IEditCommandRequest editCommandRequest=contextRequest.getEditCommandRequest();
- if(editCommandRequest instanceof CreateRelationshipRequest){
- CreateRelationshipRequest relationshipRequest= (CreateRelationshipRequest)editCommandRequest;
- if (relationshipRequest.getSource() == null && relationshipRequest.getTarget() == null) {
- return false;
- }
- if (relationshipRequest.getSource() != null && false == relationshipRequest.getSource() instanceof OccurrenceSpecification) {
- return false;
- }
- if (relationshipRequest.getTarget() != null && false == relationshipRequest.getTarget() instanceof OccurrenceSpecification) {
- return false;
- }
- }
- }
- return super.approveRequest(request);
- }
}
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/Model/UML/ui/MultipleGeneralOrdering.xwt b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/Model/UML/ui/MultipleGeneralOrdering.xwt
index 2c29867de9c..daedfcded32 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/Model/UML/ui/MultipleGeneralOrdering.xwt
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/Model/UML/ui/MultipleGeneralOrdering.xwt
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
-<Composite xmlns:ppe="clr-namespace:org.eclipse.papyrus.infra.properties.ui.widgets"
+<Composite xmlns="http://www.eclipse.org/xwt/presentation"
+ xmlns:j="clr-namespace:java.lang"
+ xmlns:ppe="clr-namespace:org.eclipse.papyrus.infra.properties.ui.widgets"
xmlns:ppel="clr-namespace:org.eclipse.papyrus.infra.properties.ui.widgets.layout"
- xmlns="http://www.eclipse.org/xwt/presentation" xmlns:j="clr-namespace:java.lang"
xmlns:x="http://www.eclipse.org/xwt">
<Composite.layout>
<ppel:PropertiesLayout></ppel:PropertiesLayout>
@@ -10,6 +11,16 @@
<Composite.layout>
<ppel:PropertiesLayout></ppel:PropertiesLayout>
</Composite.layout>
- <ppe:EnumCombo input="{Binding}" property="UML:NamedElement:visibility"></ppe:EnumCombo>
+ <ppe:EnumCombo input="{Binding}"
+ property="UML:NamedElement:visibility"></ppe:EnumCombo>
</Composite>
-</Composite>
+ <Composite>
+ <Composite.layout>
+ <ppel:PropertiesLayout numColumns="2"></ppel:PropertiesLayout>
+ </Composite.layout>
+ <ppe:ReferenceDialog input="{Binding}"
+ property="UML:GeneralOrdering:before"></ppe:ReferenceDialog>
+ <ppe:ReferenceDialog input="{Binding}"
+ property="UML:GeneralOrdering:after"></ppe:ReferenceDialog>
+ </Composite>
+</Composite> \ No newline at end of file
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/Model/UML/ui/SingleGeneralOrdering.xwt b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/Model/UML/ui/SingleGeneralOrdering.xwt
index 5e73f3ed24b..9f5f9fb262e 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/Model/UML/ui/SingleGeneralOrdering.xwt
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/Model/UML/ui/SingleGeneralOrdering.xwt
@@ -1,7 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
-<Composite xmlns:ppel="clr-namespace:org.eclipse.papyrus.infra.properties.ui.widgets.layout"
- xmlns:j="clr-namespace:java.lang" xmlns:x="http://www.eclipse.org/xwt"
- xmlns:ppe="clr-namespace:org.eclipse.papyrus.infra.properties.ui.widgets" xmlns="http://www.eclipse.org/xwt/presentation">
+<Composite xmlns="http://www.eclipse.org/xwt/presentation"
+ xmlns:j="clr-namespace:java.lang"
+ xmlns:ppe="clr-namespace:org.eclipse.papyrus.infra.properties.ui.widgets"
+ xmlns:ppel="clr-namespace:org.eclipse.papyrus.infra.properties.ui.widgets.layout"
+ xmlns:x="http://www.eclipse.org/xwt">
<Composite.layout>
<ppel:PropertiesLayout></ppel:PropertiesLayout>
</Composite.layout>
@@ -9,13 +11,20 @@
<Composite.layout>
<ppel:PropertiesLayout></ppel:PropertiesLayout>
</Composite.layout>
- <ppe:StringEditor input="{Binding}" property="UML:NamedElement:name"></ppe:StringEditor>
- <ppe:StringEditor input="{Binding}" property="UML:NamedElement:label"></ppe:StringEditor>
+ <ppe:StringEditor input="{Binding}"
+ property="UML:NamedElement:name"></ppe:StringEditor>
+ <ppe:StringEditor input="{Binding}"
+ property="UML:NamedElement:label"></ppe:StringEditor>
+ <ppe:EnumCombo input="{Binding}"
+ property="UML:NamedElement:visibility"></ppe:EnumCombo>
</Composite>
<Composite>
<Composite.layout>
- <ppel:PropertiesLayout></ppel:PropertiesLayout>
+ <ppel:PropertiesLayout numColumns="2"></ppel:PropertiesLayout>
</Composite.layout>
- <ppe:EnumCombo input="{Binding}" property="UML:NamedElement:visibility"></ppe:EnumCombo>
+ <ppe:ReferenceDialog input="{Binding}"
+ property="UML:GeneralOrdering:before"></ppe:ReferenceDialog>
+ <ppe:ReferenceDialog input="{Binding}"
+ property="UML:GeneralOrdering:after"></ppe:ReferenceDialog>
</Composite>
-</Composite>
+</Composite> \ No newline at end of file
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/UMLModelElement.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/UMLModelElement.java
index 9a0f9a53124..a649f0f752c 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/UMLModelElement.java
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/UMLModelElement.java
@@ -205,7 +205,7 @@ public class UMLModelElement extends EMFModelElement {
.map(interaction -> element -> isAncestor(interaction, element));
}
- return isValid.map(
+ return isValid.<UMLContentProvider> map(
valid -> new UMLContentProvider(source, feature, null, resourceSet) {
@Override
public boolean isValidValue(Object element) {
@@ -234,7 +234,7 @@ public class UMLModelElement extends EMFModelElement {
EReference reference = (EReference) feature;
if (reference == UMLPackage.eINSTANCE.getMessage_Argument()) {
if (source instanceof Message) {
- Set<ParameterDirectionKind> directions = new HashSet<ParameterDirectionKind>();
+ Set<ParameterDirectionKind> directions = new HashSet<>();
switch (((Message) source).getMessageSort()) {
case REPLY_LITERAL:
directions.add(OUT_LITERAL);
@@ -277,7 +277,7 @@ public class UMLModelElement extends EMFModelElement {
protected List<EClass> getAvailableEClasses() {
// according to the UML norm 2.5, section 17.4.3.1
// The signature of a Message refers to either an Operation or a Signal.
- final List<EClass> eClasses = new ArrayList<EClass>();
+ final List<EClass> eClasses = new ArrayList<>();
eClasses.add(UMLPackage.eINSTANCE.getOperation());
eClasses.add(UMLPackage.eINSTANCE.getSignal());
return eClasses;
@@ -323,7 +323,7 @@ public class UMLModelElement extends EMFModelElement {
/**
* The set of all EStructuralFeature representing subsets of {@link Namespace#getOwnedRules()}
*/
- public static final Set<EStructuralFeature> ownedRuleSubsets = new HashSet<EStructuralFeature>();
+ public static final Set<EStructuralFeature> ownedRuleSubsets = new HashSet<>();
static {
// Behavior

Back to the top