Changeset 5760
- Timestamp:
- Sep 26, 2011, 1:20:01 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/net/sf/basedb/util/extensions/Registry.java
r5607 r5760 59 59 org.apache.log4j.LogManager.getLogger("net.sf.basedb.util.extensions.Registry"); 60 60 61 private static final Comparator<ExtensionPoint<?>> EXTENSIONPOINT_COMPARATOR = 62 new Comparator<ExtensionPoint<?>>() 61 /** 62 Comparator that sort extension points according to their names. 63 If two names are equal, the sort is also done on the id. 64 @since 3.0 65 */ 66 public static final Comparator<ExtensionPoint> EXTENSIONPOINT_COMPARATOR = 67 new Comparator<ExtensionPoint>() 63 68 { 64 69 @Override 65 public int compare(ExtensionPoint <?> o1, ExtensionPoint<?>o2)70 public int compare(ExtensionPoint o1, ExtensionPoint o2) 66 71 { 67 return o1.getName().compareTo(o2.getName()); 72 int result = o1.getName().compareTo(o2.getName()); 73 if (result == 0) result = o1.getId().compareTo(o2.getId()); 74 return result; 68 75 } 69 76 }; 70 77 78 /** 79 Comparator that sort extensions according to their names. 80 If two names are equal, the sort is also done on the id. 81 @since 3.0 82 */ 83 public static final Comparator<Extension> EXTENSION_COMPARATOR = 84 new Comparator<Extension>() 85 { 86 @Override 87 public int compare(Extension o1, Extension o2) 88 { 89 String name1 = o1.getAbout() == null ? null : o1.getAbout().getName(); 90 String name2 = o2.getAbout() == null ? null : o2.getAbout().getName(); 91 int result = name1 != null && name2 != null ? name1.compareTo(name2) : 0; 92 if (result == 0) result = o1.getId().compareTo(o2.getId()); 93 return result; 94 } 95 }; 96 97 71 98 private final Map<String, RegisteredExtensionPoint<?>> extensionPoints; 72 99 private final Map<String, RegisteredExtension<?>> extensions; … … 320 347 List<ExtensionPoint<?>> copy = 321 348 new ArrayList<ExtensionPoint<?>>(extensionPoints.values()); 322 Collections.sort(copy, EXTENSIONPOINT_COMPARATOR);323 349 return copy; 324 350 } … … 496 522 List<Extension<?>> copy = 497 523 new ArrayList<Extension<?>>(rep.getExtensions()); 498 Collections.sort(copy, DefaultFilter.INDEX_COMPARATOR_EXT);499 524 return copy; 500 525 } -
trunk/src/core/net/sf/basedb/util/extensions/xml/PluginInfo.java
r5615 r5760 22 22 package net.sf.basedb.util.extensions.xml; 23 23 24 import java.util.Comparator; 24 25 import java.util.HashMap; 25 26 import java.util.Map; … … 43 44 { 44 45 46 47 /** 48 Comparator that sort plug-ins according to their names. 49 If two names are equal, the sort is also done on the class 50 name. 51 */ 52 public static final Comparator<PluginInfo> NAME_COMPARATOR = 53 new Comparator<PluginInfo>() 54 { 55 @Override 56 public int compare(PluginInfo o1, PluginInfo o2) 57 { 58 String name1 = o1.getAbout() == null ? null : o1.getAbout().getName(); 59 String name2 = o2.getAbout() == null ? null : o2.getAbout().getName(); 60 int result = name1 != null && name2 != null ? name1.compareTo(name2) : 0; 61 if (result == 0) result = o1.getClassName().compareTo(o2.getClassName()); 62 return result; 63 } 64 }; 65 66 45 67 private final String id; 46 68 private About about; -
trunk/www/admin/extensions/tree.jsp
r5715 r5760 31 31 import="net.sf.basedb.clients.web.util.HTML" 32 32 import="net.sf.basedb.util.Values" 33 import="net.sf.basedb.util.extensions.Registry" 33 34 import="net.sf.basedb.util.extensions.ExtensionPoint" 34 35 import="net.sf.basedb.util.extensions.Extension" … … 42 43 import="java.util.List" 43 44 import="java.util.Iterator" 45 import="java.util.Collections" 44 46 %> 45 47 <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> … … 175 177 ExtensionsControl ec = ExtensionsControl.get(dc); 176 178 List<ExtensionPoint<?>> extensionPoints = ec.getExtensionPoints(); 179 Collections.sort(extensionPoints, Registry.EXTENSIONPOINT_COMPARATOR); 177 180 for (ExtensionPoint ep : extensionPoints) 178 181 { … … 186 189 <% 187 190 List<Extension<?>> extensions = ec.getExtensions(ep.getId()); 191 Collections.sort(extensions, Registry.EXTENSION_COMPARATOR); 188 192 for (Extension ext : extensions) 189 193 { … … 211 215 <% 212 216 List<ExtensionPoint> eps = ef.getObjectsOfClass(ExtensionPoint.class); 217 Collections.sort(eps, Registry.EXTENSIONPOINT_COMPARATOR); 213 218 for (ExtensionPoint ep : eps) 214 219 { … … 218 223 } 219 224 List<Extension> exts = ef.getObjectsOfClass(Extension.class); 225 Collections.sort(exts, Registry.EXTENSION_COMPARATOR); 220 226 String currentGroupId = null; 221 227 for (Extension ext : exts) … … 243 249 } 244 250 List<PluginInfo> plugins = ef.getObjectsOfClass(PluginInfo.class); 251 Collections.sort(plugins, PluginInfo.NAME_COMPARATOR); 245 252 for (PluginInfo info : plugins) 246 253 {
Note: See TracChangeset
for help on using the changeset viewer.