svn commit: r15104 - branches/xmlpropertypanels-penyaskito-soc08/argouml-core-propertypanels-scratch/src/org/argouml/core/propertypanels/panel/XmlPropertyPanel.java

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: penyaskito
Date: 2008-06-28 09:03:26-0700
New Revision: 15104

Modified:
   branches/xmlpropertypanels-penyaskito-soc08/argouml-core-propertypanels-scratch/src/org/argouml/core/propertypanels/panel/XmlPropertyPanel.java

Log:
The XML panels title is updated when a target is set.

Modified: branches/xmlpropertypanels-penyaskito-soc08/argouml-core-propertypanels-scratch/src/org/argouml/core/propertypanels/panel/XmlPropertyPanel.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/xmlpropertypanels-penyaskito-soc08/argouml-core-propertypanels-scratch/src/org/argouml/core/propertypanels/panel/XmlPropertyPanel.java?view=diff&rev=15104&p1=branches/xmlpropertypanels-penyaskito-soc08/argouml-core-propertypanels-scratch/src/org/argouml/core/propertypanels/panel/XmlPropertyPanel.java&p2=branches/xmlpropertypanels-penyaskito-soc08/argouml-core-propertypanels-scratch/src/org/argouml/core/propertypanels/panel/XmlPropertyPanel.java&r1=15103&r2=15104
==============================================================================
--- branches/xmlpropertypanels-penyaskito-soc08/argouml-core-propertypanels-scratch/src/org/argouml/core/propertypanels/panel/XmlPropertyPanel.java	(original)
+++ branches/xmlpropertypanels-penyaskito-soc08/argouml-core-propertypanels-scratch/src/org/argouml/core/propertypanels/panel/XmlPropertyPanel.java	2008-06-28 09:03:26-0700
@@ -25,6 +25,7 @@
 package org.argouml.core.propertypanels.panel;
 
 import javax.swing.ImageIcon;
+import javax.swing.JLabel;
 import javax.swing.JPanel;
 
 import org.apache.log4j.Logger;
@@ -54,7 +55,7 @@
      * The instance.
      */
     private static final XmlPropertyPanel INSTANCE =
-        new XmlPropertyPanel("XML Property Panel", null);
+        new XmlPropertyPanel("XML Properties", null);
 
     /**
      * @return The instance.
@@ -83,10 +84,25 @@
         }
         try {
             currentPanel = UIFactory.getInstance().createGUI(target);
+            this.getTitleLabel().setText(getPanelTitle(target));
             this.add(currentPanel);
         } catch (Exception e) {
             // TODO: Auto-generated catch block
             LOG.error("Exception", e);
         }        
     }
+    
+    // TODO: Code duplication. This is the same that
+    // UIFactory.getXMLFileName
+    /**
+     * @return the title of the panel, according to the target 
+     */
+    private String getPanelTitle(Object target) {
+        String classname = target.getClass().getSimpleName();
+        // TODO: I don't like this hack, it may exist a better way.
+        return classname.replace("$Impl", "");
+        // this returns UmlClass for classes, in the original PropPanels
+        // it's Class... Should we change it?
+    }
+   
 }
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.