svn commit: r13778 - trunk/src_new/org/argouml/uml: . ui/foundation/core

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: tfmorris
Date: 2007-11-15 22:37:48-0800
New Revision: 13778

Modified:
   trunk/src_new/org/argouml/uml/StereotypeUtility.java
   trunk/src_new/org/argouml/uml/ui/foundation/core/UMLStructuralFeatureTypeComboBoxModel.java

Log:
Issue 4909 - Fix comparators used in Sets to handle equality correctly

Modified: trunk/src_new/org/argouml/uml/StereotypeUtility.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/StereotypeUtility.java?view=diff&rev=13778&p1=trunk/src_new/org/argouml/uml/StereotypeUtility.java&p2=trunk/src_new/org/argouml/uml/StereotypeUtility.java&r1=13777&r2=13778
==============================================================================
--- trunk/src_new/org/argouml/uml/StereotypeUtility.java	(original)
+++ trunk/src_new/org/argouml/uml/StereotypeUtility.java	2007-11-15 22:37:48-0800
@@ -82,12 +82,19 @@
                 new Comparator<Object>() {
                     public int compare(Object o1, Object o2) {
                         try {
+                            if (o1.equals(o2)) {
+                                return 0;
+                            }
                             String name1 = Model.getFacade().getName(o1);
                             String name2 = Model.getFacade().getName(o2);
                             name1 = (name1 != null ? name1 : "");
                             name2 = (name2 != null ? name2 : "");
-
-                            return name1.compareTo(name2);
+                            int nameCompare = name1.compareTo(name2);
+                            if (nameCompare == 0) {
+                                return 1;
+                            } else {
+                                return nameCompare;
+                            }
                         } catch (Exception e) {
                             throw new ClassCastException(e.getMessage());
                         }

Modified: trunk/src_new/org/argouml/uml/ui/foundation/core/UMLStructuralFeatureTypeComboBoxModel.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/ui/foundation/core/UMLStructuralFeatureTypeComboBoxModel.java?view=diff&rev=13778&p1=trunk/src_new/org/argouml/uml/ui/foundation/core/UMLStructuralFeatureTypeComboBoxModel.java&p2=trunk/src_new/org/argouml/uml/ui/foundation/core/UMLStructuralFeatureTypeComboBoxModel.java&r1=13777&r2=13778
==============================================================================
--- trunk/src_new/org/argouml/uml/ui/foundation/core/UMLStructuralFeatureTypeComboBoxModel.java	(original)
+++ trunk/src_new/org/argouml/uml/ui/foundation/core/UMLStructuralFeatureTypeComboBoxModel.java	2007-11-15 22:37:48-0800
@@ -75,6 +75,9 @@
     protected void buildModelList() {
         Set<Object> elements = new TreeSet<Object>(new Comparator<Object>() {
             public int compare(Object o1, Object o2) {
+                if (o1.equals(o2)) {
+                    return 0;
+                }
                 // Elements are collated first by name and then by 
                 // their enclosing path to distinguish them
                 List<String> path1 = Model.getModelManagementHelper()
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.