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.

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

Review by: pengzhuang@google.com

git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@10259 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/user/cellview/client/AbstractCellTable.java b/user/src/com/google/gwt/user/cellview/client/AbstractCellTable.java
index 019f4d4..169d915 100644
--- a/user/src/com/google/gwt/user/cellview/client/AbstractCellTable.java
+++ b/user/src/com/google/gwt/user/cellview/client/AbstractCellTable.java
@@ -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
@@ -676,6 +690,17 @@
   }
 
   /**
+   * 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);
+  }
+
+  /**
    * Get the widget displayed when the table has no rows.
    * 
    * @return the empty table widget
@@ -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;
diff --git a/user/test/com/google/gwt/user/cellview/client/AbstractCellTableTestBase.java b/user/test/com/google/gwt/user/cellview/client/AbstractCellTableTestBase.java
index 59f3178..185ff86 100644
--- a/user/test/com/google/gwt/user/cellview/client/AbstractCellTableTestBase.java
+++ b/user/test/com/google/gwt/user/cellview/client/AbstractCellTableTestBase.java
@@ -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,28 @@
     }
   }
 
+  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.0, Unit.EM);
+    assertEquals("100px", table.getColumnWidth(col0));
+
+    // Some browsers return 200.0, others 200.
+    assertTrue(table.getColumnWidth(col1).contains("200"));
+
+    // 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());