svn commit: r17541 - 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-24 17:19:48-0800
New Revision: 17541

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

Log:
Allow reorder of association-ends in association

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=17541&r1=17540&r2=17541
==============================================================================
--- 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-24 17:19:48-0800
@@ -38,6 +38,7 @@
 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.UmlAssociation;
 import org.omg.uml.foundation.core.UmlClass;
 
 /**
@@ -130,26 +131,35 @@
         if (element instanceof Feature) {
             Feature att = (Feature) element;
             Classifier cls = att.getOwner();
+            List f = Model.getFacade().getFeatures(cls);
+            int index = f.indexOf(att);
+            Model.getCoreHelper().removeFeature(cls, att);
             
             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);
+                Model.getCoreHelper().addFeature(cls, index + 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);
+                Model.getCoreHelper().addFeature(cls, index - 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);
             }
+        } else if (element instanceof AssociationEnd) {
+            AssociationEnd assEnd = (AssociationEnd) element;
+            UmlAssociation assoc = assEnd.getAssociation();
+            List<AssociationEnd> f =  assoc.getConnection();
+            int index = f.indexOf(assEnd);
+            f.remove(assEnd);
+            
+            if (direction == Direction.DOWN) {
+                f.add(index + 1, assEnd);
+            } else if (direction == Direction.UP) {
+                f.add(index - 1, assEnd);
+            } else if (direction == Direction.TOP) {
+                f.add(0, assEnd);
+            } else if (direction == Direction.BOTTOM) {
+                f.add(f.size() - 1, assEnd);
+            }
         }
     }
 }

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

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.