1 11 package org.eclipse.ui.views.properties; 12 13 import java.text.Collator ; import java.util.Arrays ; 15 import java.util.Comparator ; 16 17 27 public class PropertySheetSorter { 28 29 32 private Collator collator; 33 34 37 public PropertySheetSorter() { 38 this(Collator.getInstance()); 39 } 40 41 47 public PropertySheetSorter(Collator collator) { 48 this.collator = collator; 49 } 50 51 68 public int compare(IPropertySheetEntry entryA, IPropertySheetEntry entryB) { 69 return getCollator().compare(entryA.getDisplayName(), 70 entryB.getDisplayName()); 71 } 72 73 90 public int compareCategories(String categoryA, String categoryB) { 91 return getCollator().compare(categoryA, categoryB); 92 } 93 94 99 protected Collator getCollator() { 100 return collator; 101 } 102 103 118 public void sort(IPropertySheetEntry[] entries) { 119 Arrays.sort(entries, new Comparator () { 120 public int compare(Object a, Object b) { 121 return PropertySheetSorter.this.compare( 122 (IPropertySheetEntry) a, (IPropertySheetEntry) b); 123 } 124 }); 125 } 126 127 133 void sort(PropertySheetCategory[] categories) { 134 Arrays.sort(categories, new Comparator () { 135 public int compare(Object a, Object b) { 136 return PropertySheetSorter.this.compareCategories( 137 ((PropertySheetCategory) a).getCategoryName(), 138 ((PropertySheetCategory) b).getCategoryName()); 139 } 140 }); 141 } 142 } 143 | Popular Tags |