From 67afb87a3d525cb8700e94db35adeb6467542cd1 Mon Sep 17 00:00:00 2001 From: Martin Oberhuber < martin.oberhuber@windriver.com> Date: Thu, 26 Apr 2007 09:21:40 +0000 Subject: [PATCH] Use ICU4J to sort system type labels according to international unicode rules --- .../org.eclipse.rse.ui/META-INF/MANIFEST.MF | 1 + .../eclipse/rse/ui/SystemWidgetHelpers.java | 23 +++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/rse/plugins/org.eclipse.rse.ui/META-INF/MANIFEST.MF b/rse/plugins/org.eclipse.rse.ui/META-INF/MANIFEST.MF index 6034a239eda..01b0e1576ee 100644 --- a/rse/plugins/org.eclipse.rse.ui/META-INF/MANIFEST.MF +++ b/rse/plugins/org.eclipse.rse.ui/META-INF/MANIFEST.MF @@ -15,6 +15,7 @@ Require-Bundle: org.eclipse.ui, org.eclipse.ui.ide, org.eclipse.ui.workbench.texteditor, org.eclipse.rse.core +Import-Package: com.ibm.icu.text Eclipse-LazyStart: true Export-Package: org.eclipse.rse.core, org.eclipse.rse.core.comm, diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/SystemWidgetHelpers.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/SystemWidgetHelpers.java index 956cec26b64..8c81803ca05 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/SystemWidgetHelpers.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/SystemWidgetHelpers.java @@ -51,6 +51,8 @@ import org.eclipse.swt.widgets.Text; import org.eclipse.ui.IViewPart; import org.eclipse.ui.PlatformUI; +import com.ibm.icu.text.Collator; + /** * Static methods that can be used when writing SWT GUI code. * They simply make it more productive. @@ -1100,7 +1102,8 @@ public class SystemWidgetHelpers { * * A system type is considered valid, if at least one subsystem * 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 * returned list of valid system types to only those requested, @@ -1140,23 +1143,19 @@ public class SystemWidgetHelpers { * type label. * * Note that this method sorts the array in place, so clients are - * responsible for creating a copy of the array when needed. In the - * future, this may sort using an internationalization enabled - * collate algorithm for translated labels (currently, normal - * String compare is used). + * responsible for creating a copy of the array when needed. + * Labels are sorted with a Collator according to international + * unicode rules, in the current Locale. * * @param systemTypes list of system types to sort */ public static void sortSystemTypesByLabel(IRSESystemType[] systemTypes) { Arrays.sort(systemTypes, new Comparator() { + private Collator collator = Collator.getInstance(); public int compare(Object o1, Object o2) { - String l1 = ((IRSESystemType)o1).getLabel(); - String l2 = ((IRSESystemType)o2).getLabel(); - //FIXME use com.ibm.icu.text.Collator.getInstance(Locale) - return l1.compareTo(l2); - } - public boolean equals(Object obj) { - return this==obj; + IRSESystemType t1 = (IRSESystemType)o1; + IRSESystemType t2 = (IRSESystemType)o2; + return collator.compare(t1.getLabel(), t2.getLabel()); } }); }