jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1212961 - /jmeter/trunk/src/core/org/apache/jmeter/gui/util/MenuFactory.java
Date Sun, 11 Dec 2011 02:29:32 GMT
Author: sebb
Date: Sun Dec 11 02:29:32 2011
New Revision: 1212961

URL: http://svn.apache.org/viewvc?rev=1212961&view=rev
Log:
Don't want to ignore case when sorting THREADS menu

Modified:
    jmeter/trunk/src/core/org/apache/jmeter/gui/util/MenuFactory.java

Modified: jmeter/trunk/src/core/org/apache/jmeter/gui/util/MenuFactory.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/util/MenuFactory.java?rev=1212961&r1=1212960&r2=1212961&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/gui/util/MenuFactory.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/gui/util/MenuFactory.java Sun Dec 11 02:29:32
2011
@@ -30,6 +30,7 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.Set;
 
 import javax.swing.JMenu;
@@ -673,18 +674,27 @@ public final class MenuFactory {
      */
     private static class MenuInfoComparator implements Comparator<MenuInfo>, Serializable
{
         private static final long serialVersionUID = 1L;
+        private final boolean caseBlind;
+        MenuInfoComparator(boolean caseBlind){
+            this.caseBlind = caseBlind;
+        }
         public int compare(MenuInfo o1, MenuInfo o2) {
-              return o1.getLabel().toLowerCase(Locale.ENGLISH)
-          .compareTo(o2.getLabel().toLowerCase(Locale.ENGLISH));
+            String lab1 = o1.getLabel();
+            String lab2 = o2.getLabel();
+            if (caseBlind) {
+                return lab1.toLowerCase(Locale.ENGLISH).compareTo(lab2.toLowerCase(Locale.ENGLISH));
               
+            }
+            return lab1.compareTo(lab2);                
         }
     }
 
     /**
-     * Sort loaded menus
+     * Sort loaded menus; all but THREADS are sorted case-blind.
+     * [This is so Thread Group appears before setUp and tearDown]
      */
     private static void sortPluginMenus() {
-       for (List<MenuInfo> menuToSort : menuMap.values()) {
-          Collections.sort(menuToSort, new MenuInfoComparator());
-       }
+        for(Entry<String, List<MenuInfo>> me : menuMap.entrySet()){
+            Collections.sort(me.getValue(), new MenuInfoComparator(!me.getKey().equals(THREADS)));
+        }
     }
 }



Mime
View raw message