Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnsgar Radermacher2015-11-23 19:48:49 +0000
committerGerrit Code Review @ Eclipse.org2015-11-23 22:16:25 +0000
commita30f72f151a291511c04eee26da2486ddfabaefb (patch)
tree8be4a43bf036a32119aa582a669fac3fe973d3ab /plugins/uml
parent525fcd480677d1c9d6d5204f08ddc832b7ab0b91 (diff)
downloadorg.eclipse.papyrus-a30f72f151a291511c04eee26da2486ddfabaefb.tar.gz
org.eclipse.papyrus-a30f72f151a291511c04eee26da2486ddfabaefb.tar.xz
org.eclipse.papyrus-a30f72f151a291511c04eee26da2486ddfabaefb.zip
Bug 481773 - [State Machine Diagram] - Drop of an state inside a composite state lead to an unexpected layout
Diffstat (limited to 'plugins/uml')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/policies/CustomStateMachineDiagramDragDropEditPolicy.java11
1 files changed, 8 insertions, 3 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/policies/CustomStateMachineDiagramDragDropEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/policies/CustomStateMachineDiagramDragDropEditPolicy.java
index e2f879926ed..9b433ee792c 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/policies/CustomStateMachineDiagramDragDropEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/policies/CustomStateMachineDiagramDragDropEditPolicy.java
@@ -455,14 +455,19 @@ public class CustomStateMachineDiagramDragDropEditPolicy extends CommonDiagramDr
cc.compose(createState);
cc.compose(createRegion);
+ // calculate position relative to graphical parent (passed position is absolute)
+ Rectangle parentBounds = graphicalParentEditPart.getFigure().getBounds().getCopy();
+ graphicalParentEditPart.getFigure().translateToAbsolute(parentBounds);
+ Point relLocation = new Point(location.x - parentBounds.x, location.y - parentBounds.y);
+
// take care of the case when a simple state is dropped, then we should provide a reasonable size
if (droppedElement.getRegions().isEmpty()) {
// final state has default size 20
- int sizeHint = (droppedElement instanceof FinalState) ? 20 : 40;
- setBoundsCommand = new CustomCompositeStateSetBoundsCommand(getEditingDomain(), null, descriptor, new Rectangle(location.x, location.y, sizeHint, sizeHint), false);
+ int sizeHint = (droppedElement instanceof FinalState) ? 20 : 60;
+ setBoundsCommand = new CustomCompositeStateSetBoundsCommand(getEditingDomain(), null, descriptor, new Rectangle(relLocation.x, relLocation.y, sizeHint, sizeHint), false);
cc.compose(setBoundsCommand);
} else {
- setBoundsCommand = new CustomCompositeStateSetBoundsCommand(getEditingDomain(), null, descriptor, new Rectangle(location.x, location.y, -1, -1), true);
+ setBoundsCommand = new CustomCompositeStateSetBoundsCommand(getEditingDomain(), null, descriptor, new Rectangle(relLocation.x, relLocation.y, -1, -1), true);
cc.compose(setBoundsCommand);
// force compartment to be shown
SetPropertyCommand showCompartment = new SetPropertyCommand(getEditingDomain(), (IAdaptable) createState.getCommandResult().getReturnValue(), "notation.View.visible", "Visibility", true) {

Back to the top