click-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sa...@apache.org
Subject svn commit: r942299 - in /click/trunk/click: extras/src/org/apache/click/extras/control/CheckList.java extras/src/org/apache/click/extras/control/PickList.java framework/src/org/apache/click/control/Select.java
Date Sat, 08 May 2010 03:35:57 GMT
Author: sabob
Date: Sat May  8 03:35:57 2010
New Revision: 942299

URL: http://svn.apache.org/viewvc?rev=942299&view=rev
Log:
more performant option list assignment

Modified:
    click/trunk/click/extras/src/org/apache/click/extras/control/CheckList.java
    click/trunk/click/extras/src/org/apache/click/extras/control/PickList.java
    click/trunk/click/framework/src/org/apache/click/control/Select.java

Modified: click/trunk/click/extras/src/org/apache/click/extras/control/CheckList.java
URL: http://svn.apache.org/viewvc/click/trunk/click/extras/src/org/apache/click/extras/control/CheckList.java?rev=942299&r1=942298&r2=942299&view=diff
==============================================================================
--- click/trunk/click/extras/src/org/apache/click/extras/control/CheckList.java (original)
+++ click/trunk/click/extras/src/org/apache/click/extras/control/CheckList.java Sat May  8
03:35:57 2010
@@ -504,7 +504,7 @@ public class CheckList extends Field {
 
     /**
      * Set the CheckList option list DataProvider. The dataProvider can return
-     * any mixture of Option/String/Number/Boolean values.
+     * any mixture of Option and OptionGroup values.
      * <p/>
      * Example usage:
      *
@@ -529,7 +529,7 @@ public class CheckList extends Field {
         if (dataProvider != null) {
             if (optionList != null) {
                 ClickUtils.getLogService().warn("please note that setting a"
-                    + " dataProvider will nullify the optionList");
+                    + " dataProvider nullifies the optionList");
             }
             setOptionList(null);
         }
@@ -726,19 +726,19 @@ public class CheckList extends Field {
     public List getOptionList() {
         if (optionList == null) {
 
-            optionList = new ArrayList();
-
             DataProvider dp = getDataProvider();
 
             if (dp != null) {
                 Iterable iterableData = dp.getData();
 
-                // Create and populate the optionList from the Iterable data
-                if (iterableData instanceof Collection) {
-                    // Popuplate optionList from options
-                    addAll((Collection) iterableData);
+                if (iterableData instanceof List) {
+                    // Set optionList to data
+                    setOptionList((List) iterableData);
 
                 } else {
+                    // Create and populate the optionList from the Iterable data
+                    optionList = new ArrayList();
+
                     if (iterableData != null) {
                         // Popuplate optionList from options
                         for (Object option : iterableData) {
@@ -746,6 +746,9 @@ public class CheckList extends Field {
                         }
                     }
                 }
+            } else {
+                // Create empty list
+                optionList = new ArrayList();
             }
         }
         return optionList;

Modified: click/trunk/click/extras/src/org/apache/click/extras/control/PickList.java
URL: http://svn.apache.org/viewvc/click/trunk/click/extras/src/org/apache/click/extras/control/PickList.java?rev=942299&r1=942298&r2=942299&view=diff
==============================================================================
--- click/trunk/click/extras/src/org/apache/click/extras/control/PickList.java (original)
+++ click/trunk/click/extras/src/org/apache/click/extras/control/PickList.java Sat May  8
03:35:57 2010
@@ -459,7 +459,7 @@ public class PickList extends Field {
 
     /**
      * Set the PickList option list DataProvider. The dataProvider can return
-     * any mixture of Option/String/Number/Boolean values.
+     * any mixture of Option and OptionGroup values.
      * <p/>
      * Example usage:
      *
@@ -485,7 +485,7 @@ public class PickList extends Field {
         if (dataProvider != null) {
             if (optionList != null) {
                 ClickUtils.getLogService().warn("please note that setting a"
-                    + " dataProvider will nullify the optionList");
+                    + " dataProvider nullifies the optionList");
             }
             setOptionList(null);
         }
@@ -511,19 +511,19 @@ public class PickList extends Field {
     public List getOptionList() {
         if (optionList == null) {
 
-            optionList = new ArrayList();
-
             DataProvider dp = getDataProvider();
 
             if (dp != null) {
                 Iterable iterableData = dp.getData();
 
-                // Create and populate the optionList from the Iterable data
-                if (iterableData instanceof Collection) {
-                    // Populate optionList from options
-                    addAll((Collection) iterableData);
+                if (iterableData instanceof List) {
+                    // Set optionList to data
+                    setOptionList((List) iterableData);
 
                 } else {
+                    // Create and populate the optionList from the Iterable data
+                    optionList = new ArrayList();
+
                     if (iterableData != null) {
                         // Populate optionList from options
                         for (Object option : iterableData) {
@@ -531,6 +531,9 @@ public class PickList extends Field {
                         }
                     }
                 }
+            } else {
+                // Create empty list
+                optionList = new ArrayList();
             }
         }
         return optionList;

Modified: click/trunk/click/framework/src/org/apache/click/control/Select.java
URL: http://svn.apache.org/viewvc/click/trunk/click/framework/src/org/apache/click/control/Select.java?rev=942299&r1=942298&r2=942299&view=diff
==============================================================================
--- click/trunk/click/framework/src/org/apache/click/control/Select.java (original)
+++ click/trunk/click/framework/src/org/apache/click/control/Select.java Sat May  8 03:35:57
2010
@@ -498,7 +498,7 @@ public class Select extends Field {
      * @throws IllegalArgumentException if options is null, or the collection
      *     contains an unsupported class
      */
-    public void addAll(Collection<? extends Object> options) {
+    public void addAll(Collection<?> options) {
         if (options == null) {
             String msg = "options parameter cannot be null";
             throw new IllegalArgumentException(msg);
@@ -651,7 +651,7 @@ public class Select extends Field {
 
     /**
      * Set the select option list DataProvider. The dataProvider can return any
-     * mixture of Option/OptionGroup/String/Number/Boolean values.
+     * mixture of Option and OptionGroup values.
      * <p/>
      * Example usage:
      *
@@ -678,7 +678,7 @@ public class Select extends Field {
         if (dataProvider != null) {
             if (optionList != null) {
                 ClickUtils.getLogService().warn("please note that setting a"
-                    + " dataProvider will nullify the optionList");
+                    + " dataProvider nullifies the optionList");
             }
             setOptionList(null);
         }
@@ -827,31 +827,41 @@ public class Select extends Field {
     public List getOptionList() {
         if (optionList == null) {
 
-            optionList = new ArrayList();
-
             Option defaultOption = getDefaultOption();
-            if (defaultOption != null) {
-                optionList.add(defaultOption);
-            }
 
             DataProvider dp = getDataProvider();
 
             if (dp != null) {
                 Iterable iterableData = dp.getData();
 
-                // Create and populate the optionList from the Iterable data
-                if (iterableData instanceof Collection) {
-                    // Populate optionList from options
-                    addAll((Collection) iterableData);
+                if (iterableData instanceof List) {
+                    // Set optionList to data
+                    List listData = (List) iterableData;
+                    if (defaultOption != null) {
+                        // Insert default option as first option
+                        listData.add(0, defaultOption);
+                    }
+                    setOptionList(listData);
 
                 } else {
+                    // Create and populate the optionList from the Iterable data
+                    optionList = new ArrayList();
+
                     if (iterableData != null) {
+
+                        if (defaultOption != null) {
+                            optionList.add(defaultOption);
+                        }
+
                         // Populate optionList from options
                         for (Object option : iterableData) {
                             add(option);
                         }
                     }
                 }
+            } else {
+                // Create empty list
+                optionList = new ArrayList();
             }
         }
         return optionList;



Mime
View raw message