svn commit: r17523 - trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/XmlPropertyPanel.java

Bob Tarling <[email protected]>
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: bobtarling
Date: 2009-11-22 12:03:20-0800
New Revision: 17523

Modified:
   trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/XmlPropertyPanel.java

Log:
Improve mechanism for clearing selections so that we don't have to drop and add listeners each time a selection changes.

Modified: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/XmlPropertyPanel.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/XmlPropertyPanel.java?view=diff&pathrev=17523&r1=17522&r2=17523
==============================================================================
--- trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/XmlPropertyPanel.java	(original)
+++ trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/XmlPropertyPanel.java	2009-11-22 12:03:20-0800
@@ -46,6 +46,8 @@
      */
     private static final Logger LOG = Logger.getLogger(XmlPropertyPanel.class);
     
+    private JList selectedList;
+    
     public XmlPropertyPanel() {
         super(new LabelledLayout());
         setName("UML Properties");
@@ -82,38 +84,15 @@
     public void valueChanged(ListSelectionEvent e) {
         final JList list = (JList) e.getSource();
         
-        /**
-         * Remove all the listeners first as we will get events from them
-         * while their selctions are being cleared
-         */
-        for (Component c : getComponents()) {
-            if (c instanceof RowSelector) {
-                RowSelector rs = (RowSelector) c;
-                rs.removeListSelectionListener(this);
-            }
-        }
-        
-        /**
-         * If a row has been selected then clear the selections in all other
-         * RowSelectors.
-         */
-        if (list.getSelectedValues().length > 0) {
+        if (selectedList == null && list.getSelectedValues().length > 0) {
+            selectedList = list;
             for (Component c : getComponents()) {
                 if (c instanceof RowSelector && ((RowSelector) c).getList() != list) {
                     ((RowSelector) c).getList().clearSelection();
                 }
             }
+            selectedList = null;
         }
         
-        /**
-         * Remove all the listeners first as we will get events from them
-         * while their selctions are being cleared
-         */
-        for (Component c : getComponents()) {
-            if (c instanceof RowSelector) {
-                RowSelector rs = (RowSelector) c;
-                rs.addListSelectionListener(this);
-            }
-        }
     }
 }

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

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.