svn commit: r19214 - trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLComboBoxModel.java

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: bobtarling
Date: 2011-04-11 07:21:34-0700
New Revision: 19214

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

Log:
Use null instead of "<none>" to mean no value - this means we no longer mix model elements and strings in a combo model

Modified: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLComboBoxModel.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLComboBoxModel.java?view=diff&pathrev=19214&r1=19213&r2=19214
==============================================================================
--- trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLComboBoxModel.java	(original)
+++ trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLComboBoxModel.java	2011-04-11 07:21:34-0700
@@ -78,13 +78,6 @@
     private static final long serialVersionUID = 6038919811554379037L;
 
     private static final Logger LOG = Logger.getLogger(UMLComboBoxModel.class);
-
-    /**
-     * The string that represents a null or cleared choice.
-     */
-    // TODO: I18N
-    // Don't use the empty string for this or it won't show in the list
-    protected static final String CLEARED = "<none>";
     
     /**
      * The target of the comboboxmodel. This is some UML modelelement
@@ -182,14 +175,14 @@
         buildMinimalModelList();
         // Do not set buildingModel = false here, 
         // otherwise the action for selection is performed.
-        setSelectedItem(external2internal(getSelectedModelElement()));
+        setSelectedItem(getSelectedModelElement());
         buildingModel = false;
 
         if (getSize() > 0) {
             fireIntervalAdded(this, 0, getSize() - 1);
         }
         if (getSelectedItem() != null && isClearable) {
-            addElement(CLEARED); // makes sure we can select 'none'
+            addElement(null); // makes sure we can select 'none'
         }
     }
 
@@ -259,9 +252,9 @@
         } else if (evt instanceof RemoveAssociationEvent && isValidEvent(evt)) {
             if (evt.getPropertyName().equals(propertySetName) 
                     && (evt.getSource() == getTarget())) {
-                if (evt.getOldValue() == internal2external(getSelectedItem())) {
+                if (evt.getOldValue() == getSelectedItem()) {
                     /* TODO: Here too? */
-                    setSelectedItem(external2internal(evt.getNewValue()));
+                    setSelectedItem(evt.getNewValue());
                 }
             } else {
                 Object o = getChangedElement(evt);
@@ -300,7 +293,7 @@
             String name = (n != null ? (String) n : "");
             return name;
         } catch (InvalidElementException e) {
-            return "";
+            return "<invalid>";
         }
     }
 
@@ -321,15 +314,15 @@
                                 // compatibility.  Don't remove without 
                                 // checking subclasses and warning downstream
                                 // developers - tfm - 20081211
-                                && ("".equals(o) || CLEARED.equals(o)))) {
+                                && (o == null || "".equals(o)))) {
                     toBeRemoved.add(o);
                 }
             }
             removeAll(toBeRemoved);
             addAll(elements);
             
-            if (isClearable && !elements.contains(CLEARED)) {
-                addElement(CLEARED);
+            if (isClearable && !elements.contains(null)) {
+                addElement(null);
             }
             if (!objects.contains(selectedObject)) {
                 selectedObject = null;
@@ -397,7 +390,7 @@
                 addElement(o);
             }
         }
-        setSelectedItem(external2internal(selected));
+        setSelectedItem(selected);
         fireListEvents = true;
         if (objects.size() != oldSize) {
             fireIntervalAdded(this, oldSize == 0 ? 0 : oldSize - 1, 
@@ -450,14 +443,14 @@
         buildMinimalModelList();
         // Do not set buildingModel = false here, 
         // otherwise the action for selection is performed.
-        setSelectedItem(external2internal(getSelectedModelElement()));
+        setSelectedItem(getSelectedModelElement());
         buildingModel = false;
 
         if (getSize() > 0) {
             fireIntervalAdded(this, 0, getSize() - 1);
         }
         if (getSelectedItem() != null && isClearable) {
-            addElement(CLEARED); // makes sure we can select 'none'
+            addElement(null); // makes sure we can select 'none'
         }
     }
     
@@ -610,14 +603,6 @@
         return selectedObject;
     }
     
-    private Object external2internal(Object o) {
-        return o == null && isClearable ? CLEARED : o;
-    }
-
-    private Object internal2external(Object o) {
-        return isClearable && CLEARED.equals(o) ? null : o;
-    }
-    
     /**
      * Returns true if some object elem is contained by the list of choices.
      *

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

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.