svn commit: r13394 - branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: b00__1
Date: 2007-08-18 05:48:34-0700
New Revision: 13394

Modified:
   branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/UMLUtil.java
   branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/UmlFactoryEUMLImpl.java
   branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/XmiReaderEUMLImpl.java

Log:
Fix the loader to map the elements to XMI ids and remove the TEMPORARY_URI because it is causing more trouble than it is worth it (problems when saving).

Modified: branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/UMLUtil.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/UMLUtil.java?view=diff&rev=13394&p1=branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/UMLUtil.java&p2=branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/UMLUtil.java&r1=13393&r2=13394
==============================================================================
--- branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/UMLUtil.java	(original)
+++ branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/UMLUtil.java	2007-08-18 05:48:34-0700
@@ -53,12 +53,7 @@
      * The default URI used for eUML
      */
     public static final URI DEFAULT_URI = URI.createURI("http://argouml.tigris.org/euml/resource/default_uri.xmi"); //$NON-NLS-1$
-    
-    /**
-     * A temporary URI used when the DEFAULT_URI is not used yet
-     */
-    public static final URI TEMPORARY_URI = URI.createURI("http://argouml.tigris.org/euml/resource/temporary_uri.xmi"); //$NON-NLS-1$
-    
+        
     /**
      * Getter for the attributes of a Type
      * 

Modified: branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/UmlFactoryEUMLImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/UmlFactoryEUMLImpl.java?view=diff&rev=13394&p1=branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/UmlFactoryEUMLImpl.java&p2=branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/UmlFactoryEUMLImpl.java&r1=13393&r2=13394
==============================================================================
--- branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/UmlFactoryEUMLImpl.java	(original)
+++ branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/UmlFactoryEUMLImpl.java	2007-08-18 05:48:34-0700
@@ -307,8 +307,6 @@
                     "Attempted to create unsupported model element type: " //$NON-NLS-1$
                             + elementType);
         }
-        Resource r = UMLUtil.getResource(modelImpl, UMLUtil.TEMPORARY_URI);
-        r.getContents().add((EObject) o);
         return o;
     }
 
@@ -321,9 +319,8 @@
     
     public boolean isRemoved(Object o) {
         // This triggers some warnings (in logs) because some elements are
-        // created without an owner (and eResource is null) we solve this
-        // by adding the newly created element (not owned yet) to a dummy
-        // resource.
+        // created without an owner (and eResource is null)
+        // TODO: fix this
         // The warning log (if we would not add the EObject to a resource) would
         // looks like this: "...WARN [AWT-EventQueue-0] Encountered deleted
         // object during delete of..."

Modified: branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/XmiReaderEUMLImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/XmiReaderEUMLImpl.java?view=diff&rev=13394&p1=branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/XmiReaderEUMLImpl.java&p2=branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/XmiReaderEUMLImpl.java&r1=13393&r2=13394
==============================================================================
--- branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/XmiReaderEUMLImpl.java	(original)
+++ branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/XmiReaderEUMLImpl.java	2007-08-18 05:48:34-0700
@@ -34,11 +34,15 @@
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import org.argouml.model.UmlException;
 import org.argouml.model.XmiReader;
+import org.eclipse.emf.ecore.EObject;
 import org.eclipse.emf.ecore.resource.Resource;
 import org.eclipse.emf.edit.domain.EditingDomain;
 import org.xml.sax.InputSource;
@@ -53,7 +57,9 @@
      */
     private EUMLModelImplementation modelImpl;
     
-    private static List<String> searchDirs = new ArrayList();
+    private static Set<String> searchDirs = new HashSet();
+    
+    private Resource resource;
 
     /**
      * Constructor.
@@ -75,9 +81,18 @@
         return new String[0];
     }
 
+    @SuppressWarnings("unchecked")
     public Map getXMIUUIDToObjectMap() {
-        // TODO Auto-generated method stub
-        return new HashMap();
+        if (resource == null) {
+            throw new IllegalStateException();
+        }
+        HashMap map = new HashMap();
+        Iterator<EObject> it = resource.getAllContents();
+        while (it.hasNext()) {
+            EObject o  = it.next();
+            map.put(resource.getURIFragment(o), o);
+        }
+        return map;
     }
 
     public Collection parse(InputSource inputSource) throws UmlException {
@@ -123,10 +138,10 @@
         try {
             modelImpl.getModelEventPump().stopPumpingEvents();
             r.load(is, null);
-            modelImpl.getModelEventPump().startPumpingEvents();
         } catch (IOException e) {
             throw new UmlException(e);
         } finally {
+            modelImpl.getModelEventPump().startPumpingEvents();
             if (needsClosing) {
                 try {
                     is.close();
@@ -135,7 +150,7 @@
                 }
             }
         }
-
+        resource = r;
         return r.getContents();
     }
 
@@ -145,9 +160,15 @@
     }
 
     public String getTagName() {
-        // This is not quite right
-        // TODO: Solve this
-        return "uml:Model"; //$NON-NLS-1$
+        if (resource == null) {
+            throw new IllegalStateException();
+        }
+        List l = resource.getContents();
+        if (!l.isEmpty()) {
+            return "uml:" + modelImpl.getMetaTypes().getName(l.get(0)); //$NON-NLS-1$
+        } else {
+            return null;
+        }
     }
 
     public void addSearchPath(String path) {
@@ -155,7 +176,7 @@
     }
 
     public List<String> getSearchPath() {
-        return searchDirs;
+        return new ArrayList<String>(searchDirs);
     }
 
     public void removeSearchPath(String path) {
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.