1 11 package org.eclipse.ui.internal; 12 13 import com.ibm.icu.text.Collator; 14 import java.util.Comparator ; 15 16 import org.eclipse.ui.IWorkingSet; 17 18 21 public class WorkingSetComparator implements Comparator { 22 23 27 public static WorkingSetComparator INSTANCE = new WorkingSetComparator(); 28 29 private Collator fCollator = Collator.getInstance(); 30 31 36 public int compare(Object o1, Object o2) { 37 String name1 = null; 38 String name2 = null; 39 40 if (o1 instanceof IWorkingSet) { 41 name1 = ((IWorkingSet) o1).getLabel(); 42 } 43 44 if (o2 instanceof IWorkingSet) { 45 name2 = ((IWorkingSet) o2).getLabel(); 46 } 47 48 int result = fCollator.compare(name1, name2); 49 if (result == 0) { 51 if (o1 instanceof IWorkingSet) { 52 name1 = ((IWorkingSet) o1).getName(); 53 } 54 55 if (o2 instanceof IWorkingSet) { 56 name2 = ((IWorkingSet) o2).getName(); 57 } 58 59 result = fCollator.compare(name1, name2); 60 } 61 return result; 62 } 63 } 64 | Popular Tags |