r1799 - trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation
Author: sletellier Date: 2010-03-22 15:05:21 +0100 (Mon, 22 Mar 2010) New Revision: 1799 Log: Allow to ignore case of rendrer comparator Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationSortedTreeAdapter.java Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationSortedTreeAdapter.java =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationSortedTreeAdapter.java 2010-03-20 17:23:36 UTC (rev 1798) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationSortedTreeAdapter.java 2010-03-22 14:05:21 UTC (rev 1799) @@ -44,8 +44,8 @@ protected NavigationModel model; protected List<Comparator> comparators; + protected boolean ignoreCase = false; - /** * Used to sort NavigationTreeModel by decorator * @@ -57,6 +57,18 @@ } /** + * Used to sort NavigationTreeModel by decorator + * + * @param model of navigation tree + * @param ignoreCase tio ignore renderer case renderer + */ + public NavigationSortedTreeAdapter(NavigationModel model, boolean ignoreCase){ + this.ignoreCase = ignoreCase; + this.model = model; + model.addTreeModelListener(this); + } + + /** * Used to sort NavigationTreeModel by comparator * * @param model of navigation tree @@ -134,7 +146,7 @@ List<NavigationTreeNode> children = Collections.list(parent.children()); if (comparators == null || comparators.isEmpty()){ - Collections.sort(children, RENDERER_COMPARATOR); + Collections.sort(children, rendererDecorator); } else { children = sortWithComparators(children); } @@ -230,12 +242,15 @@ return children; } - static final Comparator RENDERER_COMPARATOR = new Comparator() { + final Comparator rendererDecorator = new Comparator() { @Override public int compare(Object o1, Object o2) { try { String label1 = ((NavigationTreeNode)o1).getRenderer().toString(); String label2 = ((NavigationTreeNode)o2).getRenderer().toString(); + if (ignoreCase){ + return label1.compareToIgnoreCase(label2); + } return label1.compareTo(label2); } catch (Exception eee) { return 0;
participants (1)
-
sletellier@users.nuiton.org