svn commit: r17528 - trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/UmlHelperMDRImpl.java

Bob Tarling <[email protected]>
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: bobtarling
Date: 2009-11-23 06:44:19-0800
New Revision: 17528

Modified:
   trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/UmlHelperMDRImpl.java

Log:
Put the model subsystem in charge of moving elements within its owner. This is demonstrated with the move attribute functionality within XML prop panels

Modified: trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/UmlHelperMDRImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/UmlHelperMDRImpl.java?view=diff&pathrev=17528&r1=17527&r2=17528
==============================================================================
--- trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/UmlHelperMDRImpl.java	(original)
+++ trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/UmlHelperMDRImpl.java	2009-11-23 06:44:19-0800
@@ -26,12 +26,19 @@
 
 import java.util.Collection;
 import java.util.Iterator;
+import java.util.List;
 
+import org.argouml.model.Model;
 import org.argouml.model.UmlHelper;
+import org.argouml.model.UmlHelper.Direction;
 import org.omg.uml.behavioralelements.collaborations.Message;
 import org.omg.uml.behavioralelements.statemachines.Transition;
 import org.omg.uml.foundation.core.AssociationEnd;
+import org.omg.uml.foundation.core.Attribute;
+import org.omg.uml.foundation.core.Classifier;
+import org.omg.uml.foundation.core.Feature;
 import org.omg.uml.foundation.core.Relationship;
+import org.omg.uml.foundation.core.UmlClass;
 
 /**
  * Helper class for UML metamodel.
@@ -114,5 +121,35 @@
         }
         throw new IllegalArgumentException();
     }
+    
 
+    /*
+     * @see org.argouml.model.UmlHelper#move(java.lang.Object, org.argouml.model.UmlHelper.Direction)
+     */
+    public void move(Object element, Direction direction) {
+        if (element instanceof Feature) {
+            Feature att = (Feature) element;
+            Classifier cls = att.getOwner();
+            
+            if (direction == Direction.DOWN) {
+                List f = Model.getFacade().getFeatures(cls);
+                int index1 = f.indexOf(att);
+                Model.getCoreHelper().removeFeature(cls, att);
+                Model.getCoreHelper().addFeature(cls, index1 + 1, att);
+            } else if (direction == Direction.UP) {
+                List f = Model.getFacade().getFeatures(cls);
+                int index1 = f.indexOf(att);
+                Model.getCoreHelper().removeFeature(cls, att);
+                Model.getCoreHelper().addFeature(cls, index1 - 1, att);
+            } else if (direction == Direction.TOP) {
+                List f = Model.getFacade().getFeatures(cls);
+                Model.getCoreHelper().removeFeature(cls, att);
+                Model.getCoreHelper().addFeature(cls, 0, att);
+            } else if (direction == Direction.BOTTOM) {
+                List f = Model.getFacade().getFeatures(cls);
+                Model.getCoreHelper().removeFeature(cls, att);
+                Model.getCoreHelper().addFeature(cls, f.size() - 1, att);
+            }
+        }
+    }
 }

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

To unsubscribe from this discussion, e-mail: [[email protected]].
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.