svn commit: r13580 - trunk/src_new/org/argouml/uml/ui/TabStyle.java

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: tfmorris
Date: 2007-09-24 01:49:45-0700
New Revision: 13580

Modified:
   trunk/src_new/org/argouml/uml/ui/TabStyle.java

Log:
Issue 4862 - Fix exception when target is as halfway created association class fig

Add Java 5 generic types

Modified: trunk/src_new/org/argouml/uml/ui/TabStyle.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/ui/TabStyle.java?view=diff&rev=13580&p1=trunk/src_new/org/argouml/uml/ui/TabStyle.java&p2=trunk/src_new/org/argouml/uml/ui/TabStyle.java&r1=13579&r2=13580
==============================================================================
--- trunk/src_new/org/argouml/uml/ui/TabStyle.java	(original)
+++ trunk/src_new/org/argouml/uml/ui/TabStyle.java	2007-09-24 01:49:45-0700
@@ -47,6 +47,7 @@
 import org.argouml.ui.targetmanager.TargetListener;
 import org.argouml.uml.diagram.ArgoDiagram;
 import org.argouml.uml.diagram.ui.FigAssociationClass;
+import org.argouml.uml.diagram.ui.FigClassAssociationClass;
 import org.argouml.uml.util.namespace.Namespace;
 import org.argouml.uml.util.namespace.StringNamespace;
 import org.argouml.uml.util.namespace.StringNamespaceElement;
@@ -106,7 +107,8 @@
 
     private JPanel blankPanel = new JPanel();
 
-    private Hashtable panels = new Hashtable();
+    private Hashtable<Class, TabFigTarget> panels = 
+        new Hashtable<Class, TabFigTarget>();
 
     private JPanel lastPanel = null;
 
@@ -171,8 +173,13 @@
             if (target instanceof FigAssociationClass) {
                 // In this case, the bounds (of the box) are determined 
                 // by the FigClassAssociationClass
-                ((FigAssociationClass) target).getAssociationClass()
-                    .removePropertyChangeListener(this);
+                FigClassAssociationClass ac = 
+                    ((FigAssociationClass) target).getAssociationClass();
+                // A newly created AssociationClass may not have all its parts
+                // created by the time we are called
+                if (ac != null) {
+                    ac.removePropertyChangeListener(this);
+                }
             }
         }
         
@@ -180,8 +187,8 @@
 
         // the responsibility of determining if the given target is a
         // correct one for this tab has been moved from the
-        // DetailsPane to the member tabs of th detailpane. Reason for
-        // this is that the detailspane is configurable and cannot
+        // DetailsPane to the member tabs of the details pane. Reason for
+        // this is that the details pane is configurable and cannot
         // know what's the correct target for some tab.
         if (!(t instanceof Fig)) {
             if (Model.getFacade().isAModelElement(t)) {
@@ -201,6 +208,9 @@
         target = (Fig) t;
         if (target != null) {
             target.addPropertyChangeListener(this);
+            // TODO: This shouldn't know about the specific type of Fig that 
+            // is being displayed.  That couples it too strongly to things it
+            // shouldn't need to know about - tfm - 20070924
             if (target instanceof FigEdge) {
                 // In this case, the bounds are determined by the FigEdge
                 ((FigEdge) target).getFig().addPropertyChangeListener(this);
@@ -208,8 +218,13 @@
             if (target instanceof FigAssociationClass) {
                 // In this case, the bounds (of the box) are determined 
                 // by the FigClassAssociationClass
-                ((FigAssociationClass) target).getAssociationClass()
-                    .addPropertyChangeListener(this);
+                FigClassAssociationClass ac = 
+                    ((FigAssociationClass) target).getAssociationClass();
+                // A newly created AssociationClass may not have all its parts
+                // created by the time we are called
+                if (ac != null) {
+                    ac.addPropertyChangeListener(this);
+                }
             }
         }
         if (lastPanel != null) {
@@ -268,7 +283,7 @@
      */
     public StylePanel findPanelFor(Class targetClass) {
         Class panelClass = null;
-        TabFigTarget p = (TabFigTarget) panels.get(targetClass);
+        TabFigTarget p = panels.get(targetClass);
         if (p == null) {
             Class newClass = targetClass;
             while (newClass != null && panelClass == 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.