click-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From med...@apache.org
Subject svn commit: r922081 - in /click/trunk/click: examples/src/org/apache/click/examples/page/table/ extras/src/org/apache/click/extras/util/ framework/src/org/apache/click/control/ framework/src/org/apache/click/util/
Date Fri, 12 Mar 2010 00:18:01 GMT
Author: medgar
Date: Fri Mar 12 00:18:01 2010
New Revision: 922081

URL: http://svn.apache.org/viewvc?rev=922081&view=rev
Log:
changed DataProvider to use more generic Iterable interface

Modified:
    click/trunk/click/examples/src/org/apache/click/examples/page/table/LargeDatasetDemo.java
    click/trunk/click/extras/src/org/apache/click/extras/util/PaginatingList.java
    click/trunk/click/framework/src/org/apache/click/control/Table.java
    click/trunk/click/framework/src/org/apache/click/util/DataProvider.java

Modified: click/trunk/click/examples/src/org/apache/click/examples/page/table/LargeDatasetDemo.java
URL: http://svn.apache.org/viewvc/click/trunk/click/examples/src/org/apache/click/examples/page/table/LargeDatasetDemo.java?rev=922081&r1=922080&r2=922081&view=diff
==============================================================================
--- click/trunk/click/examples/src/org/apache/click/examples/page/table/LargeDatasetDemo.java
(original)
+++ click/trunk/click/examples/src/org/apache/click/examples/page/table/LargeDatasetDemo.java
Fri Mar 12 00:18:01 2010
@@ -55,8 +55,8 @@ public class LargeDatasetDemo extends Bo
         table.setClass(Table.CLASS_ITS);
         table.setSortable(true);
 
-        // We will sort the data ourselves. We set table sorted attribute to true
-        // so the table doesn't attempt to sort the data
+        // VERY IMPORTANT: we will sort the data ourselves using the database,
+        // make sure the Table does not attempt to sort data set.
         table.setSorted(true);
 
         Column column = new Column("name");

Modified: click/trunk/click/extras/src/org/apache/click/extras/util/PaginatingList.java
URL: http://svn.apache.org/viewvc/click/trunk/click/extras/src/org/apache/click/extras/util/PaginatingList.java?rev=922081&r1=922080&r2=922081&view=diff
==============================================================================
--- click/trunk/click/extras/src/org/apache/click/extras/util/PaginatingList.java (original)
+++ click/trunk/click/extras/src/org/apache/click/extras/util/PaginatingList.java Fri Mar
12 00:18:01 2010
@@ -23,6 +23,7 @@ import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
 import java.util.ListIterator;
+import java.util.Set;
 
 /**
  * Provides a paginating list for displaying a sliding window into a much larger
@@ -45,6 +46,9 @@ import java.util.ListIterator;
  *        // Setup table
  *        table.setPageSize(5);
  *        table.setSortable(true);
+ *
+ *        // VERY IMPORTANT: we will sort the data ourselves using the database,
+ *        // make sure the Table does not attempt to sort data set.
  *        table.setSorted(true);
  *
  *        table.addColumn(new Column("id"));
@@ -54,12 +58,12 @@ import java.util.ListIterator;
  *
  *        table.setDataProvider(new DataProvider<Customer>() {
  *            public List<Customer> getData() {
- *                return getPaginatingList();
+ *                return getCustomerList();
  *            }
  *        });
  *    }
  *
- *    private PaginatingList<Customer> getPaginatingList() {
+ *    private List<Customer> getCustomerList() {
  *
  *        // Below we retrieve only those customers between:
  *        //     first row .. (first row + page size)
@@ -71,6 +75,10 @@ import java.util.ListIterator;
  *
  *        int customerCount = customerService.getNumberOfCustomers();
  *
+ *        // Return a paginating list for the Table control. The paginating list
+ *        // provides a wrapper around the "page" of customer data, so that the
+ *        // Table control thinks it is working will the full result set rather
+ *        // than just a window.
  *        return new PaginatingList<Customer>(customerList,
  *                                            table.getFirstRow(),
  *                                            table.getPageSize(),
@@ -100,7 +108,7 @@ public class PaginatingList<E> implement
      * Create a paginating list with the given pageData, first page item index,
      * page size and the total data set size.
      *
-     * @param pageData the page of data to display
+     * @param pageData the iterator page of data to display
      * @param pageSize the number of items read from the pageData and display
      * @param firstIndex the index of the first item to display
      * @param totalSize the total size of the paginated data set
@@ -132,6 +140,19 @@ public class PaginatingList<E> implement
      * Create a paginating list with the given pageData, first page item index,
      * page size and the total data set size.
      *
+     * @param pageData the set of page of data to display
+     * @param pageSize the number of items read from the pageData and display
+     * @param firstIndex the index of the first item to display
+     * @param totalSize the total size of the paginated data set
+     */
+    public PaginatingList(Set<E> pageData, int firstIndex, int pageSize, int totalSize)
{
+        this(pageData.iterator(), firstIndex, pageSize, totalSize);
+    }
+
+    /**
+     * Create a paginating list with the given pageData, first page item index,
+     * page size and the total data set size.
+     *
      * @param pageData the page of data to display
      * @param pageSize the number of items read from the pageData and display
      * @param firstIndex the index of the first item to display

Modified: click/trunk/click/framework/src/org/apache/click/control/Table.java
URL: http://svn.apache.org/viewvc/click/trunk/click/framework/src/org/apache/click/control/Table.java?rev=922081&r1=922080&r2=922081&view=diff
==============================================================================
--- click/trunk/click/framework/src/org/apache/click/control/Table.java (original)
+++ click/trunk/click/framework/src/org/apache/click/control/Table.java Fri Mar 12 00:18:01
2010
@@ -1024,7 +1024,16 @@ public class Table extends AbstractContr
         if (rowList == null || rowList.isEmpty()) {
 
             if (getDataProvider() != null) {
-                rowList = getDataProvider().getData();
+                Iterable iterableData = getDataProvider().getData();
+
+                if (iterableData instanceof List) {
+                    rowList = (List) iterableData;
+
+                } else {
+                    for (Object row : iterableData) {
+                        rowList.add(row);
+                    }
+                }
 
                 if (rowList == null) {
                     throw new IllegalStateException("DataProvider provided null data");

Modified: click/trunk/click/framework/src/org/apache/click/util/DataProvider.java
URL: http://svn.apache.org/viewvc/click/trunk/click/framework/src/org/apache/click/util/DataProvider.java?rev=922081&r1=922080&r2=922081&view=diff
==============================================================================
--- click/trunk/click/framework/src/org/apache/click/util/DataProvider.java (original)
+++ click/trunk/click/framework/src/org/apache/click/util/DataProvider.java Fri Mar 12 00:18:01
2010
@@ -18,18 +18,16 @@
  */
 package org.apache.click.util;
 
-import java.util.List;
-
 /**
  * An interface to provide data on demand to controls.
  */
 public interface DataProvider<T> {
 
     /**
-     * Return the list of data items supplied by the data provider.
+     * Return the iterable collection of data items supplied by the data provider.
      *
-     * @return the list of data items supplied by the data provider.
+     * @return the iterable collection of data items supplied by the data provider.
      */
-    public List<T> getData();
+    public Iterable<T> getData();
 
 }



Mime
View raw message