Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMickael ADAM2017-09-08 12:00:16 +0000
committerMickael ADAM2017-09-12 13:58:45 +0000
commitb8647a42710067e6e8082fa3c96b3aae033d85dd (patch)
treec56d4a1058a33370ca92a7f3167864637d656440 /plugins/uml
parent9d6a4eba9f345b698bffcd7ed32747c3fe5f57be (diff)
downloadorg.eclipse.papyrus-b8647a42710067e6e8082fa3c96b3aae033d85dd.tar.gz
org.eclipse.papyrus-b8647a42710067e6e8082fa3c96b3aae033d85dd.tar.xz
org.eclipse.papyrus-b8647a42710067e6e8082fa3c96b3aae033d85dd.zip
Bug 522047 - [Sequence Diagram] Execution specification created with
message Sync is misplaced https://bugs.eclipse.org/bugs/show_bug.cgi?id=522047 - Cherry pick from https://git.eclipse.org/r/104745 Change-Id: I6e93caa1cfb58f4c2dd4e4ddc8d2801a84a392a2 Signed-off-by: Mickael ADAM <mickael.adam@all4tec.net>
Diffstat (limited to 'plugins/uml')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/.options3
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/command/CreateExecutionSpecificationWithMessage.java90
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/UpdateNodeReferenceEditPolicy.java14
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/DisplayEvent.java13
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/LifeLineGraphicalNodeEditPolicy.java11
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/SequenceUtil.java14
6 files changed, 87 insertions, 58 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/.options b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/.options
index e280f1a9a6b..6dbd6ad54b8 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/.options
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/.options
@@ -5,3 +5,6 @@ org.eclipse.papyrus.uml.diagram.sequence/debug=false
# Visual IDs
org.eclipse.papyrus.uml.diagram.sequence/debug/visualID=false
+org.eclipse.papyrus.uml.diagram.sequence/debug/SequenceDebug=false
+org.eclipse.papyrus.uml.diagram.sequence/debug/SequenceDebugGrid=false
+org.eclipse.papyrus.uml.diagram.sequence/debug/SequenceDebugUtil=false
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/command/CreateExecutionSpecificationWithMessage.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/command/CreateExecutionSpecificationWithMessage.java
index 12854dd9e77..233b62868f5 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/command/CreateExecutionSpecificationWithMessage.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/command/CreateExecutionSpecificationWithMessage.java
@@ -26,23 +26,24 @@ import org.eclipse.gef.commands.Command;
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.requests.CreateConnectionViewAndElementRequest;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewAndElementRequest.ConnectionViewAndElementDescriptor;
import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewRequest;
import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequestFactory;
-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewAndElementRequest.ConnectionViewAndElementDescriptor;
import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
import org.eclipse.gmf.runtime.emf.type.core.IHintedType;
import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.papyrus.uml.diagram.sequence.messages.Messages;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CustomActionExecutionSpecificationEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.messages.Messages;
import org.eclipse.papyrus.uml.diagram.sequence.part.UMLDiagramEditorPlugin;
import org.eclipse.papyrus.uml.diagram.sequence.preferences.CustomDiagramGeneralPreferencePage;
+import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceUtil;
import org.eclipse.papyrus.uml.service.types.element.UMLDIElementTypes;
import org.eclipse.uml2.uml.Message;
/**
- * this class is used to automatically create execution specifications at target
+ * this class is used to automatically create execution specifications at target
* from the request in charge of creating a message between lifelines
* according to the preferences for this message sort
*/
@@ -54,17 +55,19 @@ public class CreateExecutionSpecificationWithMessage extends AbstractTransaction
protected String preference;
protected IHintedType type;
protected boolean createReply;
-
+
/**
* @param domain
- * @param request the request that is in charge of creating the message
- * @param graphicalContainer the lifeline that will contain the event representation
+ * @param request
+ * the request that is in charge of creating the message
+ * @param graphicalContainer
+ * the lifeline that will contain the event representation
*/
public CreateExecutionSpecificationWithMessage(TransactionalEditingDomain domain, CreateConnectionViewAndElementRequest request, EditPart graphicalContainer) {
super(domain, Messages.Commands_CreateExecutionSpecification_Label, null);
- this.request=request;
- this.graphicalContainer= graphicalContainer;
-
+ this.request = request;
+ this.graphicalContainer = graphicalContainer;
+
this.createReply = false;
}
@@ -78,44 +81,43 @@ public class CreateExecutionSpecificationWithMessage extends AbstractTransaction
*/
@Override
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- //1. look for the message triggering the creation of the execution specification
- Message message=getMessage();
- if( message==null){
+ // 1. look for the message triggering the creation of the execution specification
+ Message message = getMessage();
+ if (message == null) {
throw new ExecutionException("null message"); //$NON-NLS-1$
}
- //2. retrieve preferences to apply
+ // 2. retrieve preferences to apply
// according to the message sort
retrievePreferences();
- if( type==null || CustomDiagramGeneralPreferencePage.CHOICE_NONE.equals(preference)) {
+ if (type == null || CustomDiagramGeneralPreferencePage.CHOICE_NONE.equals(preference)) {
throw new ExecutionException("undefined preference"); //$NON-NLS-1$
}
- //3. create execution specification at target
+ // 3. create execution specification at target
createExecutionSpecification();
return CommandResult.newOKCommandResult();
}
-
-
+
+
/**
* creates an execution specification on the target lifeline
* creation location is computed from the request
*/
- private void createExecutionSpecification() {
+ private void createExecutionSpecification() {
LifelineEditPart lifelineEditPart = (LifelineEditPart) graphicalContainer;
- CreateViewRequest requestcreation = CreateViewRequestFactory.getCreateShapeRequest(type, lifelineEditPart.getDiagramPreferencesHint());
- Point point=request.getLocation().getCopy();
- requestcreation.setLocation(point);
+ CreateViewRequest requestcreation = CreateViewRequestFactory.getCreateShapeRequest(type, lifelineEditPart.getDiagramPreferencesHint());
+ Point point = request.getLocation().getCopy();
+ requestcreation.setLocation(point);
Command command = lifelineEditPart.getCommand(requestcreation);
command.execute();
-
+
// case where a reply message must also be created
- if(createReply) {
+ if (createReply) {
Point replysourcepoint = point.getCopy();
- replysourcepoint.setY(replysourcepoint.y+CustomActionExecutionSpecificationEditPart.DEFAULT_HEIGHT);
+ replysourcepoint.setY(replysourcepoint.y + CustomActionExecutionSpecificationEditPart.DEFAULT_HEIGHT);
// source of the reply message is the end of the execution specification
- createReplyMessage(lifelineEditPart, replysourcepoint);
+ createReplyMessage(lifelineEditPart, replysourcepoint);
}
-
}
/**
@@ -123,27 +125,27 @@ public class CreateExecutionSpecificationWithMessage extends AbstractTransaction
*/
private void createReplyMessage(LifelineEditPart lifelineEditPart, Point replysourcepoint) {
CreateConnectionViewRequest requestreplycreation = CreateViewRequestFactory.getCreateConnectionRequest(UMLDIElementTypes.MESSAGE_REPLY_EDGE, lifelineEditPart.getDiagramPreferencesHint());
- requestreplycreation.setLocation(replysourcepoint);
+ requestreplycreation.setLocation(replysourcepoint);
requestreplycreation.setSourceEditPart(null);
requestreplycreation.setTargetEditPart(lifelineEditPart);
requestreplycreation.setType(RequestConstants.REQ_CONNECTION_START);
Command replycommand = lifelineEditPart.getCommand(requestreplycreation);
-
+
// setup the request in preparation to get the connection end command
requestreplycreation.setSourceEditPart(lifelineEditPart);
LifelineEditPart target = (LifelineEditPart) request.getSourceEditPart();
requestreplycreation.setTargetEditPart(target);
requestreplycreation.setType(RequestConstants.REQ_CONNECTION_END);
-
- IFigure f = ((LifelineEditPart)target).getPrimaryShape();
+
+ IFigure f = ((LifelineEditPart) target).getPrimaryShape();
Rectangle b = f.getBounds().getCopy();
f.translateToAbsolute(b);
Point c = b.getCenter().getCopy();
-
+
Point replytargetpoint = replysourcepoint.getCopy();
replytargetpoint.setX(c.x);
requestreplycreation.setLocation(replytargetpoint);
- replycommand = target.getCommand(requestreplycreation);
+ replycommand = target.getCommand(requestreplycreation);
replycommand.execute();
}
@@ -152,15 +154,15 @@ public class CreateExecutionSpecificationWithMessage extends AbstractTransaction
* @return the message from the given request, can return null
*/
private Message getMessage() {
- Message message=null;
- ConnectionViewAndElementDescriptor connectionViewAndElementDescriptor=request.getConnectionViewAndElementDescriptor();
- if( connectionViewAndElementDescriptor!=null){
- CreateElementRequestAdapter createElementRequestAdapter=connectionViewAndElementDescriptor.getCreateElementRequestAdapter();
- message=(Message)createElementRequestAdapter.getAdapter(Message.class);
+ Message message = null;
+ ConnectionViewAndElementDescriptor connectionViewAndElementDescriptor = request.getConnectionViewAndElementDescriptor();
+ if (connectionViewAndElementDescriptor != null) {
+ CreateElementRequestAdapter createElementRequestAdapter = connectionViewAndElementDescriptor.getCreateElementRequestAdapter();
+ message = (Message) createElementRequestAdapter.getAdapter(Message.class);
}
return message;
}
-
+
/**
* retrieve preferences concerned with automatic creation of execution specifications
*/
@@ -168,21 +170,21 @@ public class CreateExecutionSpecificationWithMessage extends AbstractTransaction
this.type = null;
IPreferenceStore store = UMLDiagramEditorPlugin.getInstance().getPreferenceStore();
if (request.getConnectionViewAndElementDescriptor().getSemanticHint().equals(UMLDIElementTypes.MESSAGE_ASYNCH_EDGE.getSemanticHint())) {
- //for asynchronous messages
+ // for asynchronous messages
this.preference = store.getString(CustomDiagramGeneralPreferencePage.PREF_EXECUTION_SPECIFICATION_ASYNC_MSG);
}
if (request.getConnectionViewAndElementDescriptor().getSemanticHint().equals(UMLDIElementTypes.MESSAGE_SYNCH_EDGE.getSemanticHint())) {
- //for synchronous messages
+ // for synchronous messages
this.preference = store.getString(CustomDiagramGeneralPreferencePage.PREF_EXECUTION_SPECIFICATION_SYNC_MSG);
- }
+ }
// case where a behavior execution specification must be created at target
if (CustomDiagramGeneralPreferencePage.CHOICE_BEHAVIOR.equals(preference) || CustomDiagramGeneralPreferencePage.CHOICE_BEHAVIOR_AND_REPLY.equals(preference)) {
- this.type = UMLDIElementTypes.BEHAVIOR_EXECUTION_SPECIFICATION_SHAPE;
+ this.type = UMLDIElementTypes.BEHAVIOR_EXECUTION_SPECIFICATION_SHAPE;
}
// case where an action execution specification must be created at target
if (CustomDiagramGeneralPreferencePage.CHOICE_ACTION.equals(preference) || CustomDiagramGeneralPreferencePage.CHOICE_ACTION_AND_REPLY.equals(preference)) {
- this.type = UMLDIElementTypes.ACTION_EXECUTION_SPECIFICATION_SHAPE;
- }
+ this.type = UMLDIElementTypes.ACTION_EXECUTION_SPECIFICATION_SHAPE;
+ }
// case where a message reply must also be created
if (CustomDiagramGeneralPreferencePage.CHOICE_BEHAVIOR_AND_REPLY.equals(preference) || CustomDiagramGeneralPreferencePage.CHOICE_ACTION_AND_REPLY.equals(preference)) {
this.createReply = true;
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/UpdateNodeReferenceEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/UpdateNodeReferenceEditPolicy.java
index 1eb4bb9052a..b7442746c35 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/UpdateNodeReferenceEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/UpdateNodeReferenceEditPolicy.java
@@ -35,6 +35,7 @@ import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.part.UMLDiagramEditorPlugin;
import org.eclipse.papyrus.uml.diagram.sequence.util.CoordinateReferentialUtils;
import org.eclipse.papyrus.uml.diagram.sequence.util.LogOptions;
+import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceUtil;
/**
* this editpolicy is to manage the movement of message on node as lifeline
@@ -69,7 +70,7 @@ public class UpdateNodeReferenceEditPolicy extends GraphicalEditPolicy {
ConnectionEditPart linkEditPart = reconnectRequest.getConnectionEditPart();
UMLDiagramEditorPlugin.log.trace(LogOptions.SEQUENCE_DEBUG, "+ MOVE ANCHORS of " + linkEditPart.getClass().getName());//$NON-NLS-1$
Point locationOnDiagram = CoordinateReferentialUtils.transformPointFromScreenToDiagramReferential(reconnectRequest.getLocation(), (GraphicalViewer) getHost().getViewer());
- UMLDiagramEditorPlugin.log.trace(LogOptions.SEQUENCE_DEBUG, "+-- LocationOnDiagram " + locationOnDiagram);// $NON-NLS-2$ //$NON-NLS-1$
+ UMLDiagramEditorPlugin.log.trace(LogOptions.SEQUENCE_DEBUG, "+-- LocationOnDiagram " + locationOnDiagram);//$NON-NLS-1$
if (linkEditPart.getEditPolicy(SequenceReferenceEditPolicy.SEQUENCE_REFERENCE) != null) {
SequenceReferenceEditPolicy references = (SequenceReferenceEditPolicy) linkEditPart.getEditPolicy(SequenceReferenceEditPolicy.SEQUENCE_REFERENCE);
@@ -80,19 +81,22 @@ public class UpdateNodeReferenceEditPolicy extends GraphicalEditPolicy {
GraphicalEditPart gEditPart = (GraphicalEditPart) editPart;
Point GEPlocationOnDiagram = CoordinateReferentialUtils.getFigurePositionRelativeToDiagramReferential(gEditPart.getFigure(), getDiagramEditPart(getHost()));
- UMLDiagramEditorPlugin.log.trace(LogOptions.SEQUENCE_DEBUG, "+--> try to Move from " + GEPlocationOnDiagram + " " + editPart.getClass().getName());// $NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-2$
+ locationOnDiagram = CoordinateReferentialUtils.transformPointFromScreenToDiagramReferential(SequenceUtil.getSnappedLocation(gEditPart, reconnectRequest.getLocation().getCopy()), (GraphicalViewer) getHost().getViewer());
+
+ UMLDiagramEditorPlugin.log.trace(LogOptions.SEQUENCE_DEBUG, "+--> try to Move from " + GEPlocationOnDiagram + " " + editPart.getClass().getName()); //$NON-NLS-1$ //$NON-NLS-2$
ChangeBoundsRequest changeBoundsRequest = new ChangeBoundsRequest(RequestConstants.REQ_RESIZE);
- changeBoundsRequest.setLocation(reconnectRequest.getLocation());
+ changeBoundsRequest.setLocation(reconnectRequest.getLocation().getCopy());
changeBoundsRequest.setEditParts(editPart);
+
if (references.getStrongReferences().get(editPart).equals(SequenceReferenceEditPolicy.ROLE_START)) {
int delta = (locationOnDiagram.y() - GEPlocationOnDiagram.y());
- UMLDiagramEditorPlugin.log.trace(LogOptions.SEQUENCE_DEBUG, "+--> Delta " + delta + " " + editPart.getClass().getName());// $NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-2$
+ UMLDiagramEditorPlugin.log.trace(LogOptions.SEQUENCE_DEBUG, "+--> Delta " + delta + " " + editPart.getClass().getName()); //$NON-NLS-1$ //$NON-NLS-2$
changeBoundsRequest.setMoveDelta(new Point(0, delta));
changeBoundsRequest.setSizeDelta(new Dimension(0, 0));
}
if (references.getStrongReferences().get(editPart).equals(SequenceReferenceEditPolicy.ROLE_FINISH)) {
int delta = (locationOnDiagram.y() - GEPlocationOnDiagram.y() - gEditPart.getFigure().getBounds().height);
- UMLDiagramEditorPlugin.log.trace(LogOptions.SEQUENCE_DEBUG, "+--> Delta " + delta + " " + editPart.getClass().getName());// $NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-2$
+ UMLDiagramEditorPlugin.log.trace(LogOptions.SEQUENCE_DEBUG, "+--> Delta " + delta + " " + editPart.getClass().getName());//$NON-NLS-1$ //$NON-NLS-2$
changeBoundsRequest.setMoveDelta(new Point(0, delta));
changeBoundsRequest.setSizeDelta(new Dimension(0, 0));
}
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 636e5059f1e..61f6815c283 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
@@ -32,6 +32,7 @@ import org.eclipse.papyrus.infra.gmfdiag.common.editpart.NodeEditPart;
import org.eclipse.papyrus.infra.gmfdiag.common.helper.IdentityAnchorHelper;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.AbstractExecutionSpecificationEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CLifeLineEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceUtil;
import org.eclipse.swt.graphics.Color;
import org.eclipse.uml2.uml.ExecutionSpecification;
import org.eclipse.uml2.uml.Message;
@@ -150,10 +151,12 @@ public class DisplayEvent {
* @return the location if no event found around, or the event precise location if existing
*/
public Point getRealEventLocation(final Point location) {
- Point realLocationEvent = getRealEventLocationFromExecutionSpecification(location);
+ Point snappedLocation = SequenceUtil.getSnappedLocation(editpart, location).getCopy();
+ Point realLocationEvent = getRealEventLocationFromExecutionSpecification(location.getCopy());
if (location.equals(realLocationEvent)) {
- realLocationEvent = getRealEventLocationFromMessage(location);
+ realLocationEvent = getRealEventLocationFromMessage(location.getCopy());
}
+ realLocationEvent = SequenceUtil.getSnappedLocation(editpart, realLocationEvent).getCopy();
return realLocationEvent;
}
@@ -212,8 +215,9 @@ public class DisplayEvent {
*/
private Point getNewEventLocationY(Point relativeMouseLocation, int referenceY, IFigure editPartFigure) {
Point newPoint = new Point(relativeMouseLocation);
- if (referenceY - EVENT_SELECTION_DELTA < relativeMouseLocation.y() && relativeMouseLocation.y() < referenceY + EVENT_SELECTION_DELTA) {
+ // Point newPoint = SequenceUtil.getSnappedLocation(editpart, relativeMouseLocation);
+ if (referenceY - EVENT_SELECTION_DELTA < relativeMouseLocation.y() && relativeMouseLocation.y() < referenceY + EVENT_SELECTION_DELTA) {
newPoint.setY(referenceY);
newPoint.setX(relativeMouseLocation.x());
}
@@ -231,7 +235,8 @@ public class DisplayEvent {
public Point getRealEventLocationFromMessage(final Point location) {
// The Relative Position of the Mouse on screen
- Point relativeLocation = location.getCopy();
+ // Point relativeLocation = location.getCopy();
+ Point relativeLocation = SequenceUtil.getSnappedLocation(editpart, location);
IFigure editPartFigure = ((GraphicalEditPart) editpart).getFigure();
editPartFigure.getParent().translateToRelative(relativeLocation);
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 5a3562c536d..ef8cae30b31 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
@@ -100,6 +100,9 @@ public class LifeLineGraphicalNodeEditPolicy extends DefaultGraphicalNodeEditPol
*/
@Override
protected Command getConnectionCreateCommand(CreateConnectionRequest request) {
+ // Snap to grid the request location
+ request.setLocation(SequenceUtil.getSnappedLocation(getHost(), request.getLocation()));
+
displayEvent.addFigureEvent(getHostFigure(), request.getLocation());
MessageEnd end = getPreviousEventFromPosition(request.getLocation());
if (end != null) {
@@ -156,6 +159,8 @@ public class LifeLineGraphicalNodeEditPolicy extends DefaultGraphicalNodeEditPol
*/
@Override
protected ConnectionAnchor getTargetConnectionAnchor(CreateConnectionRequest request) {
+ // Snap to grid the request location
+ request.setLocation(SequenceUtil.getSnappedLocation(getHost(), request.getLocation()));
ConnectionAnchor targetConnectionAnchor = super.getTargetConnectionAnchor(request);
ConnectionAnchor newTargetConnectionAnchor = targetConnectionAnchor;
if (null != targetConnectionAnchor) {
@@ -318,6 +323,8 @@ public class LifeLineGraphicalNodeEditPolicy extends DefaultGraphicalNodeEditPol
*/
@Override
protected Command getConnectionAndRelationshipCompleteCommand(CreateConnectionViewAndElementRequest request) {
+ // Snap to grid the request location
+ request.setLocation(SequenceUtil.getSnappedLocation(getHost(), request.getLocation()));
// 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) {
@@ -641,6 +648,8 @@ public class LifeLineGraphicalNodeEditPolicy extends DefaultGraphicalNodeEditPol
*/
@Override
protected Command getReconnectSourceCommand(final ReconnectRequest request) {
+ // Snap to grid the request location
+ request.setLocation(SequenceUtil.getSnappedLocation(getHost(), request.getLocation()));
return getBasicGraphicalNodeEditPolicy().getCommand(request);
}
@@ -652,6 +661,8 @@ public class LifeLineGraphicalNodeEditPolicy extends DefaultGraphicalNodeEditPol
@Override
protected Command getReconnectTargetCommand(final ReconnectRequest request) {
Command command = null;
+ // Snap to grid the request location
+ request.setLocation(SequenceUtil.getSnappedLocation(getHost(), request.getLocation()));
Command reconnectTargetCommand = getBasicGraphicalNodeEditPolicy().getCommand(request);
NodeEditPart nodeEP = (NodeEditPart) request.getTarget();
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 63f4d7ec394..b37d9fca6ae 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
@@ -1685,14 +1685,15 @@ public class SequenceUtil {
/**
* update the bounds of the rectangle to snap to grid
+ * Snap is done with screen position.
*
* @param editPart
+ * the referential edit part
* @param bounds
- * @param request
- * @return
+ * the bounds to snap
*
*/
- public static PrecisionRectangle getSnappedBounds(EditPart editPart, Rectangle bounds) {
+ public static PrecisionRectangle getSnappedBounds(final EditPart editPart, final Rectangle bounds) {
PrecisionRectangle baseRect = new PrecisionRectangle(bounds);
PrecisionRectangle result = baseRect.getPreciseCopy();
if (editPart != null) {
@@ -1705,13 +1706,16 @@ public class SequenceUtil {
}
/**
- * update the bounds of the rectangle to snap to grid
+ * update the bounds of the rectangle to snap to grid.
+ * Snap is done with screen position.
*
* @param editPart
+ * the referential edit part
* @param location
+ * the location to snap
*
*/
- public static PrecisionPoint getSnappedLocation(EditPart editPart, Point location) {
+ public static PrecisionPoint getSnappedLocation(final EditPart editPart, final Point location) {
PrecisionPoint baseRect = new PrecisionPoint(location);
PrecisionPoint result = baseRect.getPreciseCopy();
if (editPart != null) {

Back to the top