Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamille Letavernier2018-07-30 07:48:53 -0400
committerCamille Letavernier2018-09-24 06:48:21 -0400
commit3c9aff73f121f786391eeb5de1d7adc8740e48ad (patch)
treeb2c41a0d432741171bc7836fe86432e6fb2ec051
parent1a1ca0c51e44297008efcd0fe6cb7aec20a4199e (diff)
downloadorg.eclipse.papyrus-3c9aff73f121f786391eeb5de1d7adc8740e48ad.tar.gz
org.eclipse.papyrus-3c9aff73f121f786391eeb5de1d7adc8740e48ad.tar.xz
org.eclipse.papyrus-3c9aff73f121f786391eeb5de1d7adc8740e48ad.zip
Bug 536641 [Sequence Diagram] Durations can only be created on
OccurrenceSpecifications - Add support for Messages (Send/Receive) - Add support for DestructionOccurrences Change-Id: I0ba9dc5bf1c8892f395cb536ff7d912e22771301 Signed-off-by: Camille Letavernier <cletavernier@eclipsesource.com>
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/AbstractMessageEditPart.java93
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CDestructionOccurrenceSpecificationEditPart.java95
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomDestructionOccurrenceSpecificationEditPart.java97
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/DestructionOccurrenceGraphicalNodeEditPolicy.java84
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/ExecutionSpecificationGraphicalNodeEditPolicy.java6
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/MessageGraphicalNodeEditPolicy.java152
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/UpdateWeakReferenceForMessageSpecEditPolicy.java6
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/DestructionEventFigure.java17
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/DestructionEventNodePlate.java57
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/MessageFigure.java14
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/CustomEditPartProvider.java10
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/CustomViewProvider.java7
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/PostEditPolicyProvider.java4
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/LifeLineGraphicalNodeEditPolicy.java7
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/DurationConstraintEditHelperAdvice.java4
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/DurationObservationEditHelperAdvice.java4
16 files changed, 532 insertions, 125 deletions
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 ab6208ae860..68facc7f0a0 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
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2017 CEA LIST and others.
+ * Copyright (c) 2017 CEA LIST, EclipseSource and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -11,13 +11,17 @@
* Contributors:
* CEA LIST - Initial API and implementation
* Celine Janssens (ALL4TEC) - Bug 507348
+ * EclipseSource - Bug 536631
*
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.sequence.edit.parts;
import java.util.List;
+import org.eclipse.draw2d.Connection;
+import org.eclipse.draw2d.ConnectionAnchor;
import org.eclipse.draw2d.Cursors;
+import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.PointList;
import org.eclipse.emf.common.notify.Notification;
@@ -25,10 +29,13 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.gef.ConnectionEditPart;
import org.eclipse.gef.DragTracker;
import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPolicy;
import org.eclipse.gef.Request;
+import org.eclipse.gef.requests.CreateRequest;
import org.eclipse.gef.requests.ReconnectRequest;
import org.eclipse.gmf.runtime.diagram.ui.editparts.LabelEditPart;
import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramColorRegistry;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewRequest;
import org.eclipse.gmf.runtime.diagram.ui.requests.CreateUnspecifiedTypeConnectionRequest;
import org.eclipse.gmf.runtime.diagram.ui.requests.CreateUnspecifiedTypeRequest;
import org.eclipse.gmf.runtime.draw2d.ui.geometry.LineSeg;
@@ -39,6 +46,9 @@ import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
import org.eclipse.papyrus.uml.diagram.common.editparts.UMLConnectionNodeEditPart;
import org.eclipse.papyrus.uml.diagram.common.figure.edge.UMLEdgeFigure;
+import org.eclipse.papyrus.uml.diagram.sequence.anchors.ConnectionSourceAnchor;
+import org.eclipse.papyrus.uml.diagram.sequence.anchors.ConnectionTargetAnchor;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.MessageGraphicalNodeEditPolicy;
import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.MessageLabelEditPolicy;
import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.SequenceReferenceEditPolicy;
import org.eclipse.papyrus.uml.diagram.sequence.figures.MessageDelete;
@@ -273,6 +283,7 @@ public abstract class AbstractMessageEditPart extends UMLConnectionNodeEditPart
// Ordering Message Occurrence Specification. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=403233
installEditPolicy(ConnectRectangleToGridEditPolicy.CONNECT_TO_GRILLING_MANAGEMENT, new ConnectMessageToGridEditPolicy());
installEditPolicy(SequenceReferenceEditPolicy.SEQUENCE_REFERENCE, new SequenceReferenceEditPolicy());
+ installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new MessageGraphicalNodeEditPolicy());
}
@Override
@@ -394,4 +405,84 @@ public abstract class AbstractMessageEditPart extends UMLConnectionNodeEditPart
super.refreshFont();
}
}
+
+ @Override
+ public ConnectionAnchor getSourceConnectionAnchor(Request request) {
+ if (request instanceof CreateUnspecifiedTypeConnectionRequest) {
+ CreateUnspecifiedTypeConnectionRequest createRequest = (CreateUnspecifiedTypeConnectionRequest) request;
+ List<?> relationshipTypes = createRequest.getElementTypes();
+ for (Object type : relationshipTypes) {
+ if (UMLElementTypes.DurationConstraint_Edge.equals(type) || UMLElementTypes.DurationObservation_Edge.equals(type)) {
+ return isSource(createRequest) ? new ConnectionSourceAnchor(getPrimaryShape()) : new ConnectionTargetAnchor(getPrimaryShape());
+ }
+ }
+ } else if (request instanceof CreateConnectionViewRequest) {
+ CreateConnectionViewRequest createRequest = (CreateConnectionViewRequest) request;
+ if (isDurationLink(createRequest)) {
+ return isSource(createRequest) ? new ConnectionSourceAnchor(getPrimaryShape()) : new ConnectionTargetAnchor(getPrimaryShape());
+ }
+ }
+ return super.getSourceConnectionAnchor(request);
+ }
+
+ @Override
+ public ConnectionAnchor getTargetConnectionAnchor(Request request) {
+ if (request instanceof CreateUnspecifiedTypeConnectionRequest) {
+ CreateUnspecifiedTypeConnectionRequest createRequest = (CreateUnspecifiedTypeConnectionRequest) request;
+ List<?> relationshipTypes = createRequest.getElementTypes();
+ for (Object type : relationshipTypes) {
+ if (UMLElementTypes.DurationConstraint_Edge.equals(type) || UMLElementTypes.DurationObservation_Edge.equals(type)) {
+ return isSource(createRequest) ? new ConnectionSourceAnchor(getPrimaryShape()) : new ConnectionTargetAnchor(getPrimaryShape());
+ }
+ }
+ } else if (request instanceof CreateConnectionViewRequest) {
+ CreateConnectionViewRequest createRequest = (CreateConnectionViewRequest) request;
+ if (isDurationLink(createRequest)) {
+ return isSource(createRequest) ? new ConnectionSourceAnchor(getPrimaryShape()) : new ConnectionTargetAnchor(getPrimaryShape());
+ }
+ }
+ return super.getTargetConnectionAnchor(request);
+ }
+
+ /**
+ * Test whether the given request is closer to the source or to the target point of 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
+ */
+ private boolean isSource(CreateRequest createRequest) {
+ Point location = createRequest.getLocation();
+ IFigure connection = getPrimaryShape();
+ if (connection != null) {
+ 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;
+ }
+
+ /**
+ * @param createRequest
+ * @return
+ */
+ private boolean isDurationLink(CreateConnectionViewRequest createRequest) {
+ String semanticHint = createRequest.getConnectionViewDescriptor().getSemanticHint();
+ switch (semanticHint) {
+ case DurationConstraintLinkEditPart.VISUAL_ID:
+ case DurationObservationLinkEditPart.VISUAL_ID:
+ return true;
+ }
+ return false;
+ }
+
}
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
new file mode 100644
index 00000000000..e42e292e62b
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CDestructionOccurrenceSpecificationEditPart.java
@@ -0,0 +1,95 @@
+/*****************************************************************************
+ * Copyright (c) 2018 CEA LIST, EclipseSource and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * EclipseSource - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.diagram.sequence.edit.parts;
+
+import java.util.List;
+
+import org.eclipse.draw2d.ConnectionAnchor;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.Request;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewRequest;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateUnspecifiedTypeConnectionRequest;
+import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.uml.diagram.sequence.anchors.CenterAnchor;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.DestructionOccurrenceGraphicalNodeEditPolicy;
+import org.eclipse.papyrus.uml.diagram.sequence.figures.DestructionEventNodePlate;
+import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
+
+public class CDestructionOccurrenceSpecificationEditPart extends DestructionOccurrenceSpecificationEditPart {
+
+ public CDestructionOccurrenceSpecificationEditPart(View view) {
+ super(view);
+ }
+
+ @Override
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DestructionOccurrenceGraphicalNodeEditPolicy());
+ }
+
+ @Override
+ public ConnectionAnchor getTargetConnectionAnchor(Request request) {
+ if (request instanceof CreateUnspecifiedTypeConnectionRequest) {
+ CreateUnspecifiedTypeConnectionRequest createRequest = (CreateUnspecifiedTypeConnectionRequest) request;
+ List<?> relationshipTypes = createRequest.getElementTypes();
+ for (Object type : relationshipTypes) {
+ if (UMLElementTypes.DurationConstraint_Edge.equals(type) || UMLElementTypes.DurationObservation_Edge.equals(type)) {
+ return new CenterAnchor(getFigure());
+ }
+ }
+ } else if (request instanceof CreateConnectionViewRequest) {
+ CreateConnectionViewRequest createRequest = (CreateConnectionViewRequest) request;
+ if (isDurationLink(createRequest)) {
+ return new CenterAnchor(getFigure());
+ }
+ }
+ return super.getTargetConnectionAnchor(request);
+ }
+
+ @Override
+ public ConnectionAnchor getSourceConnectionAnchor(Request request) {
+ if (request instanceof CreateUnspecifiedTypeConnectionRequest) {
+ CreateUnspecifiedTypeConnectionRequest createRequest = (CreateUnspecifiedTypeConnectionRequest) request;
+ List<?> relationshipTypes = createRequest.getElementTypes();
+ for (Object type : relationshipTypes) {
+ if (UMLElementTypes.DurationConstraint_Edge.equals(type) || UMLElementTypes.DurationObservation_Edge.equals(type)) {
+ return new CenterAnchor(getFigure());
+ }
+ }
+ } else if (request instanceof CreateConnectionViewRequest) {
+ CreateConnectionViewRequest createRequest = (CreateConnectionViewRequest) request;
+ if (isDurationLink(createRequest)) {
+ return new CenterAnchor(getFigure());
+ }
+ }
+ return super.getSourceConnectionAnchor(request);
+ }
+
+ @Override
+ protected NodeFigure createNodePlate() {
+ // Use a custom NodePlate to support the Destruction's CenterAnchor
+ DestructionEventNodePlate nodePlate = new DestructionEventNodePlate(40, 40);
+ return nodePlate;
+ }
+
+ private boolean isDurationLink(CreateConnectionViewRequest createRequest) {
+ String semanticHint = createRequest.getConnectionViewDescriptor().getSemanticHint();
+ switch (semanticHint) {
+ case DurationConstraintLinkEditPart.VISUAL_ID:
+ case DurationObservationLinkEditPart.VISUAL_ID:
+ 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/parts/CustomDestructionOccurrenceSpecificationEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomDestructionOccurrenceSpecificationEditPart.java
deleted file mode 100644
index d33fb72202a..00000000000
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomDestructionOccurrenceSpecificationEditPart.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 CEA
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Soyatec - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.sequence.edit.parts;
-
-import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure;
-import org.eclipse.gmf.runtime.notation.NotationPackage;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IPapyrusEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.AppliedStereotypeCommentCreationEditPolicyEx;
-import org.eclipse.papyrus.uml.diagram.stereotype.edition.editpolicies.AppliedStereotypeCommentEditPolicy;
-
-/**
- * Add implementing interface IPapyrusEditPart to displaying Stereotypes.
- *
- * @author Jin Liu (jin.liu@soyatec.com)
- */
-public class CustomDestructionOccurrenceSpecificationEditPart extends DestructionOccurrenceSpecificationEditPart implements IPapyrusEditPart {
-
- /**
- * Constructor.
- *
- * @param view
- */
- public CustomDestructionOccurrenceSpecificationEditPart(View view) {
- super(view);
- }
-
- @Override
- protected NodeFigure createNodePlate() {
- NodeFigure result = super.createNodePlate();
- // FIXME: workaround for #154536
- result.getBounds().setSize(result.getPreferredSize());
- return result;
- }
-
- /**
- * @Override
- */
- @Override
- protected void createDefaultEditPolicies() {
- super.createDefaultEditPolicies();
- // install a editpolicy to display stereotypes
- installEditPolicy(AppliedStereotypeCommentEditPolicy.APPLIED_STEREOTYPE_COMMENT, new AppliedStereotypeCommentCreationEditPolicyEx());
- }
-
- @Override
- protected void refreshBounds() {
- if (getBorderItemLocator() != null) {
- int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue();
- int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue();
- Point loc = new Point(x, y);
- int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue();
- int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue();
- Dimension size = new Dimension(width, height);
- if (width != -1 && height != -1) {
- getFigure().setBounds(new Rectangle(loc, size));
- }
- getBorderItemLocator().setConstraint(new Rectangle(loc, size));
- } else {
- super.refreshBounds();
- }
- }
-
- @Override
- protected void handleNotificationEvent(Notification notification) {
- super.handleNotificationEvent(notification);
- Object feature = notification.getFeature();
- if ((getModel() != null) && (getModel() == notification.getNotifier())) {
- if (NotationPackage.eINSTANCE.getLineStyle_LineWidth().equals(feature)) {
- refreshLineWidth();
- }
- }
- }
-
- @Override
- protected void refreshVisuals() {
- super.refreshVisuals();
- refreshLineWidth();
- }
-}
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
new file mode 100644
index 00000000000..9b71ae794b2
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/DestructionOccurrenceGraphicalNodeEditPolicy.java
@@ -0,0 +1,84 @@
+/*****************************************************************************
+ * Copyright (c) 2018 CEA LIST, EclipseSource and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * EclipseSource - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.sequence.edit.policies;
+
+import java.util.List;
+
+import org.eclipse.draw2d.Connection;
+import org.eclipse.draw2d.PolylineConnection;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.requests.CreateConnectionRequest;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.diagram.core.edithelpers.CreateElementRequestAdapter;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewAndElementRequest;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultGraphicalNodeEditPolicy;
+import org.eclipse.papyrus.infra.gmfdiag.common.service.palette.AspectUnspecifiedTypeConnectionTool.CreateAspectUnspecifiedTypeConnectionRequest;
+import org.eclipse.papyrus.uml.diagram.sequence.figures.DurationLinkFigure;
+import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
+
+/**
+ * An extended {@link DefaultGraphicalNodeEditPolicy} which supports creation of DurationLinks
+ */
+public class DestructionOccurrenceGraphicalNodeEditPolicy extends DefaultGraphicalNodeEditPolicy {
+
+ @Override
+ protected ICommand getAfterConnectionCompleteCommand(CreateConnectionViewAndElementRequest request, final TransactionalEditingDomain editingDomain) {
+ if (isCreateDurationLink(request)) {
+ return null; // Prevent the superclass from "Fixing" the anchors
+ }
+ return super.getAfterConnectionCompleteCommand(request, editingDomain);
+ }
+
+ @Override
+ protected Connection createDummyConnection(Request req) {
+ if (req instanceof CreateConnectionRequest && isCreateDurationLink((CreateConnectionRequest) req)) {
+ return new DurationLinkFigure();
+ }
+ return new PolylineConnection();
+ }
+
+ private boolean isCreateDurationLink(CreateConnectionRequest request) {
+ CreateRelationshipRequest createElementRequest = getCreateRelationshipRequest(request);
+ if (createElementRequest == null) {
+ if (request instanceof CreateAspectUnspecifiedTypeConnectionRequest) {
+ CreateAspectUnspecifiedTypeConnectionRequest createRequest = (CreateAspectUnspecifiedTypeConnectionRequest) request;
+ List<?> types = createRequest.getElementTypes();
+ if (types.stream().allMatch(
+ type -> type == UMLElementTypes.DurationConstraint_Edge ||
+ type == UMLElementTypes.DurationObservation_Edge)) {
+ return true;
+ }
+ }
+ } else {
+ IElementType type = createElementRequest.getElementType();
+ return type == UMLElementTypes.DurationConstraint_Edge || type == UMLElementTypes.DurationObservation_Edge;
+ }
+ return false;
+ }
+
+ private CreateRelationshipRequest getCreateRelationshipRequest(CreateConnectionRequest request) {
+ if (false == request instanceof CreateConnectionViewAndElementRequest) {
+ return null;
+ }
+ CreateElementRequestAdapter requestAdapter = ((CreateConnectionViewAndElementRequest) request).getConnectionViewAndElementDescriptor().getCreateElementRequestAdapter();
+ if (requestAdapter == null) {
+ return null;
+ }
+ CreateRelationshipRequest createElementRequest = (CreateRelationshipRequest) requestAdapter.getAdapter(CreateRelationshipRequest.class);
+ return createElementRequest;
+ }
+}
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 541df0f2538..5ebddd4714d 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
@@ -124,9 +124,11 @@ public class ExecutionSpecificationGraphicalNodeEditPolicy extends ElementCreati
return true;
}
}
+ } else {
+ IElementType type = createElementRequest.getElementType();
+ return type == UMLElementTypes.DurationConstraint_Edge || type == UMLElementTypes.DurationObservation_Edge;
}
- IElementType type = createElementRequest.getElementType();
- return type == UMLElementTypes.DurationConstraint_Edge || type == UMLElementTypes.DurationObservation_Edge;
+ return false;
}
private CreateRelationshipRequest getCreateRelationshipRequest(CreateConnectionRequest request) {
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
new file mode 100644
index 00000000000..6e1c8ca2a94
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/MessageGraphicalNodeEditPolicy.java
@@ -0,0 +1,152 @@
+/*****************************************************************************
+ * Copyright (c) 2018 CEA LIST, EclipseSource and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * EclipseSource - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.diagram.sequence.edit.policies;
+
+import java.util.List;
+
+import org.eclipse.draw2d.Connection;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.PolylineConnection;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.PointList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.commands.Command;
+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.IElementType;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.papyrus.infra.gmfdiag.common.service.palette.AspectUnspecifiedTypeConnectionTool.CreateAspectUnspecifiedTypeConnectionRequest;
+import org.eclipse.papyrus.uml.diagram.sequence.figures.DurationLinkFigure;
+import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.service.types.utils.SequenceRequestConstant;
+import org.eclipse.uml2.uml.Message;
+import org.eclipse.uml2.uml.MessageEnd;
+import org.eclipse.uml2.uml.OccurrenceSpecification;
+
+public class MessageGraphicalNodeEditPolicy extends GraphicalNodeEditPolicy {
+ // Source (First half of the request)
+ @Override
+ protected Command getConnectionCreateCommand(CreateConnectionRequest request) {
+ if (isCreateDurationLink(request)) {
+ CreateRelationshipRequest createRequest = getCreateRelationshipRequest(request);
+ if (createRequest != null) {
+ MessageEnd sourceOccurrence;
+ Message message = getMessage();
+ if (message != null) {
+ sourceOccurrence = isSource(request) ? message.getSendEvent() : message.getReceiveEvent();
+ if (sourceOccurrence instanceof OccurrenceSpecification) {
+ request.getExtendedData().put(SequenceRequestConstant.SOURCE_OCCURRENCE, sourceOccurrence);
+ createRequest.setParameter(SequenceRequestConstant.SOURCE_OCCURRENCE, sourceOccurrence);
+ }
+ }
+ }
+ }
+ return super.getConnectionCreateCommand(request);
+ }
+
+ // Target (Second half of the request)
+ @Override
+ protected Command getConnectionAndRelationshipCompleteCommand(CreateConnectionViewAndElementRequest request) {
+ if (isCreateDurationLink(request)) {
+ CreateRelationshipRequest createRequest = getCreateRelationshipRequest(request);
+ if (createRequest != null) {
+ MessageEnd targetOccurrence;
+ Message message = getMessage();
+ if (message != null) {
+ targetOccurrence = isSource(request) ? message.getSendEvent() : message.getReceiveEvent();
+ if (targetOccurrence instanceof OccurrenceSpecification) {
+ request.getExtendedData().put(SequenceRequestConstant.TARGET_OCCURRENCE, targetOccurrence);
+ createRequest.setParameter(SequenceRequestConstant.TARGET_OCCURRENCE, targetOccurrence);
+ }
+ }
+ }
+ }
+ return super.getConnectionAndRelationshipCompleteCommand(request);
+ }
+
+ /**
+ * Test whether the given request is closer to the source or to the target point of 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
+ */
+ private boolean isSource(CreateRequest createRequest) {
+ Point location = createRequest.getLocation();
+ IFigure connection = getHostFigure();
+ 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;
+ }
+
+ private Message getMessage() {
+ EObject model = EMFHelper.getEObject(getHost());
+ return model instanceof Message ? (Message) model : null;
+ }
+
+ private boolean isCreateDurationLink(CreateConnectionRequest request) {
+ CreateRelationshipRequest createElementRequest = getCreateRelationshipRequest(request);
+ if (createElementRequest == null) {
+ if (request instanceof CreateAspectUnspecifiedTypeConnectionRequest) {
+ CreateAspectUnspecifiedTypeConnectionRequest createRequest = (CreateAspectUnspecifiedTypeConnectionRequest) request;
+ List<?> types = createRequest.getElementTypes();
+ if (types.stream().allMatch(
+ type -> type == UMLElementTypes.DurationConstraint_Edge ||
+ type == UMLElementTypes.DurationObservation_Edge)) {
+ return true;
+ }
+ }
+ } else {
+ IElementType type = createElementRequest.getElementType();
+ return type == UMLElementTypes.DurationConstraint_Edge || type == UMLElementTypes.DurationObservation_Edge;
+ }
+ return false;
+ }
+
+ private CreateRelationshipRequest getCreateRelationshipRequest(CreateConnectionRequest request) {
+ if (false == request instanceof CreateConnectionViewAndElementRequest) {
+ return null;
+ }
+ CreateElementRequestAdapter requestAdapter = ((CreateConnectionViewAndElementRequest) request).getConnectionViewAndElementDescriptor().getCreateElementRequestAdapter();
+ if (requestAdapter == null) {
+ return null;
+ }
+ CreateRelationshipRequest createElementRequest = (CreateRelationshipRequest) requestAdapter.getAdapter(CreateRelationshipRequest.class);
+ return createElementRequest;
+ }
+
+ @Override
+ protected Connection createDummyConnection(Request req) {
+ if (req instanceof CreateConnectionRequest && isCreateDurationLink((CreateConnectionRequest) req)) {
+ return new DurationLinkFigure();
+ }
+ return new PolylineConnection();
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/UpdateWeakReferenceForMessageSpecEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/UpdateWeakReferenceForMessageSpecEditPolicy.java
index bac5c403d1b..73c501b53b0 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/UpdateWeakReferenceForMessageSpecEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/UpdateWeakReferenceForMessageSpecEditPolicy.java
@@ -31,7 +31,7 @@ import org.eclipse.gef.RequestConstants;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.commands.CompoundCommand;
import org.eclipse.gef.requests.ReconnectRequest;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewAndElementRequest;
import org.eclipse.gmf.runtime.draw2d.ui.figures.PolylineConnectionEx;
import org.eclipse.gmf.runtime.notation.View;
@@ -132,8 +132,8 @@ public class UpdateWeakReferenceForMessageSpecEditPolicy extends UpdateWeakRefer
for (OccurrenceSpecification nextEvent : nextEventsFromPosition) {
UMLDiagramEditorPlugin.log.trace(LogOptions.SEQUENCE_DEBUG, "\tNext Event: " + nextEvent);
- GraphicalEditPart sourceLifeLineEP = (GraphicalEditPart) createRequest.getSourceEditPart();
- GraphicalEditPart targetLifeLineEP = (GraphicalEditPart) createRequest.getTargetEditPart();
+ IGraphicalEditPart sourceLifeLineEP = (IGraphicalEditPart) createRequest.getSourceEditPart();
+ IGraphicalEditPart targetLifeLineEP = (IGraphicalEditPart) createRequest.getTargetEditPart();
ArrayList<EditPart> senderList = SenderRequestUtils.getSenders(request);
List<?> connectionsAndChildren = new ArrayList<>();
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/DestructionEventFigure.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/DestructionEventFigure.java
index a4224978805..cf06364d3eb 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/DestructionEventFigure.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/DestructionEventFigure.java
@@ -14,8 +14,7 @@
* Jacques Lescot (Anyware Technologies),
* Thomas Friol (Anyware Technologies),
* Nicolas Lalevee (Anyware Technologies) - initial API and implementation
- * EclipseSource - Bug 536638
- *
+ * EclipseSource - Bug 536638, Bug 536641
****************************************************************************/
package org.eclipse.papyrus.uml.diagram.sequence.figures;
@@ -65,12 +64,6 @@ public class DestructionEventFigure extends DefaultSizeNodeFigure {
repaint();
}
- /**
- * @see org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure#getConnectionAnchor(java.lang.String)
- *
- * @param terminal
- * @return
- */
@Override
public ConnectionAnchor getConnectionAnchor(String terminal) {
if (AnchorConstants.CENTER_TERMINAL.equals(terminal)) {
@@ -79,4 +72,12 @@ public class DestructionEventFigure extends DefaultSizeNodeFigure {
return super.getConnectionAnchor(terminal);
}
+ @Override
+ public String getConnectionAnchorTerminal(ConnectionAnchor c) {
+ if (c instanceof CenterAnchor) {
+ return AnchorConstants.CENTER_TERMINAL;
+ }
+ return super.getConnectionAnchorTerminal(c);
+ }
+
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/DestructionEventNodePlate.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/DestructionEventNodePlate.java
new file mode 100644
index 00000000000..6612cb05b58
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/DestructionEventNodePlate.java
@@ -0,0 +1,57 @@
+/*****************************************************************************
+ * Copyright (c) 2018 CEA LIST, EclipseSource and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * EclipseSource - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.diagram.sequence.figures;
+
+import org.eclipse.draw2d.ConnectionAnchor;
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.LinkLFSVGNodePlateFigure;
+import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.RoundedRectangleNodePlateFigure;
+import org.eclipse.papyrus.uml.diagram.sequence.anchors.AnchorConstants;
+import org.eclipse.papyrus.uml.diagram.sequence.anchors.CenterAnchor;
+
+/**
+ * <p>
+ * Custom {@link LinkLFSVGNodePlateFigure} to support custom Anchors for the Destruction
+ * Figure.
+ * </p>
+ *
+ * @see CenterAnchor
+ * @see AnchorConstants#CENTER_TERMINAL
+ */
+public class DestructionEventNodePlate extends RoundedRectangleNodePlateFigure {
+
+ public DestructionEventNodePlate(Dimension defSize) {
+ super(defSize);
+ }
+
+ public DestructionEventNodePlate(int width, int height) {
+ super(width, height);
+ }
+
+ @Override
+ public ConnectionAnchor getConnectionAnchor(String terminal) {
+ if (AnchorConstants.CENTER_TERMINAL.equals(terminal)) {
+ return new CenterAnchor(this);
+ }
+ return super.getConnectionAnchor(terminal);
+ }
+
+ @Override
+ public String getConnectionAnchorTerminal(ConnectionAnchor c) {
+ if (c instanceof CenterAnchor) {
+ return AnchorConstants.CENTER_TERMINAL;
+ }
+ return super.getConnectionAnchorTerminal(c);
+ }
+
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/MessageFigure.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/MessageFigure.java
index 30dcf608495..f13d8fa09cf 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/MessageFigure.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/MessageFigure.java
@@ -1,6 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2010 CEA
- *
+ * 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 2.0
@@ -11,6 +10,7 @@
*
* Contributors:
* Soyatec - Initial API and implementation
+ * EclipseSource - Bug 536641
*
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.sequence.figures;
@@ -195,4 +195,14 @@ public abstract class MessageFigure extends UMLEdgeFigure {
}
return super.getConnectionAnchor(terminal);
}
+
+ @Override
+ public String getConnectionAnchorTerminal(ConnectionAnchor c) {
+ if (c instanceof ConnectionSourceAnchor) {
+ return AnchorConstants.START_TERMINAL;
+ } else if (c instanceof ConnectionTargetAnchor) {
+ return AnchorConstants.END_TERMINAL;
+ }
+ return super.getConnectionAnchorTerminal(c);
+ }
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/CustomEditPartProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/CustomEditPartProvider.java
index b05cb810c5c..f32e1ee3a49 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/CustomEditPartProvider.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/CustomEditPartProvider.java
@@ -1,6 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2010 CEA
- *
+ * 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 2.0
@@ -11,6 +10,7 @@
*
* Contributors:
* Soyatec - Initial API and implementation
+ * EclipseSource - Bug 536641
*
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.sequence.providers;
@@ -22,6 +22,7 @@ import org.eclipse.papyrus.infra.gmfdiag.common.editpart.SilentEditpart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.BehaviorExecutionSpecificationBehaviorEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CCombinedFragmentCombinedFragmentCompartmentEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CCombinedFragmentEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CDestructionOccurrenceSpecificationEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CInteractionEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CInteractionInteractionCompartmentEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CInteractionOperandEditPart;
@@ -39,6 +40,7 @@ import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CustomMessageName7Edi
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CustomMessageNameEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CustomStateInvariantEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CustomStateInvariantLabelEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DestructionOccurrenceSpecificationEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.GeneralOrderingEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.InteractionEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.InteractionInteractionCompartmentEditPart;
@@ -140,8 +142,8 @@ public class CustomEditPartProvider extends UMLEditPartProvider {
// return new CustomTimeObservationAppliedStereotypeEditPart(view);
// case DurationConstraintAppliedStereotypeEditPart.VISUAL_ID:
// return new CustomDurationConstraintAppliedStereotypeEditPart(view);
- // case DestructionOccurrenceSpecificationEditPart.VISUAL_ID:
- // return new CustomDestructionOccurrenceSpecificationEditPart(view);
+ case DestructionOccurrenceSpecificationEditPart.VISUAL_ID:
+ return new CDestructionOccurrenceSpecificationEditPart(view);
// case ConstraintEditPart.VISUAL_ID:
// return new CustomConstraintEditPart(view);
// case Constraint2EditPart.VISUAL_ID:
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/CustomViewProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/CustomViewProvider.java
index 5c02a58e47d..5f34b9e40d0 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/CustomViewProvider.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/CustomViewProvider.java
@@ -1,6 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2010 CEA
- *
+ * 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 2.0
@@ -11,6 +10,7 @@
*
* Contributors:
* Soyatec - Initial API and implementation
+ * EclipseSource - Bug 536641
*
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.sequence.providers;
@@ -25,6 +25,7 @@ import org.eclipse.gmf.runtime.diagram.core.services.view.CreateNodeViewOperatio
import org.eclipse.gmf.runtime.diagram.core.services.view.CreateViewForKindOperation;
import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil;
import org.eclipse.gmf.runtime.notation.Bounds;
+import org.eclipse.gmf.runtime.notation.Connector;
import org.eclipse.gmf.runtime.notation.DecorationNode;
import org.eclipse.gmf.runtime.notation.Edge;
import org.eclipse.gmf.runtime.notation.Location;
@@ -78,7 +79,7 @@ public class CustomViewProvider extends UMLViewProvider {
PreferencesHint preferencesHint) {
Edge edge = super.createEdge(semanticAdapter, containerView,
semanticHint, index, persisted, preferencesHint);
- if (edge != null) {
+ if (edge != null && false == edge instanceof Connector) {
edge.getStyles().add(NotationFactory.eINSTANCE.createLineStyle());
final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint
.getPreferenceStore();
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/PostEditPolicyProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/PostEditPolicyProvider.java
index dcb3cddd04f..652c7cbe123 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/PostEditPolicyProvider.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/PostEditPolicyProvider.java
@@ -25,8 +25,8 @@ import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.IEditPolicyProvide
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.AbstractExecutionSpecificationEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.AbstractMessageEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CDestructionOccurrenceSpecificationEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CustomContinuationEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CustomDestructionOccurrenceSpecificationEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CustomStateInvariantEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CustomTimeConstraintLabelEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CustomTimeObservationLabelEditPart;
@@ -95,7 +95,7 @@ public class PostEditPolicyProvider implements IEditPolicyProvider {
@Override
public void createEditPolicies(EditPart editPart) {
// Replace AppliedStereotypeCommentCreationEditPolicy to a custom one.
- if (editPart instanceof AbstractExecutionSpecificationEditPart || editPart instanceof CustomDestructionOccurrenceSpecificationEditPart
+ if (editPart instanceof AbstractExecutionSpecificationEditPart || editPart instanceof CDestructionOccurrenceSpecificationEditPart
|| editPart instanceof CustomStateInvariantEditPart || editPart instanceof CustomTimeConstraintLabelEditPart || editPart instanceof CustomTimeObservationLabelEditPart || editPart instanceof AbstractMessageEditPart
|| editPart instanceof GeneralOrderingEditPart || editPart instanceof CustomContinuationEditPart) {
editPart.installEditPolicy(AppliedStereotypeCommentEditPolicy.APPLIED_STEREOTYPE_COMMENT, new AppliedStereotypeCommentCreationEditPolicyEx());
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/LifeLineGraphicalNodeEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/LifeLineGraphicalNodeEditPolicy.java
index b1608506ae5..96147e50673 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/LifeLineGraphicalNodeEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/LifeLineGraphicalNodeEditPolicy.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2017 CEA LIST, ALL4TEC and others.
+ * Copyright (c) 2017 CEA LIST, ALL4TEC, EclipseSource and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -12,6 +12,7 @@
* CEA LIST - Initial API and implementation
* Mickaƫl ADAM (ALL4TEC) mickael.adam@all4tec.net - Bug 519621, 519756, 526191
* Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Bug 531596
+ * EclipseSource - Bug 536641
*
*****************************************************************************/
@@ -517,6 +518,10 @@ public class LifeLineGraphicalNodeEditPolicy extends DefaultGraphicalNodeEditPol
relativeSnappedLocation = SequenceUtil.getSnappedLocation(getHost(), relativeSnappedLocation);
getHostFigure().getParent().translateToRelative(relativeSnappedLocation);
+ if (false == request.getTargetEditPart() instanceof LifelineEditPart) {
+ System.out.println("TODO Handle this");
+ return null;
+ }
if (LifelineEditPartUtil.getNextEventsFromPosition(relativeSnappedLocation, (LifelineEditPart) request.getTargetEditPart()).isEmpty()) {
NodeEditPart targetEditPart = (NodeEditPart) request.getTargetEditPart();
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 3b9ecec4e29..e8940cbc8d7 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
@@ -112,7 +112,9 @@ public class DurationConstraintEditHelperAdvice extends AbstractDurationEditHelp
@Override
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
constraint.getConstrainedElements().add(0, source);
- constraint.getConstrainedElements().add(1, target);
+ if (target != source) {
+ constraint.getConstrainedElements().add(1, target);
+ }
return CommandResult.newOKCommandResult();
}
};
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 2f93b6b7f97..03f293c0d1c 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
@@ -52,7 +52,9 @@ public class DurationObservationEditHelperAdvice extends AbstractDurationEditHel
@Override
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
observation.getEvents().add(0, source);
- observation.getEvents().add(1, target);
+ if (target != source) {
+ observation.getEvents().add(1, target);
+ }
return CommandResult.newOKCommandResult();
}
};

Back to the top