Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas FAUVERGUE2018-05-22 12:42:52 +0000
committerNicolas FAUVERGUE2018-05-29 11:59:34 +0000
commit753a77c3e46d5e29301105bf9ad3277a2e0a3cd2 (patch)
treebbf342b1076d31951d714618c4235a70fbb1132b
parentcb2a5faa044591649953c7ecb499d6e123830a85 (diff)
downloadorg.eclipse.papyrus-753a77c3e46d5e29301105bf9ad3277a2e0a3cd2.tar.gz
org.eclipse.papyrus-753a77c3e46d5e29301105bf9ad3277a2e0a3cd2.tar.xz
org.eclipse.papyrus-753a77c3e46d5e29301105bf9ad3277a2e0a3cd2.zip
Bug 534941: [Sequence Diagram] The execution specification must be not
moved from a Lifeline to another one - Remove the reparent of execution specification in Layout, creation and update of node references Change-Id: I24d798ba5f9891a1380b0b0d2ff7bf43caa88eb2 Signed-off-by: Nicolas FAUVERGUE <nicolas.fauvergue@cea.fr>
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/UpdateNodeReferenceEditPolicy.java18
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/LifeLineXYLayoutEditPolicy.java7
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/LifelineCreationEditPolicy.java55
3 files changed, 72 insertions, 8 deletions
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 47d77117fba..598cdf3142b 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
@@ -14,9 +14,9 @@
package org.eclipse.papyrus.uml.diagram.sequence.edit.policies;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.Map.Entry;
-import org.eclipse.draw2d.PositionConstants;
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.gef.ConnectionEditPart;
@@ -27,6 +27,7 @@ import org.eclipse.gef.Request;
import org.eclipse.gef.RequestConstants;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.commands.CompoundCommand;
+import org.eclipse.gef.commands.UnexecutableCommand;
import org.eclipse.gef.editpolicies.GraphicalEditPolicy;
import org.eclipse.gef.requests.ChangeBoundsRequest;
import org.eclipse.gef.requests.ReconnectRequest;
@@ -36,6 +37,8 @@ import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
import org.eclipse.gmf.runtime.notation.Bounds;
import org.eclipse.gmf.runtime.notation.Node;
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.edit.parts.LifelineEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.part.UMLDiagramEditorPlugin;
import org.eclipse.papyrus.uml.diagram.sequence.referencialgrilling.BoundForEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.util.CoordinateReferentialUtils;
@@ -122,6 +125,19 @@ public class UpdateNodeReferenceEditPolicy extends GraphicalEditPolicy {
} else if (request instanceof ChangeBoundsRequest && (!org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants.REQ_AUTOSIZE.equals(request.getType()))) {
final ChangeBoundsRequest initialChangeBoundsRequest = (ChangeBoundsRequest) request;
+ final Iterator<?> editParts = initialChangeBoundsRequest.getEditParts().iterator();
+
+ // The reparent of execution specification in another life line is not allowed
+ while(editParts.hasNext()) {
+ Object childEP = editParts.next();
+ if(childEP instanceof AbstractExecutionSpecificationEditPart && getHost() instanceof CLifeLineEditPart) {
+ final LifelineEditPart parentLifeLine = SequenceUtil.getParentLifelinePart((AbstractExecutionSpecificationEditPart)childEP);
+ if (null != parentLifeLine && !parentLifeLine.equals(getHost())) {
+ return UnexecutableCommand.INSTANCE;
+ }
+ }
+ }
+
final Point moveDelta = initialChangeBoundsRequest.getMoveDelta();
final CompoundCommand compoundCommand = new CompoundCommand();
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/LifeLineXYLayoutEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/LifeLineXYLayoutEditPolicy.java
index fe52493ef28..964762465dd 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/LifeLineXYLayoutEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/LifeLineXYLayoutEditPolicy.java
@@ -62,6 +62,7 @@ import org.eclipse.papyrus.uml.diagram.sequence.preferences.CustomDiagramGeneral
import org.eclipse.papyrus.uml.diagram.sequence.util.ExecutionSpecificationUtil;
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.papyrus.uml.service.types.element.UMLDIElementTypes;
import org.eclipse.papyrus.uml.service.types.utils.ElementUtil;
@@ -433,6 +434,12 @@ public class LifeLineXYLayoutEditPolicy extends XYLayoutWithConstrainedResizedEd
protected Command createAddCommand(ChangeBoundsRequest request, EditPart child, Object constraint) {
if (child instanceof LifelineEditPart || child instanceof CombinedFragmentEditPart || child instanceof InteractionUseEditPart) {
return UnexecutableCommand.INSTANCE;
+ // The reparent of execution specification in another life line is not allowed
+ } else if(child instanceof AbstractExecutionSpecificationEditPart && getHost() instanceof CLifeLineEditPart) {
+ final LifelineEditPart parentLifeLine = SequenceUtil.getParentLifelinePart(child);
+ if (null != parentLifeLine && !parentLifeLine.equals(getHost())) {
+ return UnexecutableCommand.INSTANCE;
+ }
}
return super.createAddCommand(request, child, constraint);
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/LifelineCreationEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/LifelineCreationEditPolicy.java
index 9faeb64b938..dd092b69cea 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/LifelineCreationEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/LifelineCreationEditPolicy.java
@@ -22,9 +22,11 @@ import org.eclipse.gef.GraphicalEditPart;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.commands.CompoundCommand;
import org.eclipse.gef.requests.CreateRequest;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
import org.eclipse.gmf.runtime.diagram.core.edithelpers.CreateElementRequestAdapter;
import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil;
import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest;
import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest.ViewAndElementDescriptor;
import org.eclipse.gmf.runtime.emf.type.core.IElementType;
@@ -32,6 +34,9 @@ import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultCreationEditPolicy;
import org.eclipse.papyrus.uml.diagram.sequence.command.SetMoveAllLineAtSamePositionCommand;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.AbstractExecutionSpecificationEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceUtil;
import org.eclipse.papyrus.uml.service.types.element.UMLDIElementTypes;
import org.eclipse.papyrus.uml.service.types.utils.ElementUtil;
import org.eclipse.uml2.uml.MessageOccurrenceSpecification;
@@ -85,7 +90,7 @@ public class LifelineCreationEditPolicy extends DefaultCreationEditPolicy implem
Point pointCombinedFragment = req.getLocation();
pointCombinedFragment.x = pointCombinedFragment.x + boundsLifeline.x;
- pointCombinedFragment.y = pointCombinedFragment.y + boundsLifeline.y;
+ pointCombinedFragment.y = pointCombinedFragment.y + boundsLifeline.y;
req.setLocation(pointCombinedFragment);
@@ -93,14 +98,14 @@ public class LifelineCreationEditPolicy extends DefaultCreationEditPolicy implem
}
}
- DiagramEditPart diagramEditPart=getDiagramEditPart(getHost());
- GridManagementEditPolicy grid=(GridManagementEditPolicy)diagramEditPart.getEditPolicy(GridManagementEditPolicy.GRID_MANAGEMENT);
- if (grid!=null){
- CompoundCommand cmd= new CompoundCommand();
- SetMoveAllLineAtSamePositionCommand setMoveAllLineAtSamePositionCommand= new SetMoveAllLineAtSamePositionCommand(grid, false);
+ DiagramEditPart diagramEditPart = getDiagramEditPart(getHost());
+ GridManagementEditPolicy grid = (GridManagementEditPolicy) diagramEditPart.getEditPolicy(GridManagementEditPolicy.GRID_MANAGEMENT);
+ if (grid != null) {
+ CompoundCommand cmd = new CompoundCommand();
+ SetMoveAllLineAtSamePositionCommand setMoveAllLineAtSamePositionCommand = new SetMoveAllLineAtSamePositionCommand(grid, false);
cmd.add(setMoveAllLineAtSamePositionCommand);
cmd.add(super.getCreateElementAndViewCommand(request));
- setMoveAllLineAtSamePositionCommand= new SetMoveAllLineAtSamePositionCommand( grid, true);
+ setMoveAllLineAtSamePositionCommand = new SetMoveAllLineAtSamePositionCommand(grid, true);
cmd.add(setMoveAllLineAtSamePositionCommand);
return cmd;
}
@@ -108,6 +113,42 @@ public class LifelineCreationEditPolicy extends DefaultCreationEditPolicy implem
}
/**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultCreationEditPolicy#getReparentCommand(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart)
+ */
+ @Override
+ protected ICommand getReparentCommand(final IGraphicalEditPart gep) {
+ // The reparent of execution specification in another life line is not allowed
+ if (gep instanceof AbstractExecutionSpecificationEditPart) {
+ final LifelineEditPart parentLifeLine = SequenceUtil.getParentLifelinePart(gep);
+ if (null != parentLifeLine && !parentLifeLine.equals(getHost())) {
+ return null;
+ }
+ }
+
+ return super.getReparentCommand(gep);
+ }
+
+ /**
+ * @see org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultCreationEditPolicy#getReparentViewCommand(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart)
+ *
+ * @param gep
+ * @return
+ */
+ @Override
+ protected ICommand getReparentViewCommand(IGraphicalEditPart gep) {
+ // The reparent of execution specification in another life line is not allowed
+ if (gep instanceof AbstractExecutionSpecificationEditPart) {
+ final LifelineEditPart parentLifeLine = SequenceUtil.getParentLifelinePart(gep);
+ if (null != parentLifeLine && !parentLifeLine.equals(getHost())) {
+ return null;
+ }
+ }
+ return super.getReparentViewCommand(gep);
+ }
+
+ /**
* test if the element Type that is normally not a child of the Lifeline should be controlled by the lifeline.
* Then The lifeline will be set as the parent editpart, but not as the semantic parent.
*

Back to the top