Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsboyko2014-10-23 13:20:44 +0000
committersboyko2014-11-10 21:06:55 +0000
commit5b2ac72a5a5cc273552286a28f87846adf680fa6 (patch)
treee02892ac871a1df926a5c607eb9749f2bd4a5a59 /plugins/uml
parente6903132f559c8b3f73892be56b57aad53c9b31e (diff)
downloadorg.eclipse.papyrus-5b2ac72a5a5cc273552286a28f87846adf680fa6.tar.gz
org.eclipse.papyrus-5b2ac72a5a5cc273552286a28f87846adf680fa6.tar.xz
org.eclipse.papyrus-5b2ac72a5a5cc273552286a28f87846adf680fa6.zip
Bug 441794 - [Sequence Diagram] Resizing of an operand of a combined
fragment works incorrectly in several cases Change-Id: I749f574cc99304769c88486e7eec90a4473bd6d2 Signed-off-by: sboyko <serg.boyko2011@gmail.com>
Diffstat (limited to 'plugins/uml')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/InteractionOperandDragDropEditPolicy.java22
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/OperandBoundsComputeHelper.java152
2 files changed, 74 insertions, 100 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/InteractionOperandDragDropEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/InteractionOperandDragDropEditPolicy.java
index eba3b00d106..3b28af3563e 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/InteractionOperandDragDropEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/InteractionOperandDragDropEditPolicy.java
@@ -40,26 +40,26 @@ public class InteractionOperandDragDropEditPolicy extends ResizableEditPolicy {
*/
@Override
protected Command getResizeCommand(ChangeBoundsRequest request) {
- if ((request.getResizeDirection() & PositionConstants.EAST_WEST) != 0) {
+ boolean isVertResize = (request.getResizeDirection() & PositionConstants.NORTH_SOUTH) != 0;
+ boolean isHorResize = (request.getResizeDirection() & PositionConstants.EAST_WEST) != 0;
+ boolean isNorthResize = (request.getResizeDirection() & PositionConstants.NORTH) != 0;
+ boolean isSouthResize = (request.getResizeDirection() & PositionConstants.SOUTH) != 0;
+ if (isHorResize && !isVertResize) {
EditPart parent = getHost().getParent().getParent();
return parent.getCommand(request);
- } else {
+ } else if (isVertResize) {
if (this.getHost() instanceof InteractionOperandEditPart && this.getHost().getParent() instanceof CombinedFragmentCombinedFragmentCompartmentEditPart) {
InteractionOperandEditPart currentIOEP = (InteractionOperandEditPart) this.getHost();
CombinedFragmentCombinedFragmentCompartmentEditPart compartEP = (CombinedFragmentCombinedFragmentCompartmentEditPart) this.getHost().getParent();
- // if first interaction operand and resize direction is NORTH
- if (this.getHost() == OperandBoundsComputeHelper.findFirstIOEP(compartEP) && (request.getResizeDirection() & PositionConstants.NORTH) != 0) {
+ // if the OP's border same as/linked to the CF's border
+ if (this.getHost() == OperandBoundsComputeHelper.findFirstIOEP(compartEP) && isNorthResize
+ || this.getHost() == OperandBoundsComputeHelper.findLastIOEP(compartEP) && isSouthResize) {
return getHost().getParent().getParent().getCommand(request);
} else {
- int heightDelta = request.getSizeDelta().height();
- if ((request.getResizeDirection() & PositionConstants.NORTH) != 0) {
- return OperandBoundsComputeHelper.createIOEPResizeCommand(currentIOEP, heightDelta, compartEP, PositionConstants.NORTH);
- } else if ((request.getResizeDirection() & PositionConstants.SOUTH) != 0) {
- return OperandBoundsComputeHelper.createIOEPResizeCommand(currentIOEP, heightDelta, compartEP, PositionConstants.SOUTH);
- }
+ return OperandBoundsComputeHelper.createIOEPResizeCommand(currentIOEP, request, compartEP);
}
}
- return null;
}
+ return null;
}
}
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 d9b8b405fe4..f7d8d134169 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
@@ -36,6 +36,7 @@ import org.eclipse.gmf.runtime.common.core.command.CommandResult;
import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
import org.eclipse.gmf.runtime.common.core.command.ICompositeCommand;
+import org.eclipse.gmf.runtime.diagram.ui.commands.CommandProxy;
import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
import org.eclipse.gmf.runtime.diagram.ui.commands.SetBoundsCommand;
import org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionNodeEditPart;
@@ -552,7 +553,11 @@ public class OperandBoundsComputeHelper {
* @param direction
* @return
*/
- public static Command createIOEPResizeCommand(InteractionOperandEditPart currentIOEP, int heightDelta, CombinedFragmentCombinedFragmentCompartmentEditPart compartEP, int direction) {
+ public static Command createIOEPResizeCommand(InteractionOperandEditPart currentIOEP, ChangeBoundsRequest request, CombinedFragmentCombinedFragmentCompartmentEditPart compartEP) {
+ int heightDelta = request.getSizeDelta().height();
+ int widthDelta = request.getSizeDelta().width();
+ int direction = request.getResizeDirection();
+ int directionEastWest = request.getResizeDirection() & PositionConstants.EAST_WEST;
Bounds currentIOEPBounds = OperandBoundsComputeHelper.getEditPartBounds(currentIOEP);
if (currentIOEPBounds == null) {
return null;
@@ -564,99 +569,68 @@ public class OperandBoundsComputeHelper {
targetIOEP = OperandBoundsComputeHelper.findLatterIOEP(compartEP, currentIOEP);
}
CompositeCommand compositeCommand = new CompositeCommand("Resize Operand");
- // if last operand
- if (targetIOEP == null) {
- if (heightDelta < 0) {
- if (currentIOEPBounds.getHeight() - Math.abs(heightDelta) < OperandBoundsComputeHelper.MIN_INTERACTION_OPERAND_HEIGHT) {
- return null;
- }
- }
- Rectangle currentIOEPRect = OperandBoundsComputeHelper.fillRectangle(currentIOEPBounds);
- currentIOEPRect.setHeight(currentIOEPBounds.getHeight() + heightDelta);
- int minHeight = getMinimumHeightFor(currentIOEP);
- if (currentIOEPRect.height < minHeight) {
- return UnexecutableCommand.INSTANCE;
- }
- ICommand currentIOEPCommand = OperandBoundsComputeHelper.createUpdateEditPartBoundsCommand(currentIOEP, currentIOEPRect);
- compositeCommand.add(currentIOEPCommand);
- Command shiftPreviousExecutions = getShiftEnclosedFragmentsCommand(currentIOEP, currentIOEPRect, heightDelta);
- if (shiftPreviousExecutions != null) {
- compositeCommand.add(new EMFtoGMFCommandWrapper(new GEFtoEMFCommandWrapper(shiftPreviousExecutions)));
- }
- // auto update CombinedFragmentEditPart bounds after resize the last operand
- if (compartEP.getParent() instanceof CombinedFragmentEditPart) {
- CombinedFragmentEditPart parent = (CombinedFragmentEditPart) compartEP.getParent();
- if (parent.getModel() instanceof Node) {
- Node node = (Node) parent.getModel();
- if (node.getLayoutConstraint() instanceof Bounds) {
- Bounds containerBounds = (Bounds) node.getLayoutConstraint();
- Dimension preferredSize = parent.getFigure().getPreferredSize();
- int width = containerBounds.getWidth() != -1 ? containerBounds.getWidth() : preferredSize.width();
- int height = containerBounds.getHeight() != -1 ? containerBounds.getHeight() : preferredSize.height();
- height = height + heightDelta;
- Rectangle containerRect = new Rectangle(containerBounds.getX(), containerBounds.getY(), width, height);
- compositeCommand.add(OperandBoundsComputeHelper.createUpdateEditPartBoundsCommand(parent, containerRect));
- // Preserve Message anchors.
- ICommand preserveMessageAnchorsCommand = MessageAnchorRepairer.createPreserveMessageAnchorsCommand(parent, heightDelta);
- if (preserveMessageAnchorsCommand != null && preserveMessageAnchorsCommand.canExecute()) {
- compositeCommand.add(preserveMessageAnchorsCommand);
- }
- ICommand expandCoveredsCommand = getExpandCoveredsCommand((CombinedFragmentEditPart) compartEP.getParent(), containerRect);
- if (expandCoveredsCommand != null) {
- compositeCommand.add(expandCoveredsCommand);
- }
- }
- }
- }
- } else {
- Bounds targetIOEPBounds = OperandBoundsComputeHelper.getEditPartBounds(targetIOEP);
- if (targetIOEPBounds == null) {
+ // Resize the CF horizontally
+ if (directionEastWest != 0) {
+ ChangeBoundsRequest reqEastWest = new ChangeBoundsRequest();
+ reqEastWest.setEditParts(currentIOEP);
+ reqEastWest.setType(request.getType());
+ reqEastWest.setMoveDelta(new Point(request.getMoveDelta().x, 0));
+ reqEastWest.setSizeDelta(new Dimension(request.getSizeDelta().width, 0));
+ reqEastWest.setLocation(request.getLocation());
+ reqEastWest.setExtendedData(request.getExtendedData());
+ reqEastWest.setResizeDirection(directionEastWest);
+ ICommand horResizeCommand = new CommandProxy(currentIOEP.getParent().getParent().getCommand(reqEastWest));
+ compositeCommand.add(horResizeCommand);
+ }
+ Bounds targetIOEPBounds = OperandBoundsComputeHelper.getEditPartBounds(targetIOEP);
+ if (targetIOEPBounds == null) {
+ return null;
+ }
+ if (heightDelta > 0) {
+ if (targetIOEPBounds.getHeight() - heightDelta < OperandBoundsComputeHelper.MIN_INTERACTION_OPERAND_HEIGHT) {
return null;
}
- if (heightDelta > 0) {
- if (targetIOEPBounds.getHeight() - heightDelta < OperandBoundsComputeHelper.MIN_INTERACTION_OPERAND_HEIGHT) {
- return null;
- }
- } else {
- if (currentIOEPBounds.getHeight() - Math.abs(heightDelta) < OperandBoundsComputeHelper.MIN_INTERACTION_OPERAND_HEIGHT) {
- return null;
- }
- }
- Rectangle targetIOEPRect = OperandBoundsComputeHelper.fillRectangle(targetIOEPBounds);
- Rectangle currentIOEPRect = OperandBoundsComputeHelper.fillRectangle(currentIOEPBounds);
- targetIOEPRect.setHeight(targetIOEPBounds.getHeight() - heightDelta);
- currentIOEPRect.setHeight(currentIOEPBounds.getHeight() + heightDelta);
- int shiftY = 0;
- if ((direction & PositionConstants.NORTH) != 0) {
- currentIOEPRect.setY(currentIOEPRect.y() - heightDelta);
- shiftY = -heightDelta;
- } else if ((direction & PositionConstants.SOUTH) != 0) {
- targetIOEPRect.setY(targetIOEPRect.y() + heightDelta);
- shiftY = heightDelta;
- }
- int minHeightOfTargetOperand = getMinimumHeightFor(targetIOEP);
- if (targetIOEPRect.height < minHeightOfTargetOperand) {
+ } else {
+ if (currentIOEPBounds.getHeight() - Math.abs(heightDelta) < OperandBoundsComputeHelper.MIN_INTERACTION_OPERAND_HEIGHT) {
return null;
}
- ICommand previousIOEPCommand = OperandBoundsComputeHelper.createUpdateEditPartBoundsCommand(targetIOEP, targetIOEPRect);
- compositeCommand.add(previousIOEPCommand);
- if ((shiftY < 0 && targetIOEPRect.y < currentIOEPRect.y) || shiftY > 0 && (targetIOEPRect.y > currentIOEPRect.y)) {
- Command shiftPreviousExecutions = getShiftEnclosedFragmentsCommand(targetIOEP, targetIOEPRect, shiftY);
- if (shiftPreviousExecutions != null) {
- compositeCommand.add(new EMFtoGMFCommandWrapper(new GEFtoEMFCommandWrapper(shiftPreviousExecutions)));
- }
- }
- int minHeughtOfCurrentOperand = getMinimumHeightFor(currentIOEP);
- if (currentIOEPRect.height < minHeughtOfCurrentOperand) {
- return null;
+ }
+ Rectangle targetIOEPRect = OperandBoundsComputeHelper.fillRectangle(targetIOEPBounds);
+ Rectangle currentIOEPRect = OperandBoundsComputeHelper.fillRectangle(currentIOEPBounds);
+ targetIOEPRect.setHeight(targetIOEPBounds.getHeight() - heightDelta);
+ targetIOEPRect.setWidth(targetIOEPBounds.getWidth() + widthDelta);
+ currentIOEPRect.setHeight(currentIOEPBounds.getHeight() + heightDelta);
+ currentIOEPRect.setWidth(currentIOEPBounds.getWidth() + widthDelta);
+ int shiftY = 0;
+ if ((direction & PositionConstants.NORTH) != 0) {
+ currentIOEPRect.setY(currentIOEPRect.y() - heightDelta);
+ shiftY = -heightDelta;
+ } else if ((direction & PositionConstants.SOUTH) != 0) {
+ targetIOEPRect.setY(targetIOEPRect.y() + heightDelta);
+ shiftY = heightDelta;
+ }
+ int minHeightOfTargetOperand = getMinimumHeightFor(targetIOEP);
+ if (targetIOEPRect.height < minHeightOfTargetOperand) {
+ return null;
+ }
+ ICommand previousIOEPCommand = OperandBoundsComputeHelper.createUpdateEditPartBoundsCommand(targetIOEP, targetIOEPRect);
+ compositeCommand.add(previousIOEPCommand);
+ if ((shiftY < 0 && targetIOEPRect.y < currentIOEPRect.y) || shiftY > 0 && (targetIOEPRect.y > currentIOEPRect.y)) {
+ Command shiftPreviousExecutions = getShiftEnclosedFragmentsCommand(targetIOEP, targetIOEPRect, shiftY);
+ if (shiftPreviousExecutions != null) {
+ compositeCommand.add(new EMFtoGMFCommandWrapper(new GEFtoEMFCommandWrapper(shiftPreviousExecutions)));
}
- ICommand currentIOEPCommand = OperandBoundsComputeHelper.createUpdateEditPartBoundsCommand(currentIOEP, currentIOEPRect);
- compositeCommand.add(currentIOEPCommand);
- if ((shiftY < 0 && currentIOEPRect.y < targetIOEPRect.y) || (shiftY > 0 && currentIOEPRect.y > targetIOEPRect.y)) {
- Command shiftCurrentExecutions = getShiftEnclosedFragmentsCommand(currentIOEP, currentIOEPRect, shiftY);
- if (shiftCurrentExecutions != null) {
- compositeCommand.add(new EMFtoGMFCommandWrapper(new GEFtoEMFCommandWrapper(shiftCurrentExecutions)));
- }
+ }
+ int minHeughtOfCurrentOperand = getMinimumHeightFor(currentIOEP);
+ if (currentIOEPRect.height < minHeughtOfCurrentOperand) {
+ return null;
+ }
+ ICommand currentIOEPCommand = OperandBoundsComputeHelper.createUpdateEditPartBoundsCommand(currentIOEP, currentIOEPRect);
+ compositeCommand.add(currentIOEPCommand);
+ if ((shiftY < 0 && currentIOEPRect.y < targetIOEPRect.y) || (shiftY > 0 && currentIOEPRect.y > targetIOEPRect.y)) {
+ Command shiftCurrentExecutions = getShiftEnclosedFragmentsCommand(currentIOEP, currentIOEPRect, shiftY);
+ if (shiftCurrentExecutions != null) {
+ compositeCommand.add(new EMFtoGMFCommandWrapper(new GEFtoEMFCommandWrapper(shiftCurrentExecutions)));
}
}
return new ICommandProxy(compositeCommand);

Back to the top