svn commit: r13573 - trunk/src_new/org/argouml/kernel/ProjectImpl.java

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: tfmorris
Date: 2007-09-17 21:20:33-0700
New Revision: 13573

Modified:
   trunk/src_new/org/argouml/kernel/ProjectImpl.java

Log:
Improve compatibility between get/setRoot and get/setRoots

Modified: trunk/src_new/org/argouml/kernel/ProjectImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/kernel/ProjectImpl.java?view=diff&rev=13573&p1=trunk/src_new/org/argouml/kernel/ProjectImpl.java&p2=trunk/src_new/org/argouml/kernel/ProjectImpl.java&r1=13572&r2=13573
==============================================================================
--- trunk/src_new/org/argouml/kernel/ProjectImpl.java	(original)
+++ trunk/src_new/org/argouml/kernel/ProjectImpl.java	2007-09-17 21:20:33-0700
@@ -970,13 +970,13 @@
 
 
     @SuppressWarnings("deprecation")
-    public Object getRoot() {
+    public final Object getRoot() {
         return root;
     }
 
 
     @SuppressWarnings("deprecation")
-    public void setRoot(Object theRoot) {
+    public void setRoot(final Object theRoot) {
 
         if (theRoot == null) {
             throw new IllegalArgumentException(
@@ -997,15 +997,19 @@
         // what depends on it - tfm - 20070725
         Model.getModelManagementFactory().setRootModel(theRoot);
         addModel(theRoot);
+        Collection newRoots = new ArrayList();
+        roots.add(theRoot);
+        roots = newRoots;
     }
 
     
-    public Collection getRoots() {
+    public final Collection getRoots() {
         return roots;
     }
 
 
-    public void setRoots(Collection elements) {
+    public void setRoots(final Collection elements) {
+        boolean modelFound = false;
         for (Object element : elements) {
             if (!Model.getFacade().isAPackage(element)) {
                 LOG.warn("Top level element other than package found - " 
@@ -1013,6 +1017,10 @@
             }
             if (Model.getFacade().isAModel(element)) {
                 addModel(element);
+                if (!modelFound) {
+                    setRoot(element);
+                    modelFound = true;
+                }
             }
         }
         roots = elements;
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.