[isidorus-cvs] r974 - in branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets: base text

lgiessmann at common-lisp.net lgiessmann at common-lisp.net
Mon Sep 26 09:39:42 UTC 2011


Author: lgiessmann
Date: Mon Sep 26 02:39:41 2011
New Revision: 974

Log:
gdl-frontend: Widgets: the options of a GdlListBox are sorted now

Modified:
   branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/Utils.java
   branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/text/GdlListBox.java

Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/Utils.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/Utils.java	Mon Sep 26 02:12:04 2011	(r973)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/Utils.java	Mon Sep 26 02:39:41 2011	(r974)
@@ -1,6 +1,8 @@
 package us.isidor.gdl.anaToMia.Widgets.base;
 
 import java.util.ArrayList;
+import java.util.Arrays;
+
 import com.google.gwt.core.client.JavaScriptObject;
 
 import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Association;
@@ -12,6 +14,21 @@
 
 public class Utils {
 	
+	// sorts a passed ArrayList
+	@SuppressWarnings("unchecked")
+	public static <T> ArrayList<T> sort(ArrayList<T> arrayList){
+		if(arrayList == null) return new ArrayList<T>();
+		
+		Object[] array = arrayList.toArray();
+		Arrays.sort(array);
+		
+		ArrayList<T> result = new ArrayList<T>();
+		for (Object item : array) result.add((T)item);
+		
+		return result;
+	}
+	
+	
 	// returns an array with two string objects.
 	//  * the first element is the uri prefix until the last "/" or "#" character
 	//  * the second element is the sufix

Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/text/GdlListBox.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/text/GdlListBox.java	Mon Sep 26 02:12:04 2011	(r973)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/text/GdlListBox.java	Mon Sep 26 02:39:41 2011	(r974)
@@ -12,6 +12,7 @@
 import us.isidor.gdl.anaToMia.Widgets.base.GdlVisibleObject;
 import us.isidor.gdl.anaToMia.Widgets.base.PSIs;
 import us.isidor.gdl.anaToMia.Widgets.base.TmHelper;
+import us.isidor.gdl.anaToMia.Widgets.base.Utils;
 import us.isidor.gdl.anaToMia.Widgets.environment.ActiveStyleHandler;
 import us.isidor.gdl.anaToMia.Widgets.environment.ExecutionException;
 import us.isidor.gdl.anaToMia.Widgets.environment.FocusStyleHandler;
@@ -70,6 +71,7 @@
 		}		
 		
 		ListBox lb = this.createNewListBox();
+		options = Utils.sort(options);
 		for(String item : options) lb.addItem(item);
 		
 		for(int i = 0; i != lb.getItemCount(); ++i){




More information about the Isidorus-cvs mailing list