svn commit: r17422 - trunk/src/argouml-app/src/org/argouml/uml/ui/ActionAddDiagram.java

Thomas Neustupny <[email protected]>
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: thn
Date: 2009-10-22 14:42:14-0700
New Revision: 17422

Modified:
   trunk/src/argouml-app/src/org/argouml/uml/ui/ActionAddDiagram.java

Log:
fixing todo in findNamespace() (for newly created diagram)

Modified: trunk/src/argouml-app/src/org/argouml/uml/ui/ActionAddDiagram.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/ui/ActionAddDiagram.java?view=diff&pathrev=17422&r1=17421&r2=17422
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/ui/ActionAddDiagram.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/uml/ui/ActionAddDiagram.java	2009-10-22 14:42:14-0700
@@ -26,6 +26,7 @@
 
 import java.awt.event.ActionEvent;
 import java.util.Collection;
+import java.util.Iterator;
 
 import javax.swing.Action;
 
@@ -112,12 +113,21 @@
         Object ns = null;
         if (target == null || !Model.getFacade().isAModelElement(target)
                 || Model.getModelManagementHelper().isReadOnly(target)) {
-            // TODO: When read-only projects are supported (instead of just
-            // profiles), this could be a read-only extent as well
-            Collection c = p.getRoots();
-            if ((c != null) && !c.isEmpty()) {
-                target = c.iterator().next();
-            } // else what?
+            // get the first editable extent (which is OK unless there is more
+            // than one editable extent)
+            target = null;
+            Iterator iter = p.getRoots().iterator();
+            while (iter.hasNext()) {
+                Object o = iter.next();
+                if (!Model.getModelManagementHelper().isReadOnly(o)) {
+                    target = o;
+                    break;
+                }
+            }
+            if (target == null) {
+                // no way, we have to give up
+                return null;
+            }
         }
         if (Model.getFacade().isANamespace(target)) {
             ns = target;

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

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.