1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-06 07:45:50 +02:00

Use ICU4J to sort system type labels according to international unicode rules

This commit is contained in:
Martin Oberhuber 2007-04-26 09:21:40 +00:00
parent 44400301a9
commit 67afb87a3d
2 changed files with 12 additions and 12 deletions

View file

@ -15,6 +15,7 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.ui.ide, org.eclipse.ui.ide,
org.eclipse.ui.workbench.texteditor, org.eclipse.ui.workbench.texteditor,
org.eclipse.rse.core org.eclipse.rse.core
Import-Package: com.ibm.icu.text
Eclipse-LazyStart: true Eclipse-LazyStart: true
Export-Package: org.eclipse.rse.core, Export-Package: org.eclipse.rse.core,
org.eclipse.rse.core.comm, org.eclipse.rse.core.comm,

View file

@ -51,6 +51,8 @@ import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IViewPart; import org.eclipse.ui.IViewPart;
import org.eclipse.ui.PlatformUI; import org.eclipse.ui.PlatformUI;
import com.ibm.icu.text.Collator;
/** /**
* Static methods that can be used when writing SWT GUI code. * Static methods that can be used when writing SWT GUI code.
* They simply make it more productive. * They simply make it more productive.
@ -1100,7 +1102,8 @@ public class SystemWidgetHelpers {
* *
* A system type is considered valid, if at least one subsystem * A system type is considered valid, if at least one subsystem
* configuration is registered against it. The list is ordered * configuration is registered against it. The list is ordered
* alphabetically by system type label. * alphabetically by system type label according to international
* unicode rules, in the current Locale.
* *
* @param restrictIds An array of system type IDs to restrict the * @param restrictIds An array of system type IDs to restrict the
* returned list of valid system types to only those requested, * returned list of valid system types to only those requested,
@ -1140,23 +1143,19 @@ public class SystemWidgetHelpers {
* type label. * type label.
* *
* Note that this method sorts the array in place, so clients are * Note that this method sorts the array in place, so clients are
* responsible for creating a copy of the array when needed. In the * responsible for creating a copy of the array when needed.
* future, this may sort using an internationalization enabled * Labels are sorted with a Collator according to international
* collate algorithm for translated labels (currently, normal * unicode rules, in the current Locale.
* String compare is used).
* *
* @param systemTypes list of system types to sort * @param systemTypes list of system types to sort
*/ */
public static void sortSystemTypesByLabel(IRSESystemType[] systemTypes) { public static void sortSystemTypesByLabel(IRSESystemType[] systemTypes) {
Arrays.sort(systemTypes, new Comparator() { Arrays.sort(systemTypes, new Comparator() {
private Collator collator = Collator.getInstance();
public int compare(Object o1, Object o2) { public int compare(Object o1, Object o2) {
String l1 = ((IRSESystemType)o1).getLabel(); IRSESystemType t1 = (IRSESystemType)o1;
String l2 = ((IRSESystemType)o2).getLabel(); IRSESystemType t2 = (IRSESystemType)o2;
//FIXME use com.ibm.icu.text.Collator.getInstance(Locale) return collator.compare(t1.getLabel(), t2.getLabel());
return l1.compareTo(l2);
}
public boolean equals(Object obj) {
return this==obj;
} }
}); });
} }