Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsboyko2014-08-19 16:52:14 +0000
committerCamille Letavernier2014-09-29 12:28:05 +0000
commit23e8fac0e97cd5baa45424b9a7a0b0c646081c75 (patch)
treee32944808dc2c579bf0523184a5f28058d6d9fb7 /plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence
parentd05ec3ca82e0db78a959a31fe9e3b82cf21cc3a9 (diff)
downloadorg.eclipse.papyrus-23e8fac0e97cd5baa45424b9a7a0b0c646081c75.tar.gz
org.eclipse.papyrus-23e8fac0e97cd5baa45424b9a7a0b0c646081c75.tar.xz
org.eclipse.papyrus-23e8fac0e97cd5baa45424b9a7a0b0c646081c75.zip
Bug 395248 - [Sequence Diagram] frame/operator of a combinedFragment
hidden when shifted inside another one supported: + move of several CFs + move into top/middle/bottom operands + move from one operand to another + move of nested CFs + move into nested CF + move out of nested CF + move to a diagram from CF/nested CF + move to an outer CF + expanding borders of an outer CF when moving a CF into it Change-Id: I1e11fc64f26a686fa23f64e6d1825484704bb216 Signed-off-by: sboyko <serg.boyko2011@gmail.com>
Diffstat (limited to 'plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomCombinedFragmentEditPart.java8
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/CustomDiagramDragDropEditPolicy.java105
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/InteractionCompartmentXYLayoutEditPolicy.java22
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/CombinedFragmentMoveHelper.java195
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/OperandBoundsComputeHelper.java57
5 files changed, 382 insertions, 5 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomCombinedFragmentEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomCombinedFragmentEditPart.java
index aff07686d2c..177eb636165 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomCombinedFragmentEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomCombinedFragmentEditPart.java
@@ -207,6 +207,14 @@ public class CustomCombinedFragmentEditPart extends CombinedFragmentEditPart imp
return getContentPane();
}
+ public InteractionInteractionCompartmentEditPart getParentInteractionCompartmentEditPart() {
+ EditPart part = this;
+ do {
+ part = part.getParent();
+ } while(part != null && !(part instanceof InteractionInteractionCompartmentEditPart));
+ return (InteractionInteractionCompartmentEditPart)part;
+ }
+
public final BorderedNodeFigure getBorderedFigure() {
return (BorderedNodeFigure) getFigure();
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/CustomDiagramDragDropEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/CustomDiagramDragDropEditPolicy.java
index 1ec8e6b79d4..3a3546c4512 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/CustomDiagramDragDropEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/CustomDiagramDragDropEditPolicy.java
@@ -22,17 +22,22 @@ import java.util.Set;
import org.eclipse.core.commands.operations.IUndoableOperation;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.draw2d.ConnectionAnchor;
+import org.eclipse.draw2d.PositionConstants;
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
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;
+import org.eclipse.gef.requests.ChangeBoundsRequest;
import org.eclipse.gef.requests.CreateConnectionRequest;
import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.diagram.core.commands.AddCommand;
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.commands.CommandProxy;
@@ -48,10 +53,12 @@ import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest.ViewDescriptor;
import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequestFactory;
import org.eclipse.gmf.runtime.diagram.ui.requests.DropObjectsRequest;
+import org.eclipse.gmf.runtime.diagram.ui.requests.EditCommandRequestWrapper;
import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
import org.eclipse.gmf.runtime.emf.type.core.IElementType;
import org.eclipse.gmf.runtime.emf.type.core.IHintedType;
import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.MoveRequest;
import org.eclipse.gmf.runtime.notation.Node;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.jface.dialogs.MessageDialog;
@@ -78,6 +85,7 @@ import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.Constraint2EditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.ConstraintConstrainedElementEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.ConstraintEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.ContinuationEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CustomCombinedFragmentEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DestructionOccurrenceSpecificationEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationConstraintEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationConstraintInMessageEditPart;
@@ -103,6 +111,7 @@ import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeObservationEditPa
import org.eclipse.papyrus.uml.diagram.sequence.part.UMLDiagramEditorPlugin;
import org.eclipse.papyrus.uml.diagram.sequence.part.UMLVisualIDRegistry;
import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
+import org.eclipse.papyrus.uml.diagram.sequence.util.CombinedFragmentMoveHelper;
import org.eclipse.papyrus.uml.diagram.sequence.util.GateHelper;
import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceLinkMappingHelper;
import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceRequestConstant;
@@ -199,6 +208,102 @@ public class CustomDiagramDragDropEditPolicy extends CommonDiagramDragDropEditPo
}
@Override
+ public Command getCommand(Request request) {
+ Command command = super.getCommand(request);
+ if (false == request instanceof ChangeBoundsRequest) {
+ return command;
+ }
+
+ boolean someCombinedFragment = false;
+ boolean someNonCombinedFragment = false;
+ for (Object part : ((ChangeBoundsRequest)request).getEditParts()) {
+ someCombinedFragment |= (part instanceof CustomCombinedFragmentEditPart);
+ someNonCombinedFragment |= !(part instanceof CustomCombinedFragmentEditPart);
+ }
+
+ if (someCombinedFragment && someNonCombinedFragment) {
+ // Can't Drop CombinedFragment and other nodes at the same time
+ return UnexecutableCommand.INSTANCE;
+ }
+ else if (someNonCombinedFragment) {
+ return command;
+ }
+ else {
+ return getMoveCombinedFragmentCommand((ChangeBoundsRequest)request);
+ }
+ }
+
+ /*
+ * "In-place" drag-and-drop command for Combined Fragment
+ *
+ */
+ protected Command getMoveCombinedFragmentCommand(ChangeBoundsRequest request) {
+ CompoundCommand cc = new CompoundCommand("move CombinedFragments to new parent"); //$NON-NLS-1$
+
+ Rectangle rectangleDroppedCombined = CombinedFragmentMoveHelper.calcCombinedRect(request);
+ GraphicalEditPart newParentEP = CombinedFragmentMoveHelper.findNewParentEP(request, getHost());
+
+ // Move the request's CFs models and views
+ for (Object part : ((ChangeBoundsRequest)request).getEditParts()) {
+ CustomCombinedFragmentEditPart combinedFragmentEP = (CustomCombinedFragmentEditPart)part;
+ CombinedFragment combinedFragment = (CombinedFragment)ViewUtil.
+ resolveSemanticElement((View)((IGraphicalEditPart)combinedFragmentEP).getModel());
+
+ if (combinedFragmentEP.getParent() == newParentEP) {
+ continue; // no change of the parent
+ }
+
+ View containerNewParent = (View)newParentEP.getModel();
+ EObject contextNewParent = ViewUtil.resolveSemanticElement(containerNewParent);
+ TransactionalEditingDomain editingDomain = ((IGraphicalEditPart)getHost()).getEditingDomain();
+
+ // Move semantic
+ Command moveSemanticCmd = getHost().getCommand(new EditCommandRequestWrapper(
+ new MoveRequest(editingDomain, contextNewParent, combinedFragment)));
+ if (moveSemanticCmd == null) {
+ return UnexecutableCommand.INSTANCE;
+ }
+ cc.add(moveSemanticCmd);
+
+ // Move view
+ View container = (View)newParentEP.getModel();
+ View view = (View)combinedFragmentEP.getModel();
+ cc.add(new ICommandProxy(new AddCommand(combinedFragmentEP.getEditingDomain(), new EObjectAdapter(container),
+ new EObjectAdapter(view))));
+ }
+
+ // Calc new parent rect
+ Rectangle newParentOldRect = newParentEP.getFigure().getBounds().getCopy();
+ newParentEP.getFigure().translateToAbsolute(newParentOldRect);
+ Rectangle newParentNewRect = new Rectangle(newParentOldRect.getUnion(rectangleDroppedCombined));
+
+ if (getHost().getParent() instanceof CustomCombinedFragmentEditPart) {
+ CombinedFragmentMoveHelper.adjustNewParentOperands(cc, newParentNewRect, newParentOldRect, getHost());
+ }
+ // TODO: resize parent's parent (and so on)
+
+ // Move & resize parent CF
+ Point newParentOffsetSW = new Point(newParentNewRect.x - newParentOldRect.x, newParentNewRect.y - newParentOldRect.y);
+ if (newParentEP.getParent().getParent() != null) {
+ final ChangeBoundsRequest moveParentRequest = new ChangeBoundsRequest();
+ moveParentRequest.setType(REQ_MOVE);
+ moveParentRequest.setMoveDelta(newParentOffsetSW);
+ moveParentRequest.setEditParts(newParentEP.getParent().getParent());
+ moveParentRequest.setSizeDelta(new Dimension(newParentNewRect.width - newParentOldRect.width,
+ newParentNewRect.height - newParentOldRect.height));
+ moveParentRequest.setResizeDirection(PositionConstants.SOUTH_WEST);
+ cc.add(newParentEP.getParent().getParent().getCommand(moveParentRequest));
+ }
+
+ for (Object part : ((ChangeBoundsRequest)request).getEditParts()) {
+ CustomCombinedFragmentEditPart combinedFragmentEP = (CustomCombinedFragmentEditPart)part;
+ CombinedFragmentMoveHelper.moveCombinedFragmentEP(cc, request, combinedFragmentEP, newParentEP, newParentOffsetSW);
+ }
+
+ return cc;
+ }
+
+ @Override
protected IUndoableOperation getDropObjectCommand(DropObjectsRequest dropRequest, final EObject droppedObject) {
IUndoableOperation dropObjectCommand = super.getDropObjectCommand(dropRequest, droppedObject);
if (dropObjectCommand != null && dropObjectCommand.canExecute()) {
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/InteractionCompartmentXYLayoutEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/InteractionCompartmentXYLayoutEditPolicy.java
index bcee2b76db6..9fe7ee77e4c 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/InteractionCompartmentXYLayoutEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/InteractionCompartmentXYLayoutEditPolicy.java
@@ -97,6 +97,8 @@ import org.eclipse.uml2.uml.Lifeline;
*/
public class InteractionCompartmentXYLayoutEditPolicy extends XYLayoutEditPolicy {
+ public static final String CHILDREN_MOVEDELTA = "CHILDREN_MOVEDELTA"; //$NON-NLS-1$
+
@Override
protected Command getCreateCommand(CreateRequest request) {
CreateViewRequest req = (CreateViewRequest) request;
@@ -366,6 +368,10 @@ public class InteractionCompartmentXYLayoutEditPolicy extends XYLayoutEditPolicy
@SuppressWarnings("unchecked")
public static Command getCombinedFragmentResizeChildrenCommand(ChangeBoundsRequest request, CombinedFragmentEditPart combinedFragmentEditPart) {
Point moveDelta = request.getMoveDelta();
+ if (request.getExtendedData().get(CHILDREN_MOVEDELTA) instanceof Point) {
+ moveDelta = (Point) request.getExtendedData().get(CHILDREN_MOVEDELTA);
+ }
+
Dimension sizeDelta = request.getSizeDelta();
IFigure cfFigure = combinedFragmentEditPart.getFigure();
Rectangle origCFBounds = cfFigure.getBounds().getCopy();
@@ -650,11 +656,17 @@ public class InteractionCompartmentXYLayoutEditPolicy extends XYLayoutEditPolicy
*/
@Override
public Command getAddCommand(Request request) {
- if (request instanceof ChangeBoundsRequest) {
- // Only allow to move-in AppliedStereotypeCommentEditPart.
- List editParts = ((ChangeBoundsRequest) request).getEditParts();
- if (editParts.size() == 1 && editParts.get(0) instanceof AppliedStereotypesCommentEditPart) {
- return super.getAddCommand(request);
+ if(request instanceof ChangeBoundsRequest) {
+ List<?> editParts = ((ChangeBoundsRequest)request).getEditParts();
+ if(editParts.size() == 1) {
+ if (editParts.get(0) instanceof AppliedStereotypesCommentEditPart) {
+ // Allow to move-in AppliedStereotypeCommentEditPart
+ return super.getAddCommand(request);
+ }
+ if(editParts.get(0) instanceof CombinedFragmentEditPart) {
+ // Prevent UnexecutableCommand.INSTANCE to be added to a valid CombinedFragmentEditPart move command chain
+ return null;
+ }
}
return UnexecutableCommand.INSTANCE;
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/CombinedFragmentMoveHelper.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/CombinedFragmentMoveHelper.java
new file mode 100644
index 00000000000..b313fc856fa
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/CombinedFragmentMoveHelper.java
@@ -0,0 +1,195 @@
+/*****************************************************************************
+ * Copyright (c) 2009 CEA
+ *
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ * Alex Paperno - bug 395248
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.diagram.sequence.util;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.draw2d.PositionConstants;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.RequestConstants;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.CompoundCommand;
+import org.eclipse.gef.requests.ChangeBoundsRequest;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
+import org.eclipse.gmf.runtime.notation.Bounds;
+import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
+import org.eclipse.papyrus.commands.wrappers.GEFtoEMFCommandWrapper;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CombinedFragmentEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CustomCombinedFragmentEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CustomInteractionOperandEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.InteractionOperandEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.InteractionCompartmentXYLayoutEditPolicy;
+
+public class CombinedFragmentMoveHelper {
+
+ protected final static int CF_PADDING = 10;
+
+ /**
+ * Calculate combined rect
+ *
+ */
+ public static Rectangle calcCombinedRect(ChangeBoundsRequest request) {
+ Rectangle rectangleDroppedCombined = new Rectangle();
+ for (Object part : request.getEditParts()) {
+ CombinedFragmentEditPart combinedFragmentEP = (CombinedFragmentEditPart)part;
+ Rectangle rectangleDropped = combinedFragmentEP.getFigure().getBounds().getCopy();
+ combinedFragmentEP.getFigure().translateToAbsolute(rectangleDropped);
+
+ if (!rectangleDroppedCombined.isEmpty()) {
+ rectangleDroppedCombined = new Rectangle(rectangleDropped.getUnion(rectangleDroppedCombined));
+ }
+ else {
+ rectangleDroppedCombined = rectangleDropped;
+ }
+ }
+ rectangleDroppedCombined.translate(request.getMoveDelta());
+ rectangleDroppedCombined.expand(CF_PADDING, CF_PADDING);
+ return rectangleDroppedCombined;
+ }
+
+ /**
+ * Find the EP that we're dropping to
+ *
+ */
+ public static GraphicalEditPart findNewParentEP(ChangeBoundsRequest request, EditPart hostEP) {
+ GraphicalEditPart parentEP = (GraphicalEditPart)hostEP;
+ if (hostEP.getParent() instanceof CustomCombinedFragmentEditPart) {
+ // Select which InteractionOperand we're dropping to
+ CustomCombinedFragmentEditPart hostCFEP = (CustomCombinedFragmentEditPart)hostEP.getParent();
+ List<CustomInteractionOperandEditPart> operands = hostCFEP.getOperandChildrenEditParts();
+ if (!operands.isEmpty()) {
+ Point location = request.getLocation();
+ parentEP = operands.get(0);
+ for (CustomInteractionOperandEditPart operand : operands) {
+ Rectangle bounds = operand.getFigure().getBounds().getCopy();
+ operand.getFigure().translateToAbsolute(bounds);
+ if (bounds.contains(location)) {
+ parentEP = operand;
+ }
+ }
+ }
+ }
+ return parentEP;
+ }
+
+ /**
+ * Move new parent's operands
+ *
+ */
+ public static void adjustNewParentOperands(CompoundCommand cc, Rectangle newParentNewRect, Rectangle newParentOldRect, EditPart hostEP) {
+ Set<Object> alreadyMovedBlocks = new HashSet<Object>();
+ CustomCombinedFragmentEditPart hostCFEP = (CustomCombinedFragmentEditPart)hostEP.getParent();
+ List<CustomInteractionOperandEditPart> operands = hostCFEP.getOperandChildrenEditParts();
+ int moveUpperYOffset = newParentNewRect.y - newParentOldRect.y;
+ int moveLowerYOffset = newParentNewRect.height - newParentOldRect.height;
+ for (CustomInteractionOperandEditPart operand : operands) {
+ Rectangle rectangleOperand = operand.getFigure().getBounds().getCopy();
+ operand.getFigure().translateToAbsolute(rectangleOperand);
+ Bounds operandBounds = OperandBoundsComputeHelper.getEditPartBounds(operand);
+ Rectangle operandRect = OperandBoundsComputeHelper.fillRectangle(operandBounds);
+ operandRect.width = newParentNewRect.width;
+ int moveItemsOffset = moveUpperYOffset;
+ Point offsetInnerCFs = new Point(newParentOldRect.x - newParentNewRect.x, 0);
+ if (rectangleOperand.y == newParentOldRect.y) {
+ operandRect.height += moveLowerYOffset;
+ moveItemsOffset = 0;
+ offsetInnerCFs.y = -moveUpperYOffset;
+ }
+ else if (rectangleOperand.y > newParentOldRect.y) {
+ operandRect.y += moveLowerYOffset;
+ moveItemsOffset = moveLowerYOffset + moveUpperYOffset;
+ }
+ ICommand resizeOperandCommand = OperandBoundsComputeHelper.createUpdateEditPartBoundsCommand(operand, operandRect);
+ cc.add(new ICommandProxy(resizeOperandCommand));
+ Command adjustInnerCFsCommand = getShiftEnclosedCFsCommand(operand, offsetInnerCFs);
+ if (adjustInnerCFsCommand != null) {
+ cc.add(adjustInnerCFsCommand);
+ }
+ Command shiftExecutions = OperandBoundsComputeHelper.getForcedShiftEnclosedFragmentsCommand(operand, moveItemsOffset, alreadyMovedBlocks);
+ if(shiftExecutions != null) {
+ cc.add(new ICommandProxy(new EMFtoGMFCommandWrapper(new GEFtoEMFCommandWrapper(shiftExecutions))));
+ }
+ }
+ }
+
+ /**
+ * Shift inner CFs so that they don't change absolute coords
+ *
+ */
+ public static Command getShiftEnclosedCFsCommand(InteractionOperandEditPart editPart, Point offset) {
+ if(editPart == null || offset.x == 0 && offset.y == 0) {
+ return null;
+ }
+ CompoundCommand cc = new CompoundCommand("shift inner CFs"); //$NON-NLS-1$
+ List<?> children = editPart.getChildren();
+ for (int i = 0; i < children.size(); i++) {
+ if (false == children.get(i) instanceof CustomCombinedFragmentEditPart) {
+ continue;
+ }
+ CustomCombinedFragmentEditPart childCF = (CustomCombinedFragmentEditPart)children.get(i);
+
+ final ChangeBoundsRequest moveChildCFRequest = new ChangeBoundsRequest();
+ moveChildCFRequest.setType(RequestConstants.REQ_MOVE);
+ moveChildCFRequest.setMoveDelta(offset);
+ moveChildCFRequest.setEditParts(childCF);
+ moveChildCFRequest.setResizeDirection(PositionConstants.SOUTH_WEST);
+ cc.add(childCF.getCommand(moveChildCFRequest));
+
+ }
+ if (cc.size() == 0)
+ return null;
+ return cc;
+ }
+
+ /**
+ * Move CombinedFragment EP
+ *
+ */
+ public static void moveCombinedFragmentEP(CompoundCommand cc, ChangeBoundsRequest request, CustomCombinedFragmentEditPart combinedFragmentEP, GraphicalEditPart newParentEP, Point newParentOffsetSW) {
+ // Calc CF moveDelta
+ final ChangeBoundsRequest forceLocationRequest = new ChangeBoundsRequest();
+ forceLocationRequest.setType(RequestConstants.REQ_MOVE_CHILDREN);
+ Point moveDelta = request.getMoveDelta().getCopy();
+
+ // CFs children moveDelta need special processing (no need to translate coords)
+ Point childrenMoveDelta = moveDelta.getCopy();
+ HashMap<String,Object> extData = new HashMap<String,Object>();
+ forceLocationRequest.setExtendedData(extData);
+ extData.put(InteractionCompartmentXYLayoutEditPolicy.CHILDREN_MOVEDELTA, childrenMoveDelta);
+
+ // Translate moveDelta into new parents coords
+ Rectangle oldParentBounds = ((GraphicalEditPart)combinedFragmentEP.getParent()).getFigure().getBounds().getCopy();
+ ((GraphicalEditPart)combinedFragmentEP.getParent()).getFigure().translateToAbsolute(oldParentBounds);
+ moveDelta.translate(oldParentBounds.x, oldParentBounds.y);
+ Rectangle parentBounds = newParentEP.getFigure().getBounds().getCopy();
+ newParentEP.getFigure().translateToAbsolute(parentBounds);
+ moveDelta.translate(-parentBounds.x - newParentOffsetSW.x, -parentBounds.y - newParentOffsetSW.y);
+ forceLocationRequest.setMoveDelta(moveDelta);
+
+ Point moveLocation = request.getLocation();
+ //newParentEP.getFigure().translateToRelative(moveLocation);
+ forceLocationRequest.setLocation(moveLocation);
+ forceLocationRequest.setEditParts(combinedFragmentEP);
+ cc.add(combinedFragmentEP.getParentInteractionCompartmentEditPart().getCommand(forceLocationRequest));
+ }
+
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/OperandBoundsComputeHelper.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/OperandBoundsComputeHelper.java
index 36a58ea83bb..1601fffe1bd 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/OperandBoundsComputeHelper.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/OperandBoundsComputeHelper.java
@@ -67,6 +67,8 @@ import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.AbstractExecutionSpec
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.AbstractMessageEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CombinedFragmentCombinedFragmentCompartmentEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CombinedFragmentEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CustomCombinedFragmentEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CustomInteractionOperandEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.GateEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.InteractionInteractionCompartmentEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.InteractionOperandEditPart;
@@ -789,6 +791,40 @@ public class OperandBoundsComputeHelper {
return new ICommandProxy(new MoveOperandBlockCommand(editPart.getEditingDomain(), blockToMove));
}
+ public static Command getForcedShiftEnclosedFragmentsCommand(InteractionOperandEditPart editPart, int movedY, Set<Object> alreadyMovedItems) {
+ if(editPart == null || movedY == 0) {
+ return null;
+ }
+ // Recursively process children
+ CompoundCommand cc = new CompoundCommand("shift inner CFs' exec blocks"); //$NON-NLS-1$
+ List<?> children = editPart.getChildren();
+ for (int i = 0; i < children.size(); i++) {
+ if (false == children.get(i) instanceof CustomCombinedFragmentEditPart) {
+ continue;
+ }
+ CustomCombinedFragmentEditPart childCF = (CustomCombinedFragmentEditPart)children.get(i);
+ List<CustomInteractionOperandEditPart> childOperands = childCF.getOperandChildrenEditParts();
+ for (CustomInteractionOperandEditPart childOperand : childOperands) {
+ cc.add(getForcedShiftEnclosedFragmentsCommand(childOperand, movedY, alreadyMovedItems));
+ }
+ }
+
+ List<OperandBlock> operandBlocks = getOperandBlocks(editPart);
+ if(operandBlocks.isEmpty()) {
+ return null;
+ }
+
+ final Map<OperandBlock, Integer> blockToMove = new HashMap<OperandBoundsComputeHelper.OperandBlock, Integer>();
+ for(OperandBlock blk : operandBlocks) {
+ blockToMove.put(blk, movedY);
+ }
+ if(blockToMove.isEmpty()) {
+ return null;
+ }
+ cc.add(new ICommandProxy(new MoveOperandBlockCommand(editPart.getEditingDomain(), blockToMove, alreadyMovedItems)));
+ return cc;
+ }
+
private static ICommand getMoveAnchorCommand(int yDelta, Rectangle figureBounds, IdentityAnchor gmfAnchor) {
String oldTerminal = gmfAnchor.getId();
PrecisionPoint pp = BaseSlidableAnchor.parseTerminalString(oldTerminal);
@@ -1475,6 +1511,7 @@ public class OperandBoundsComputeHelper {
private static class MoveOperandBlockCommand extends AbstractTransactionalCommand {
private Map<OperandBlock, Integer> blockToMove;
+ private Set<Object> alreadyMovedItems;
/**
* Constructor.
@@ -1489,6 +1526,18 @@ public class OperandBoundsComputeHelper {
}
/**
+ * Constructor.
+ *
+ * @param domain
+ * @param label
+ * @param affectedFiles
+ */
+ public MoveOperandBlockCommand(TransactionalEditingDomain domain, Map<OperandBlock, Integer> blockToMove, Set<Object> alreadyMovedItems) {
+ this(domain, blockToMove);
+ this.alreadyMovedItems = alreadyMovedItems;
+ }
+
+ /**
* @see org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand#doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
*
* @param monitor
@@ -1544,6 +1593,14 @@ public class OperandBoundsComputeHelper {
if (block instanceof ExecutionOperandBlock) {
List<ShapeNodeEditPart> children = ((ExecutionOperandBlock) block).getShapeNodeChildren();
for (ShapeNodeEditPart child : children) {
+ if (alreadyMovedItems != null) {
+ if (alreadyMovedItems.contains(child)) {
+ continue;
+ }
+ else {
+ alreadyMovedItems.add(child);
+ }
+ }
Bounds bounds = getInteractionOperandEPBounds(child);
Rectangle newBounds = fillRectangle(bounds);
newBounds.y += moveDelta;

Back to the top