Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/LifelineNodePlate.java11
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/command/DropDestructionOccurenceSpecification.java117
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/draw2d/routers/MessageRouter.java27
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/AbstractMessageEditPart.java4
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CLifeLineEditPart.java52
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/OLDLifelineEditPart.java6
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/LifeLineRestorePositionEditPolicy.java31
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/LifelineChildGraphicalNodeEditPolicy.java2
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/LifelineSelectionEditPolicy.java132
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/MessageConnectionLineSegEditPolicy.java81
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/OLDMessageConnectionEditPolicy.java3
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/SequenceReferenceEditPolicy.java2
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/LifeLineLayoutManager.java7
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/LifelineFigure.java88
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/locator/CenterLocator.java87
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/locator/MessageCreateLifelineAnchor.java77
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/ConnectRectangleToGridEditPolicy.java66
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/DisplayEvent.java22
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/LifeLineGraphicalNodeEditPolicy.java179
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LifelineEditPartUtil.java89
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LifelineMessageCreateHelper.java22
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LifelineMessageDeleteHelper.java75
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/SelfMessageHelper.java4
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/SequenceUtil.java47
24 files changed, 834 insertions, 397 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/LifelineNodePlate.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/LifelineNodePlate.java
index 850c5507673..999229d4a7a 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/LifelineNodePlate.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/LifelineNodePlate.java
@@ -70,10 +70,15 @@ public class LifelineNodePlate extends LinkLFSVGNodePlateFigure {
Point temp = p.getCopy();
translateToRelative(temp);
PrecisionPoint pt = BaseSlidableAnchor.getAnchorRelativeLocation(temp, getBounds());
- pt.setPreciseX(0.5);// a changer
-
-
return createAnchor(pt);
}
}
+
+ /**
+ * @see org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure#isDefaultAnchorArea(org.eclipse.draw2d.geometry.PrecisionPoint)
+ */
+ @Override
+ protected boolean isDefaultAnchorArea(PrecisionPoint p) {
+ return false;
+ }
} \ No newline at end of file
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/command/DropDestructionOccurenceSpecification.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/command/DropDestructionOccurenceSpecification.java
index 08269802f10..2478c49f633 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/command/DropDestructionOccurenceSpecification.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/command/DropDestructionOccurenceSpecification.java
@@ -14,6 +14,7 @@
package org.eclipse.papyrus.uml.diagram.sequence.command;
import java.util.ArrayList;
+import java.util.Optional;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.IAdaptable;
@@ -23,14 +24,19 @@ import org.eclipse.draw2d.geometry.Point;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gef.EditPart;
-import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.Request;
import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.requests.BendpointRequest;
+import org.eclipse.gef.requests.ReconnectRequest;
import org.eclipse.gmf.runtime.common.core.command.CommandResult;
import org.eclipse.gmf.runtime.diagram.core.edithelpers.CreateElementRequestAdapter;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewAndElementRequest;
import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewAndElementRequest.ConnectionViewAndElementDescriptor;
import org.eclipse.gmf.runtime.diagram.ui.requests.DropObjectsRequest;
import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DestructionOccurrenceSpecificationEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.figures.DestructionEventFigure;
import org.eclipse.papyrus.uml.diagram.sequence.messages.Messages;
import org.eclipse.uml2.uml.DestructionOccurrenceSpecification;
@@ -38,26 +44,27 @@ import org.eclipse.uml2.uml.Message;
import org.eclipse.uml2.uml.MessageEnd;
/**
- *this class is used to drop the representation of the DestructionOccurrenceSpecification from the request in charge to create the message delete
- *
+ * this class is used to drop the representation of the DestructionOccurrenceSpecification from the request in charge to create the message delete
*/
public class DropDestructionOccurenceSpecification extends AbstractTransactionalCommand {
- private CreateConnectionViewAndElementRequest request;
+ private Request request;
private EditPart graphicalContainer;
private Point absolutePosition;
-
+
/**
* @param domain
- * @param request the request that has in charge to create the deleteMessage
- * @param graphicalContainer for example the lifeline that will contain the representation of the event
+ * @param request
+ * the request that has in charge to create the deleteMessage
+ * @param graphicalContainer
+ * for example the lifeline that will contain the representation of the event
*/
- public DropDestructionOccurenceSpecification(TransactionalEditingDomain domain, CreateConnectionViewAndElementRequest request, EditPart graphicalContainer, Point absolutePosition) {
+ public DropDestructionOccurenceSpecification(TransactionalEditingDomain domain, Request request, EditPart graphicalContainer, Point absolutePosition) {
super(domain, Messages.Commands_DropDestructionOccurenceSpecification_Label, null);
- this.request=request;
- this.graphicalContainer= graphicalContainer;
- this.absolutePosition=absolutePosition;
+ this.request = request;
+ this.graphicalContainer = graphicalContainer;
+ this.absolutePosition = absolutePosition;
}
@@ -72,17 +79,17 @@ public class DropDestructionOccurenceSpecification extends AbstractTransactional
@Override
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
CommandResult commandresult = null;
- //1. look for the message
- Message deleteMessage=getDeleteMessage();
- if( deleteMessage==null){
+ // 1. look for the message
+ Message deleteMessage = getDeleteMessage();
+ if (deleteMessage == null) {
return commandresult;
}
- //2. look for the Destruction occurrence
- DestructionOccurrenceSpecification destructionOccurrenceSpecification=getDestructionOccurrence(deleteMessage);
- if( destructionOccurrenceSpecification==null){
+ // 2. look for the Destruction occurrence
+ DestructionOccurrenceSpecification destructionOccurrenceSpecification = getDestructionOccurrence(deleteMessage);
+ if (destructionOccurrenceSpecification == null) {
return commandresult;
}
- //3. drop the Destruction Occurrence
+ // 3. drop the Destruction Occurrence
dropDestructionOccurrence(destructionOccurrenceSpecification);
return CommandResult.newOKCommandResult();
}
@@ -91,32 +98,44 @@ public class DropDestructionOccurenceSpecification extends AbstractTransactional
* @param destructionOccurrenceSpecification
*/
private void dropDestructionOccurrence(DestructionOccurrenceSpecification destructionOccurrenceSpecification) {
- DropObjectsRequest dropDestructionOccurrenceRequest= new DropObjectsRequest();
- Point point=request.getLocation().getCopy();
- IFigure parentFigure=((GraphicalEditPart)graphicalContainer).getFigure();
- parentFigure.translateToRelative(absolutePosition);
- DestructionEventFigure destructionEventFigure= new DestructionEventFigure();
- point.y=point.y-destructionEventFigure.getDefaultSize().height/2;
- dropDestructionOccurrenceRequest.setLocation(point);
- ArrayList<EObject> destructionOccurrenceListToDrop=new ArrayList<EObject>();
- destructionOccurrenceListToDrop.add(destructionOccurrenceSpecification);
- dropDestructionOccurrenceRequest.setObjects(destructionOccurrenceListToDrop);
-
- //give the position from the layer it is not relative
- Command command=graphicalContainer.getCommand(dropDestructionOccurrenceRequest);
- command.execute();
+ DropObjectsRequest dropDestructionOccurrenceRequest = new DropObjectsRequest();
+ Point point = absolutePosition.getCopy();
+ IFigure parentFigure = ((GraphicalEditPart) graphicalContainer).getFigure();
+ parentFigure.translateToRelative(point);
+
+ // look for existing DestructionEventFigure
+ DestructionEventFigure destructionEventFigure = null;
+ Optional<DestructionOccurrenceSpecificationEditPart> findFirst = graphicalContainer.getChildren().stream()
+ .filter(DestructionOccurrenceSpecificationEditPart.class::isInstance)
+ .map(DestructionOccurrenceSpecificationEditPart.class::cast)
+ .findFirst();
+
+ // If not present create one
+ if (!findFirst.isPresent()) {
+ destructionEventFigure = new DestructionEventFigure();
+ point.y = point.y - destructionEventFigure.getDefaultSize().height / 2;
+ dropDestructionOccurrenceRequest.setLocation(point);
+ ArrayList<EObject> destructionOccurrenceListToDrop = new ArrayList<EObject>();
+ destructionOccurrenceListToDrop.add(destructionOccurrenceSpecification);
+ dropDestructionOccurrenceRequest.setObjects(destructionOccurrenceListToDrop);
+ // give the position from the layer it is not relative
+ Command command = graphicalContainer.getCommand(dropDestructionOccurrenceRequest);
+ command.execute();
+ }
}
/**
* get the DestructionOccurenceSpecification from a given message
- * @param deleteMessage the message to look for must be never null
+ *
+ * @param deleteMessage
+ * the message to look for must be never null
* @return DestructionOccurenceSpecification or null
*/
private DestructionOccurrenceSpecification getDestructionOccurrence(Message deleteMessage) {
- DestructionOccurrenceSpecification destructionOccurrenceSpecification=null;
- MessageEnd messageEnd =deleteMessage.getReceiveEvent();
- if(messageEnd instanceof DestructionOccurrenceSpecification){
- destructionOccurrenceSpecification=(DestructionOccurrenceSpecification)messageEnd;
+ DestructionOccurrenceSpecification destructionOccurrenceSpecification = null;
+ MessageEnd messageEnd = deleteMessage.getReceiveEvent();
+ if (messageEnd instanceof DestructionOccurrenceSpecification) {
+ destructionOccurrenceSpecification = (DestructionOccurrenceSpecification) messageEnd;
}
return destructionOccurrenceSpecification;
}
@@ -125,15 +144,25 @@ public class DropDestructionOccurenceSpecification extends AbstractTransactional
* @return the delete message from the given request, can return null
*/
private Message getDeleteMessage() {
- Message deleteMessage=null;
- ConnectionViewAndElementDescriptor connectionViewAndElementDescriptor=request.getConnectionViewAndElementDescriptor();
- if( connectionViewAndElementDescriptor!=null){
- CreateElementRequestAdapter createElementRequestAdapter=connectionViewAndElementDescriptor.getCreateElementRequestAdapter();
- deleteMessage=(Message)createElementRequestAdapter.getAdapter(Message.class);
+ Message deleteMessage = null;
+ if (request instanceof CreateConnectionViewAndElementRequest) {
+ ConnectionViewAndElementDescriptor connectionViewAndElementDescriptor = ((CreateConnectionViewAndElementRequest) request).getConnectionViewAndElementDescriptor();
+ if (null != connectionViewAndElementDescriptor) {
+ CreateElementRequestAdapter createElementRequestAdapter = connectionViewAndElementDescriptor.getCreateElementRequestAdapter();
+ deleteMessage = (Message) createElementRequestAdapter.getAdapter(Message.class);
+ }
+ } else if (request instanceof ReconnectRequest) {
+ EObject element = ((View) ((ReconnectRequest) request).getConnectionEditPart().getModel()).getElement();
+ if (element instanceof Message) {
+ deleteMessage = (Message) element;
+ }
+ } else if (request instanceof BendpointRequest) {
+ EObject element = ((View) ((BendpointRequest) request).getSource().getModel()).getElement();
+ if (element instanceof Message) {
+ deleteMessage = (Message) element;
+ }
}
return deleteMessage;
}
-
-
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/draw2d/routers/MessageRouter.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/draw2d/routers/MessageRouter.java
index e3e487bd679..7b9ffeafa29 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/draw2d/routers/MessageRouter.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/draw2d/routers/MessageRouter.java
@@ -31,9 +31,8 @@ import org.eclipse.gmf.runtime.draw2d.ui.geometry.PointListUtilities;
import org.eclipse.gmf.runtime.draw2d.ui.internal.routers.ObliqueRouter;
import org.eclipse.gmf.runtime.draw2d.ui.internal.routers.OrthogonalRouterUtilities;
import org.eclipse.gmf.runtime.draw2d.ui.mapmode.MapModeUtil;
+import org.eclipse.papyrus.uml.diagram.sequence.LifelineNodePlate;
import org.eclipse.papyrus.uml.diagram.sequence.edit.helpers.AnchorHelper;
-import org.eclipse.papyrus.uml.diagram.sequence.figures.LifelineFigure;
-import org.eclipse.papyrus.uml.diagram.sequence.figures.MessageCreate;
import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceDiagramConstants;
/**
@@ -93,11 +92,11 @@ public class MessageRouter extends ObliqueRouter {
return false;
}
IFigure sourceLifeline = conn.getSourceAnchor().getOwner();
- while (sourceLifeline != null && !(sourceLifeline instanceof LifelineFigure)) {
+ while (sourceLifeline != null && !(sourceLifeline instanceof LifelineNodePlate)) {
sourceLifeline = sourceLifeline.getParent();
}
IFigure targetLifeline = conn.getTargetAnchor().getOwner();
- while (targetLifeline != null && !(targetLifeline instanceof LifelineFigure)) {
+ while (targetLifeline != null && !(targetLifeline instanceof LifelineNodePlate)) {
targetLifeline = targetLifeline.getParent();
}
return sourceLifeline != null && sourceLifeline.equals(targetLifeline);
@@ -156,16 +155,16 @@ public class MessageRouter extends ObliqueRouter {
}
protected void adjustCreateEndpoint(Connection conn, PointList newLine) {
-// if (conn instanceof MessageCreate) {
-// if (newLine.size() >= 2) {
-// Point start = newLine.getFirstPoint();
-// Point end = newLine.getLastPoint();
-// if (start.y != end.y) {
-// start.y = end.y;
-// newLine.setPoint(start, 0);
-// }
-// }
-// }
+ // if (conn instanceof MessageCreate) {
+ // if (newLine.size() >= 2) {
+ // Point start = newLine.getFirstPoint();
+ // Point end = newLine.getLastPoint();
+ // if (start.y != end.y) {
+ // start.y = end.y;
+ // newLine.setPoint(start, 0);
+ // }
+ // }
+ // }
}
@Override
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 19a3b938ef4..ff15b5d0aa6 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
@@ -24,13 +24,13 @@ 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.edit.policies.LifelineChildGraphicalNodeEditPolicy;
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.MessageFigure;
import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
import org.eclipse.papyrus.uml.diagram.sequence.referencialgrilling.ConnectMessageToGridEditPolicy;
import org.eclipse.papyrus.uml.diagram.sequence.referencialgrilling.ConnectPointToGridEditPolicy;
+import org.eclipse.papyrus.uml.diagram.sequence.referencialgrilling.LifeLineGraphicalNodeEditPolicy;
import org.eclipse.papyrus.uml.diagram.sequence.util.SelectMessagesEditPartTracker;
import org.eclipse.papyrus.uml.diagram.sequence.util.SelfMessageHelper;
import org.eclipse.swt.events.MouseMoveListener;
@@ -282,7 +282,7 @@ public abstract class AbstractMessageEditPart extends UMLConnectionNodeEditPart
*/
@Override
protected void installRouter() {
- getConnectionFigure().setConnectionRouter(LifelineChildGraphicalNodeEditPolicy.messageRouter);
+ getConnectionFigure().setConnectionRouter(LifeLineGraphicalNodeEditPolicy.messageRouter);
getConnectionFigure().setCursor(org.eclipse.gmf.runtime.gef.ui.internal.l10n.Cursors.CURSOR_SEG_MOVE);
refreshBendpoints();
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CLifeLineEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CLifeLineEditPart.java
index c54ba0cf2e4..8256eb8c477 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CLifeLineEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CLifeLineEditPart.java
@@ -13,16 +13,22 @@
package org.eclipse.papyrus.uml.diagram.sequence.edit.parts;
+import org.eclipse.draw2d.ConnectionAnchor;
import org.eclipse.draw2d.IFigure;
+import org.eclipse.gef.ConnectionEditPart;
import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPolicy;
import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure;
import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.uml.diagram.common.draw2d.anchors.FixedAnchor;
import org.eclipse.papyrus.uml.diagram.sequence.LifelineNodePlate;
import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.LifeLineRestorePositionEditPolicy;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.LifelineSelectionEditPolicy;
import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.UpdateNodeReferenceEditPolicy;
import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.UpdateWeakReferenceForMessageSpecEditPolicy;
import org.eclipse.papyrus.uml.diagram.sequence.figures.ILifelineInternalFigure;
import org.eclipse.papyrus.uml.diagram.sequence.figures.LifeLineLayoutManager;
+import org.eclipse.papyrus.uml.diagram.sequence.locator.MessageCreateLifelineAnchor;
/**
* @author PT202707
@@ -61,9 +67,10 @@ public class CLifeLineEditPart extends LifelineEditPart {
*/
@Override
protected NodeFigure createSVGNodePlate() {
- svgNodePlate = new LifelineNodePlate(this, -1, -1).withLinkLFEnabled();
- svgNodePlate.setDefaultNodePlate(createNodePlate());
-
+ if (null == svgNodePlate) {
+ svgNodePlate = new LifelineNodePlate(this, -1, -1).withLinkLFEnabled();
+ svgNodePlate.setDefaultNodePlate(createNodePlate());
+ }
return svgNodePlate;
}
@@ -74,10 +81,11 @@ public class CLifeLineEditPart extends LifelineEditPart {
*/
@Override
protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new LifelineSelectionEditPolicy());
installEditPolicy(LifeLineRestorePositionEditPolicy.KEY, new LifeLineRestorePositionEditPolicy());
installEditPolicy(UpdateNodeReferenceEditPolicy.UDPATE_NODE_REFERENCE, new UpdateNodeReferenceEditPolicy());
installEditPolicy(UpdateWeakReferenceForMessageSpecEditPolicy.UDPATE_WEAK_REFERENCE_FOR_MESSAGE, new UpdateWeakReferenceForMessageSpecEditPolicy());
- super.createDefaultEditPolicies();
}
/**
@@ -104,4 +112,40 @@ public class CLifeLineEditPart extends LifelineEditPart {
return -1;
}
+ /**
+ * Create specific anchor to handle connection on top, on center and on bottom of the lifeline
+ */
+ @Override
+ public ConnectionAnchor getTargetConnectionAnchor(ConnectionEditPart connEditPart) {
+ if (connEditPart instanceof MessageCreateEditPart) {
+ // Create message anchor
+ return new MessageCreateLifelineAnchor(getPrimaryShape(), this);
+
+ } else if (connEditPart instanceof MessageDeleteEditPart) {
+ // delete message anchor
+ return new FixedAnchor(getPrimaryShape(), FixedAnchor.BOTTOM);
+ }
+ // if (connEditPart instanceof MessageAsyncEditPart) {// TODO_MIA test it
+ // String terminal = AnchorHelper.getAnchorId(getEditingDomain(), connEditPart, false);
+ // if (terminal.length() > 0) {
+ // int start = terminal.indexOf("{") + 1;
+ // PrecisionPoint pt = BaseSlidableAnchor.parseTerminalString(terminal);
+ // boolean rightHand = true;
+ // if (start > 0) {
+ // if (terminal.charAt(start) == 'L') {
+ // rightHand = false;
+ // }
+ // } else {
+ // Connection c = (Connection) connEditPart.getFigure();
+ // PointList list = c.getPoints();
+ // if (list.getPoint(0).x > list.getPoint(1).x) {
+ // rightHand = false;
+ // }
+ // }
+ // return new AnchorHelper.SideAnchor(getNodeFigure(), pt, rightHand);
+ // }
+ // }
+ return super.getTargetConnectionAnchor(connEditPart);
+ }
+
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/OLDLifelineEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/OLDLifelineEditPart.java
index 5de906500b0..a24a84f3656 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/OLDLifelineEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/OLDLifelineEditPart.java
@@ -167,7 +167,7 @@ public class OLDLifelineEditPart extends LifelineEditPart {
if (isInlineMode()) {
// return true;
}
- if (fFigureLifelineNameContainerFigure != null && fFigureLifelineNameContainerFigure.containsPoint(x, y)) {
+ if (lifelineHeaderBoundsFigure != null && lifelineHeaderBoundsFigure.containsPoint(x, y)) {
return true;
} else if (!isInlineMode() && fFigureLifelineDotLineFigure != null) {
Rectangle bounds = fFigureLifelineDotLineFigure.getDashLineRectangle().getBounds().getCopy();
@@ -186,7 +186,7 @@ public class OLDLifelineEditPart extends LifelineEditPart {
return null;
}
// 1. First check if the location is enter the Title.
- if (fFigureLifelineNameContainerFigure != null && fFigureLifelineNameContainerFigure.containsPoint(x, y)) {
+ if (lifelineHeaderBoundsFigure != null && lifelineHeaderBoundsFigure.containsPoint(x, y)) {
// Return label figure for supporting direct edit.
EditPart editPart = (EditPart) getViewer().getVisualPartMap().get(figure);
while (editPart == null) {
@@ -923,7 +923,7 @@ public class OLDLifelineEditPart extends LifelineEditPart {
// Create message
return new LifelineAnchor(getPrimaryShape().getFigureLifelineNameContainerFigure());
}
- if (connEditPart instanceof MessageAsyncEditPart) {
+ if (connEditPart instanceof MessageAsyncEditPart) {// TODO_MIA test it
String terminal = AnchorHelper.getAnchorId(getEditingDomain(), connEditPart, false);
if (terminal.length() > 0) {
int start = terminal.indexOf("{") + 1;
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/LifeLineRestorePositionEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/LifeLineRestorePositionEditPolicy.java
index 2bdd3277648..9b0123472d4 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/LifeLineRestorePositionEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/LifeLineRestorePositionEditPolicy.java
@@ -14,7 +14,6 @@ package org.eclipse.papyrus.uml.diagram.sequence.edit.policies;
import static org.eclipse.papyrus.uml.diagram.common.Activator.log;
import java.util.Collections;
-import java.util.List;
import java.util.Map;
import org.eclipse.core.commands.ExecutionException;
@@ -23,7 +22,6 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Status;
-import org.eclipse.draw2d.geometry.Point;
import org.eclipse.emf.transaction.Transaction;
import org.eclipse.emf.workspace.AbstractEMFOperation;
import org.eclipse.gef.ConnectionEditPart;
@@ -37,14 +35,11 @@ import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.SemanticEditPolicy;
import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramGraphicalViewer;
import org.eclipse.gmf.runtime.diagram.ui.util.EditPartUtil;
-import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest;
-import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
-import org.eclipse.papyrus.infra.services.edit.utils.RequestParameterConstants;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageCreateEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageDeleteEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.figures.MessageCreate;
import org.eclipse.papyrus.uml.diagram.sequence.util.LifelineEditPartUtil;
-import org.eclipse.uml2.uml.MessageEnd;
/**
* Edit policy to restore target lifeline line position after a deletion of a {@link MessageCreate}.
@@ -94,14 +89,6 @@ public class LifeLineRestorePositionEditPolicy extends SemanticEditPolicy implem
*/
@Override
protected Command getSemanticCommand(IEditCommandRequest request) {
- if (request instanceof CreateRelationshipRequest
- || request instanceof ReorientRelationshipRequest) {
- Object targetPoint = request.getParameter(RequestParameterConstants.EDGE_TARGET_POINT);
- if (targetPoint instanceof Point) {
- List<MessageEnd> previous = LifelineEditPartUtil.getPreviousEventsFromPosition((Point) targetPoint, (LifelineEditPart) getHost());
- request.setParameter(org.eclipse.papyrus.uml.service.types.utils.RequestParameterConstants.IS_FIRST_EVENT, previous.isEmpty());
- }
- }
return null;
}
@@ -115,9 +102,17 @@ public class LifeLineRestorePositionEditPolicy extends SemanticEditPolicy implem
*/
@Override
public void removingTargetConnection(final ConnectionEditPart connection, final int index) {
- Command restoreLifelinePositionCommand = LifelineEditPartUtil.getRestoreLifelinePositionOnMessageCreateRemovedCommand(connection);
- if (null != restoreLifelinePositionCommand && restoreLifelinePositionCommand.canExecute()) {
- executeCommand(restoreLifelinePositionCommand);
+ if (connection instanceof MessageCreateEditPart) {
+ Command restoreLifelinePositionCommand = LifelineEditPartUtil.getRestoreLifelinePositionOnMessageCreateRemovedCommand(connection);
+ if (null != restoreLifelinePositionCommand && restoreLifelinePositionCommand.canExecute()) {
+ executeCommand(restoreLifelinePositionCommand);
+ }
+ }
+ if (connection instanceof MessageDeleteEditPart) {
+ Command restoreLifelinePositionCommand = LifelineEditPartUtil.getRestoreLifelinePositionOnMessageDeleteRemovedCommand(connection);
+ if (null != restoreLifelinePositionCommand && restoreLifelinePositionCommand.canExecute()) {
+ executeCommand(restoreLifelinePositionCommand);
+ }
}
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/LifelineChildGraphicalNodeEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/LifelineChildGraphicalNodeEditPolicy.java
index 07ccc8e6988..7bcee68e247 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/LifelineChildGraphicalNodeEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/LifelineChildGraphicalNodeEditPolicy.java
@@ -69,6 +69,8 @@ import org.eclipse.uml2.uml.MessageEnd;
* - Creation of general ordering links.
* This edit policy is intended to be installed on parts which represent a lifeline or which are contained within a lifeline part.
*/
+// TODO_MIA check if can be deleted
+@Deprecated
public class LifelineChildGraphicalNodeEditPolicy extends OLDSequenceGraphicalNodeEditPolicy {
/** the feedback for creating a duration constraint node */
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/LifelineSelectionEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/LifelineSelectionEditPolicy.java
index 0ecdac5f885..7e00316ac05 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/LifelineSelectionEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/LifelineSelectionEditPolicy.java
@@ -24,19 +24,16 @@ import org.eclipse.gef.handles.RelativeHandleLocator;
import org.eclipse.gef.handles.ResizeHandle;
import org.eclipse.gef.requests.ChangeBoundsRequest;
import org.eclipse.gef.tools.ResizeTracker;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.ResizableEditPolicyEx;
import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.PapyrusResizableShapeEditPolicy;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CombinedFragmentEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.OLDLifelineEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DestructionOccurrenceSpecificationEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.figures.LifelineFigure;
-import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceUtil;
import org.eclipse.swt.graphics.Cursor;
import org.eclipse.uml2.uml.InteractionFragment;
import org.eclipse.uml2.uml.Lifeline;
-public class LifelineSelectionEditPolicy extends ResizableEditPolicyEx {
+public class LifelineSelectionEditPolicy extends PapyrusResizableShapeEditPolicy {
public LifelineSelectionEditPolicy() {
setResizeDirections(PositionConstants.WEST | PositionConstants.EAST);
@@ -86,68 +83,69 @@ public class LifelineSelectionEditPolicy extends ResizableEditPolicyEx {
list.add(westResizer);
}
- @Override
- protected void showChangeBoundsFeedback(ChangeBoundsRequest request) {
- IFigure feedback = getDragSourceFeedbackFigure();
- PrecisionRectangle rect = new PrecisionRectangle(getInitialFeedbackBounds().getCopy());
- getHostFigure().translateToAbsolute(rect);
- boolean skipMinSize = false;
- // Only enable horizontal dragging on lifelines(except lifelines that are result of a create message).
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=364688
- if (this.getHost() instanceof OLDLifelineEditPart) {
- skipMinSize = true;
- OLDLifelineEditPart lifelineEP = (OLDLifelineEditPart) this.getHost();
- if (!SequenceUtil.isCreateMessageEndLifeline(lifelineEP)) {
- request.getMoveDelta().y = 0;
- }
- // keepNameLabelBounds(lifelineEP, request, rect);
- // restrict child size within parent bounds
- keepInParentBounds(lifelineEP, request, rect);
- changeCombinedFragmentBounds(request, lifelineEP);
- // Adjust lifeline's height if no DestructionOccurrenceSpecification
- List<?> children = lifelineEP.getChildren();
- boolean hasDOS = false;
- for (Object child : children) {
- if (child instanceof DestructionOccurrenceSpecificationEditPart) {
- hasDOS = true;
- }
- }
- if (!hasDOS) {
- rect.height -= request.getMoveDelta().y;
- }
- }
- Point left = rect.getLeft();
- Point right = rect.getRight();
- rect.translate(request.getMoveDelta());
- rect.resize(request.getSizeDelta());
- IFigure f = getHostFigure();
- Dimension min = f.getMinimumSize().getCopy();
- Dimension max = f.getMaximumSize().getCopy();
- // IMapMode mmode = MapModeUtil.getMapMode(f);
- // min.height = mmode.LPtoDP(min.height);
- // min.width = mmode.LPtoDP(min.width);
- // max.height = mmode.LPtoDP(max.height);
- // max.width = mmode.LPtoDP(max.width);
- getHostFigure().translateToAbsolute(min);
- getHostFigure().translateToAbsolute(max);
- // In manual mode, there is no minimal width, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=383723
- if (min.width > rect.width && !skipMinSize) {
- if (request.getMoveDelta().x > 0 && request.getSizeDelta().width != 0) {
- rect.x = right.x - min.width;
- request.getMoveDelta().x = rect.x - left.x;
- }
- rect.width = min.width;
- } else if (max.width < rect.width) {
- rect.width = max.width;
- }
- if (min.height > rect.height) {
- rect.height = min.height;
- } else if (max.height < rect.height) {
- rect.height = max.height;
- }
- feedback.translateToRelative(rect);
- feedback.setBounds(rect);
- }
+ // TODO_MIA check it
+ // @Override
+ // protected void showChangeBoundsFeedback(ChangeBoundsRequest request) {
+ // IFigure feedback = getDragSourceFeedbackFigure();
+ // PrecisionRectangle rect = new PrecisionRectangle(getInitialFeedbackBounds().getCopy());
+ // getHostFigure().translateToAbsolute(rect);
+ // boolean skipMinSize = false;
+ // // Only enable horizontal dragging on lifelines(except lifelines that are result of a create message).
+ // // https://bugs.eclipse.org/bugs/show_bug.cgi?id=364688
+ // if (this.getHost() instanceof OLDLifelineEditPart) {
+ // skipMinSize = true;
+ // OLDLifelineEditPart lifelineEP = (OLDLifelineEditPart) this.getHost();
+ // if (!SequenceUtil.isCreateMessageEndLifeline(lifelineEP)) {
+ // request.getMoveDelta().y = 0;
+ // }
+ // // keepNameLabelBounds(lifelineEP, request, rect);
+ // // restrict child size within parent bounds
+ // keepInParentBounds(lifelineEP, request, rect);
+ // changeCombinedFragmentBounds(request, lifelineEP);
+ // // Adjust lifeline's height if no DestructionOccurrenceSpecification
+ // List<?> children = lifelineEP.getChildren();
+ // boolean hasDOS = false;
+ // for (Object child : children) {
+ // if (child instanceof DestructionOccurrenceSpecificationEditPart) {
+ // hasDOS = true;
+ // }
+ // }
+ // if (!hasDOS) {
+ // rect.height -= request.getMoveDelta().y;
+ // }
+ // }
+ // Point left = rect.getLeft();
+ // Point right = rect.getRight();
+ // rect.translate(request.getMoveDelta());
+ // rect.resize(request.getSizeDelta());
+ // IFigure f = getHostFigure();
+ // Dimension min = f.getMinimumSize().getCopy();
+ // Dimension max = f.getMaximumSize().getCopy();
+ // // IMapMode mmode = MapModeUtil.getMapMode(f);
+ // // min.height = mmode.LPtoDP(min.height);
+ // // min.width = mmode.LPtoDP(min.width);
+ // // max.height = mmode.LPtoDP(max.height);
+ // // max.width = mmode.LPtoDP(max.width);
+ // getHostFigure().translateToAbsolute(min);
+ // getHostFigure().translateToAbsolute(max);
+ // // In manual mode, there is no minimal width, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=383723
+ // if (min.width > rect.width && !skipMinSize) {
+ // if (request.getMoveDelta().x > 0 && request.getSizeDelta().width != 0) {
+ // rect.x = right.x - min.width;
+ // request.getMoveDelta().x = rect.x - left.x;
+ // }
+ // rect.width = min.width;
+ // } else if (max.width < rect.width) {
+ // rect.width = max.width;
+ // }
+ // if (min.height > rect.height) {
+ // rect.height = min.height;
+ // } else if (max.height < rect.height) {
+ // rect.height = max.height;
+ // }
+ // feedback.translateToRelative(rect);
+ // feedback.setBounds(rect);
+ // }
private void keepNameLabelBounds(LifelineEditPart lifelineEP, ChangeBoundsRequest request, PrecisionRectangle rect) {
PrecisionRectangle size = getMovedRectangle(rect, request);
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/MessageConnectionLineSegEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/MessageConnectionLineSegEditPolicy.java
index 362c676eb51..8c0b4fa2f0f 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/MessageConnectionLineSegEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/MessageConnectionLineSegEditPolicy.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2010 CEA
+ * Copyright (c) 2010-2017 CEA
*
*
* All rights reserved. This program and the accompanying materials
@@ -9,7 +9,7 @@
*
* Contributors:
* Atos Origin - Initial API and implementation
- *
+ * Mickaƫl ADAM (ALL4TEC) mickael.adam@all4tec.net - Bug 519408
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.sequence.edit.policies;
@@ -37,6 +37,7 @@ import org.eclipse.gef.requests.ReconnectRequest;
import org.eclipse.gef.ui.parts.ScrollingGraphicalViewer;
import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
import org.eclipse.gmf.runtime.diagram.ui.commands.SetBoundsCommand;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart;
import org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionNodeEditPart;
import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.ConnectionBendpointEditPolicy;
@@ -48,6 +49,7 @@ import org.eclipse.gmf.runtime.notation.Bounds;
import org.eclipse.gmf.runtime.notation.Node;
import org.eclipse.papyrus.infra.gmfdiag.common.editpart.NodeEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.CustomMessages;
+import org.eclipse.papyrus.uml.diagram.sequence.command.DropDestructionOccurenceSpecification;
import org.eclipse.papyrus.uml.diagram.sequence.draw2d.routers.MessageRouter.RouterKind;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.AbstractExecutionSpecificationEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.AbstractMessageEditPart;
@@ -55,6 +57,7 @@ import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CLifeLineEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageAsyncEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageCreateEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageDeleteEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageFoundEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageLostEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageSyncEditPart;
@@ -88,6 +91,9 @@ public class MessageConnectionLineSegEditPolicy extends ConnectionBendpointEditP
private static final String MOVED_HORIZONTAL = "Moved Horizontal";
+ /** The minimum height of the figure. */
+ private static final int LIFELINE_MIN_HEIGHT = 100;
+
public MessageConnectionLineSegEditPolicy() {
super(LineMode.ORTHOGONAL_FREE);
}
@@ -163,9 +169,9 @@ public class MessageConnectionLineSegEditPolicy extends ConnectionBendpointEditP
MessageEnd send = ((Message) message).getSendEvent();
MessageEnd rcv = ((Message) message).getReceiveEvent();
EditPart srcPart = connectionPart.getSource();
- CLifeLineEditPart srcLifelinePart = SequenceUtil.getParentLifelinePart(srcPart);
+ CLifeLineEditPart srcLifelinePart = (CLifeLineEditPart) SequenceUtil.getParentLifelinePart(srcPart);
EditPart tgtPart = connectionPart.getTarget();
- CLifeLineEditPart targetLifelinePart = SequenceUtil.getParentLifelinePart(tgtPart);
+ CLifeLineEditPart targetLifelinePart = (CLifeLineEditPart) SequenceUtil.getParentLifelinePart(tgtPart);
if (/* send instanceof OccurrenceSpecification && rcv instanceof OccurrenceSpecification && */srcLifelinePart != null && targetLifelinePart != null) {
RouterKind kind = RouterKind.getKind(getConnection(), getConnection().getPoints());
if ((getHost() instanceof MessageSyncEditPart || getHost() instanceof MessageAsyncEditPart) && kind == RouterKind.SELF) {
@@ -176,19 +182,23 @@ public class MessageConnectionLineSegEditPolicy extends ConnectionBendpointEditP
IFigure targetFigure = targetLifelinePart.getPrimaryShape();
Point sourcePoint = request.getLocation().getCopy();
+ sourcePoint = SequenceUtil.getSnappedLocation(targetLifelinePart, sourcePoint);
targetFigure.getParent().translateToRelative(sourcePoint);
+ // gets the final snapped position
+ // Take into account of the sticker size
int stickerHeight = ((CLifeLineEditPart) targetLifelinePart).getStickerHeight();
if (stickerHeight != -1) {
sourcePoint.y = sourcePoint.y - (stickerHeight / 2);
}
+
Bounds bounds = ((Bounds) ((Node) targetLifelinePart.getModel()).getLayoutConstraint());
SetBoundsCommand moveLifelineCmd = new SetBoundsCommand(targetLifelinePart.getEditingDomain(), "Move LifeLine", new EObjectAdapter(((GraphicalEditPart) targetLifelinePart).getNotationView()), //$NON-NLS-1$
new Point(bounds.getX(), sourcePoint.y));
SetBoundsCommand setSizeCommand = new SetBoundsCommand(targetLifelinePart.getEditingDomain(), "Size LifeLine", new EObjectAdapter(((GraphicalEditPart) targetLifelinePart).getNotationView()), //$NON-NLS-1$
- new Dimension(bounds.getWidth(), bounds.getHeight() - (sourcePoint.y + stickerHeight / 2 - targetFigure.getBounds().y)));
+ new Dimension(bounds.getWidth(), bounds.getHeight() - (sourcePoint.y - targetFigure.getBounds().y)));
// Move message End
int y = request.getLocation().y;
@@ -212,6 +222,49 @@ public class MessageConnectionLineSegEditPolicy extends ConnectionBendpointEditP
}
return compoudCmd;
}
+ } else if (getHost() instanceof MessageDeleteEditPart) {
+ // Reposition lifeline
+ IFigure targetFigure = targetLifelinePart.getPrimaryShape();
+
+ Point refPoint = SequenceUtil.getSnappedLocation(targetLifelinePart, request.getLocation().getCopy());
+ targetFigure.getParent().translateToRelative(refPoint);
+ Bounds bounds = ((Bounds) ((Node) targetLifelinePart.getModel()).getLayoutConstraint());
+
+
+ SetBoundsCommand setSizeCommand = new SetBoundsCommand(targetLifelinePart.getEditingDomain(), "Size LifeLine", new EObjectAdapter(((GraphicalEditPart) targetLifelinePart).getNotationView()), //$NON-NLS-1$
+ new Dimension(bounds.getWidth(), refPoint.y - bounds.getY()));
+
+ CompoundCommand compoudCmd = new CompoundCommand(CustomMessages.MoveMessageCommand_Label);
+ if (kind == RouterKind.SELF) {
+ // Only resize for down moved
+ if (MOVED_DOWN.equals(request.getExtendedData().get(MOVE_LINE_ORIENTATION_DATA))) {
+ compoudCmd.add(new ICommandProxy(setSizeCommand));
+ }
+ } else {
+ // Move message End
+ int y = request.getLocation().y;
+ Command srcCmd = createMoveMessageEndCommand((Message) message, srcPart, send, y, srcLifelinePart, request);
+ Command tgtCmd = createMoveMessageEndCommand((Message) message, tgtPart, rcv, y, targetLifelinePart, request);
+ DropDestructionOccurenceSpecification dropDestructionOccurenceSpecification = new DropDestructionOccurenceSpecification(((ConnectionEditPart) getHost()).getEditingDomain(), request, targetLifelinePart,
+ request.getLocation().getCopy());
+
+ Point oldLocation = SequenceUtil.getAbsoluteEdgeExtremity(connectionPart, true);
+ if (oldLocation != null) {
+ int oldY = oldLocation.y;
+ if (oldY < y) {// down
+ compoudCmd.add(new ICommandProxy(setSizeCommand));
+ compoudCmd.add(tgtCmd);
+ compoudCmd.add(srcCmd);
+ compoudCmd.add(new ICommandProxy(dropDestructionOccurenceSpecification));
+ } else {// up
+ compoudCmd.add(srcCmd);
+ compoudCmd.add(tgtCmd);
+ compoudCmd.add(new ICommandProxy(setSizeCommand));
+ compoudCmd.add(new ICommandProxy(dropDestructionOccurenceSpecification));
+ }
+ }
+ }
+ return compoudCmd;
} else {
// TODO_MIA to test
int y = request.getLocation().y;
@@ -385,13 +438,14 @@ public class MessageConnectionLineSegEditPolicy extends ConnectionBendpointEditP
@SuppressWarnings("unchecked")
protected void showMoveLineSegFeedback(BendpointRequest request) {
RouterKind kind = RouterKind.getKind(getConnection(), getConnection().getPoints());
- if ((getHost() instanceof MessageSyncEditPart || getHost() instanceof MessageAsyncEditPart) && kind == RouterKind.SELF) {
+ if ((getHost() instanceof MessageSyncEditPart || getHost() instanceof MessageAsyncEditPart || getHost() instanceof MessageDeleteEditPart) && kind == RouterKind.SELF) {
if (router == null) {
router = getConnection().getConnectionRouter();
getConnection().setConnectionRouter(new DummyRouter());
}
PointList linkPoints = getConnection().getPoints().getCopy();
- Point ptLoc = new Point(request.getLocation());
+ Point ptLoc = SequenceUtil.getSnappedLocation(getHost(), request.getLocation());
+
getConnection().translateToRelative(ptLoc);
int dy = 0;
int dx = 0;
@@ -426,14 +480,12 @@ public class MessageConnectionLineSegEditPolicy extends ConnectionBendpointEditP
}
}
// link should not exceed lifeline bounds
- if (checkBounds(linkPoints)) {
- getConnection().setPoints(linkPoints);
- getConnection().getLayoutManager().layout(getConnection());
- }
+ getConnection().setPoints(linkPoints);
+ getConnection().getLayoutManager().layout(getConnection());
return;
}
// Add impossible to dragging MessageLost and MessageFound. See bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=403138
- if (getHost() instanceof MessageCreateEditPart || getHost() instanceof MessageLostEditPart || getHost() instanceof MessageFoundEditPart) {
+ if (getHost() instanceof MessageCreateEditPart || getHost() instanceof MessageDeleteEditPart || getHost() instanceof MessageLostEditPart || getHost() instanceof MessageFoundEditPart) {
if (router == null) {
router = getConnection().getConnectionRouter();
getConnection().setConnectionRouter(new DummyRouter());
@@ -445,6 +497,7 @@ public class MessageConnectionLineSegEditPolicy extends ConnectionBendpointEditP
int size = linkPoints.size();
for (int i = 0; i < size; i++) {
Point p = linkPoints.getPoint(i).translate(0, dy);
+ p.y = SequenceUtil.getSnappedLocation(getHost(), p).y;
linkPoints.setPoint(p, i);
}
if (checkBounds(linkPoints)) {
@@ -473,12 +526,12 @@ public class MessageConnectionLineSegEditPolicy extends ConnectionBendpointEditP
boundsToMatch.setY(boundsToMatch.y + sourceLifelineEditPart.getStickerHeight());
}
- if (targetPart instanceof CLifeLineEditPart) {
+ if (getHost() instanceof MessageCreateEditPart && targetPart instanceof CLifeLineEditPart) {
NodeFigure targetFigure = (NodeFigure) ((NodeEditPart) targetPart).getPrimaryShape();
// If the bottom of the target is higher
int bottom = targetFigure.getBounds().bottom();
if (bottom < boundsToMatch.bottom()) {
- int delta = boundsToMatch.bottom() - bottom + CLifeLineEditPart.MIN_HEIGHT;
+ int delta = boundsToMatch.bottom() - bottom + LIFELINE_MIN_HEIGHT;
boundsToMatch.setHeight(boundsToMatch.height - delta);
}
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/OLDMessageConnectionEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/OLDMessageConnectionEditPolicy.java
index 93832d3f0ce..4f612116bde 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/OLDMessageConnectionEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/OLDMessageConnectionEditPolicy.java
@@ -27,9 +27,11 @@ import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceDeleteHelper;
*
* @since 3.0
*/
+@Deprecated
public class OLDMessageConnectionEditPolicy extends ConnectionEditPolicy {
@Override
+ @Deprecated
protected Command createDeleteSemanticCommand(GroupRequest deleteRequest) {
CompoundCommand deleteSemanticsCommand = new CompoundCommand();
Command deleteSemanticCommand = super.createDeleteSemanticCommand(deleteRequest);
@@ -41,6 +43,7 @@ public class OLDMessageConnectionEditPolicy extends ConnectionEditPolicy {
* {@inheritDoc}
*/
@Override
+ @Deprecated
protected Command createDeleteViewCommand(GroupRequest deleteRequest) {
CompoundCommand deleteViewsCommand = new CompoundCommand();
Command deleteViewCommand = super.createDeleteViewCommand(deleteRequest);
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/SequenceReferenceEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/SequenceReferenceEditPolicy.java
index 58864a225c3..c0f11550a04 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/SequenceReferenceEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/SequenceReferenceEditPolicy.java
@@ -187,7 +187,7 @@ public class SequenceReferenceEditPolicy extends GraphicalEditPolicy implements
*/
protected ExecutionSpecification getExecutionSpecificationAssociatedToEvent(OccurrenceSpecification event) {
ExecutionSpecification exec = null;
- if (event.getCovereds().size() > 0) {
+ if (null != event && !event.getCovereds().isEmpty()) {
Lifeline currentLifeline = event.getCovereds().get(0);
int index = 0;
while (exec == null && index < currentLifeline.getCoveredBys().size()) {
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/LifeLineLayoutManager.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/LifeLineLayoutManager.java
index ba5b0142c3f..15a15bc4de8 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/LifeLineLayoutManager.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/LifeLineLayoutManager.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2016 CEA LIST and others.
+ * Copyright (c) 2016 - 2017 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
@@ -8,7 +8,7 @@
*
* Contributors:
* CEA LIST - Initial API and implementation
- *
+ * Mickaƫl ADAM (ALL4TEC) mickael.adam@all4tec.net - Bug 519408
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.sequence.figures;
@@ -22,6 +22,7 @@ import org.eclipse.gmf.runtime.diagram.ui.figures.BorderedNodeFigure;
import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.ScalableCompartmentFigure;
import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SelectableBorderedNodeFigure;
import org.eclipse.papyrus.uml.diagram.common.figure.node.AutomaticCompartmentLayoutManager;
+import org.eclipse.papyrus.uml.diagram.sequence.figures.LifelineFigure.LifelineHeaderFigure;
/**
* @since 3.0
@@ -207,6 +208,8 @@ public class LifeLineLayoutManager extends AutomaticCompartmentLayoutManager {
((BorderedNodeFigure) child).setBounds(theConstraint);
}
}
+ } else if (child instanceof LifelineHeaderFigure) {
+ ((LifelineHeaderFigure) child).setBounds(container.getBounds().getCopy().setHeight(bottomHeaderY - container.getBounds().y + 1));
}
}
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/LifelineFigure.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/LifelineFigure.java
index bfd75e2bc14..41e25dd43f3 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/LifelineFigure.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/LifelineFigure.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2010 CEA
+ * Copyright (c) 2010 - 2017 CEA
*
*
* All rights reserved. This program and the accompanying materials
@@ -9,7 +9,7 @@
*
* Contributors:
* Soyatec - Initial API and implementation
- *
+ * Mickaƫl ADAM (ALL4TEC) mickael.adam@all4tec.net - Bug 519408
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.sequence.figures;
@@ -33,8 +33,34 @@ import org.eclipse.swt.graphics.Color;
* @author Jin Liu (jin.liu@soyatec.com)
*/
public class LifelineFigure extends RoundedCompartmentFigure {
- @Deprecated
- protected RectangleFigure fFigureLifelineNameContainerFigure;
+
+ /**
+ * Utility figure to get header. Used for selection bounds.
+ *
+ * @author Mickael ADAM
+ *
+ */
+ public final class LifelineHeaderFigure extends RectangleFigure {
+ /**
+ *
+ * @see org.eclipse.draw2d.RectangleFigure#fillShape(org.eclipse.draw2d.Graphics)
+ */
+ @Override
+ protected void fillShape(Graphics graphics) {
+ // do nothing
+ }
+
+ /**
+ * @see org.eclipse.draw2d.RectangleFigure#outlineShape(org.eclipse.draw2d.Graphics)
+ */
+ @Override
+ protected void outlineShape(Graphics graphics) {
+ // do nothing
+ }
+ }
+
+ protected RectangleFigure lifelineHeaderBoundsFigure;
+
@Deprecated
protected RectangleFigure fFigureExecutionsContainerFigure;
@Deprecated
@@ -42,13 +68,13 @@ public class LifelineFigure extends RoundedCompartmentFigure {
/**
* Constructor.
- *
*/
public LifelineFigure() {
super();
setLayoutManager(new LifeLineLayoutManager());
// This line has been used in order to display combinedFragment
setTransparency(100);
+ createContents();
}
/**
@@ -207,54 +233,8 @@ public class LifelineFigure extends RoundedCompartmentFigure {
* remove label creation, change layout
*/
private void createContents() {
- // fFigureLifelineNameContainerFigure = new RectangleFigure() {
- //
- // @Override
- // protected void fillShape(Graphics graphics) {
- // graphics.pushState();
- // applyTransparency(graphics);
- // graphics.fillRectangle(getBounds());
- // graphics.popState();
- // }
- // };
- // // do not fill to enable gradient
- // fFigureLifelineNameContainerFigure.setFill(false);
- // fFigureLifelineNameContainerFigure.setBorder(new MarginBorder(getMapMode().DPtoLP(7), getMapMode().DPtoLP(7), getMapMode().DPtoLP(7), getMapMode().DPtoLP(7)));
- // fFigureLifelineNameContainerFigure.setPreferredSize(new Dimension(getMapMode().DPtoLP(100), getMapMode().DPtoLP(30)));
- // //this.add(fFigureLifelineNameContainerFigure, BorderLayout.TOP);
- // // change layout
- // ToolbarLayout layout = new ToolbarLayout(false);
- // layout.setMinorAlignment(OrderedLayout.ALIGN_CENTER);
- // fFigureLifelineNameContainerFigure.setLayoutManager(layout);
- // // remove label creation (created by parent figure)
- // // fFigureLifelineLabelFigure = new WrappingLabel();
- // //
- // //
- // //
- // //
- // // fFigureLifelineLabelFigure.setText("<...>");
- // //
- // //
- // //
- // //
- // // fFigureLifelineLabelFigure.setTextWrap(true);
- // //
- // //
- // //
- // //
- // // fFigureLifelineLabelFigure.setAlignment(PositionConstants.CENTER);
- // //
- // //
- // //
- // // fFigureLifelineNameContainerFigure.add(fFigureLifelineLabelFigure);
- // fFigureExecutionsContainerFigure = new RectangleFigure();
- // fFigureExecutionsContainerFigure.setFill(false);
- // fFigureExecutionsContainerFigure.setOutline(false);
- // fFigureExecutionsContainerFigure.setLineWidth(1);
- // //this.add(fFigureExecutionsContainerFigure, BorderLayout.CENTER);
- // fFigureExecutionsContainerFigure.setLayoutManager(new StackLayout());
- // fFigureLifelineDotLineFigure = new LifelineDotLineCustomFigure();
- // fFigureExecutionsContainerFigure.add(fFigureLifelineDotLineFigure);
+ lifelineHeaderBoundsFigure = new LifelineHeaderFigure();
+ this.add(lifelineHeaderBoundsFigure);
}
protected IMapMode getMapMode() {
@@ -270,7 +250,7 @@ public class LifelineFigure extends RoundedCompartmentFigure {
@Deprecated
public RectangleFigure getFigureLifelineNameContainerFigure() {
- return fFigureLifelineNameContainerFigure;
+ return lifelineHeaderBoundsFigure;
}
@Deprecated
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/locator/CenterLocator.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/locator/CenterLocator.java
index 9a65d0c5699..fd37443dd50 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/locator/CenterLocator.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/locator/CenterLocator.java
@@ -14,9 +14,12 @@
package org.eclipse.papyrus.uml.diagram.sequence.locator;
import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gmf.runtime.diagram.ui.internal.figures.BorderItemContainerFigure;
+import org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure;
import org.eclipse.papyrus.uml.diagram.common.locator.AdvancedBorderItemLocator;
+import org.eclipse.papyrus.uml.diagram.sequence.figures.DestructionEventFigure;
/**
* This class is used to place all BorderItem node in the middle of the figure for the X but let the position Y
@@ -37,33 +40,77 @@ public class CenterLocator extends AdvancedBorderItemLocator {
super(parentFigure, location);
}
+ /**
+ * The DestructionEventFigure.
+ *
+ * It must be access through the method {@link #getDestructionEventFigure()}
+ */
+ private DestructionEventFigure destructionEventFigure = null;
/**
- * Overrides :
- * - the destructionEventFigure is always drawn at the end of the figure
+ * The BorderItemContainerFigure. It must be access through the method {@link #getBorderItemContainerFigure()}
+ */
+ private BorderItemContainerFigure borderItemContainerFigure = null;
+
+ /**
+ * Get the DestructionEventFigure of the lifeline, if it is drawn.
*
- * @see org.eclipse.draw2d.Locator#relocate(org.eclipse.draw2d.IFigure)
+ * @return the DestructionEventFigure or null
*/
- @Override
- public void relocate(IFigure borderItem) {
- Dimension size = getSize(borderItem);
- // get constraint is relative
- Rectangle rectSuggested = getConstraint();
- rectSuggested.setSize(size);
- // GetValid constraint is absolute
- Rectangle suggestedRectIndiagram = rectSuggested.getCopy();
- suggestedRectIndiagram.x = suggestedRectIndiagram.x + getParentFigure().getBounds().x;
- suggestedRectIndiagram.y = suggestedRectIndiagram.y + getParentFigure().getBounds().y;
- suggestedRectIndiagram = getValidLocation(suggestedRectIndiagram, borderItem);
- borderItem.setBounds(suggestedRectIndiagram.getCopy());
- suggestedRectIndiagram.x = suggestedRectIndiagram.x - getParentFigure().getBounds().x;
- suggestedRectIndiagram.y = suggestedRectIndiagram.y - getParentFigure().getBounds().y;
- setConstraint(suggestedRectIndiagram);
+ private DestructionEventFigure getDestructionEventFigure() {
+ if (destructionEventFigure == null) {
+ BorderItemContainerFigure borderItemContainerFigure = getBorderItemContainerFigure();
+ if (borderItemContainerFigure != null) {
+ for (Object child : borderItemContainerFigure.getChildren()) {
+ if (child instanceof DefaultSizeNodeFigure) {
+ for (Object figure : ((DefaultSizeNodeFigure) child).getChildren()) {
+ if (figure instanceof DestructionEventFigure) {
+ destructionEventFigure = (DestructionEventFigure) figure;
+ return destructionEventFigure;
+ }
+ }
+ }
+ }
+ }
+ }
+ return destructionEventFigure;
+ }
+ /**
+ * Get the BorderItemContainerFigure
+ *
+ * @return the borderItemContainerFigure or null
+ */
+ private BorderItemContainerFigure getBorderItemContainerFigure() {
+ if (borderItemContainerFigure == null) {
+ IFigure figure = getParentFigure().getParent();
+ for (Object object : figure.getChildren()) {
+ if (object instanceof BorderItemContainerFigure) {
+ borderItemContainerFigure = (BorderItemContainerFigure) object;
+ return borderItemContainerFigure;
+ }
+ }
+ }
+ return borderItemContainerFigure;
}
+ /**
+ * Overridden :
+ * - the destructionEventFigure is always drawn at the end of the figure
+ *
+ * @see org.eclipse.papyrus.uml.diagram.common.locator.AdvancedBorderItemLocator#getValidLocation(org.eclipse.draw2d.geometry.Rectangle, org.eclipse.draw2d.IFigure)
+ */
@Override
public Rectangle getValidLocation(Rectangle proposedLocation, IFigure borderItem) {
+ // The valid position for destruction event is always the bottom
+ if (getDestructionEventFigure() != null) {
+ if (borderItem.equals(getDestructionEventFigure().getParent())) {
+ Rectangle realLocation = new Rectangle(proposedLocation);
+ Point point = new Point(getParentBorder().getCenter().x - realLocation.getSize().width / 2, getParentBorder().y + getParentBorder().height - realLocation.height / 2);
+ realLocation.setLocation(point);
+ return realLocation;
+ }
+ }
proposedLocation.setX(getParentFigure().getBounds().x + getParentFigure().getBounds().width / 2 - borderItem.getBounds().width() / 2);
if (proposedLocation.y - proposedLocation.height / 2 <= getParentFigure().getBounds().y) {
@@ -72,8 +119,8 @@ public class CenterLocator extends AdvancedBorderItemLocator {
if (proposedLocation.y - proposedLocation.height / 2 >= getParentFigure().getBounds().getBottomLeft().y) {
proposedLocation.setY(getParentFigure().getBounds().getBottomLeft().y);
}
-
return super.getValidLocation(proposedLocation, borderItem);
}
+
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/locator/MessageCreateLifelineAnchor.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/locator/MessageCreateLifelineAnchor.java
new file mode 100644
index 00000000000..bab619fc6b5
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/locator/MessageCreateLifelineAnchor.java
@@ -0,0 +1,77 @@
+/*****************************************************************************
+ * Copyright (c) 2017 CEA LIST, ALL4TEC 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:
+ * Mickaƫl ADAM (ALL4TEC) mickael.adam@all4tec.net - Bug 519408
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.diagram.sequence.locator;
+
+import org.eclipse.draw2d.AbstractConnectionAnchor;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CLifeLineEditPart;
+
+/**
+ * A specific anchor to attach "create message" to the middle of the rectangle
+ * representing the header of the lifeline
+ *
+ */
+public class MessageCreateLifelineAnchor extends AbstractConnectionAnchor {
+
+ private CLifeLineEditPart cLifeLineEditPart;
+
+ public MessageCreateLifelineAnchor(IFigure owner, CLifeLineEditPart cLifeLineEditPart) {
+ super(owner);
+ this.cLifeLineEditPart = cLifeLineEditPart;
+ }
+
+ /**
+ * @see org.eclipse.draw2d.ConnectionAnchor#getLocation(org.eclipse.draw2d.geometry.Point)
+ */
+ @Override
+ public Point getLocation(Point reference) {
+
+ if (getOwner() == null) {
+ return null;
+ }
+
+ Rectangle r = getOwner().getBounds().getCopy();
+ r.setHeight(cLifeLineEditPart.getStickerHeight());
+
+ Point p = new Point();
+
+ p.y = r.y + r.getSize().height / 2;
+ // By default x is set to the left side of the figure
+ p.x = r.getLeft().x;
+
+ if (reference != null) {
+ // If the reference point is located at the right of the figure
+ // means the point should be attached to the right side.
+ if (reference.x > r.x) {
+ p.x = r.getRight().x;
+ }
+ }
+
+ // Translate the point to absolute
+ getOwner().translateToAbsolute(p);
+
+ return p;
+ }
+
+ /**
+ * Overrides to disable the reference point
+ *
+ * @see org.eclipse.draw2d.AbstractConnectionAnchor#getReferencePoint()
+ */
+ @Override
+ public Point getReferencePoint() {
+ return getLocation(null);
+ }
+
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/ConnectRectangleToGridEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/ConnectRectangleToGridEditPolicy.java
index d8a7105e61b..1c6b6ebf2aa 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/ConnectRectangleToGridEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/ConnectRectangleToGridEditPolicy.java
@@ -247,11 +247,17 @@ public class ConnectRectangleToGridEditPolicy extends ConnectToGridEditPolicy im
Node node = (Node) this.getHost().getModel();
java.util.List<Edge> sourceEdge = node.getSourceEdges();
for (Edge edge : sourceEdge) {
- updateAnchorFromHeight(edge, ((Node) getHost().getModel()), notification.getNewIntValue() - notification.getOldIntValue());
+ IdentityAnchor anchor = (IdentityAnchor) edge.getSourceAnchor();
+ if (anchor instanceof IdentityAnchor) {
+ updateAnchorFromHeight(anchor, ((Node) getHost().getModel()), notification.getNewIntValue() - notification.getOldIntValue());
+ }
}
java.util.List<Edge> targetEdge = node.getTargetEdges();
for (Edge edge : targetEdge) {
- updateAnchorFromHeight(edge, ((Node) getHost().getModel()), notification.getNewIntValue() - notification.getOldIntValue());
+ IdentityAnchor anchor = (IdentityAnchor) edge.getTargetAnchor();
+ if (anchor instanceof IdentityAnchor) {
+ updateAnchorFromHeight(anchor, ((Node) getHost().getModel()), notification.getNewIntValue() - notification.getOldIntValue());
+ }
}
}
}
@@ -266,11 +272,17 @@ public class ConnectRectangleToGridEditPolicy extends ConnectToGridEditPolicy im
Node node = (Node) this.getHost().getModel();
java.util.List<Edge> sourceEdge = node.getSourceEdges();
for (Edge edge : sourceEdge) {
- updateAnchorFromY(edge, ((Node) getHost().getModel()), notification.getOldIntValue(), notification.getNewIntValue());
+ IdentityAnchor anchor = (IdentityAnchor) edge.getSourceAnchor();
+ if (anchor instanceof IdentityAnchor) {
+ updateAnchorFromY(anchor, ((Node) getHost().getModel()), notification.getOldIntValue(), notification.getNewIntValue());
+ }
}
java.util.List<Edge> targetEdge = node.getTargetEdges();
for (Edge edge : targetEdge) {
- updateAnchorFromY(edge, ((Node) getHost().getModel()), notification.getOldIntValue(), notification.getNewIntValue());
+ IdentityAnchor anchor = (IdentityAnchor) edge.getTargetAnchor();
+ if (anchor instanceof IdentityAnchor) {
+ updateAnchorFromY(anchor, ((Node) getHost().getModel()), notification.getOldIntValue(), notification.getNewIntValue());
+ }
}
}
}
@@ -411,27 +423,27 @@ public class ConnectRectangleToGridEditPolicy extends ConnectToGridEditPolicy im
/**
* this class update the position of anchor after the resize
*
- * @param sourceEdge
- * @param eObject
+ * @param edge
+ * the edge anchor to update
+ * @param node
+ * @param deltaHeight
+ * @param isSource
+ * true is it is the anchor source to update, false for the target.
*/
- protected void updateAnchorFromHeight(Edge edge, Node node, int deltaHeight) {
- IdentityAnchor anchor = null;
- if (edge.getSource().equals(node)) {
- anchor = (IdentityAnchor) edge.getSourceAnchor();
- } else {
- anchor = (IdentityAnchor) edge.getTargetAnchor();
- }
- double yPercent = IdentityAnchorHelper.getYPercentage(anchor);
- double xPercent = IdentityAnchorHelper.getXPercentage(anchor);
+ protected void updateAnchorFromHeight(IdentityAnchor anchor, Node node, int deltaHeight) {
+ if (null != anchor) {
+ double yPercent = IdentityAnchorHelper.getYPercentage(anchor);
+ double xPercent = IdentityAnchorHelper.getXPercentage(anchor);
- // calculate bounds from notation
- PrecisionRectangle bounds = NotationHelper.getAbsoluteBounds(node);
- double oldHeight = BoundForEditPart.getHeightFromView(node) - deltaHeight;
+ // calculate bounds from notation
+ PrecisionRectangle bounds = NotationHelper.getAbsoluteBounds(node);
+ double oldHeight = BoundForEditPart.getHeightFromView(node) - deltaHeight;
- double newPercentY = (yPercent * oldHeight) / (bounds.preciseHeight());
- if (newPercentY <= 1 && newPercentY >= 0 && newPercentY <= 1 && newPercentY >= 0) {
- final String newIdValue = IdentityAnchorHelper.createNewAnchorIdValue(xPercent, newPercentY);
- execute(new SetCommand(getDiagramEditPart(getHost()).getEditingDomain(), anchor, NotationPackage.eINSTANCE.getIdentityAnchor_Id(), newIdValue));
+ double newPercentY = (yPercent * oldHeight) / (bounds.preciseHeight());
+ if (newPercentY <= 1 && newPercentY >= 0 && newPercentY <= 1 && newPercentY >= 0) {
+ final String newIdValue = IdentityAnchorHelper.createNewAnchorIdValue(xPercent, newPercentY);
+ execute(new SetCommand(getDiagramEditPart(getHost()).getEditingDomain(), anchor, NotationPackage.eINSTANCE.getIdentityAnchor_Id(), newIdValue));
+ }
}
}
@@ -442,14 +454,8 @@ public class ConnectRectangleToGridEditPolicy extends ConnectToGridEditPolicy im
* @param sourceEdge
* @param eObject
*/
- protected void updateAnchorFromY(Edge edge, Node node, int oldY, int newY) {
- IdentityAnchor anchor = null;
- if (edge.getSource().equals(node)) {
- anchor = (IdentityAnchor) edge.getSourceAnchor();
- } else {
- anchor = (IdentityAnchor) edge.getTargetAnchor();
- }
- if (!anchor.getId().trim().equals("")) { //$NON-NLS-1$
+ protected void updateAnchorFromY(IdentityAnchor anchor, Node node, int oldY, int newY) {
+ if (null != anchor && !anchor.getId().trim().equals("")) { //$NON-NLS-1$
double yPercent = IdentityAnchorHelper.getYPercentage(anchor);
double xPercent = IdentityAnchorHelper.getXPercentage(anchor);
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/DisplayEvent.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/DisplayEvent.java
index bf1da4ba693..636e5059f1e 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/DisplayEvent.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/DisplayEvent.java
@@ -256,10 +256,12 @@ public class DisplayEvent {
for (Edge edge : targetEdges) {
IdentityAnchor anchor = (IdentityAnchor) edge.getTargetAnchor();
- int y = getYfromAnchor(node, anchor);
+ if (anchor != null) {
+ int y = getYfromAnchor(node, anchor);
- if (eventLocation.equals(relativeLocation)) {
- eventLocation = getNewEventLocationY(relativeLocation, editPartFigure.getBounds().y + y, editPartFigure);
+ if (eventLocation.equals(relativeLocation)) {
+ eventLocation = getNewEventLocationY(relativeLocation, editPartFigure.getBounds().y + y, editPartFigure);
+ }
}
}
@@ -418,15 +420,17 @@ public class DisplayEvent {
} else {
anchor = (IdentityAnchor) edge.getTargetAnchor();
}
- double yPercent = IdentityAnchorHelper.getYPercentage(anchor);
- // calculate bounds from notation
- double height = 0;
- height = BoundForEditPart.getHeightFromView(node);
+ if (null != anchor) {
+ double yPercent = IdentityAnchorHelper.getYPercentage(anchor);
- double posY = yPercent * height;
- addAnEvent(container.getFigure(), posY, ColorConstants.white, currentPosition);
+ // calculate bounds from notation
+ double height = 0;
+ height = BoundForEditPart.getHeightFromView(node);
+ double posY = yPercent * height;
+ addAnEvent(container.getFigure(), posY, ColorConstants.white, currentPosition);
+ }
}
/**
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 e4ccc642e27..811bb776a52 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
@@ -18,6 +18,7 @@ import java.util.List;
import java.util.Map;
import org.eclipse.draw2d.ConnectionAnchor;
+import org.eclipse.draw2d.ConnectionRouter;
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.PointList;
@@ -27,6 +28,7 @@ import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gef.ConnectionEditPart;
import org.eclipse.gef.EditPart;
+import org.eclipse.gef.Request;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.commands.CompoundCommand;
import org.eclipse.gef.commands.UnexecutableCommand;
@@ -37,7 +39,6 @@ import org.eclipse.gef.requests.DropRequest;
import org.eclipse.gef.requests.ReconnectRequest;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
import org.eclipse.gmf.runtime.diagram.ui.commands.SetBoundsCommand;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionNodeEditPart;
import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart;
import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.GraphicalNodeEditPolicy;
@@ -57,12 +58,15 @@ import org.eclipse.papyrus.infra.services.edit.utils.RequestParameterConstants;
import org.eclipse.papyrus.uml.diagram.sequence.command.CreateExecutionSpecificationWithMessage;
import org.eclipse.papyrus.uml.diagram.sequence.command.DropDestructionOccurenceSpecification;
import org.eclipse.papyrus.uml.diagram.sequence.command.SetMoveAllLineAtSamePositionCommand;
+import org.eclipse.papyrus.uml.diagram.sequence.draw2d.routers.MessageRouter;
import org.eclipse.papyrus.uml.diagram.sequence.edit.helpers.AnchorHelper;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CLifeLineEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageCreateEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageDeleteEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.util.LifelineEditPartUtil;
import org.eclipse.papyrus.uml.diagram.sequence.util.LifelineMessageCreateHelper;
+import org.eclipse.papyrus.uml.diagram.sequence.util.LifelineMessageDeleteHelper;
import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceDiagramConstants;
import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceUtil;
import org.eclipse.papyrus.uml.service.types.element.UMLDIElementTypes;
@@ -85,6 +89,10 @@ public class LifeLineGraphicalNodeEditPolicy extends DefaultGraphicalNodeEditPol
private DisplayEvent displayEvent;
private boolean precisionMode;
+
+ /** the router to use for messages */
+ public static ConnectionRouter messageRouter = new MessageRouter();
+
/**
* @see org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultGraphicalNodeEditPolicy#getConnectionCreateCommand(org.eclipse.gef.requests.CreateConnectionRequest)
*
@@ -174,18 +182,15 @@ public class LifeLineGraphicalNodeEditPolicy extends DefaultGraphicalNodeEditPol
/**
+ * {@inheritDoc}
+ *
* @see org.eclipse.gmf.runtime.diagram.ui.editpolicies.GraphicalNodeEditPolicy#getSourceConnectionAnchor(org.eclipse.gef.requests.CreateConnectionRequest)
- *
- * @param request
- * @return
*/
@Override
- protected ConnectionAnchor getSourceConnectionAnchor(CreateConnectionRequest request) {
+ protected ConnectionAnchor getSourceConnectionAnchor(final CreateConnectionRequest request) {
+ // Snap to event if necessary
request.setLocation(displayEvent.getRealEventLocation(request.getLocation()));
- ConnectionAnchor sourceConnectionAnchor = super.getSourceConnectionAnchor(request);
- ConnectionAnchor newSourceConnectionAnchor = sourceConnectionAnchor;
-
- return newSourceConnectionAnchor;
+ return super.getSourceConnectionAnchor(request);
}
/**
@@ -312,7 +317,6 @@ public class LifeLineGraphicalNodeEditPolicy extends DefaultGraphicalNodeEditPol
*/
@Override
protected Command getConnectionAndRelationshipCompleteCommand(CreateConnectionViewAndElementRequest request) {
-
// Update request with the real Location of the Event if location next to an Event
Point realEventLocation = displayEvent.getRealEventLocation(request.getLocation());
if (request.getLocation() != realEventLocation) {
@@ -497,15 +501,34 @@ public class LifeLineGraphicalNodeEditPolicy extends DefaultGraphicalNodeEditPol
* @return Compound cmd with the Delete Occurrence Specification command
*/
protected Command getDeleteEdgeCommand(CreateConnectionViewAndElementRequest request, Command cmd) {
- Rectangle relativePt = new Rectangle(request.getLocation().x, request.getLocation().y, 0, 0);
- getHostFigure().getParent().translateToRelative(relativePt);
- DropDestructionOccurenceSpecification dropDestructionOccurenceSpecification = new DropDestructionOccurenceSpecification(getDiagramEditPart(getHost()).getEditingDomain(), request, (NodeEditPart) request.getTargetEditPart(), relativePt.getTopLeft());
- CompoundCommand compoundCommand = new CompoundCommand();
- compoundCommand.add(cmd);
- compoundCommand.add(new GMFtoGEFCommandWrapper(dropDestructionOccurenceSpecification));
- return compoundCommand;
+ // if it's the first message delete and the last event on the target lifeline
+ if (!LifelineMessageDeleteHelper.hasIncomingMessageDelete(request.getTargetEditPart())) {
+ Point relativeSnappedLocation = request.getLocation().getCopy();
+ relativeSnappedLocation = SequenceUtil.getSnappedLocation(getHost(), relativeSnappedLocation);
+ getHostFigure().getParent().translateToRelative(relativeSnappedLocation);
+
+ if (LifelineEditPartUtil.getNextEventsFromPosition(relativeSnappedLocation, (LifelineEditPart) request.getTargetEditPart()).isEmpty()) {
+
+ NodeEditPart targetEditPart = (NodeEditPart) request.getTargetEditPart();
+ DropDestructionOccurenceSpecification dropDestructionOccurenceSpecification = new DropDestructionOccurenceSpecification(getDiagramEditPart(getHost()).getEditingDomain(), request, targetEditPart, request.getLocation().getCopy());
+ CompoundCommand compoundCommand = new CompoundCommand();
+ compoundCommand.add(cmd);
+ compoundCommand.add(new GMFtoGEFCommandWrapper(dropDestructionOccurenceSpecification)); // Get resize command
+ if (targetEditPart instanceof CLifeLineEditPart) {
+ Bounds lifelineBounds = ((Bounds) ((Node) targetEditPart.getModel()).getLayoutConstraint());
+ Dimension size = new Dimension(lifelineBounds.getWidth(), relativeSnappedLocation.y - lifelineBounds.getY());
+
+ SetBoundsCommand setSizeCommand = new SetBoundsCommand(getDiagramEditPart(getHost()).getEditingDomain(), "Size LifeLine", new EObjectAdapter(((GraphicalEditPart) targetEditPart).getNotationView()), //$NON-NLS-1$
+ size);
+ compoundCommand.add(new GMFtoGEFCommandWrapper(setSizeCommand));
+ }
+ return compoundCommand;
+ }
+ }
+ return UnexecutableCommand.INSTANCE;
}
+
/**
* Get the Command for a Message Create creation
* Adding the command to update the grid accordingly
@@ -518,7 +541,8 @@ public class LifeLineGraphicalNodeEditPolicy extends DefaultGraphicalNodeEditPol
*/
protected Command getCreateEdgeCommand(final CreateConnectionViewAndElementRequest request, final Command cmd) {
// if it's the first message create
- if (LifelineMessageCreateHelper.getIncomingMessageCreate(request.getTargetEditPart()).isEmpty()) {
+ if (request.getTargetEditPart() instanceof LifelineEditPart && !LifelineMessageCreateHelper.hasIncomingMessageCreate(request.getTargetEditPart())
+ && !LifelineEditPartUtil.hasPreviousEvent(request.getLocation().getCopy(), (LifelineEditPart) request.getTargetEditPart())) {
NodeEditPart nodeEP = (NodeEditPart) request.getTargetEditPart();
Map<String, Object> requestParameters = request.getExtendedData();
final Point sourcePoint = ((Point) requestParameters.get(RequestParameterConstants.EDGE_SOURCE_POINT)).getCopy();
@@ -540,30 +564,24 @@ public class LifeLineGraphicalNodeEditPolicy extends DefaultGraphicalNodeEditPol
*/
protected CompoundCommand getSetLifelinePositionCommand(final Command originalCommand, final NodeEditPart targetEditPart, final Point sourcePoint) {
CompoundCommand compoundCommand = new CompoundCommand();
- getHostFigure().getParent().translateToRelative(sourcePoint);
if (targetEditPart instanceof CLifeLineEditPart) {
+ // Get the snapped location
+ PrecisionPoint snappedLocation = SequenceUtil.getSnappedLocation(getHost(), sourcePoint);
+ // Translate to relative
+ getHostFigure().getParent().translateToRelative(snappedLocation);
int stickerHeight = ((CLifeLineEditPart) targetEditPart).getStickerHeight();
if (stickerHeight != -1) {
- sourcePoint.y = sourcePoint.y - (stickerHeight / 2);
+ snappedLocation.y = snappedLocation.y - (stickerHeight / 2);
}
- Bounds bounds = ((Bounds) ((Node) targetEditPart.getModel()).getLayoutConstraint());
+ Rectangle bounds = getHostFigure().getBounds();
- SetBoundsCommand setPositionCommand = new SetBoundsCommand(getDiagramEditPart(getHost()).getEditingDomain(), "Move LifeLine", new EObjectAdapter(((GraphicalEditPart) targetEditPart).getNotationView()), //$NON-NLS-1$
- new Point(bounds.getX(), sourcePoint.y));
+ Rectangle newBounds = new Rectangle(new Point(bounds.x(), snappedLocation.y), new Dimension(bounds.width(), bounds.height() - snappedLocation.y));
- SetBoundsCommand setSizeCommand = new SetBoundsCommand(getDiagramEditPart(getHost()).getEditingDomain(), "Size LifeLine", new EObjectAdapter(((GraphicalEditPart) targetEditPart).getNotationView()), //$NON-NLS-1$
- new Dimension(bounds.getWidth(), bounds.getHeight() - sourcePoint.y + stickerHeight / 2));
+ SetBoundsCommand setBoundsCommand = new SetBoundsCommand(getDiagramEditPart(getHost()).getEditingDomain(), "Move&Size LifeLine", new EObjectAdapter(((GraphicalEditPart) targetEditPart).getNotationView()), //$NON-NLS-1$
+ newBounds);
- // // // TODO_MIA Aks if SetMoveAllLineAtSamePositionCommand is up to date: to delete if not useful
- // DiagramEditPart diagramEditPart = getDiagramEditPart(getHost());
- // GridManagementEditPolicy grid = (GridManagementEditPolicy) diagramEditPart.getEditPolicy(GridManagementEditPolicy.GRID_MANAGEMENT);
- // SetMoveAllLineAtSamePositionCommand setMoveAllLineAtSamePositionCommand = new SetMoveAllLineAtSamePositionCommand(grid, false);
- // compoundCommand.add(setMoveAllLineAtSamePositionCommand);
compoundCommand.add(originalCommand);
- compoundCommand.add(new GMFtoGEFCommandWrapper(setPositionCommand));
- // setMoveAllLineAtSamePositionCommand = new SetMoveAllLineAtSamePositionCommand(grid, true);
- // compoundCommand.add(setMoveAllLineAtSamePositionCommand);
- compoundCommand.add(new GMFtoGEFCommandWrapper(setSizeCommand));
+ compoundCommand.add(new GMFtoGEFCommandWrapper(setBoundsCommand));
}
return compoundCommand;
}
@@ -637,49 +655,56 @@ public class LifeLineGraphicalNodeEditPolicy extends DefaultGraphicalNodeEditPol
NodeEditPart nodeEP = (NodeEditPart) request.getTarget();
// in case of reconnect target for message create it is need to move up the old target and move down the new target
- if (nodeEP instanceof CLifeLineEditPart && request.getConnectionEditPart() instanceof MessageCreateEditPart) {
- command = new CompoundCommand();
- if (LifelineMessageCreateHelper.getIncomingMessageCreate(nodeEP).isEmpty()) {
- // if first message, need to move it down
- ((CompoundCommand) command).add(getSetLifelinePositionCommand(reconnectTargetCommand, nodeEP, request.getLocation()));
- } else {
- ((CompoundCommand) command).add(reconnectTargetCommand);
- }
+ if (nodeEP instanceof CLifeLineEditPart) {
+ Point requestLocationCopy = request.getLocation().getCopy();
+ if (request.getConnectionEditPart() instanceof MessageCreateEditPart) {
+ if (!LifelineEditPartUtil.hasPreviousEvent((Point) requestLocationCopy, (LifelineEditPart) getHost())) {
+
+ command = new CompoundCommand();
+ if (!LifelineMessageCreateHelper.hasIncomingMessageCreate(nodeEP)) {
+ // if first message, need to move it down
+ ((CompoundCommand) command).add(getSetLifelinePositionCommand(reconnectTargetCommand, nodeEP, requestLocationCopy));
+ } else {
+ ((CompoundCommand) command).add(reconnectTargetCommand);
+ }
+ // move up old target if the target is different of the source
+ if (!request.getConnectionEditPart().getTarget().equals(request.getTarget())) {
+ ((CompoundCommand) command).add(LifelineEditPartUtil.getRestoreLifelinePositionOnMessageCreateRemovedCommand((ConnectionEditPart) request.getConnectionEditPart()));
+ }
+ }
+ } else if (request.getConnectionEditPart() instanceof MessageDeleteEditPart) {
+ if (!LifelineEditPartUtil.hasNextEvent((Point) requestLocationCopy, (LifelineEditPart) getHost())) {
+ command = new CompoundCommand();
+ if (!LifelineMessageDeleteHelper.hasIncomingMessageDelete(nodeEP)) {
+
+ NodeEditPart targetEditPart = (NodeEditPart) (LifelineEditPart) getHost();
+ DropDestructionOccurenceSpecification dropDestructionOccurenceSpecification = new DropDestructionOccurenceSpecification(getDiagramEditPart(getHost()).getEditingDomain(), request, targetEditPart, requestLocationCopy);
+ CompoundCommand compoundCommand = new CompoundCommand();
+ compoundCommand.add(reconnectTargetCommand);
+ compoundCommand.add(new GMFtoGEFCommandWrapper(dropDestructionOccurenceSpecification));
+ // Get resize command
+ if (targetEditPart instanceof CLifeLineEditPart) {
+ Bounds lifeLineBounds = ((Bounds) ((Node) targetEditPart.getModel()).getLayoutConstraint());
+ SetBoundsCommand setSizeCommand = new SetBoundsCommand(getDiagramEditPart(getHost()).getEditingDomain(), "Size LifeLine", new EObjectAdapter(((GraphicalEditPart) targetEditPart).getNotationView()), //$NON-NLS-1$
+ new Dimension(lifeLineBounds.getWidth(), request.getLocation().y - lifeLineBounds.getY()));
+ compoundCommand.add(new GMFtoGEFCommandWrapper(setSizeCommand));
+ }
+ } else {
+ ((CompoundCommand) command).add(reconnectTargetCommand);
+ }
- // move up old target if the target is different of the source
- if (!request.getConnectionEditPart().getTarget().equals(request.getTarget())) {
- ((CompoundCommand) command).add(LifelineEditPartUtil.getRestoreLifelinePositionOnMessageCreateRemovedCommand((ConnectionEditPart) request.getConnectionEditPart()));
+ // restore position of the old target
+ if (!request.getConnectionEditPart().getTarget().equals(request.getTarget())) {
+ ((CompoundCommand) command).add(LifelineEditPartUtil.getRestoreLifelinePositionOnMessageCreateRemovedCommand((ConnectionEditPart) request.getConnectionEditPart()));
+ }
+ }
+ } else {
+ command = reconnectTargetCommand;
}
} else {
command = reconnectTargetCommand;
}
-
- // Set request extended data if it's the first event on the lifeline
- if (request.getLocation() != null) {
- List<MessageEnd> previous = LifelineEditPartUtil.getPreviousEventsFromPosition((Point) request.getLocation(), (LifelineEditPart) getHost());
- request.getExtendedData().put(org.eclipse.papyrus.uml.service.types.utils.RequestParameterConstants.IS_FIRST_EVENT, previous.isEmpty());
- }
-
- return command;
- }
-
- protected Command getReconnectCommand(ConnectionNodeEditPart connectionPart, EditPart targetPart, Point location, String requestType) {
- ReconnectRequest req = new ReconnectRequest(REQ_RECONNECT_TARGET);
- req.setConnectionEditPart(connectionPart);
- req.setTargetEditPart(targetPart);
- Point newlocation = SequenceUtil.getAbsoluteEdgeExtremity(connectionPart, false);
- location.setY(newlocation.y);
- req.setLocation(location);
- Command command = targetPart.getCommand(req);
return command;
- // // Create and set the properties of the request
- // ReconnectRequest reconnReq = new ReconnectRequest();
- // reconnReq.setConnectionEditPart(connectionPart);
- // reconnReq.setLocation(location);
- // reconnReq.setTargetEditPart(targetPart);
- // reconnReq.setType(requestType);
- // Command cmd = targetPart.getCommand(reconnReq);
- // return cmd;
}
@@ -694,8 +719,6 @@ public class LifeLineGraphicalNodeEditPolicy extends DefaultGraphicalNodeEditPol
return previousEventsFromPosition.isEmpty() ? null : previousEventsFromPosition.get(0);
}
-
-
/**
* This method update the request in order to make the point at the correct position on the grill.
*
@@ -721,6 +744,16 @@ public class LifeLineGraphicalNodeEditPolicy extends DefaultGraphicalNodeEditPol
}
}
+ /**
+ * Get the replacing connection router for routing messages correctly
+ *
+ * @see org.eclipse.gef.editpolicies.GraphicalNodeEditPolicy#getDummyConnectionRouter(org.eclipse.gef.requests.CreateConnectionRequest)
+ */
+ @Override
+ protected ConnectionRouter getDummyConnectionRouter(CreateConnectionRequest req) {
+ return messageRouter;
+ }
+
/**
*
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LifelineEditPartUtil.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LifelineEditPartUtil.java
index 7af733340fa..826f7fbb6d9 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LifelineEditPartUtil.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LifelineEditPartUtil.java
@@ -42,8 +42,10 @@ import org.eclipse.gmf.runtime.notation.Shape;
import org.eclipse.gmf.runtime.notation.impl.ShapeImpl;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.BehaviorExecutionSpecificationEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CCombinedCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CLifeLineEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageCreateEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageDeleteEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.figures.LifelineDotLineCustomFigure;
import org.eclipse.papyrus.uml.diagram.sequence.referencialgrilling.GridManagementEditPolicy;
import org.eclipse.uml2.uml.Lifeline;
@@ -123,7 +125,7 @@ public class LifelineEditPartUtil {
Command commands = null;
if (editPart instanceof MessageCreateEditPart) {
MessageCreateEditPart part = (MessageCreateEditPart) editPart;
- if (part.getTarget() instanceof LifelineEditPart && 1 == LifelineMessageCreateHelper.getIncomingMessageCreate(part.getTarget()).size()) {
+ if (part.getTarget() instanceof LifelineEditPart && LifelineMessageCreateHelper.hasIncomingMessageCreate(part.getTarget())) {
LifelineEditPart target = (LifelineEditPart) part.getTarget();
if (target.getModel() instanceof Shape) {
Shape view = (ShapeImpl) target.getModel();
@@ -145,6 +147,38 @@ public class LifelineEditPartUtil {
}
/**
+ * @param editPart
+ * the remove {@link MessageCreateEditPart}
+ * @return the command when the last delete message is remove to a lifeline to move it up and resize it.
+ * @since 3.1
+ *
+ */
+ public static Command getRestoreLifelinePositionOnMessageDeleteRemovedCommand(final ConnectionEditPart editPart) {
+ Command commands = null;
+ if (editPart instanceof MessageDeleteEditPart) {
+ MessageDeleteEditPart part = (MessageDeleteEditPart) editPart;
+ if (part.getTarget() instanceof LifelineEditPart && LifelineMessageDeleteHelper.hasIncomingMessageDelete(part.getTarget())) {
+ LifelineEditPart target = (LifelineEditPart) part.getTarget();
+ if (target.getModel() instanceof Shape) {
+ Shape view = (ShapeImpl) target.getModel();
+ if (view.getLayoutConstraint() instanceof Bounds) {
+ Bounds bounds = (Bounds) view.getLayoutConstraint();
+ // get the set bounds command
+ Point newLocation = new Point(bounds.getX(), bounds.getY());
+ Dimension newDimension = new Dimension(bounds.getWidth(), CLifeLineEditPart.DEFAUT_HEIGHT - bounds.getY());
+ Rectangle newBounds = new Rectangle(newLocation, newDimension);
+
+ ICommand boundsCommand = new SetBoundsCommand(target.getEditingDomain(), DiagramUIMessages.SetLocationCommand_Label_Resize, new EObjectAdapter(view), newBounds);
+
+ commands = new ICommandProxy(boundsCommand);
+ }
+ }
+ }
+ }
+ return commands;
+ }
+
+ /**
* Get the list of previous {@link MessageEnd} on the {@link LifelineEditPart} according to the position.
*
* @param position
@@ -179,8 +213,61 @@ public class LifelineEditPartUtil {
}
/**
+ * @since 3.1
+ *
+ */
+ public static boolean hasPreviousEvent(final Point position, final LifelineEditPart lifelineEditPart) {
+ return !getPreviousEventsFromPosition(position, lifelineEditPart).isEmpty();
+ }
+
+ /**
+ * @since 3.1
+ *
+ */
+ public static boolean hasNextEvent(final Point position, final LifelineEditPart lifelineEditPart) {
+ return !getNextEventsFromPosition(position, lifelineEditPart).isEmpty();
+ }
+
+ /**
+ * Get the list of previous {@link MessageEnd} on the {@link LifelineEditPart} according to the position.
+ *
+ * @param position
+ * The reference position.
+ * @param lifelineEditPart
+ * The lifeline edit part
+ * @since 3.1
+ */
+ public static List<MessageEnd> getNextEventsFromPosition(final Point position, final LifelineEditPart lifelineEditPart) {
+ List<MessageEnd> previous = new ArrayList<MessageEnd>();
+ DiagramEditPart diagramEditPart = getDiagramEditPart(lifelineEditPart);
+ Lifeline lifeline = (Lifeline) lifelineEditPart.resolveSemanticElement();
+ try {
+ GridManagementEditPolicy grilling = (GridManagementEditPolicy) diagramEditPart.getEditPolicy(GridManagementEditPolicy.GRID_MANAGEMENT);
+ if (grilling != null) {
+ for (DecorationNode row : grilling.rows) {
+ Point currentPoint = GridManagementEditPolicy.getLocation(row);
+ if (currentPoint.y > position.y) {
+ if (row.getElement() != null) {
+ EObject referedElement = row.getElement();
+ if (referedElement instanceof MessageEnd) {
+ if (lifeline.getCoveredBys().contains(referedElement)) {
+ previous.add((MessageEnd) referedElement);
+ }
+ }
+ }
+ }
+ }
+ }
+ } catch (Exception e) {
+ }
+ return previous;
+ }
+
+ /**
* Walks up the editpart hierarchy to find and return the
* <code>TopGraphicEditPart</code> instance.
+ *
+ * @since 3.1
*/
public static DiagramEditPart getDiagramEditPart(EditPart editPart) {
while (editPart instanceof IGraphicalEditPart) {
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LifelineMessageCreateHelper.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LifelineMessageCreateHelper.java
index ffa7eace43e..a55d2f0eef9 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LifelineMessageCreateHelper.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LifelineMessageCreateHelper.java
@@ -38,12 +38,12 @@ import org.eclipse.gmf.runtime.notation.Bounds;
import org.eclipse.gmf.runtime.notation.Shape;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.gmf.runtime.notation.impl.ShapeImpl;
-import org.eclipse.papyrus.uml.diagram.common.draw2d.anchors.LifelineAnchor;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CInteractionEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CLifeLineEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageCreateEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.OLDLifelineEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.figures.LifelineDotLineCustomFigure;
+import org.eclipse.papyrus.uml.diagram.sequence.locator.MessageCreateLifelineAnchor;
public class LifelineMessageCreateHelper {
@@ -59,15 +59,11 @@ public class LifelineMessageCreateHelper {
}
}
- @Deprecated // TODO_MIA TO_DELETE
+
public static ConnectionAnchor getCreateMessageAnchor(LifelineEditPart part, Request request, Point location) {
IFigure fig = part.getPrimaryShape();
fig.translateToRelative(location);
- if (fig.containsPoint(location)) {// move to header
- return new LifelineAnchor(part.getPrimaryShape());
- }
- // move to dash line
- return getTargetConnectionAnchor(part, request);
+ return new MessageCreateLifelineAnchor(part.getPrimaryShape(), (CLifeLineEditPart) part);
}
@Deprecated // TODO_MIA TO_DELETE
@@ -96,6 +92,7 @@ public class LifelineMessageCreateHelper {
}
// when a create message is deleted, move its target lifelines up
+ @Deprecated // TODO_MIA TO_DELETE
public static Command restoreLifelineOnMessageDelete(Command commands, EditPart editPart) {
if (editPart instanceof MessageCreateEditPart) {
MessageCreateEditPart part = (MessageCreateEditPart) editPart;
@@ -116,6 +113,7 @@ public class LifelineMessageCreateHelper {
return commands;
}
+ // TODO_MIA TO_DELETE
// when a lifleine is deleted, move its created lifelines up
public static Command restoreLifelineOnDelete(Command command, LifelineEditPart part) {
List<?> list = part.getSourceConnections();
@@ -228,8 +226,8 @@ public class LifelineMessageCreateHelper {
@Deprecated // TODO_MIA TO_DELETE
public static Command moveCascadeLifeline(LifelineEditPart part, Command command, int dy) {
- command = moveCascadeLifelineRecursive(part, command, dy);
- CInteractionEditPart interactionEP = (CInteractionEditPart) part.getParent().getParent();
+ // command = moveCascadeLifelineRecursive(part, command, dy);
+ // CInteractionEditPart interactionEP = (CInteractionEditPart) part.getParent().getParent();
// command = interactionEP.getUpdateLifelinesHeightsCommand(command);
return command;
}
@@ -241,7 +239,7 @@ public class LifelineMessageCreateHelper {
if (list != null && list.size() > 0) {
for (Object l : list) {
if (l instanceof MessageCreateEditPart) {
- EditPart target = ((MessageCreateEditPart) l).getTarget();
+ // EditPart target = ((MessageCreateEditPart) l).getTarget();
// if (target instanceof CLifeLineEditPart) {
// CLifeLineEditPart lp = (CLifeLineEditPart) target;
// Rectangle bounds = lp.getFigure().getBounds().getCopy();
@@ -264,7 +262,7 @@ public class LifelineMessageCreateHelper {
}
public static boolean canMoveLifelineVertical(LifelineEditPart child, Rectangle newBounds) {
- int halfHeight = child.getPrimaryShape().getFigureLifelineNameContainerFigure().getBounds().height / 2;
+ int halfHeight = child.getPrimaryShape().getFigureLifelineNameContainerFigure().getBounds().height / 2; // TODO_MIA check the use of this methode
// check outgoing links
List<?> list = child.getSourceConnections();
if (list != null && list.size() > 0) {
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LifelineMessageDeleteHelper.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LifelineMessageDeleteHelper.java
index 779e0d5b2f3..412b33ab84e 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LifelineMessageDeleteHelper.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LifelineMessageDeleteHelper.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2014 CEA LIST and others.
+ * Copyright (c) 2014-2017 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
@@ -9,18 +9,18 @@
* Contributors:
* CEA LIST - Initial API and implementation
* Alex Paperno - bug 444956
- *
+ * Mickaƫl ADAM (ALL4TEC) mickael.adam@all4tec.net - Bug 519408
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.sequence.util;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.emf.common.util.EList;
+import java.util.ArrayList;
+import java.util.List;
+
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.commands.Command;
-import org.eclipse.gef.commands.UnexecutableCommand;
import org.eclipse.gef.requests.ReconnectRequest;
import org.eclipse.gef.requests.TargetRequest;
import org.eclipse.gmf.runtime.common.core.util.StringStatics;
@@ -29,26 +29,15 @@ import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewAndElementRequest;
import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
-import org.eclipse.gmf.runtime.emf.type.core.IHintedType;
-import org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand;
-import org.eclipse.gmf.runtime.notation.Edge;
-import org.eclipse.papyrus.uml.diagram.sequence.command.ChangeEdgeTargetCommand;
-import org.eclipse.papyrus.uml.diagram.sequence.command.CreateElementAndNodeCommand;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.AbstractExecutionSpecificationEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DestructionOccurrenceSpecificationEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
-import org.eclipse.papyrus.uml.service.types.utils.SequenceRequestConstant;
-import org.eclipse.uml2.uml.DestructionOccurrenceSpecification;
-import org.eclipse.uml2.uml.InteractionFragment;
-import org.eclipse.uml2.uml.Lifeline;
-import org.eclipse.uml2.uml.Message;
-import org.eclipse.uml2.uml.MessageEnd;
-import org.eclipse.uml2.uml.MessageOccurrenceSpecification;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageDeleteEditPart;
+/**
+ * @since 3.1
+ */
public class LifelineMessageDeleteHelper {
-
/*
* Set edge.target to the target lifeline
*/
@@ -70,7 +59,49 @@ public class LifelineMessageDeleteHelper {
sceCommand.setEdgeAdaptor(createRequest.getConnectionViewDescriptor());
sceCommand.setNewTargetAdaptor(targetEP);
return new ICommandProxy(sceCommand);
- }
- return null;
+ }
+ return null;
+ }
+
+ /**
+ * @return true if a Message Delete exist between the source and the target.
+ * @since 4.0
+ */
+ public static boolean hasMessageDelete(final GraphicalEditPart sourceEditPart, final EditPart targetEditPart) {
+ List<?> list = sourceEditPart.getSourceConnections();
+ for (Object o : list) {
+ if (o instanceof MessageDeleteEditPart && targetEditPart.equals(((MessageDeleteEditPart) o).getTarget())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * @return true if edit part as has incoming message delete.
+ * @since 4.0
+ */
+ public static boolean hasIncomingMessageDelete(final EditPart target) {
+ return !getIncomingMessageDelete(target).isEmpty();
+ }
+
+ /**
+ * Get the list of incoming message delete of an edit part.
+ *
+ * @since 4.0
+ */
+ public static List<?> getIncomingMessageDelete(final EditPart target) {
+ List<EditPart> create = new ArrayList<EditPart>();
+ if (target instanceof LifelineEditPart) {
+ List<?> list = ((LifelineEditPart) target).getTargetConnections();
+ if (list != null && list.size() > 0) {
+ for (Object l : list) {
+ if (l instanceof MessageDeleteEditPart) {
+ create.add((MessageDeleteEditPart) l);
+ }
+ }
+ }
+ }
+ return create;
}
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/SelfMessageHelper.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/SelfMessageHelper.java
index 74b7dc0aa73..1b1989ab6bc 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/SelfMessageHelper.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/SelfMessageHelper.java
@@ -20,7 +20,7 @@ import org.eclipse.gmf.runtime.notation.LayoutConstraint;
import org.eclipse.gmf.runtime.notation.Location;
import org.eclipse.gmf.runtime.notation.Node;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.AbstractMessageEditPart;
-import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.OLDGateEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.GateEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.locator.SelfMessageLabelLocator;
@@ -77,7 +77,7 @@ public class SelfMessageHelper {
return sourceLifeline == targetLifeline;
}
// Fixed bug about displaying label for gate to gate messages.
- if (source instanceof OLDGateEditPart && target instanceof OLDGateEditPart) {
+ if (source instanceof GateEditPart && target instanceof GateEditPart) {
if (source.getParent() == target.getParent() && (source.getParent() instanceof LifelineEditPart)) {
return true;
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/SequenceUtil.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/SequenceUtil.java
index d5fcb75fe5b..63f4d7ec394 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/SequenceUtil.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/SequenceUtil.java
@@ -36,6 +36,7 @@ import org.eclipse.draw2d.PositionConstants;
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.PrecisionPoint;
+import org.eclipse.draw2d.geometry.PrecisionRectangle;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.EObject;
@@ -44,6 +45,8 @@ import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.edit.command.SetCommand;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gef.EditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.SnapToHelper;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.commands.CompoundCommand;
import org.eclipse.gmf.runtime.common.core.command.CommandResult;
@@ -799,7 +802,7 @@ public class SequenceUtil {
* the contained edit part or itself
* @return lifeline edit part or null
*/
- public static CLifeLineEditPart getParentLifelinePart(EditPart nodeEditPart) {
+ public static LifelineEditPart getParentLifelinePart(EditPart nodeEditPart) {
EditPart parent = nodeEditPart;
while (parent != null) {
if (parent instanceof CLifeLineEditPart) {
@@ -810,7 +813,7 @@ public class SequenceUtil {
}
return null;
}
-
+
/**
* Return the combined fragment edit part containing this part (directly or indirectly).
*
@@ -1679,4 +1682,44 @@ public class SequenceUtil {
editPart.getParent().installEditPolicy(editPolicy, new ObservationLinkPolicy(editPart));
}
}
+
+ /**
+ * update the bounds of the rectangle to snap to grid
+ *
+ * @param editPart
+ * @param bounds
+ * @param request
+ * @return
+ *
+ */
+ public static PrecisionRectangle getSnappedBounds(EditPart editPart, Rectangle bounds) {
+ PrecisionRectangle baseRect = new PrecisionRectangle(bounds);
+ PrecisionRectangle result = baseRect.getPreciseCopy();
+ if (editPart != null) {
+ SnapToHelper helper = editPart.getAdapter(SnapToHelper.class);
+ if (helper != null) {
+ helper.snapRectangle(new Request(), PositionConstants.NSEW, baseRect, result);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * update the bounds of the rectangle to snap to grid
+ *
+ * @param editPart
+ * @param location
+ *
+ */
+ public static PrecisionPoint getSnappedLocation(EditPart editPart, Point location) {
+ PrecisionPoint baseRect = new PrecisionPoint(location);
+ PrecisionPoint result = baseRect.getPreciseCopy();
+ if (editPart != null) {
+ SnapToHelper helper = editPart.getAdapter(SnapToHelper.class);
+ if (helper != null) {
+ helper.snapPoint(new Request(), PositionConstants.NSEW, baseRect, result);
+ }
+ }
+ return result;
+ }
}

Back to the top