svn commit: r16231 - trunk/src/argouml-app/src/org/argouml/ui/DisplayTextTree.java

Tom Morris <[email protected]>
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: tfmorris
Date: 2008-12-03 12:39:07-0800
New Revision: 16231

Modified:
   trunk/src/argouml-app/src/org/argouml/ui/DisplayTextTree.java

Log:
Refactor to use Facade.toString() as much as possible

Modified: trunk/src/argouml-app/src/org/argouml/ui/DisplayTextTree.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/ui/DisplayTextTree.java?view=diff&pathrev=16231&r1=16230&r2=16231
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/ui/DisplayTextTree.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/ui/DisplayTextTree.java	2008-12-03 12:39:07-0800
@@ -56,9 +56,7 @@
  * navigation (the explorer) and the todo list.
  */
 public class DisplayTextTree extends JTree {
-    /**
-     * Logger.
-     */
+
     private static final Logger LOG = Logger.getLogger(DisplayTextTree.class);
 
     /**
@@ -148,21 +146,7 @@
                 if (Model.getFacade().isATransition(value)) {
                     name = formatTransitionLabel(value);
                 } else if (Model.getFacade().isAExtensionPoint(value)) {
-                    NotationProvider notationProvider =
-                        NotationProviderFactory2.getInstance()
-                            .getNotationProvider(
-                                NotationProviderFactory2.TYPE_EXTENSION_POINT,
-                                value);
-                    /* TODO: move this Map outside this method 
-                     * for performance. */
-                    HashMap<String, Object> npArguments = 
-                        new HashMap<String, Object>();
-                    Project p = ProjectManager.getManager().getCurrentProject();
-                    if (p != null) {
-                        npArguments.put("useGuillemets", p.getProjectSettings()
-                                .getDefaultDiagramSettings().isUseGuillemets());
-                    }
-                    name = notationProvider.toString(value, npArguments);
+                    name = formatExtensionPoint(value);
                 } else if (Model.getFacade().isAComment(value)) {
                     name = (String) Model.getFacade().getBody(value);
                 } else if (Model.getFacade().isATaggedValue(value)) {
@@ -200,23 +184,8 @@
             return name;
         }
 
-        if (Model.getFacade().isAExpression(value)) {
-            try {
-                String name = Model.getFacade().getUMLClassName(value);
-                String language = Model.getDataTypesHelper().getLanguage(value);
-                String body = Model.getDataTypesHelper().getBody(value);
-                if (language != null && language.length() > 0) {
-                    name += " (" + language + ")";
-                }
-                if (body != null && body.length() > 0) {
-                    name += ": " + body;
-                }
-                return name;
-            } catch (InvalidElementException e) {
-                return Translator.localize("misc.name.deleted");
-            }
-        }
-        
+        // TODO: This duplicates code in Facade.toString(), but this version
+        // is localized, so we'll leave it for now.
         if (Model.getFacade().isAElementImport(value)) {
             try {
                 Object me = Model.getFacade().getImportedElement(value);
@@ -239,25 +208,15 @@
             }
         }
 
-        if (Model.getFacade().isAMultiplicity(value)) {
+        // Use default formatting for any other type of UML element
+        if (Model.getFacade().isAUMLElement(value)) {
             try {
-                // TODO: Localize
-                return "Multiplicity: "
-                    + Model.getDataTypesHelper().multiplicityToString(value);
-            } catch (InvalidElementException e) {
-                return Translator.localize("misc.name.deleted");
-            }
-        }
-        
-        if (Model.getFacade().isAElementResidence(value)) {
-            try {
-                // TODO: Add the container and resident names
-                return "ElementResidence";
+                return Model.getFacade().toString(value);
             } catch (InvalidElementException e) {
                 return Translator.localize("misc.name.deleted");
             }            
         }
-
+        
         if (value instanceof ArgoDiagram) {
             return ((ArgoDiagram) value).getName();
         }
@@ -268,6 +227,26 @@
         return "-";
     }
 
+    private String formatExtensionPoint(Object value) {
+        String name;
+        NotationProvider notationProvider =
+            NotationProviderFactory2.getInstance()
+                .getNotationProvider(
+                    NotationProviderFactory2.TYPE_EXTENSION_POINT,
+                    value);
+        /* TODO: move this Map outside this method 
+         * for performance. */
+        HashMap<String, Object> npArguments = 
+            new HashMap<String, Object>();
+        Project p = ProjectManager.getManager().getCurrentProject();
+        if (p != null) {
+            npArguments.put("useGuillemets", p.getProjectSettings()
+                    .getDefaultDiagramSettings().isUseGuillemets());
+        }
+        name = notationProvider.toString(value, npArguments);
+        return name;
+    }
+
     private String formatTaggedValueLabel(Object value) {
         String name;
         String tagName = Model.getFacade().getTag(value);

------------------------------------------------------
http://argouml.tigris.org/ds/viewMessage.do?dsForumId=5905&dsMessageId=979101

To unsubscribe from this discussion, e-mail: [[email protected]].
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.