Reviewers: jlabanca,
Description:
Adding a couple of useful methods to AbstractCellTable.
getColumnWidth() can be used to access the width of a column set using
setColumnWidth(). flush() will immediately flush pending changes into
the view.
Please review this at http://gwt-code-reviews.appspot.com/1453801/
Affected files:
M user/src/com/google/gwt/user/cellview/client/AbstractCellTable.java
M
user/test/com/google/gwt/user/cellview/client/AbstractCellTableTestBase.java
Index: user/src/com/google/gwt/user/cellview/client/AbstractCellTable.java
===================================================================
--- user/src/com/google/gwt/user/cellview/client/AbstractCellTable.java
(revision 10236)
+++ user/src/com/google/gwt/user/cellview/client/AbstractCellTable.java
(working copy)
@@ -635,6 +635,20 @@
}
/**
+ * Flush all pending changes to the table and render immediately.
+ *
+ * <p>
+ * Modifications to the table, such as adding columns or setting data,
are not
+ * rendered immediately. Instead, changes are coalesced at the end of the
+ * current event loop to avoid rendering the table multiple times. Use
this
+ * method to force the table to render all pending modifications
immediately.
+ * </p>
+ */
+ public void flush() {
+ getPresenter().flush();
+ }
+
+ /**
* Get the column at the specified index.
*
* @param col the index of the column to retrieve
@@ -673,6 +687,17 @@
*/
public ColumnSortList getColumnSortList() {
return sortList;
+ }
+
+ /**
+ * Get the width of a {@link Column}.
+ *
+ * @param column the column
+ * @return the width of the column, or null if not set
+ * @see #setColumnWidth(Column, double, Unit)
+ */
+ public String getColumnWidth(Column<T, ?> column) {
+ return columnWidths.get(column);
}
/**
@@ -703,7 +728,7 @@
* current page
*/
public TableRowElement getRowElement(int row) {
- getPresenter().flush();
+ flush();
checkRowBounds(row);
NodeList<TableRowElement> rows = getTableBodyElement().getRows();
return rows.getLength() > row ? rows.getItem(row) : null;
Index:
user/test/com/google/gwt/user/cellview/client/AbstractCellTableTestBase.java
===================================================================
---
user/test/com/google/gwt/user/cellview/client/AbstractCellTableTestBase.java
(revision 10236)
+++
user/test/com/google/gwt/user/cellview/client/AbstractCellTableTestBase.java
(working copy)
@@ -21,6 +21,7 @@
import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.NativeEvent;
import com.google.gwt.dom.client.TableCellElement;
+import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import
com.google.gwt.user.cellview.client.LoadingStateChangeEvent.LoadingState;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
@@ -272,6 +273,26 @@
}
}
+ public void testSetColumnWidth() {
+ AbstractCellTable<String> table = createAbstractHasData(new
TextCell());
+ Column<String, ?> col0 = new MockColumn<String, String>();
+ Column<String, ?> col1 = new MockColumn<String, String>();
+ Column<String, ?> col2 = new MockColumn<String, String>();
+
+ // Set a column width.
+ table.setColumnWidth(col0, "100px");
+ table.setColumnWidth(col1, 200, Unit.EM);
+ assertEquals("100px", table.getColumnWidth(col0));
+ assertEquals("200em", table.getColumnWidth(col1));
+
+ // Check a column that has not been set.
+ assertNull(table.getColumnWidth(col2));
+
+ // Check a column that has been cleared.
+ table.clearColumnWidth(col0);
+ assertNull(table.getColumnWidth(col0));
+ }
+
public void testSetEmptyTableWidget() {
AbstractCellTable<String> table = createAbstractHasData(new
TextCell());
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors