svn commit: r12993 - branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/EUMLModelImplementation.java

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: b00__1
Date: 2007-07-07 06:21:25-0700
New Revision: 12993

Modified:
   branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/EUMLModelImplementation.java

Log:
Fix the AdapterFacory usage in case we are in a standalone ArgoUML instance.

Modified: branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/EUMLModelImplementation.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/EUMLModelImplementation.java?view=diff&rev=12993&p1=branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/EUMLModelImplementation.java&p2=branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/EUMLModelImplementation.java&r1=12992&r2=12993
==============================================================================
--- branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/EUMLModelImplementation.java	(original)
+++ branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/EUMLModelImplementation.java	2007-07-07 06:21:25-0700
@@ -36,11 +36,8 @@
 
 package org.argouml.model.euml;
 
-import java.io.File;
 import java.io.FileInputStream;
-import java.io.FileNotFoundException;
 import java.io.IOException;
-import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.Writer;
 import java.util.ArrayList;
@@ -95,6 +92,7 @@
 import org.eclipse.emf.ecore.provider.EcoreItemProviderAdapterFactory;
 import org.eclipse.emf.ecore.resource.ResourceSet;
 import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
+import org.eclipse.emf.edit.domain.EditingDomain;
 import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
 import org.eclipse.uml2.common.edit.domain.UML2AdapterFactoryEditingDomain;
 import org.eclipse.uml2.uml.UMLPackage;
@@ -200,11 +198,6 @@
     private AdapterFactoryEditingDomain editingDomain;
     
     /**
-     * This is the one adapter factory used for providing views of the model.
-     */
-    private ComposedAdapterFactory adapterFactory;
-    
-    /**
      * Constructor.
      */
     public EUMLModelImplementation() {
@@ -237,14 +230,13 @@
      * This sets up the editing domain for the model editor.
      */
     private void initializeEditingDomain() {
-	List<AdapterFactory> factories = new ArrayList<AdapterFactory>();
-	factories.add(new UMLResourceItemProviderAdapterFactory());
-	factories.add(new UMLItemProviderAdapterFactory());
-	factories.add(new EcoreItemProviderAdapterFactory());
-	factories.add(new UMLReflectiveItemProviderAdapterFactory());
-
-	adapterFactory = new ComposedAdapterFactory(factories);
+	// If the eUML.resources system property is defined then we are in a
+	// stand alone application, else we're in an Eclipse plug in.
+	// The eUML.resource should contain the path to the org.eclipse.uml2.uml.resource jar plugin.
+	String path = System.getProperty("eUML.resources"); //$NON-NLS-1$
 
+	ComposedAdapterFactory adapterFactory = null;
+	
 	BasicCommandStack commandStack = new BasicCommandStack() {
 
 	    @Override
@@ -254,7 +246,7 @@
 	    }
 
 	};
-
+	
 	commandStack.addCommandStackListener(new CommandStackListener() {
 
 	    public void commandStackChanged(final EventObject event) {
@@ -269,6 +261,15 @@
 
 	});
 
+	if (path == null) {
+	    List<AdapterFactory> factories = new ArrayList<AdapterFactory>();
+	    factories.add(new UMLResourceItemProviderAdapterFactory());
+	    factories.add(new UMLItemProviderAdapterFactory());
+	    factories.add(new EcoreItemProviderAdapterFactory());
+	    factories.add(new UMLReflectiveItemProviderAdapterFactory());
+	    adapterFactory = new ComposedAdapterFactory(factories);
+	}
+	
 	editingDomain = new UML2AdapterFactoryEditingDomain(adapterFactory,
 		commandStack);
 	
@@ -276,12 +277,8 @@
 	Map<String, Object> extensionToFactoryMap = resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap();
 	Map<URI, URI> uriMap = resourceSet.getURIConverter().getURIMap();
 
-	// If the eUML.resources system property is defined then we are in a
-	// stand alone application, else we're in an Eclipse plug in.
-	// The eUML.resource should contain the path to the org.eclipse.uml2.uml.resource jar plugin.
-	String path = System.getProperty("eUML.resources"); //$NON-NLS-1$
 	
-	if (path != null && path.length() > 0) {
+	if (path != null) {
 	    try {
 		FileInputStream in = new FileInputStream(path);
 		in.close();
@@ -309,6 +306,14 @@
 	uriMap.putAll(XMI2UMLExtendedMetaData.getURIMap());
 	
     }
+    
+    /**
+     * Getter for {@link #editingDomain the Editing Domain}
+     * @return the editing domain of the current EUMLModelImplementation instance
+     */
+    public EditingDomain getEditingDomain() {
+	return editingDomain;
+    }
 
     public ActivityGraphsFactory getActivityGraphsFactory() {
         if (theActivityGraphsFactory == null) {
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.