svn commit: r17501 - trunk/src/argouml-app/src/org/argouml/ui/explorer/ExplorerPopup.java

Thomas Neustupny <[email protected]>
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: thn
Date: 2009-11-20 00:01:06-0800
New Revision: 17501

Modified:
   trunk/src/argouml-app/src/org/argouml/ui/explorer/ExplorerPopup.java

Log:
allow adding of a (sub)profile, but only inside a profile (UML2 only)

Modified: trunk/src/argouml-app/src/org/argouml/ui/explorer/ExplorerPopup.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/ui/explorer/ExplorerPopup.java?view=diff&pathrev=17501&r1=17500&r2=17501
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/ui/explorer/ExplorerPopup.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/ui/explorer/ExplorerPopup.java	2009-11-20 00:01:06-0800
@@ -98,8 +98,10 @@
      */
     private static final Object[] MODEL_ELEMENT_MENUITEMS = 
         new Object[] {
-    		Model.getMetaTypes().getTemplateParameter(),
-    		"button.new-template-parameter",
+            Model.getMetaTypes().getProfile(), // needs to be the first entry
+            "button.new-profile-package", // because of UML1/UML2 differences
+            Model.getMetaTypes().getTemplateParameter(),
+            "button.new-template-parameter",
             Model.getMetaTypes().getPackage(), 
             "button.new-package",
             Model.getMetaTypes().getActor(), 
@@ -457,20 +459,24 @@
 
             // iterate through all possible model elements to determine which  
             // are valid to be contained by the selected target
-            for (int iter = 0; iter < MODEL_ELEMENT_MENUITEMS.length; 
+            int start = 0;
+            if (Model.getFacade().getUmlVersion().charAt(0) == '1') {
+                // skip profile item for UML1
+                start = 2;
+            }
+            for (int iter = start; iter < MODEL_ELEMENT_MENUITEMS.length; 
                 iter += 2) {
                 
+                Object me = MODEL_ELEMENT_MENUITEMS[iter];
+                String md = (String) MODEL_ELEMENT_MENUITEMS[iter + 1];
+                
                 // test if this element can be contained by the target
-                if (Model.getUmlFactory().isContainmentValid(
-                        MODEL_ELEMENT_MENUITEMS[iter], target)) {
+                if (Model.getUmlFactory().isContainmentValid(me, target)) {
                     // this element can be contained add a menu item 
                     // that allows the user to take that action
                     menuItems.add(new OrderedMenuItem(
                             new ActionCreateContainedModelElement(
-                                    MODEL_ELEMENT_MENUITEMS[iter],
-                                    target, 
-                                    (String) 
-                                    MODEL_ELEMENT_MENUITEMS[iter + 1])));
+                                    me, target, md)));
                 }
             }    
         }

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

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.