svn commit: r15225 - trunk/src/argouml-app/src/org/argouml/notation/providers/uml/AttributeNotationUml.java

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: thn
Date: 2008-07-09 14:31:46-0700
New Revision: 15225

Modified:
   trunk/src/argouml-app/src/org/argouml/notation/providers/uml/AttributeNotationUml.java

Log:


Modified: trunk/src/argouml-app/src/org/argouml/notation/providers/uml/AttributeNotationUml.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/notation/providers/uml/AttributeNotationUml.java?view=diff&rev=15225&p1=trunk/src/argouml-app/src/org/argouml/notation/providers/uml/AttributeNotationUml.java&p2=trunk/src/argouml-app/src/org/argouml/notation/providers/uml/AttributeNotationUml.java&r1=15224&r2=15225
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/notation/providers/uml/AttributeNotationUml.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/notation/providers/uml/AttributeNotationUml.java	2008-07-09 14:31:46-0700
@@ -138,9 +138,26 @@
             s = text.substring(start, end).trim();
             if (s.length() > 0) {
                 // yes, there are more:
+                Object model = project.getModel();
                 Object attrType = project.getDefaultAttributeType();
+                // Force type element into given namespace if not already there
+                // Dangerous! Why are we changing the model 
+                // as a side effect? - tfm 20070307
+                // Because if the type is unknown, a class without valid
+                // was created, so we MUST set it's namespace! - thn 20080709
+                Object ns = Model.getFacade().getNamespace(attrType);
+                while (ns != null && !Model.getFacade().isAModel(ns)) {
+                    ns = Model.getFacade().getNamespace(ns);
+                }
+                if (!project.getModels().contains(ns)) {
+                    // namespace not found in the project's namespace tree, so
+                    // set a valid namespace:
+                    Model.getCoreHelper().setNamespace(attrType, model);
+                }
+                
                 Object newAttribute = Model.getUmlFactory().buildNode(
                         Model.getMetaTypes().getAttribute());
+                
                 Model.getCoreHelper().setType(newAttribute, attrType);
                 
                 if (newAttribute != 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.