Changeset 5760


Ignore:
Timestamp:
Sep 26, 2011, 1:20:01 PM (10 years ago)
Author:
Nicklas Nordborg
Message:

References #1592: Unified installation procedure for plug-ins, extensions and more...

Sort almost everything by name in the overview tree.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/net/sf/basedb/util/extensions/Registry.java

    r5607 r5760  
    5959    org.apache.log4j.LogManager.getLogger("net.sf.basedb.util.extensions.Registry");
    6060
    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>()
    6368    {
    6469      @Override
    65       public int compare(ExtensionPoint<?> o1, ExtensionPoint<?> o2)
     70      public int compare(ExtensionPoint o1, ExtensionPoint o2)
    6671      {
    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;
    6875      }
    6976    };
    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   
    7198  private final Map<String, RegisteredExtensionPoint<?>> extensionPoints;
    7299  private final Map<String, RegisteredExtension<?>> extensions;
     
    320347    List<ExtensionPoint<?>> copy =
    321348      new ArrayList<ExtensionPoint<?>>(extensionPoints.values());
    322     Collections.sort(copy, EXTENSIONPOINT_COMPARATOR);
    323349    return copy;
    324350  }
     
    496522      List<Extension<?>> copy =
    497523        new ArrayList<Extension<?>>(rep.getExtensions());
    498       Collections.sort(copy, DefaultFilter.INDEX_COMPARATOR_EXT);
    499524      return copy;
    500525    }
  • trunk/src/core/net/sf/basedb/util/extensions/xml/PluginInfo.java

    r5615 r5760  
    2222package net.sf.basedb.util.extensions.xml;
    2323
     24import java.util.Comparator;
    2425import java.util.HashMap;
    2526import java.util.Map;
     
    4344{
    4445
     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 
    4567  private final String id;
    4668  private About about;
  • trunk/www/admin/extensions/tree.jsp

    r5715 r5760  
    3131  import="net.sf.basedb.clients.web.util.HTML"
    3232  import="net.sf.basedb.util.Values"
     33  import="net.sf.basedb.util.extensions.Registry"
    3334  import="net.sf.basedb.util.extensions.ExtensionPoint"
    3435  import="net.sf.basedb.util.extensions.Extension"
     
    4243  import="java.util.List"
    4344  import="java.util.Iterator"
     45  import="java.util.Collections"
    4446%>
    4547<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
     
    175177    ExtensionsControl ec = ExtensionsControl.get(dc);
    176178    List<ExtensionPoint<?>> extensionPoints = ec.getExtensionPoints();
     179    Collections.sort(extensionPoints, Registry.EXTENSIONPOINT_COMPARATOR);
    177180    for (ExtensionPoint ep : extensionPoints)
    178181    {
     
    186189      <%
    187190      List<Extension<?>> extensions = ec.getExtensions(ep.getId());
     191      Collections.sort(extensions, Registry.EXTENSION_COMPARATOR);
    188192      for (Extension ext : extensions)
    189193      {
     
    211215      <%
    212216      List<ExtensionPoint> eps = ef.getObjectsOfClass(ExtensionPoint.class);
     217      Collections.sort(eps, Registry.EXTENSIONPOINT_COMPARATOR);
    213218      for (ExtensionPoint ep : eps)
    214219      {
     
    218223      }
    219224      List<Extension> exts = ef.getObjectsOfClass(Extension.class);
     225      Collections.sort(exts, Registry.EXTENSION_COMPARATOR);
    220226      String currentGroupId = null;
    221227      for (Extension ext : exts)
     
    243249      }
    244250      List<PluginInfo> plugins = ef.getObjectsOfClass(PluginInfo.class);
     251      Collections.sort(plugins, PluginInfo.NAME_COMPARATOR);
    245252      for (PluginInfo info : plugins)
    246253      {
Note: See TracChangeset for help on using the changeset viewer.