svn commit: r14362 - trunk/src/model-mdr/src/org/argouml/model/mdr/FacadeMDRImpl.java

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: tfmorris
Date: 2008-04-15 21:22:17-0700
New Revision: 14362

Modified:
   trunk/src/model-mdr/src/org/argouml/model/mdr/FacadeMDRImpl.java

Log:
Add getRoot and deprecate getModel.

Modified: trunk/src/model-mdr/src/org/argouml/model/mdr/FacadeMDRImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/model-mdr/src/org/argouml/model/mdr/FacadeMDRImpl.java?view=diff&rev=14362&p1=trunk/src/model-mdr/src/org/argouml/model/mdr/FacadeMDRImpl.java&p2=trunk/src/model-mdr/src/org/argouml/model/mdr/FacadeMDRImpl.java&r1=14361&r2=14362
==============================================================================
--- trunk/src/model-mdr/src/org/argouml/model/mdr/FacadeMDRImpl.java	(original)
+++ trunk/src/model-mdr/src/org/argouml/model/mdr/FacadeMDRImpl.java	2008-04-15 21:22:17-0700
@@ -2155,6 +2155,22 @@
         }
     }
 
+    public Object getRoot(final Object handle) {
+        Object result = handle;
+        try {
+            if (!isAUMLElement(handle)) {
+                return illegalArgumentObject(handle);
+            }
+            Object container = getModelElementContainer(handle);
+            while (container != null) {
+                result = container;
+                container = getModelElementContainer(result);
+            }
+        } catch (InvalidObjectException e) {
+            throw new InvalidElementException(e);
+        }
+        return result;
+    }
 
     public Collection getRootElements() {
         Collection elements = new ArrayList();
@@ -3913,6 +3929,28 @@
             if (handle instanceof ElementResidence) {
                 return "";
             }
+            if (handle instanceof TemplateParameter) {
+                // TODO: Do we want to construct an artificial name here?
+                StringBuffer result = new StringBuffer();
+                ModelElement template =
+                        ((TemplateParameter) handle).getTemplate();
+                if (template != null) {
+                    String name = template.getName();
+                    if (name != null) {
+                        result.append(name);
+                    }
+                }
+                result.append(":");
+                ModelElement parameter =
+                        ((TemplateParameter) handle).getParameter();
+                if (parameter != null) {
+                    String name = parameter.getName();
+                    if (name != null) {
+                        result.append(name);
+                    }
+                }
+                return "";
+            }
             // TODO: What other non-ModelElement types do we need to handle here?
         } catch (InvalidObjectException e) {
             String uuid = getUUID(handle);
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.