Relaxing the requirement that users specify a loading indicator image resource. If the image resource is null, the table will not create a default loading indicator.
Review at http://gwt-code-reviews.appspot.com/1349801
Review by: jasonmheim@google.com
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@9692 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/user/cellview/client/CellTable.java b/user/src/com/google/gwt/user/cellview/client/CellTable.java
index c01d333..9bd263c 100644
--- a/user/src/com/google/gwt/user/cellview/client/CellTable.java
+++ b/user/src/com/google/gwt/user/cellview/client/CellTable.java
@@ -643,8 +643,14 @@
loadingIndicatorContainer.setStyleName(style.cellTableLoading());
}
- // Set the default loading indicator.
- setLoadingIndicator(new Image(resources.cellTableLoading()));
+ /*
+ * Set the default loading indicator to use if the user provided a loading
+ * image resource.
+ */
+ ImageResource loadingImg = resources.cellTableLoading();
+ if (loadingImg != null) {
+ setLoadingIndicator(new Image(loadingImg));
+ }
// Sink events.
Set<String> eventTypes = new HashSet<String>();
diff --git a/user/test/com/google/gwt/user/cellview/client/CellTableTest.java b/user/test/com/google/gwt/user/cellview/client/CellTableTest.java
index 6c27ac2..924a247 100644
--- a/user/test/com/google/gwt/user/cellview/client/CellTableTest.java
+++ b/user/test/com/google/gwt/user/cellview/client/CellTableTest.java
@@ -27,6 +27,7 @@
import com.google.gwt.dom.client.TableRowElement;
import com.google.gwt.dom.client.TableSectionElement;
import com.google.gwt.dom.client.Style.Unit;
+import com.google.gwt.resources.client.ImageResource;
import com.google.gwt.safehtml.shared.SafeHtml;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.google.gwt.user.cellview.client.CellTable.Resources;
@@ -225,6 +226,44 @@
assertNotNull(table.getRowElement(9));
}
+ public void testNullLoadingImage() {
+ // Create a Resources instance that does not include a loading image.
+ CellTable.Resources resources = new CellTable.Resources() {
+ private final CellTable.Resources defaultRes = GWT.create(CellTable.Resources.class);
+
+ public ImageResource cellTableFooterBackground() {
+ return defaultRes.cellTableFooterBackground();
+ }
+
+ public ImageResource cellTableHeaderBackground() {
+ return defaultRes.cellTableHeaderBackground();
+ }
+
+ public ImageResource cellTableLoading() {
+ return null;
+ }
+
+ public ImageResource cellTableSelectedBackground() {
+ return defaultRes.cellTableSelectedBackground();
+ }
+
+ public ImageResource cellTableSortAscending() {
+ return defaultRes.cellTableSortAscending();
+ }
+
+ public ImageResource cellTableSortDescending() {
+ return defaultRes.cellTableSortDescending();
+ }
+
+ public Style cellTableStyle() {
+ return defaultRes.cellTableStyle();
+ }
+ };
+
+ CellTable<String> table = new CellTable<String>(25, resources);
+ assertNull(table.getLoadingIndicator());
+ }
+
public void testInsertColumn() {
CellTable<String> table = new CellTable<String>();
assertEquals(0, table.getColumnCount());
@@ -453,16 +492,13 @@
public void testSetTableLayoutFixed() {
CellTable<String> table = createAbstractHasData(new TextCell());
- assertNotSame("fixed",
- table.getElement().getStyle().getTableLayout());
+ assertNotSame("fixed", table.getElement().getStyle().getTableLayout());
table.setTableLayoutFixed(true);
- assertEquals("fixed",
- table.getElement().getStyle().getTableLayout());
+ assertEquals("fixed", table.getElement().getStyle().getTableLayout());
table.setTableLayoutFixed(false);
- assertNotSame("fixed",
- table.getElement().getStyle().getTableLayout());
+ assertNotSame("fixed", table.getElement().getStyle().getTableLayout());
}
public void testSortableColumn() {