1 11 package org.eclipse.ui.internal.cheatsheets.registry; 12 13 import org.eclipse.jface.viewers.IBasicPropertyConstants; 14 import org.eclipse.jface.viewers.Viewer; 15 import org.eclipse.jface.viewers.ViewerComparator; 16 import org.eclipse.ui.model.WorkbenchAdapter; 17 18 import com.ibm.icu.text.Collator; 19 20 25 public class CheatSheetCollectionSorter extends ViewerComparator { 26 public final static CheatSheetCollectionSorter INSTANCE = new CheatSheetCollectionSorter(); 27 private Collator collator = Collator.getInstance(); 28 29 34 private CheatSheetCollectionSorter() { 35 super(); 36 } 37 38 45 public int compare(Viewer viewer, Object o1, Object o2) { 46 String name1 = ((WorkbenchAdapter)o1).getLabel(o1); 47 String name2 = ((WorkbenchAdapter)o2).getLabel(o2); 48 49 if (name1.equals(name2)) 50 return 0; 51 52 return collator.compare(name1, name2); 53 } 54 55 59 public boolean isSorterProperty(Object object, String propertyId) { 60 return propertyId.equals(IBasicPropertyConstants.P_TEXT); 61 } 62 } 63 | Popular Tags |