Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/uml/diagram')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/UpdateWeakReferenceEditPolicy.java8
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/UpdateWeakReferenceForMessageSpecEditPolicy.java137
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/messages/Messages.java5
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/messages/messages.properties1
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/preferences/CustomDiagramGeneralPreferencePage.java21
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/ConnectRectangleToGridEditPolicy.java10
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/DisplayEvent.java1
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/LifeLineGraphicalNodeEditPolicy.java14
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LifelineEditPartUtil.java24
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/TooltipUtil.java4
10 files changed, 188 insertions, 37 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/UpdateWeakReferenceEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/UpdateWeakReferenceEditPolicy.java
index 905b346bb54..c6d9be80228 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/UpdateWeakReferenceEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/UpdateWeakReferenceEditPolicy.java
@@ -114,7 +114,9 @@ public abstract class UpdateWeakReferenceEditPolicy extends GraphicalEditPolicy
ReconnectRequest reconnectRequest = new ReconnectRequest();
reconnectRequest.setConnectionEditPart(connectionEditPart);
SenderRequestUtils.addRequestSenders(reconnectRequest, senderList);
- SenderRequestUtils.addRequestSender(reconnectRequest, hostEditpart);
+ if (null != hostEditpart) {
+ SenderRequestUtils.addRequestSender(reconnectRequest, hostEditpart);
+ }
reconnectRequest.setLocation(location.getLocation().getCopy());
reconnectRequest.setType(reconnectType);
if (RequestConstants.REQ_RECONNECT_TARGET.equals(reconnectType)) {
@@ -148,7 +150,9 @@ public abstract class UpdateWeakReferenceEditPolicy extends GraphicalEditPolicy
protected static void moveRoundedEditPart(EditPart hostEditPart, Point moveDelta, CompoundCommand compoundCommand, EditPart editPartToMove, ArrayList<EditPart> senderList) {
ChangeBoundsRequest changeBoundsRequest = new ChangeBoundsRequest(RequestConstants.REQ_MOVE);
SenderRequestUtils.addRequestSenders(changeBoundsRequest, senderList);
- SenderRequestUtils.addRequestSender(changeBoundsRequest, hostEditPart);
+ if (null != hostEditPart) {
+ SenderRequestUtils.addRequestSender(changeBoundsRequest, hostEditPart);
+ }
GraphicalEditPart gEditPart = (GraphicalEditPart) editPartToMove;
Point newLocation = new Point(gEditPart.getFigure().getBounds().getTopLeft().x, gEditPart.getFigure().getBounds().getTopLeft().y + moveDelta.y());
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/UpdateWeakReferenceForMessageSpecEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/UpdateWeakReferenceForMessageSpecEditPolicy.java
index 1243a3d2526..ab1e7987bd5 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/UpdateWeakReferenceForMessageSpecEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/UpdateWeakReferenceForMessageSpecEditPolicy.java
@@ -8,7 +8,7 @@
*
* Contributors:
* CEA LIST - Initial API and implementation
- * Mickaël ADAM (ALL4TEC) mickael.adam@all4tec.net - Bug 526191
+ * Mickaël ADAM (ALL4TEC) mickael.adam@all4tec.net - Bug 526191, 526462
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.sequence.edit.policies;
@@ -16,8 +16,11 @@ package org.eclipse.papyrus.uml.diagram.sequence.edit.policies;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.List;
+import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.emf.ecore.EObject;
import org.eclipse.gef.ConnectionEditPart;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.GraphicalViewer;
@@ -26,11 +29,23 @@ import org.eclipse.gef.RequestConstants;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.commands.CompoundCommand;
import org.eclipse.gef.requests.ReconnectRequest;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewAndElementRequest;
import org.eclipse.gmf.runtime.draw2d.ui.figures.PolylineConnectionEx;
+import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.uml.diagram.common.editparts.RoundedCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.AbstractExecutionSpecificationEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.AbstractMessageEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
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.CoordinateReferentialUtils;
+import org.eclipse.papyrus.uml.diagram.sequence.util.LifelineEditPartUtil;
import org.eclipse.papyrus.uml.diagram.sequence.util.LogOptions;
+import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceUtil;
+import org.eclipse.uml2.uml.ExecutionSpecification;
+import org.eclipse.uml2.uml.Message;
+import org.eclipse.uml2.uml.OccurrenceSpecification;
/**
* this editpolicy is to manage the movement of Execution specification and update move of messages
@@ -48,7 +63,6 @@ public class UpdateWeakReferenceForMessageSpecEditPolicy extends UpdateWeakRefer
* @param request
* @return
*
- *
* <img src="../../../../../../../../../icons/sequenceScheme.png" width="250" />
* <UL>
* <LI>when move E --> move B on the coordinate Y of E and move A on the coordinate Y of E
@@ -65,18 +79,20 @@ public class UpdateWeakReferenceForMessageSpecEditPolicy extends UpdateWeakRefer
UMLDiagramEditorPlugin.log.trace(LogOptions.SEQUENCE_DEBUG, "+ MOVE ANCHORS of " + hostConnectionEditPart.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$
+
// compute Delta
Point moveDelta = new Point(0, 0);
PolylineConnectionEx polyline = (PolylineConnectionEx) hostConnectionEditPart.getFigure();
if (RequestConstants.REQ_RECONNECT_TARGET.equals(reconnectRequest.getType())) {
- Point anchorPositionOnScreen = polyline.getSourceAnchor().getReferencePoint();
+ Point anchorPositionOnScreen = polyline.getTargetAnchor().getReferencePoint();
moveDelta.y = reconnectRequest.getLocation().y - anchorPositionOnScreen.y;
} else {
Point anchorPositionOnScreen = polyline.getSourceAnchor().getReferencePoint();
moveDelta.y = reconnectRequest.getLocation().y - anchorPositionOnScreen.y;
}
+
if (moveDelta.y != 0 && mustMove) {
if (hostConnectionEditPart.getEditPolicy(SequenceReferenceEditPolicy.SEQUENCE_REFERENCE) != null) {
SequenceReferenceEditPolicy references = (SequenceReferenceEditPolicy) hostConnectionEditPart.getEditPolicy(SequenceReferenceEditPolicy.SEQUENCE_REFERENCE);
@@ -97,8 +113,15 @@ public class UpdateWeakReferenceForMessageSpecEditPolicy extends UpdateWeakRefer
if (editPart instanceof ConnectionEditPart) {
ConnectionEditPart connectionEditPart = (ConnectionEditPart) editPart;
// create the request
- moveSourceConnectionEditPart(hostConnectionEditPart, moveDelta, compoundCommand, connectionEditPart, senderList);
- moveTargetConnectionEditPart(hostConnectionEditPart, moveDelta, compoundCommand, connectionEditPart, senderList);
+ if (moveDelta.y > 0) {
+ // move down, target must be moved before
+ moveTargetConnectionEditPart(hostConnectionEditPart, moveDelta, compoundCommand, connectionEditPart, senderList);
+ moveSourceConnectionEditPart(hostConnectionEditPart, moveDelta, compoundCommand, connectionEditPart, senderList);
+ } else {
+ // move up, source must be moved before
+ moveSourceConnectionEditPart(hostConnectionEditPart, moveDelta, compoundCommand, connectionEditPart, senderList);
+ moveTargetConnectionEditPart(hostConnectionEditPart, moveDelta, compoundCommand, connectionEditPart, senderList);
+ }
}
if (editPart instanceof RoundedCompartmentEditPart) {
moveRoundedEditPart(hostConnectionEditPart, moveDelta, compoundCommand, editPart, senderList);
@@ -109,11 +132,113 @@ public class UpdateWeakReferenceForMessageSpecEditPolicy extends UpdateWeakRefer
// to avoid pb of non-executable command
return super.getCommand(request);
}
-
return compoundCommand;
}
}
}
+ } else if (request instanceof CreateConnectionViewAndElementRequest && !(SenderRequestUtils.isASender(request, getHost()))) {
+ CreateConnectionViewAndElementRequest createRequest = (CreateConnectionViewAndElementRequest) request;
+ UMLDiagramEditorPlugin.log.trace(LogOptions.SEQUENCE_DEBUG, "Message creation request at:" + ((View) ((IAdaptable) getHost()).getAdapter(View.class)).getElement());
+ // Snap to grid Location
+ createRequest.setLocation(SequenceUtil.getSnappedLocation(getHost(), createRequest.getLocation()));
+
+ // Get the location on screen
+ Point reqlocationOnScreen = createRequest.getLocation().getCopy();
+ getHostFigure().getParent().translateToRelative(reqlocationOnScreen);
+
+ UMLDiagramEditorPlugin.log.trace(LogOptions.SEQUENCE_DEBUG, "=> Request Location on screen: " + reqlocationOnScreen);
+ List<OccurrenceSpecification> nextEventsFromPosition = new ArrayList<OccurrenceSpecification>();
+ List<OccurrenceSpecification> previousEventsFromPosition = new ArrayList<OccurrenceSpecification>();
+
+ // Get next and previous event from the lifeline source
+ EditPart sourceEditPart = createRequest.getSourceEditPart();
+ if (sourceEditPart instanceof LifelineEditPart) {
+ nextEventsFromPosition.addAll(LifelineEditPartUtil.getNextEventsFromPosition(reqlocationOnScreen, (LifelineEditPart) sourceEditPart));
+ previousEventsFromPosition.addAll(LifelineEditPartUtil.getPreviousEventsFromPosition(new Point(reqlocationOnScreen.x, reqlocationOnScreen.y + CustomDiagramGeneralPreferencePage.PREF_MOVE_BELOW_ELEMENTS_AT_MESSAGE_CREATION_VALUE),
+ (LifelineEditPart) sourceEditPart));
+ }
+
+ // Get next and previous event from the lifeline target
+ EditPart targetEditPart = createRequest.getTargetEditPart();
+ if (sourceEditPart instanceof LifelineEditPart) {
+ nextEventsFromPosition.addAll(LifelineEditPartUtil.getNextEventsFromPosition(reqlocationOnScreen, (LifelineEditPart) targetEditPart));
+ previousEventsFromPosition.addAll(LifelineEditPartUtil.getPreviousEventsFromPosition(new Point(reqlocationOnScreen.x, reqlocationOnScreen.y + CustomDiagramGeneralPreferencePage.PREF_MOVE_BELOW_ELEMENTS_AT_MESSAGE_CREATION_VALUE),
+ (LifelineEditPart) targetEditPart));
+ }
+
+ if (!nextEventsFromPosition.isEmpty()) {
+ CompoundCommand compoundCommand = new CompoundCommand();
+ // get the list of element just below new created message
+ nextEventsFromPosition.retainAll(previousEventsFromPosition);
+ // For each next event below
+ for (OccurrenceSpecification nextEvent : nextEventsFromPosition) {
+ UMLDiagramEditorPlugin.log.trace(LogOptions.SEQUENCE_DEBUG, "\tNext Event: " + nextEvent);
+
+ GraphicalEditPart sourceLifeLineEP = (GraphicalEditPart) createRequest.getSourceEditPart();
+ GraphicalEditPart targetLifeLineEP = (GraphicalEditPart) createRequest.getTargetEditPart();
+ ArrayList<EditPart> senderList = SenderRequestUtils.getSenders(request);
+
+ List<?> connectionsAndChildren = new ArrayList<>();
+ connectionsAndChildren.addAll(sourceLifeLineEP.getSourceConnections());
+ connectionsAndChildren.addAll(sourceLifeLineEP.getTargetConnections());
+ connectionsAndChildren.addAll(sourceLifeLineEP.getChildren());
+ connectionsAndChildren.addAll(targetLifeLineEP.getSourceConnections());
+ connectionsAndChildren.addAll(targetLifeLineEP.getTargetConnections());
+ connectionsAndChildren.addAll(targetLifeLineEP.getChildren());
+
+ for (Object editPart : connectionsAndChildren) {
+ if (editPart instanceof ConnectionEditPart) {
+ EObject element = ((View) ((AbstractMessageEditPart) editPart).getAdapter(View.class)).getElement();
+ if (element instanceof Message && null != ((Message) element).getSendEvent() && ((Message) element).getSendEvent().equals(nextEvent)
+ || element instanceof Message && null != ((Message) element).getReceiveEvent() && ((Message) element).getReceiveEvent().equals(nextEvent)) {
+
+ // compute Delta
+ Point moveDelta = new Point(0, 0);
+ PolylineConnectionEx polyline = (PolylineConnectionEx) ((ConnectionEditPart) editPart).getFigure();
+ Point anchorPositionOnScreen;
+ if (((Message) element).getSendEvent().equals(nextEvent)) {
+ anchorPositionOnScreen = polyline.getTargetAnchor().getReferencePoint();
+ } else {
+ anchorPositionOnScreen = polyline.getSourceAnchor().getReferencePoint();
+ }
+ UMLDiagramEditorPlugin.log.trace(LogOptions.SEQUENCE_DEBUG, "\t\tanchorPositionOnScreen:\t" + anchorPositionOnScreen);
+
+ Point newLocation = new Point(0, createRequest.getLocation().y + CustomDiagramGeneralPreferencePage.PREF_MOVE_BELOW_ELEMENTS_AT_MESSAGE_CREATION_VALUE);
+ newLocation = SequenceUtil.getSnappedLocation(getHost(), newLocation);
+ UMLDiagramEditorPlugin.log.trace(LogOptions.SEQUENCE_DEBUG, "\t\tNew location to be set:\t" + newLocation);
+ moveDelta.y = newLocation.y - anchorPositionOnScreen.y;
+
+ // add move source and target request
+ UMLDiagramEditorPlugin.log.trace(LogOptions.SEQUENCE_DEBUG, "\t\tMoveDela:\t\t" + moveDelta.y);
+ moveTargetConnectionEditPart(null, moveDelta, compoundCommand, (ConnectionEditPart) editPart, senderList);
+ moveSourceConnectionEditPart(null, moveDelta, compoundCommand, (ConnectionEditPart) editPart, senderList);
+ }
+ } else if (editPart instanceof AbstractExecutionSpecificationEditPart) {
+ EObject element = ((View) ((AbstractExecutionSpecificationEditPart) editPart).getAdapter(View.class)).getElement();
+
+ if (element instanceof ExecutionSpecification && null != ((ExecutionSpecification) element).getStart() && ((ExecutionSpecification) element).getStart().equals(nextEvent)) {
+ // compute Delta
+ Point moveDelta = new Point(0, 0);
+ Point figureLocation = ((AbstractExecutionSpecificationEditPart) editPart).getFigure().getBounds().getLocation();
+ UMLDiagramEditorPlugin.log.trace(LogOptions.SEQUENCE_DEBUG, "\t\tlocationOfFigure:\t" + figureLocation);
+
+ Point newLocation = new Point(0, reqlocationOnScreen.y + CustomDiagramGeneralPreferencePage.PREF_MOVE_BELOW_ELEMENTS_AT_MESSAGE_CREATION_VALUE);
+ UMLDiagramEditorPlugin.log.trace(LogOptions.SEQUENCE_DEBUG, "\t\tNew location to be set:\t" + newLocation);
+ moveDelta.y = newLocation.y - figureLocation.y;
+
+ UMLDiagramEditorPlugin.log.trace(LogOptions.SEQUENCE_DEBUG, "\t\tMoveDela:\t\t" + moveDelta.y);
+ moveRoundedEditPart(null, moveDelta, compoundCommand, (EditPart) editPart, senderList);
+ }
+ }
+ }
+ }
+ if (compoundCommand.isEmpty()) {
+ // to avoid pb of non-executable command
+ return super.getCommand(request);
+ }
+ return compoundCommand;
+ }
+
}
return super.getCommand(request);
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/messages/Messages.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/messages/Messages.java
index 3971198bf01..6624cf4b35f 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/messages/Messages.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/messages/Messages.java
@@ -78,6 +78,11 @@ public class Messages extends NLS {
public static String Commands_CreateExecutionSpecification_Label;
public static String Commands_DropDestructionOccurenceSpecification_Label;
+
+ /**
+ * @since 5.0
+ */
+ public static String CustomDiagramGeneralPreferencePage_MinimumSpaceBelowMessageAtCreation;
/**
* @since 5.0
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/messages/messages.properties b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/messages/messages.properties
index 655cf501e4d..527a9404009 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/messages/messages.properties
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/messages/messages.properties
@@ -10,6 +10,7 @@ Commands_DropDestructionOccurenceSpecification_Label=Drop Destruction Occurrence
Commands_CreateExecutionSpecification_Label=Execution Specification Automatic Creation with Message
Commands_DropDestructionOccurenceSpecification_Label=Drop Destruction Occurrence Specification
Commands_CreateExecutionSpecification_Label=Execution Specification Automatic Creation with Message
+CustomDiagramGeneralPreferencePage_MinimumSpaceBelowMessageAtCreation=Minimum space below Message at creation
CustomDiagramGeneralPreferencePage_MoveBelowElementsAtMessageUpDescription=When moving up a message, everything after that message is also moved up
CustomDiagramGeneralPreferencePage_MoveBelowElementsAtMessageDownDescription=When moving down a message, everything after that message is also moved down
CustomDiagramGeneralPreferencePage_othersGroupLabel=others
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/preferences/CustomDiagramGeneralPreferencePage.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/preferences/CustomDiagramGeneralPreferencePage.java
index cc81808cfef..04b648021a9 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/preferences/CustomDiagramGeneralPreferencePage.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/preferences/CustomDiagramGeneralPreferencePage.java
@@ -8,12 +8,13 @@
*
* Contributors:
* CEA LIST - Initial API and implementation
- * Mickaël ADAM (ALL4TEC) mickael.adam@all4tec.net - Bug 521829, 526191
+ * Mickaël ADAM (ALL4TEC) mickael.adam@all4tec.net - Bug 521829, 526191, 526462
*/
package org.eclipse.papyrus.uml.diagram.sequence.preferences;
import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.IntegerFieldEditor;
import org.eclipse.jface.preference.RadioGroupFieldEditor;
import org.eclipse.papyrus.infra.gmfdiag.preferences.pages.DiagramPreferencePage;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.SequenceDiagramEditPart;
@@ -63,6 +64,20 @@ public class CustomDiagramGeneralPreferencePage extends DiagramPreferencePage {
public static final String PREF_MOVE_BELOW_ELEMENTS_AT_MESSAGE_DOWN = "PREF_MOVE_BELOW_ELEMENTS_AT_MESSAGE_DOWN"; //$NON-NLS-1$
/**
+ * preference key to move down messages in the same time that message is created.
+ *
+ * @since 5.0
+ */
+ public static final String PREF_MOVE_BELOW_ELEMENTS_AT_MESSAGE_CREATION = "PREF_MOVE_BELOW_ELEMENTS_AT_MESSAGE_CREATION"; //$NON-NLS-1$
+
+ /**
+ * Value to move down messages in the same time that message down.
+ *
+ * @since 5.0
+ */
+ public static final int PREF_MOVE_BELOW_ELEMENTS_AT_MESSAGE_CREATION_VALUE = 40;
+
+ /**
* possible preference values
*/
public static final String CHOICE_BEHAVIOR_AND_REPLY = "CHOICE_BEHAVIOR_AND_REPLY"; //$NON-NLS-1$
@@ -107,6 +122,7 @@ public class CustomDiagramGeneralPreferencePage extends DiagramPreferencePage {
otherGroup.setText(Messages.CustomDiagramGeneralPreferencePage_othersGroupLabel);
addField(new BooleanFieldEditor(PREF_MOVE_BELOW_ELEMENTS_AT_MESSAGE_DOWN, Messages.CustomDiagramGeneralPreferencePage_MoveBelowElementsAtMessageDownDescription, otherGroup));
addField(new BooleanFieldEditor(PREF_MOVE_BELOW_ELEMENTS_AT_MESSAGE_UP, Messages.CustomDiagramGeneralPreferencePage_MoveBelowElementsAtMessageUpDescription, otherGroup));
+ addField(new IntegerFieldEditor(PREF_MOVE_BELOW_ELEMENTS_AT_MESSAGE_CREATION, Messages.CustomDiagramGeneralPreferencePage_MinimumSpaceBelowMessageAtCreation, otherGroup));
}
/**
@@ -148,7 +164,8 @@ public class CustomDiagramGeneralPreferencePage extends DiagramPreferencePage {
preferenceStore.setDefault(PREF_EXECUTION_SPECIFICATION_ASYNC_MSG, CHOICE_NONE);
preferenceStore.setDefault(PREF_MOVE_BELOW_ELEMENTS_AT_MESSAGE_DOWN, true);
- preferenceStore.setDefault(PREF_MOVE_BELOW_ELEMENTS_AT_MESSAGE_UP, false);
+ preferenceStore.setDefault(PREF_MOVE_BELOW_ELEMENTS_AT_MESSAGE_UP, true);
+ preferenceStore.setDefault(PREF_MOVE_BELOW_ELEMENTS_AT_MESSAGE_CREATION, PREF_MOVE_BELOW_ELEMENTS_AT_MESSAGE_CREATION_VALUE);
}
}
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 59813c8635b..01701680f63 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
@@ -501,14 +501,12 @@ public class ConnectRectangleToGridEditPolicy extends ConnectToGridEditPolicy im
double newPercentY = (oldY - newY) / (height) + yPercent;
if (newPercentY < 0) {
newPercentY = 0.01;
- }
- if (newPercentY > 1) {
+ } else if (newPercentY > 1) {
newPercentY = 0.99;
}
- 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));
- }
+
+ final String newIdValue = IdentityAnchorHelper.createNewAnchorIdValue(xPercent, newPercentY);
+ execute(new SetCommand(getDiagramEditPart(getHost()).getEditingDomain(), anchor, NotationPackage.eINSTANCE.getIdentityAnchor_Id(), newIdValue));
}
}
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 61f6815c283..3c285f81eef 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
@@ -151,7 +151,6 @@ 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 snappedLocation = SequenceUtil.getSnappedLocation(editpart, location).getCopy();
Point realLocationEvent = getRealEventLocationFromExecutionSpecification(location.getCopy());
if (location.equals(realLocationEvent)) {
realLocationEvent = getRealEventLocationFromMessage(location.getCopy());
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 ccb68568385..c3256ec48c0 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
@@ -104,8 +104,8 @@ public class LifeLineGraphicalNodeEditPolicy extends DefaultGraphicalNodeEditPol
request.setLocation(SequenceUtil.getSnappedLocation(getHost(), request.getLocation()));
displayEvent.addFigureEvent(getHostFigure(), request.getLocation());
- MessageEnd end = getPreviousEventFromPosition(request.getLocation());
- if (end != null) {
+ OccurrenceSpecification end = getPreviousEventFromPosition(request.getLocation());
+ if (end instanceof MessageEnd) {
Map<String, Object> extendedData = request.getExtendedData();
extendedData.put(org.eclipse.papyrus.uml.service.types.utils.SequenceRequestConstant.PREVIOUS_EVENT, end);
request.setExtendedData(extendedData);
@@ -326,7 +326,7 @@ public class LifeLineGraphicalNodeEditPolicy extends DefaultGraphicalNodeEditPol
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) {
+ if (!request.getLocation().equals(realEventLocation)) {
request.setLocation(realEventLocation);
}
@@ -376,8 +376,8 @@ public class LifeLineGraphicalNodeEditPolicy extends DefaultGraphicalNodeEditPol
* initial Request to be updated
*/
private void updateExtendedData(CreateConnectionViewAndElementRequest request) {
- MessageEnd end = getPreviousEventFromPosition(request.getLocation());
- if (end != null) {
+ OccurrenceSpecification end = getPreviousEventFromPosition(request.getLocation());
+ if (end instanceof MessageEnd) {
Map<String, Object> extendedData = request.getExtendedData();
extendedData.put(org.eclipse.papyrus.uml.service.types.utils.SequenceRequestConstant.SECOND_PREVIOUS_EVENT, end);
request.setExtendedData(extendedData);
@@ -760,8 +760,8 @@ public class LifeLineGraphicalNodeEditPolicy extends DefaultGraphicalNodeEditPol
* @param point
* the position on the lifeline
*/
- public MessageEnd getPreviousEventFromPosition(final Point point) {
- List<MessageEnd> previousEventsFromPosition = LifelineEditPartUtil.getPreviousEventsFromPosition(point, (LifelineEditPart) getHost());
+ public OccurrenceSpecification getPreviousEventFromPosition(final Point point) {
+ List<OccurrenceSpecification> previousEventsFromPosition = LifelineEditPartUtil.getPreviousEventsFromPosition(point, (LifelineEditPart) getHost());
return previousEventsFromPosition.isEmpty() ? null : previousEventsFromPosition.get(0);
}
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 d4b08c99f80..3dcd7f68edc 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
@@ -9,7 +9,7 @@
*
* Contributors:
* Soyatec - Initial API and implementation
- * Mickaël ADAM (ALL4TEC) mickael.adam@all4tec.net - Bug 519621, 519756, 526079
+ * Mickaël ADAM (ALL4TEC) mickael.adam@all4tec.net - Bug 519621, 519756, 526079, 526462
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.sequence.util;
@@ -47,7 +47,7 @@ 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;
-import org.eclipse.uml2.uml.MessageEnd;
+import org.eclipse.uml2.uml.OccurrenceSpecification;
/**
* @author Jin Liu (jin.liu@soyatec.com)
@@ -175,15 +175,15 @@ public class LifelineEditPartUtil {
}
/**
- * Get the list of previous {@link MessageEnd} on the {@link LifelineEditPart} according to the position.
+ * Get the list of previous {@link OccurrenceSpecification} on the {@link LifelineEditPart} according to the position.
*
* @param position
* The reference position.
* @param lifelineEditPart
* The lifeline edit part
*/
- public static List<MessageEnd> getPreviousEventsFromPosition(final Point position, final LifelineEditPart lifelineEditPart) {
- List<MessageEnd> previous = new ArrayList<MessageEnd>();
+ public static List<OccurrenceSpecification> getPreviousEventsFromPosition(final Point position, final LifelineEditPart lifelineEditPart) {
+ List<OccurrenceSpecification> previous = new ArrayList<OccurrenceSpecification>();
DiagramEditPart diagramEditPart = getDiagramEditPart(lifelineEditPart);
Lifeline lifeline = (Lifeline) lifelineEditPart.resolveSemanticElement();
try {
@@ -194,9 +194,9 @@ public class LifelineEditPartUtil {
if (currentPoint.y < position.y) {
if (row.getElement() != null) {
EObject referedElement = row.getElement();
- if (referedElement instanceof MessageEnd) {
+ if (referedElement instanceof OccurrenceSpecification) {
if (lifeline.getCoveredBys().contains(referedElement)) {
- previous.add((MessageEnd) referedElement);
+ previous.add((OccurrenceSpecification) referedElement);
}
}
}
@@ -225,7 +225,7 @@ public class LifelineEditPartUtil {
}
/**
- * Get the list of previous {@link MessageEnd} on the {@link LifelineEditPart} according to the position.
+ * Get the list of previous {@link OccurrenceSpecification} on the {@link LifelineEditPart} according to the position.
*
* @param position
* The reference position.
@@ -233,8 +233,8 @@ public class LifelineEditPartUtil {
* The lifeline edit part
* @since 3.1
*/
- public static List<MessageEnd> getNextEventsFromPosition(final Point position, final LifelineEditPart lifelineEditPart) {
- List<MessageEnd> previous = new ArrayList<MessageEnd>();
+ public static List<OccurrenceSpecification> getNextEventsFromPosition(final Point position, final LifelineEditPart lifelineEditPart) {
+ List<OccurrenceSpecification> previous = new ArrayList<OccurrenceSpecification>();
DiagramEditPart diagramEditPart = getDiagramEditPart(lifelineEditPart);
Lifeline lifeline = (Lifeline) lifelineEditPart.resolveSemanticElement();
try {
@@ -245,9 +245,9 @@ public class LifelineEditPartUtil {
if (currentPoint.y > position.y) {
if (row.getElement() != null) {
EObject referedElement = row.getElement();
- if (referedElement instanceof MessageEnd) {
+ if (referedElement instanceof OccurrenceSpecification) {
if (lifeline.getCoveredBys().contains(referedElement)) {
- previous.add((MessageEnd) referedElement);
+ previous.add((OccurrenceSpecification) referedElement);
}
}
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/TooltipUtil.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/TooltipUtil.java
index 6083e7b55ba..a822eb5af60 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/TooltipUtil.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/TooltipUtil.java
@@ -196,7 +196,9 @@ public class TooltipUtil {
@Override
public void deactivate() {
super.deactivate();
- getHostFigure().removeMouseMotionListener(updateListener);
+ if (null != updateListener) {
+ getHostFigure().removeMouseMotionListener(updateListener);
+ }
if (getHost() instanceof LifelineEditPart) {
((LifelineEditPart) getHost()).getPrimaryView().eAdapters().remove(modelListener);
}

Back to the top