svn commit: r14455 - trunk/src/argouml-app/src/org/argouml/uml: . ui/foundation/extension_mechanisms

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: tfmorris
Date: 2008-04-24 10:33:36-0700
New Revision: 14455

Modified:
   trunk/src/argouml-app/src/org/argouml/uml/StereotypeUtility.java
   trunk/src/argouml-app/src/org/argouml/uml/ui/foundation/extension_mechanisms/UMLTagDefinitionComboBoxModel.java

Log:
Use PathComparator instead of private implementation

Modified: trunk/src/argouml-app/src/org/argouml/uml/StereotypeUtility.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/StereotypeUtility.java?view=diff&rev=14455&p1=trunk/src/argouml-app/src/org/argouml/uml/StereotypeUtility.java&p2=trunk/src/argouml-app/src/org/argouml/uml/StereotypeUtility.java&r1=14454&r2=14455
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/StereotypeUtility.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/uml/StereotypeUtility.java	2008-04-24 10:33:36-0700
@@ -1,5 +1,5 @@
 // $Id$
-// Copyright (c) 1996-2007 The Regents of the University of California. All
+// Copyright (c) 1996-2008 The Regents of the University of California. All
 // Rights Reserved. Permission to use, copy, modify, and distribute this
 // software and its documentation without fee, and without a written
 // agreement is hereby granted, provided that the above copyright notice
@@ -26,7 +26,6 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Comparator;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
@@ -38,6 +37,7 @@
 import org.argouml.kernel.Project;
 import org.argouml.kernel.ProjectManager;
 import org.argouml.model.Model;
+import org.argouml.uml.util.PathComparator;
 import org.argouml.util.MyTokenizer;
 
 /**
@@ -78,28 +78,8 @@
      */
     public static Set<Object> getAvailableStereotypes(Object modelElement) {
         Set<List> paths = new HashSet<List>();
-        Set<Object> availableStereotypes = new TreeSet<Object>(
-                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 : "");
-                            int nameCompare = name1.compareTo(name2);
-                            if (nameCompare == 0) {
-                                return 1;
-                            } else {
-                                return nameCompare;
-                            }
-                        } catch (Exception e) {
-                            throw new ClassCastException(e.getMessage());
-                        }
-                    }
-                });
+        Set<Object> availableStereotypes = 
+            new TreeSet<Object>(new PathComparator());
         Collection models =
             ProjectManager.getManager().getCurrentProject().getModels();
         

Modified: trunk/src/argouml-app/src/org/argouml/uml/ui/foundation/extension_mechanisms/UMLTagDefinitionComboBoxModel.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/ui/foundation/extension_mechanisms/UMLTagDefinitionComboBoxModel.java?view=diff&rev=14455&p1=trunk/src/argouml-app/src/org/argouml/uml/ui/foundation/extension_mechanisms/UMLTagDefinitionComboBoxModel.java&p2=trunk/src/argouml-app/src/org/argouml/uml/ui/foundation/extension_mechanisms/UMLTagDefinitionComboBoxModel.java&r1=14454&r2=14455
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/ui/foundation/extension_mechanisms/UMLTagDefinitionComboBoxModel.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/uml/ui/foundation/extension_mechanisms/UMLTagDefinitionComboBoxModel.java	2008-04-24 10:33:36-0700
@@ -1,5 +1,5 @@
 // $Id$
-// Copyright (c) 2005-2007 The Regents of the University of California. All
+// Copyright (c) 2005-2008 The Regents of the University of California. All
 // Rights Reserved. Permission to use, copy, modify, and distribute this
 // software and its documentation without fee, and without a written
 // agreement is hereby granted, provided that the above copyright notice
@@ -26,7 +26,6 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Comparator;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
@@ -36,6 +35,7 @@
 import org.argouml.kernel.ProjectManager;
 import org.argouml.model.Model;
 import org.argouml.uml.ui.UMLComboBoxModel2;
+import org.argouml.uml.util.PathComparator;
 
 /**
  * A model for tagdefinitions.
@@ -93,30 +93,8 @@
 
     private Collection getApplicableTagDefinitions(Object t) {
         Set<List<String>> paths = new HashSet<List<String>>();
-        Set<Object> availableTagDefs = new TreeSet<Object>(
-                new Comparator<Object>() {
-                    public int compare(Object o1, Object o2) {
-                        try {
-                            String name1 = Model.getFacade().getName(o1);
-                            String name2 = Model.getFacade().getName(o2);
-                            name1 = (name1 != null ? name1 : "");
-                            name2 = (name2 != null ? name2 : "");
-                            int result = name1.compareTo(name2);
-                            if (result == 0) {
-                                // Don't return equals based on name only
-                                if (o1.equals(o2)) {
-                                    return 0;
-                                } else {
-                                    return 1;
-                                }
-                            } else {
-                                return result;
-                            }
-                        } catch (Exception e) {
-                            throw new ClassCastException(e.getMessage());
-                        }
-                    }
-                });
+        Set<Object> availableTagDefs = 
+            new TreeSet<Object>(new PathComparator());
         Collection stereotypes = Model.getFacade().getStereotypes(t);
         Project project = ProjectManager.getManager().getCurrentProject();
         for (Object model : project.getModels()) {
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.