Author: bobtarling
Date: 2011-05-20 00:58:39-0700
New Revision: 19470

Modified:
   trunk/src/argouml-app/src/org/argouml/uml/diagram/state/ui/FigVertex.java

Log:
Detect drop region of vertex

Modified: 
trunk/src/argouml-app/src/org/argouml/uml/diagram/state/ui/FigVertex.java
Url: 
http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/state/ui/FigVertex.java?view=diff&pathrev=19470&r1=19469&r2=19470
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/state/ui/FigVertex.java   
(original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/state/ui/FigVertex.java   
2011-05-20 00:58:39-0700
@@ -100,19 +100,30 @@
         
         super.setEnclosingFig(encloser);
 
-        final Object region;
+        Object region = null;
         if (encloser != null) {
             // Get the region as the first Region in the State.
             // If there is no region in the StateMachine then create one.
             List regions = Model.getStateMachinesHelper().getRegions(
                     encloser.getOwner());
             if (regions.isEmpty()) {
+                // There are no regions so create one and place the vertex 
there.
                 region = Model.getUmlFactory().buildNode(
                         Model.getMetaTypes().getRegion(), encloser.getOwner());
             } else {
-                region = regions.get(0);
+                // There are one or more regions so find the one that the
+                //vertex was dropped in
+                FigVertex compositeState = (FigVertex) encloser;
+                for (DiagramElement de :
+                        compositeState.regionCompartment.getDiagramElements()) 
{
+                    if (((Fig) de).getBounds().contains(getBounds())) {
+                        region = de.getOwner();
+                        break;
+                    }
+                }
             }
         } else {
+            // The vertex was dropped onto the diagram.
             // Get the region as the first Region in the StateMachine.
             // If there is no region in the StateMachine then create one.
             ArgoDiagram diagram = (ArgoDiagram) lp.getDiagram();

------------------------------------------------------
http://argouml.tigris.org/ds/viewMessage.do?dsForumId=5905&dsMessageId=2742225

To unsubscribe from this discussion, e-mail: 
[[email protected]].

Reply via email to