Revision: 8424
Author: jlaba...@google.com
Date: Wed Jul 28 07:12:59 2010
Log: Rolling back this change because it included changes from a different patch.

Review at http://gwt-code-reviews.appspot.com/721801

http://code.google.com/p/google-web-toolkit/source/detail?r=8424

Modified:
 /trunk/user/src/com/google/gwt/view/client/AbstractListViewAdapter.java

=======================================
--- /trunk/user/src/com/google/gwt/view/client/AbstractListViewAdapter.java Wed Jul 28 06:51:41 2010 +++ /trunk/user/src/com/google/gwt/view/client/AbstractListViewAdapter.java Wed Jul 28 07:12:59 2010
@@ -1,12 +1,12 @@
 /*
  * Copyright 2010 Google Inc.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of
  * the License at
- *
+ *
  * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
  * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -22,22 +22,22 @@

 /**
  * A base implementation of a data source for list views.
- *
+ *
  * <p>
  * Note: This class is new and its interface subject to change.
  * </p>
- *
+ *
  * @param <T> the data type of records in the list
  */
public abstract class AbstractListViewAdapter<T> implements ProvidesKey<T> {

-  private class DataProvider implements ListView.DataProvider<T> {
+  private class Delegate implements ListView.Delegate<T> {
     public void onRangeChanged(ListView<T> view) {
       AbstractListViewAdapter.this.onRangeChanged(view);
     }
   }

-  private final DataProvider dataProvider = new DataProvider();
+  private final Delegate delegate = new Delegate();

   private Set<ListView<T>> views = new HashSet<ListView<T>>();

@@ -46,20 +46,10 @@
    */
   private ProvidesKey<T> keyProvider;

-  /**
-   * The last data size.
-   */
-  private int lastDataSize = -1;
-
-  /**
-   * Indicates whether or not the last data size is exact.
-   */
-  private boolean lastDataSizeExact;
-
   /**
* Adds a view to this adapter. The current range of interest of the view will
    * be populated with data.
-   *
+   *
    * @param view a {...@link ListView}.
    */
   public void addView(ListView<T> view) {
@@ -67,23 +57,14 @@
       throw new IllegalStateException("ListView already added");
     }
     views.add(view);
-
- // Set the data provider. Do not initialize until we have a change to set
-    // the data size.
-    view.setDataProvider(dataProvider, false);
-
-    // Update the data size.
-    if (lastDataSize >= 0) {
-      view.setDataSize(lastDataSize, lastDataSizeExact);
-    }
-
-    dataProvider.onRangeChanged(view);
+    view.setDelegate(delegate);
+    delegate.onRangeChanged(view);
   }

   /**
* Get the key for a list item. The default implementation returns the item
    * itself.
-   *
+   *
    * @param item the list item
    * @return the key that represents the item
    */
@@ -93,7 +74,7 @@

   /**
    * Get the {...@link ProvidesKey} that provides keys for list items.
-   *
+   *
    * @return the {...@link ProvidesKey}
    */
   public ProvidesKey<T> getKeyProvider() {
@@ -102,7 +83,7 @@

   /**
    * Get the current ranges of all views.
-   *
+   *
    * @return the ranges
    */
   public Range[] getRanges() {
@@ -116,7 +97,7 @@

   /**
    * Get the set of views currently assigned to this adapter.
-   *
+   *
    * @return the set of {...@link ListView}
    */
   public Set<ListView<T>> getViews() {
@@ -128,12 +109,12 @@
       throw new IllegalStateException("ListView not present");
     }
     views.remove(view);
-    view.setDataProvider(null);
+    view.setDelegate(null);
   }

   /**
    * Set the {...@link ProvidesKey} that provides keys for list items.
-   *
+   *
    * @param keyProvider the {...@link ProvidesKey}
    */
   public void setKeyProvider(ProvidesKey<T> keyProvider) {
@@ -142,20 +123,18 @@

   /**
    * Called when a view changes its range of interest.
-   *
+   *
    * @param view the view whose range has changed
    */
   protected abstract void onRangeChanged(ListView<T> view);

   /**
    * Inform the views of the total number of items that are available.
-   *
+   *
    * @param size the new size
    * @param exact true if the size is exact, false if it is a guess
    */
   protected void updateDataSize(int size, boolean exact) {
-    lastDataSize = size;
-    lastDataSizeExact = exact;
     for (ListView<T> view : views) {
       view.setDataSize(size, exact);
     }
@@ -163,7 +142,7 @@

   /**
    * Inform the views of the new data.
-   *
+   *
    * @param start the start index
    * @param length the length of the data
    * @param values the data values
@@ -176,14 +155,14 @@

   /**
    * Informs a single view of new data.
-   *
+   *
    * @param view the view to be updated
    * @param start the start index
    * @param length the length of the data
    * @param values the data values
    */
-  protected void updateViewData(
-      ListView<T> view, int start, int length, List<T> values) {
+  protected void updateViewData(ListView<T> view, int start, int length,
+      List<T> values) {
     int end = start + length;
     Range range = view.getRange();
     int curStart = range.getStart();
@@ -194,8 +173,8 @@
       int realStart = curStart < start ? start : curStart;
       int realEnd = curEnd > end ? end : curEnd;
       int realLength = realEnd - realStart;
-      List<T> realValues = values.subList(
-          realStart - start, realStart - start + realLength);
+ List<T> realValues = values.subList(realStart - start, realStart - start
+          + realLength);
       view.setData(realStart, realLength, realValues);
     }
   }

--
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to