svn commit: r15525 - trunk/src/argouml-app/src/org/argouml/ui/DetailsPane.java

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: dthompson
Date: 2008-08-09 01:27:19-0700
New Revision: 15525

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

Log:
Issue 5241: Restored some code that was deleted in revision 15144, to fix Target selection failing for Documentation and TaggedValues property panels.

Modified: trunk/src/argouml-app/src/org/argouml/ui/DetailsPane.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/ui/DetailsPane.java?view=diff&rev=15525&p1=trunk/src/argouml-app/src/org/argouml/ui/DetailsPane.java&p2=trunk/src/argouml-app/src/org/argouml/ui/DetailsPane.java&r1=15524&r2=15525
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/ui/DetailsPane.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/ui/DetailsPane.java	2008-08-09 01:27:19-0700
@@ -447,17 +447,37 @@
      */
     public void stateChanged(ChangeEvent e) {
         LOG.debug("DetailsPane state changed");
+        Component sel = topLevelTabbedPane.getSelectedComponent();
         
         // update the previously selected tab
         if (lastNonNullTab >= 0) {
 	    JPanel tab = tabPanelList.get(lastNonNullTab);
 	    if (tab instanceof TargetListener) {
                 // not visible any more - so remove as listener
-	        removeTargetListener((TargetListener) tab);
+                removeTargetListener((TargetListener) tab);
 	    }
-	}
+        }
         Object target = TargetManager.getInstance().getSingleTarget();
-
+        
+        // If sel is the ToDo Tab (i.e. is an instance of TabToDoTarget), we 
+        // don't need to do anything, because the ToDo Tab is already dealt 
+        // with by it's own listener. 
+        if (!(sel instanceof TabToDoTarget)) {
+            // The other tabs need to be updated depending on the selection.
+            if (sel instanceof TabTarget) {
+                ((TabTarget) sel).setTarget(target);
+            }
+            else if (sel instanceof TargetListener) {
+                removeTargetListener((TargetListener) sel);
+                addTargetListener((TargetListener) sel);
+                // Newly selected tab may have stale target info, so generate
+                // a new set target event for it to refresh it
+                ((TargetListener) sel).targetSet(new TargetEvent(this,
+                        TargetEvent.TARGET_SET, new Object[] {},
+                        new Object[] { target }));
+            }
+        }
+        
         if (target != null
             && Model.getFacade().isAUMLElement(target)
             && topLevelTabbedPane.getSelectedIndex() > 0) {
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.