Author: snjeza
Date: 2012-05-22 15:48:29 -0400 (Tue, 22 May 2012)
New Revision: 41259
Modified:
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/dialog/DownloadRuntimeViewerDialog.java
Log:
JBIDE-11959 - Order runtimes on Download dialog
Modified:
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/dialog/DownloadRuntimeViewerDialog.java
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/dialog/DownloadRuntimeViewerDialog.java 2012-05-22
19:18:47 UTC (rev 41258)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/dialog/DownloadRuntimeViewerDialog.java 2012-05-22
19:48:29 UTC (rev 41259)
@@ -10,6 +10,12 @@
************************************************************************************/
package org.jboss.tools.project.examples.dialog;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
import java.util.Map;
import org.eclipse.jface.dialogs.Dialog;
@@ -125,7 +131,35 @@
@Override
public Object[] getElements(Object inputElement) {
- return downloadRuntimes.values().toArray(new DownloadRuntime[0]);
+ DownloadRuntime[] runtimes = downloadRuntimes.values().toArray(new
DownloadRuntime[0]);
+ Arrays.sort(runtimes, new Comparator<DownloadRuntime>() {
+
+ @Override
+ public int compare(DownloadRuntime o1, DownloadRuntime o2) {
+ if (o1 == null && o2 == null) {
+ return 0;
+ }
+ if (o1 == null) {
+ return 1;
+ }
+ if (o2 == null) {
+ return -1;
+ }
+ String s1 = o1.getName();
+ String s2 = o2.getName();
+ if (s1 == null && s2 == null) {
+ return 0;
+ }
+ if (s1 == null) {
+ return 1;
+ }
+ if (s2 == null) {
+ return -1;
+ }
+ return s1.compareTo(s2);
+ }
+ });
+ return runtimes;
}
@Override
Show replies by date