Allow null ProvidesKey in PagingTableListView, remove as constructor arg
Fix DatePickerCell bug in mail sample
Remove ListEvent and SizeChangedEvent
Optimize selection change in PTLV
Fix iterator in ListViewAdapter
Fix warnings & checkstyle problems
Review at http://gwt-code-reviews.appspot.com/370801
Review by: jgw@google.com
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@7953 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/bikeshed/src/com/google/gwt/bikeshed/cells/client/DatePickerCell.java b/bikeshed/src/com/google/gwt/bikeshed/cells/client/DatePickerCell.java
index d1c302b..c676c62 100644
--- a/bikeshed/src/com/google/gwt/bikeshed/cells/client/DatePickerCell.java
+++ b/bikeshed/src/com/google/gwt/bikeshed/cells/client/DatePickerCell.java
@@ -98,6 +98,7 @@
this.viewData = viewData;
this.valueUpdater = valueUpdater;
+ datePicker.setCurrentMonth(value);
datePicker.setValue(value);
panel.setPopupPositionAndShow(new PositionCallback() {
public void setPosition(int offsetWidth, int offsetHeight) {
diff --git a/bikeshed/src/com/google/gwt/bikeshed/list/client/Column.java b/bikeshed/src/com/google/gwt/bikeshed/list/client/Column.java
index 01b41d3..7528d48 100644
--- a/bikeshed/src/com/google/gwt/bikeshed/list/client/Column.java
+++ b/bikeshed/src/com/google/gwt/bikeshed/list/client/Column.java
@@ -73,9 +73,13 @@
public abstract C getValue(T object);
+ /**
+ * @param providesKey an instance of ProvidesKey<T>, or null if the record
+ * object should act as its own key.
+ */
public void onBrowserEvent(Element elem, final int index, final T object,
NativeEvent event, ProvidesKey<T> providesKey) {
- Object key = providesKey.getKey(object);
+ Object key = providesKey == null ? object : providesKey.getKey(object);
V viewData = viewDataMap.get(key);
V newViewData = cell.onBrowserEvent(elem,
getValue(object), viewData, event, fieldUpdater == null ? null
diff --git a/bikeshed/src/com/google/gwt/bikeshed/list/client/ListView.java b/bikeshed/src/com/google/gwt/bikeshed/list/client/ListView.java
index b23145e..3b13cb3 100644
--- a/bikeshed/src/com/google/gwt/bikeshed/list/client/ListView.java
+++ b/bikeshed/src/com/google/gwt/bikeshed/list/client/ListView.java
@@ -15,9 +15,9 @@
*/
package com.google.gwt.bikeshed.list.client;
-import com.google.gwt.bikeshed.list.shared.ListEvent;
import com.google.gwt.bikeshed.list.shared.Range;
-import com.google.gwt.bikeshed.list.shared.SizeChangeEvent;
+
+import java.util.List;
/**
* A list view.
@@ -39,9 +39,7 @@
Range getRange();
- // TODO - rename to setData, don't use event?
- void onDataChanged(ListEvent<T> event);
+ void setData(int start, int length, List<T> values);
- // TODO - rename to setDataSize, don't use event?
- void onSizeChanged(SizeChangeEvent event);
+ void setDataSize(int size, boolean isExact);
}
diff --git a/bikeshed/src/com/google/gwt/bikeshed/list/client/PagingTableListView.java b/bikeshed/src/com/google/gwt/bikeshed/list/client/PagingTableListView.java
index 48048be..756ccfd 100644
--- a/bikeshed/src/com/google/gwt/bikeshed/list/client/PagingTableListView.java
+++ b/bikeshed/src/com/google/gwt/bikeshed/list/client/PagingTableListView.java
@@ -15,11 +15,9 @@
*/
package com.google.gwt.bikeshed.list.client;
-import com.google.gwt.bikeshed.list.shared.ListEvent;
import com.google.gwt.bikeshed.list.shared.ProvidesKey;
import com.google.gwt.bikeshed.list.shared.Range;
import com.google.gwt.bikeshed.list.shared.SelectionModel;
-import com.google.gwt.bikeshed.list.shared.SizeChangeEvent;
import com.google.gwt.bikeshed.list.shared.AbstractListViewAdapter.DefaultRange;
import com.google.gwt.bikeshed.list.shared.SelectionModel.SelectionChangeEvent;
import com.google.gwt.bikeshed.list.shared.SelectionModel.SelectionChangeHandler;
@@ -56,14 +54,20 @@
protected int curPage;
private List<Column<T, ?, ?>> columns = new ArrayList<Column<T, ?, ?>>();
- private ArrayList<T> data = new ArrayList<T>();
+ private ArrayList<Boolean> dataSelected = new ArrayList<Boolean>();
+ private ArrayList<T> dataValues = new ArrayList<T>();
private Delegate<T> delegate;
private List<Header<?>> footers = new ArrayList<Header<?>>();
private List<Header<?>> headers = new ArrayList<Header<?>>();
private TableRowElement hoveringRow;
private int numPages;
private int pageSize;
+
+ /**
+ * If null, each T will be used as its own key.
+ */
private ProvidesKey<T> providesKey;
+
private HandlerRegistration selectionHandler;
private SelectionModel<T> selectionModel;
private TableElement table;
@@ -72,8 +76,12 @@
private TableSectionElement thead;
private int totalSize;
- public PagingTableListView(ProvidesKey<T> providesKey, final int pageSize) {
- this.providesKey = providesKey;
+ /**
+ * Constructs a table with the given page size.
+
+ * @param pageSize the page size
+ */
+ public PagingTableListView(final int pageSize) {
this.pageSize = pageSize;
setElement(table = Document.get().createTableElement());
thead = table.createTHead();
@@ -87,15 +95,23 @@
| Event.ONCHANGE | Event.FOCUSEVENTS);
}
+ /**
+ * Adds a column to the table.
+ */
public void addColumn(Column<T, ?, ?> col) {
addColumn(col, null, null);
}
+ /**
+ * Adds a column to the table with an associated header.
+ */
public void addColumn(Column<T, ?, ?> col, Header<?> header) {
addColumn(col, header, null);
}
- // TODO: remove(Column)
+ /**
+ * Adds a column to the table with an associated header and footer.
+ */
public void addColumn(Column<T, ?, ?> col, Header<?> header, Header<?> footer) {
headers.add(header);
footers.add(footer);
@@ -105,20 +121,25 @@
setPage(curPage); // TODO: better way to refresh?
}
+ /**
+ * Adds a column to the table with an associated String header.
+ */
public void addColumn(Column<T, ?, ?> col, String headerString) {
addColumn(col, new TextHeader(headerString), null);
}
+ // TODO: remove(Column)
+
// TODO - bounds check
public T getDisplayedItem(int indexOnPage) {
if (indexOnPage < 0 || indexOnPage >= getNumDisplayedItems()) {
throw new IndexOutOfBoundsException("indexOnPage = " + indexOnPage);
}
- return data.get(indexOnPage);
+ return dataValues.get(indexOnPage);
}
public List<T> getDisplayedItems() {
- return new ArrayList<T>(data);
+ return new ArrayList<T>(dataValues);
}
public int getNumDisplayedItems() {
@@ -138,6 +159,10 @@
return pageSize;
}
+ public ProvidesKey<T> getProvidesKey() {
+ return providesKey;
+ }
+
public Range getRange() {
return new DefaultRange(curPage * pageSize, pageSize);
}
@@ -182,7 +207,7 @@
tr.removeClassName("hover");
}
- T value = data.get(row);
+ T value = dataValues.get(row);
Column<T, ?, ?> column = columns.get(col);
column.onBrowserEvent(cell, curPage * pageSize + row, value, event,
@@ -190,20 +215,6 @@
}
}
- public void onDataChanged(ListEvent<T> event) {
- render(event.getStart(), event.getLength(), event.getValues());
- }
-
- public void onSizeChanged(SizeChangeEvent event) {
- totalSize = event.getSize();
- if (totalSize <= 0) {
- numPages = 0;
- } else {
- numPages = 1 + (totalSize - 1) / pageSize;
- }
- setPage(curPage);
- }
-
public void previousPage() {
setPage(curPage - 1);
}
@@ -227,31 +238,57 @@
th = th.getNextSibling().cast();
}
+ int numCols = columns.size();
+
// Refresh body
NodeList<TableRowElement> rows = tbody.getRows();
for (int indexOnPage = 0; indexOnPage < pageSize; indexOnPage++) {
TableRowElement row = rows.getItem(indexOnPage);
- T q = data.get(indexOnPage);
- if (q != null && selectionModel != null && selectionModel.isSelected(q)) {
- row.setClassName("pagingTableListView selected");
- } else {
- row.setClassName("pagingTableListView "
- + ((indexOnPage & 0x1) == 0 ? "evenRow" : "oddRow"));
- }
- int numCols = columns.size();
- for (int c = 0; c < numCols; ++c) {
- TableCellElement cell = row.getCells().getItem(c);
- StringBuilder sb = new StringBuilder();
- Column<T, ?, ?> column = columns.get(c);
- if (column.dependsOnSelection()) {
- columns.get(c).render(q, sb);
- cell.setInnerHTML(sb.toString());
+ T q = dataValues.get(indexOnPage);
+ boolean qSelected = dataSelected.get(indexOnPage);
+ boolean selected = q != null && selectionModel.isSelected(q);
+
+ // Process the row only if the selection has changed
+ if (qSelected != selected) {
+ dataSelected.set(indexOnPage, selected);
+
+ if (selected) {
+ // item became selected
+ row.setClassName("pagingTableListView selected");
+ } else {
+ // item became unselected
+ row.setClassName("pagingTableListView "
+ + ((indexOnPage & 0x1) == 0 ? "evenRow" : "oddRow"));
+ }
+
+ for (int c = 0; c < numCols; ++c) {
+ Column<T, ?, ?> column = columns.get(c);
+ if (column.dependsOnSelection()) {
+ TableCellElement cell = row.getCells().getItem(c);
+ StringBuilder sb = new StringBuilder();
+ columns.get(c).render(q, sb);
+ cell.setInnerHTML(sb.toString());
+ }
}
}
}
}
+ public void setData(int start, int length, List<T> values) {
+ render(start, length, values);
+ }
+
+ public void setDataSize(int size, boolean isExact) {
+ totalSize = size;
+ if (totalSize <= 0) {
+ numPages = 0;
+ } else {
+ numPages = 1 + (totalSize - 1) / pageSize;
+ }
+ setPage(curPage);
+ }
+
public void setDelegate(Delegate<T> delegate) {
this.delegate = delegate;
}
@@ -293,6 +330,17 @@
setPage(curPage);
}
+ /**
+ * Sets the {@link ProvidesKey} instance that will be used to generate keys
+ * for each record object as needed.
+ *
+ * @param providesKey an instance of {@link ProvidesKey<T>} used to generate
+ * keys for record objects.
+ */
+ public void setProvidesKey(ProvidesKey<T> providesKey) {
+ this.providesKey = providesKey;
+ }
+
public void setSelectionModel(SelectionModel<T> selectionModel) {
if (selectionHandler != null) {
selectionHandler.removeHandler();
@@ -337,7 +385,7 @@
+ ((indexOnPage & 0x1) == 0 ? "evenRow" : "oddRow"));
}
- data.set(indexOnPage, q);
+ dataValues.set(indexOnPage, q);
for (int c = 0; c < numCols; ++c) {
TableCellElement cell = row.getCells().getItem(c);
StringBuilder sb = new StringBuilder();
@@ -395,9 +443,11 @@
}
// Make room for the data cache
- data.ensureCapacity(pageSize);
- while (data.size() < pageSize) {
- data.add(null);
+ dataValues.ensureCapacity(pageSize);
+ dataSelected.ensureCapacity(pageSize);
+ while (dataValues.size() < pageSize) {
+ dataValues.add(null);
+ dataSelected.add(Boolean.FALSE);
}
}
diff --git a/bikeshed/src/com/google/gwt/bikeshed/list/client/SimpleCellList.java b/bikeshed/src/com/google/gwt/bikeshed/list/client/SimpleCellList.java
index 93c846f..06156ca 100644
--- a/bikeshed/src/com/google/gwt/bikeshed/list/client/SimpleCellList.java
+++ b/bikeshed/src/com/google/gwt/bikeshed/list/client/SimpleCellList.java
@@ -17,9 +17,7 @@
import com.google.gwt.bikeshed.cells.client.Cell;
import com.google.gwt.bikeshed.cells.client.ValueUpdater;
-import com.google.gwt.bikeshed.list.shared.ListEvent;
import com.google.gwt.bikeshed.list.shared.Range;
-import com.google.gwt.bikeshed.list.shared.SizeChangeEvent;
import com.google.gwt.bikeshed.list.shared.AbstractListViewAdapter.DefaultRange;
import com.google.gwt.dom.client.DivElement;
import com.google.gwt.dom.client.Document;
@@ -111,34 +109,30 @@
}
}
- public void onDataChanged(ListEvent<T> event) {
- int start = event.getStart();
- int len = event.getLength();
- List<T> values = event.getValues();
-
- // Construct a run of element from start (inclusive) to start + len (exclusive)
+ public void setData(int start, int length, List<T> values) {
+ // Construct a run of element from start (inclusive) to start + length (exclusive)
StringBuilder sb = new StringBuilder();
- for (int i = 0; i < len; i++) {
+ for (int i = 0; i < length; i++) {
sb.append("<div __idx='" + (start + i) + "' __seq='" + seq++ + "'>");
cell.render(values.get(i), null, sb);
sb.append("</div>");
}
Element parent = getElement().getFirstChildElement();
- if (start == 0 && len == maxSize) {
+ if (start == 0 && length == maxSize) {
parent.setInnerHTML(sb.toString());
} else {
makeElements();
tmpElem.setInnerHTML(sb.toString());
- for (int i = 0; i < len; i++) {
+ for (int i = 0; i < length; i++) {
Element child = parent.getChild(start + i).cast();
parent.replaceChild(tmpElem.getChild(0), child);
}
}
}
- public void onSizeChanged(SizeChangeEvent event) {
- size = event.getSize();
+ public void setDataSize(int size, boolean isExact) {
+ this.size = size;
sizeChanged();
}
diff --git a/bikeshed/src/com/google/gwt/bikeshed/list/shared/AbstractListViewAdapter.java b/bikeshed/src/com/google/gwt/bikeshed/list/shared/AbstractListViewAdapter.java
index 4cbe210..ab0d964 100644
--- a/bikeshed/src/com/google/gwt/bikeshed/list/shared/AbstractListViewAdapter.java
+++ b/bikeshed/src/com/google/gwt/bikeshed/list/shared/AbstractListViewAdapter.java
@@ -151,9 +151,8 @@
* @param exact true if the size is exact, false if it is a guess
*/
protected void updateDataSize(int size, boolean exact) {
- SizeChangeEvent event = new SizeChangeEvent(size, exact);
for (ListView<T> view : views) {
- view.onSizeChanged(event);
+ view.setDataSize(size, exact);
}
}
@@ -191,8 +190,7 @@
int realLength = realEnd - realStart;
List<T> realValues = values.subList(realStart - start, realStart
- start + realLength);
- ListEvent<T> event = new ListEvent<T>(realStart, realLength, realValues);
- view.onDataChanged(event);
+ view.setData(realStart, realLength, realValues);
}
}
}
diff --git a/bikeshed/src/com/google/gwt/bikeshed/list/shared/ListEvent.java b/bikeshed/src/com/google/gwt/bikeshed/list/shared/ListEvent.java
deleted file mode 100644
index 1c78314..0000000
--- a/bikeshed/src/com/google/gwt/bikeshed/list/shared/ListEvent.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * 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
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.bikeshed.list.shared;
-
-import java.util.List;
-
-/**
- * Represents a list event.
- *
- * @param <T> the type of data in the list
- */
-public class ListEvent<T> {
-
- private final int length;
- private final int start;
- private final List<T> values;
-
- /**
- * Creates a {@link ListEvent}.
- *
- * @param start the start index of the data
- * @param length the length of the data
- * @param values the new values
- */
- public ListEvent(int start, int length, List<T> values) {
- this.start = start;
- this.length = length;
- this.values = values;
- }
-
- /**
- * Get the length of the changed data set.
- *
- * @return the length of the data set
- */
- public int getLength() {
- return length;
- }
-
- /**
- * Get the start index of the changed data.
- *
- * @return the start index
- */
- public int getStart() {
- return start;
- }
-
- /**
- * Gets the value.
- *
- * @return the value
- */
- public List<T> getValues() {
- return values;
- }
-}
diff --git a/bikeshed/src/com/google/gwt/bikeshed/list/shared/ListViewAdapter.java b/bikeshed/src/com/google/gwt/bikeshed/list/shared/ListViewAdapter.java
index 1d862c3..d152b65 100644
--- a/bikeshed/src/com/google/gwt/bikeshed/list/shared/ListViewAdapter.java
+++ b/bikeshed/src/com/google/gwt/bikeshed/list/shared/ListViewAdapter.java
@@ -24,6 +24,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
+import java.util.NoSuchElementException;
/**
* A concrete subclass of {@link AbstractListViewAdapter} that is backed by an
@@ -33,59 +34,82 @@
*/
public class ListViewAdapter<T> extends AbstractListViewAdapter<T> {
- private class WrappedListIterator implements ListIterator<T> {
-
- int index;
- private ListWrapper wrapper;
-
- public WrappedListIterator(ListWrapper listWrapper, int index) {
- this.wrapper = listWrapper;
- this.index = index;
- }
-
- public void add(T o) {
- throw new UnsupportedOperationException();
- }
-
- public boolean hasNext() {
- return index < wrapper.size();
- }
-
- public boolean hasPrevious() {
- return index > 0;
- }
-
- public T next() {
- return wrapper.get(index++);
- }
-
- public int nextIndex() {
- return index;
- }
-
- public T previous() {
- return wrapper.get(--index);
- }
-
- public int previousIndex() {
- return index - 1;
- }
-
- public void remove() {
- throw new UnsupportedOperationException();
- }
-
- public void set(T o) {
- wrapper.set(index, o);
- }
- }
-
/**
* A wrapper around a list that updates the model on any change.
*/
private class ListWrapper implements List<T> {
/**
+ * A wrapped ListIterator.
+ */
+ private final class WrappedListIterator implements ListIterator<T> {
+
+ int i = 0, last = -1;
+
+ private WrappedListIterator() {
+ }
+
+ private WrappedListIterator(int start) {
+ int size = ListWrapper.this.size();
+ if (start < 0 || start > size) {
+ throw new IndexOutOfBoundsException("Index: " + start + ", Size: " + size);
+ }
+ i = start;
+ }
+
+ public void add(T o) {
+ ListWrapper.this.add(i++, o);
+ last = -1;
+ }
+
+ public boolean hasNext() {
+ return i < ListWrapper.this.size();
+ }
+
+ public boolean hasPrevious() {
+ return i > 0;
+ }
+
+ public T next() {
+ if (!hasNext()) {
+ throw new NoSuchElementException();
+ }
+ return ListWrapper.this.get(last = i++);
+ }
+
+ public int nextIndex() {
+ return i;
+ }
+
+ public T previous() {
+ if (!hasPrevious()) {
+ throw new NoSuchElementException();
+ }
+ return ListWrapper.this.get(last = --i);
+ }
+
+ public int previousIndex() {
+ return i - 1;
+ }
+
+ public void remove() {
+ if (last < 0) {
+ throw new IllegalStateException();
+ }
+ ListWrapper.this.remove(last);
+ i = last;
+ last = -1;
+ }
+
+ public void set(T o) {
+ if (last == -1) {
+ throw new IllegalStateException();
+ }
+ ListWrapper.this.set(last, o);
+ }
+ }
+
+ /**
* The current size of the list.
*/
private int curSize = 0;
@@ -235,11 +259,11 @@
}
public ListIterator<T> listIterator() {
- return new WrappedListIterator(this, 0);
+ return new WrappedListIterator();
}
public ListIterator<T> listIterator(int index) {
- return new WrappedListIterator(this, index);
+ return new WrappedListIterator(index);
}
public T remove(int index) {
diff --git a/bikeshed/src/com/google/gwt/bikeshed/list/shared/SizeChangeEvent.java b/bikeshed/src/com/google/gwt/bikeshed/list/shared/SizeChangeEvent.java
deleted file mode 100644
index 81dd219..0000000
--- a/bikeshed/src/com/google/gwt/bikeshed/list/shared/SizeChangeEvent.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * 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
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.bikeshed.list.shared;
-
-/**
- * Fired when the size of a list is known or changed.
- */
-public class SizeChangeEvent {
-
- private final boolean exact;
- private final int size;
-
- /**
- * Creates a {@link SizeChangeEvent}.
- *
- * @param size the total size of the list
- * @param exact true if this is an exact size
- */
- public SizeChangeEvent(int size, boolean exact) {
- this.size = size;
- this.exact = exact;
- }
-
- /**
- * Get the length of the changed data set.
- *
- * @return the length of the data set
- */
- public int getSize() {
- return size;
- }
-
- /**
- * Check if the size is an exact size or an approximation.
- *
- * @return true if exact, false if approximation
- */
- public boolean isExact() {
- return exact;
- }
-}
diff --git a/bikeshed/src/com/google/gwt/bikeshed/tree/client/TreeNodeView.java b/bikeshed/src/com/google/gwt/bikeshed/tree/client/TreeNodeView.java
index dc77540..0def3f8 100644
--- a/bikeshed/src/com/google/gwt/bikeshed/tree/client/TreeNodeView.java
+++ b/bikeshed/src/com/google/gwt/bikeshed/tree/client/TreeNodeView.java
@@ -17,10 +17,8 @@
import com.google.gwt.bikeshed.list.client.HasCell;
import com.google.gwt.bikeshed.list.client.ListView;
-import com.google.gwt.bikeshed.list.shared.ListEvent;
import com.google.gwt.bikeshed.list.shared.ProvidesKey;
import com.google.gwt.bikeshed.list.shared.Range;
-import com.google.gwt.bikeshed.list.shared.SizeChangeEvent;
import com.google.gwt.bikeshed.list.shared.AbstractListViewAdapter.DefaultRange;
import com.google.gwt.bikeshed.tree.client.TreeViewModel.NodeInfo;
import com.google.gwt.dom.client.Document;
@@ -381,18 +379,17 @@
return new DefaultRange(0, 100);
}
- public void onDataChanged(ListEvent<C> event) {
- // TODO - handle event start and length
+ public void setData(int start, int length, List<C> values) {
+ // TODO - handle event start and length properly
+ int end = start + length;
- int start = event.getStart();
- int end = start + event.getLength();
// Ensure savedInfo has a place to store the data values
while (localSavedInfo.values.size() < end) {
savedInfo.values.add(null);
}
// Save child values into savedInfo
- int index = event.getStart();
- for (C childValue : event.getValues()) {
+ int index = start;
+ for (C childValue : values) {
localSavedInfo.values.set(index++, childValue);
}
@@ -413,7 +410,7 @@
}
List<TreeNodeView<?>> savedViews = new ArrayList<TreeNodeView<?>>();
- for (C childValue : event.getValues()) {
+ for (C childValue : values) {
// Remove any child elements that correspond to prior children
// so the call to setInnerHtml will not destroy them
TreeNodeView<?> savedView = map.get(providesKey.getKey(childValue));
@@ -425,14 +422,14 @@
// Construct the child contents.
StringBuilder sb = new StringBuilder();
- emitHtml(sb, event.getValues(), nodeInfo.getHasCells(), savedViews);
+ emitHtml(sb, values, nodeInfo.getHasCells(), savedViews);
childContainer.setInnerHTML(sb.toString());
// Create the child TreeNodeViews from the new elements.
children = new ArrayList<TreeNodeView<?>>();
Element childElem = childContainer.getFirstChildElement();
int idx = 0;
- for (C childValue : event.getValues()) {
+ for (C childValue : values) {
TreeNodeView<C> child = createTreeNodeView(nodeInfo, childElem,
childValue, null, idx);
TreeNodeView<?> savedChild = map.get(providesKey.getKey(childValue));
@@ -461,8 +458,8 @@
}
}
- public void onSizeChanged(SizeChangeEvent event) {
- if (event.getSize() == 0 && event.isExact()) {
+ public void setDataSize(int size, boolean isExact) {
+ if (size == 0 && isExact) {
ensureChildContainer().setInnerHTML("<i>no data</i>");
if (children != null) {
for (TreeNodeView<?> child : children) {
diff --git a/bikeshed/src/com/google/gwt/requestfactory/client/gen/ClientRequestObject.java b/bikeshed/src/com/google/gwt/requestfactory/client/gen/ClientRequestObject.java
index 1198429..00211bf 100644
--- a/bikeshed/src/com/google/gwt/requestfactory/client/gen/ClientRequestObject.java
+++ b/bikeshed/src/com/google/gwt/requestfactory/client/gen/ClientRequestObject.java
@@ -20,7 +20,7 @@
import java.util.Map;
/**
- * A convenience class to convert a Map<String, String> to a Json string on the
+ * A convenience class to convert a Map<String, String> to a JSON string on the
* client side.
*/
public class ClientRequestObject {
@@ -30,6 +30,7 @@
return {};
}-*/;
+ @SuppressWarnings("unused")
protected MyJSO() {
}
diff --git a/bikeshed/src/com/google/gwt/requestfactory/server/RequestFactoryServlet.java b/bikeshed/src/com/google/gwt/requestfactory/server/RequestFactoryServlet.java
index 04dd062..f1c7115 100644
--- a/bikeshed/src/com/google/gwt/requestfactory/server/RequestFactoryServlet.java
+++ b/bikeshed/src/com/google/gwt/requestfactory/server/RequestFactoryServlet.java
@@ -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
@@ -52,7 +52,7 @@
* com.google.gwt.requestfactory.shared.RequestFactory.Config.
* <p>
* e.g.
- *
+ *
* <pre> <context-param>
<param-name>servlet.serverOperation</param-name>
<param-value>com.myco.myapp.MyAppServerSideOperations</param-value>
@@ -141,6 +141,9 @@
* Allows subclass to provide hack implementation.
* <p>
* TODO real reflection based implementation.
+ *
+ * @param content
+ * @param writer
*/
protected void sync(String content, PrintWriter writer) {
return;
@@ -224,7 +227,7 @@
/**
* Converts the returnValue of a 'get' method to a JSONArray.
- *
+ *
* @param resultObject object returned by a 'get' method, must be of type
* List<?>
* @return the JSONArray
@@ -256,7 +259,7 @@
/**
* Returns methodName corresponding to the propertyName that can be invoked on
* an entity.
- *
+ *
* Example: "userName" returns "getUserName". "version" returns "getVersion"
*/
private String getMethodNameFromPropertyName(String propertyName) {
@@ -324,7 +327,7 @@
/**
* returns true if the property has been requested. TODO: fix this hack.
- *
+ *
* @param p the field of entity ref
* @return has the property value been requested
*/
diff --git a/bikeshed/src/com/google/gwt/sample/bikeshed/cookbook/client/EditableTableRecipe.java b/bikeshed/src/com/google/gwt/sample/bikeshed/cookbook/client/EditableTableRecipe.java
index 00b555b..5c22749 100644
--- a/bikeshed/src/com/google/gwt/sample/bikeshed/cookbook/client/EditableTableRecipe.java
+++ b/bikeshed/src/com/google/gwt/sample/bikeshed/cookbook/client/EditableTableRecipe.java
@@ -53,7 +53,7 @@
@Override
protected Widget createWidget() {
final ListViewAdapter<String> adapter = new ListViewAdapter<String>();
- final PagingTableListView<String> table = new PagingTableListView<String>(adapter, 10);
+ final PagingTableListView<String> table = new PagingTableListView<String>(10);
adapter.addView(table);
for (int i = 0; i < 25; ++i) {
diff --git a/bikeshed/src/com/google/gwt/sample/bikeshed/cookbook/client/MailRecipe.java b/bikeshed/src/com/google/gwt/sample/bikeshed/cookbook/client/MailRecipe.java
index de642da..b178369 100644
--- a/bikeshed/src/com/google/gwt/sample/bikeshed/cookbook/client/MailRecipe.java
+++ b/bikeshed/src/com/google/gwt/sample/bikeshed/cookbook/client/MailRecipe.java
@@ -19,7 +19,7 @@
import com.google.gwt.bikeshed.cells.client.Cell;
import com.google.gwt.bikeshed.cells.client.CheckboxCell;
import com.google.gwt.bikeshed.cells.client.ClickableTextCell;
-import com.google.gwt.bikeshed.cells.client.DateCell;
+import com.google.gwt.bikeshed.cells.client.DatePickerCell;
import com.google.gwt.bikeshed.cells.client.FieldUpdater;
import com.google.gwt.bikeshed.cells.client.TextCell;
import com.google.gwt.bikeshed.cells.client.ValueUpdater;
@@ -315,7 +315,7 @@
sortMessages(idComparator, true);
- table = new PagingTableListView<Message>(adapter, 10);
+ table = new PagingTableListView<Message>(10);
table.setSelectionModel(selectionModel);
adapter.addView(table);
@@ -358,7 +358,7 @@
});
Column<Message, Date, Void> dateColumn = addColumn(table, "Date",
- new DateCell(), new GetValue<Message, Date>() {
+ new DatePickerCell<Void>(), new GetValue<Message, Date>() {
public Date getValue(Message object) {
return object.date;
}
@@ -393,7 +393,7 @@
toggleColumn.setFieldUpdater(new FieldUpdater<Message, String, Void>() {
public void update(int index, Message object, String value, Void viewData) {
object.isRead = !object.isRead;
- table.refresh();
+ messages.set(index, object);
}
});
table.addColumn(toggleColumn, "Toggle Read/Unread");
diff --git a/bikeshed/src/com/google/gwt/sample/bikeshed/cookbook/client/ValidationRecipe.java b/bikeshed/src/com/google/gwt/sample/bikeshed/cookbook/client/ValidationRecipe.java
index 0c10eba..a1dda9a 100644
--- a/bikeshed/src/com/google/gwt/sample/bikeshed/cookbook/client/ValidationRecipe.java
+++ b/bikeshed/src/com/google/gwt/sample/bikeshed/cookbook/client/ValidationRecipe.java
@@ -84,14 +84,13 @@
String zip = "300" + i;
list.add(new Address("GA", zip));
}
- adapter.setKeyProvider(new ProvidesKey<Address>() {
+
+ PagingTableListView<Address> table = new PagingTableListView<Address>(10);
+ table.setProvidesKey(new ProvidesKey<Address>() {
public Object getKey(Address object) {
return object.key;
}
});
-
- PagingTableListView<Address> table = new PagingTableListView<Address>(
- adapter, 10);
adapter.addView(table);
TextColumn<Address> stateColumn = new TextColumn<Address>() {
@Override
diff --git a/bikeshed/src/com/google/gwt/sample/bikeshed/stocks/client/FavoritesWidget.java b/bikeshed/src/com/google/gwt/sample/bikeshed/stocks/client/FavoritesWidget.java
index 137c750..d9ad5ba 100644
--- a/bikeshed/src/com/google/gwt/sample/bikeshed/stocks/client/FavoritesWidget.java
+++ b/bikeshed/src/com/google/gwt/sample/bikeshed/stocks/client/FavoritesWidget.java
@@ -53,7 +53,7 @@
@UiFactory
PagingTableListView<StockQuote> createListView() {
- PagingTableListView<StockQuote> view = new PagingTableListView<StockQuote>(adapter, 10);
+ PagingTableListView<StockQuote> view = new PagingTableListView<StockQuote>(10);
adapter.addView(view);
return view;
}
diff --git a/bikeshed/src/com/google/gwt/sample/bikeshed/stocks/client/StockQueryWidget.java b/bikeshed/src/com/google/gwt/sample/bikeshed/stocks/client/StockQueryWidget.java
index f7a36cb..46bca5d 100644
--- a/bikeshed/src/com/google/gwt/sample/bikeshed/stocks/client/StockQueryWidget.java
+++ b/bikeshed/src/com/google/gwt/sample/bikeshed/stocks/client/StockQueryWidget.java
@@ -80,7 +80,7 @@
@UiFactory
PagingTableListView<StockQuote> createListView() {
- PagingTableListView<StockQuote> view = new PagingTableListView<StockQuote>(adapter, 10);
+ PagingTableListView<StockQuote> view = new PagingTableListView<StockQuote>(10);
adapter.addView(view);
return view;
}
diff --git a/bikeshed/src/com/google/gwt/sample/bikeshed/stocks/client/StocksMobile.java b/bikeshed/src/com/google/gwt/sample/bikeshed/stocks/client/StocksMobile.java
index 9c3c8f5..0e6fc77 100644
--- a/bikeshed/src/com/google/gwt/sample/bikeshed/stocks/client/StocksMobile.java
+++ b/bikeshed/src/com/google/gwt/sample/bikeshed/stocks/client/StocksMobile.java
@@ -120,8 +120,7 @@
@UiFactory
PagingTableListView<StockQuote> createFavoritesWidget() {
- PagingTableListView<StockQuote> favorite = new PagingTableListView<StockQuote>(
- favoritesListViewAdapter, 10);
+ PagingTableListView<StockQuote> favorite = new PagingTableListView<StockQuote>(10);
favoritesListViewAdapter.addView(favorite);
favorite.addColumn(Columns.tickerColumn, "ticker");
diff --git a/bikeshed/src/com/google/gwt/sample/expenses/gwt/customized/CustomizedShell.java b/bikeshed/src/com/google/gwt/sample/expenses/gwt/customized/CustomizedShell.java
index 5e7bd2a..3401a94 100644
--- a/bikeshed/src/com/google/gwt/sample/expenses/gwt/customized/CustomizedShell.java
+++ b/bikeshed/src/com/google/gwt/sample/expenses/gwt/customized/CustomizedShell.java
@@ -120,8 +120,7 @@
@UiFactory
PagingTableListView<ReportRecord> createListView() {
- PagingTableListView<ReportRecord> table = new PagingTableListView<ReportRecord>(
- adapter, 10);
+ PagingTableListView<ReportRecord> table = new PagingTableListView<ReportRecord>(10);
adapter.addView(table);
return table;
}
diff --git a/bikeshed/src/com/google/gwt/sample/expenses/gwt/scaffold/ScaffoldListViewBuilder.java b/bikeshed/src/com/google/gwt/sample/expenses/gwt/scaffold/ScaffoldListViewBuilder.java
index 0b8b220..7d63895 100644
--- a/bikeshed/src/com/google/gwt/sample/expenses/gwt/scaffold/ScaffoldListViewBuilder.java
+++ b/bikeshed/src/com/google/gwt/sample/expenses/gwt/scaffold/ScaffoldListViewBuilder.java
@@ -49,7 +49,7 @@
public ValuesListViewTable<?> getListView(final ExpensesListPlace newPlace) {
// TODO Will these class references prevent customized apps that keep this
- // view builder around from stripping unsued entity types?
+ // view builder around from stripping unused entity types?
if (!viewMap.containsKey(newPlace)) {
if (newPlace.getType().equals(EmployeeRecord.class)) {
EmployeeListView newView = new EmployeeListView(
diff --git a/bikeshed/src/com/google/gwt/sample/expenses/server/domain/Report.java b/bikeshed/src/com/google/gwt/sample/expenses/server/domain/Report.java
index 7027066..d661122 100644
--- a/bikeshed/src/com/google/gwt/sample/expenses/server/domain/Report.java
+++ b/bikeshed/src/com/google/gwt/sample/expenses/server/domain/Report.java
@@ -88,6 +88,7 @@
}
}
+ @SuppressWarnings("unchecked")
public static List<Report> findReportsByEmployee(String employeeId) {
EntityManager em = entityManager();
try {
@@ -117,7 +118,7 @@
private String purpose;
/**
- * Store reporter's key instead of reporter because
+ * Store reporter's key instead of reporter. See:
* http://code.google.com/appengine
* /docs/java/datastore/relationships.html#Unowned_Relationships
*/
diff --git a/bikeshed/src/com/google/gwt/valuestore/client/ValuesListViewTable.java b/bikeshed/src/com/google/gwt/valuestore/client/ValuesListViewTable.java
index cc834f7..118b8f0 100644
--- a/bikeshed/src/com/google/gwt/valuestore/client/ValuesListViewTable.java
+++ b/bikeshed/src/com/google/gwt/valuestore/client/ValuesListViewTable.java
@@ -58,7 +58,7 @@
public ValuesListViewTable(String headingMessage,
List<Column<R, ?, ?>> columns, List<Header<?>> headers) {
adapter = createAdapter();
- table = new PagingTableListView<R>(adapter, 100);
+ table = new PagingTableListView<R>(100);
adapter.addView(table);
final Iterator<Header<?>> nextHeader = headers.iterator();
for (Column<R, ?, ?> column : columns) {
diff --git a/bikeshed/src/com/google/gwt/valuestore/shared/DeltaValueStore.java b/bikeshed/src/com/google/gwt/valuestore/shared/DeltaValueStore.java
index 44c6d57..02ecd94 100644
--- a/bikeshed/src/com/google/gwt/valuestore/shared/DeltaValueStore.java
+++ b/bikeshed/src/com/google/gwt/valuestore/shared/DeltaValueStore.java
@@ -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
@@ -15,7 +15,6 @@
*/
package com.google.gwt.valuestore.shared;
-
/**
* Set of changes to a ValueStore.
*/
diff --git a/bikeshed/src/com/google/gwt/valuestore/shared/Property.java b/bikeshed/src/com/google/gwt/valuestore/shared/Property.java
index fbb8258..337206e 100644
--- a/bikeshed/src/com/google/gwt/valuestore/shared/Property.java
+++ b/bikeshed/src/com/google/gwt/valuestore/shared/Property.java
@@ -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
@@ -16,8 +16,8 @@
package com.google.gwt.valuestore.shared;
/**
- * Defines a property of a {@link Record}
- *
+ * Defines a property of a {@link Record}.
+ *
* @param <V> the type of the property's value
*/
public class Property<V> {
diff --git a/bikeshed/src/com/google/gwt/valuestore/shared/PropertyReference.java b/bikeshed/src/com/google/gwt/valuestore/shared/PropertyReference.java
index 13b919b..2c890ed 100644
--- a/bikeshed/src/com/google/gwt/valuestore/shared/PropertyReference.java
+++ b/bikeshed/src/com/google/gwt/valuestore/shared/PropertyReference.java
@@ -15,7 +15,6 @@
*/
package com.google.gwt.valuestore.shared;
-
/**
* A pointer to a particular property value.
*