Once again rolls back GridParser, due to an as yet
undiagnosed backward incompatibility.
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@8393 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/uibinder/elementparsers/GridParser.java b/user/src/com/google/gwt/uibinder/elementparsers/GridParser.java
deleted file mode 100644
index 9f92f40..0000000
--- a/user/src/com/google/gwt/uibinder/elementparsers/GridParser.java
+++ /dev/null
@@ -1,166 +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.uibinder.elementparsers;
-
-import com.google.gwt.core.ext.UnableToCompleteException;
-import com.google.gwt.core.ext.typeinfo.JClassType;
-import com.google.gwt.uibinder.rebind.UiBinderWriter;
-import com.google.gwt.uibinder.rebind.XMLElement;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * A parser for Grid rows and cells.
- */
-public class GridParser implements ElementParser {
-
- private static class CellContent {
- private String tagName;
- private String content;
-
- public CellContent(String tagName, String content) {
- this.tagName = tagName;
- this.content = content;
- }
-
- public String getConent() {
- return this.content;
- }
-
- public String getTagName() {
- return this.tagName;
- }
- }
-
- private static class Size {
- private int rows;
- private int columns;
-
- public Size() {
- this.rows = 0;
- this.columns = 0;
- }
-
- public int getColumns() {
- return this.columns;
- }
-
- public int getRows() {
- return this.rows;
- }
-
- public void setColumns(int cols) {
- this.columns = cols;
- }
-
- public void setRows(int rows) {
- this.rows = rows;
- }
- }
-
- private static final String ROW_TAG = "row";
-
- private static final String CELL_TAG = "cell";
-
- private static final String CUSTOMCELL_TAG = "customCell";
-
- public void parse(XMLElement elem, String fieldName, JClassType type,
- UiBinderWriter writer) throws UnableToCompleteException {
-
- List<List<CellContent>> matrix = new ArrayList<List<CellContent>>();
-
- parseRows(elem, fieldName, writer, matrix);
-
- Size size = getMatrixSize(matrix);
-
- writer.addStatement("%s.resize(%s, %s);", fieldName,
- Integer.toString(size.getRows()), Integer.toString(size.getColumns()));
- for (List<CellContent> row : matrix) {
- for (CellContent column : row) {
- if (column.getTagName().equals(CELL_TAG)) {
- writer.addStatement("%s.setHTML(%s, %s, \"%s\");", fieldName,
- Integer.toString(matrix.indexOf(row)),
- Integer.toString(row.indexOf(column)), column.getConent());
- }
- if (column.getTagName().equals(CUSTOMCELL_TAG)) {
- writer.addStatement("%s.setWidget(%s, %s, %s);", fieldName,
- Integer.toString(matrix.indexOf(row)),
- Integer.toString(row.indexOf(column)), column.getConent());
- }
- }
- }
- }
-
- private Size getMatrixSize(List<List<CellContent>> matrix) {
- Size size = new Size();
-
- size.setRows(matrix.size());
-
- int maxColumns = 0;
- for (List<CellContent> column : matrix) {
- maxColumns = (column.size() > maxColumns) ? column.size() : maxColumns;
- }
- size.setColumns(maxColumns);
-
- return size;
- }
-
- private void parseColumns(String fieldName, UiBinderWriter writer,
- List<List<CellContent>> matrix, XMLElement child)
- throws UnableToCompleteException {
-
- String tagName;
- for (XMLElement cell : child.consumeChildElements()) {
- tagName = cell.getLocalName();
- if (!tagName.equals(CELL_TAG) && !tagName.equals(CUSTOMCELL_TAG)
- || !cell.getPrefix().equals(child.getPrefix())) {
- writer.die("Grid's row tag in %s may only contain %s or %s element.",
- fieldName, CELL_TAG, CUSTOMCELL_TAG);
- }
- CellContent newColumn = null;
- if (tagName.equals(CELL_TAG)) {
- HtmlInterpreter htmlInt = HtmlInterpreter.newInterpreterForUiObject(
- writer, fieldName);
- String html = cell.consumeInnerHtml(htmlInt);
- newColumn = new CellContent(tagName, html);
- }
- if (tagName.equals(CUSTOMCELL_TAG)) {
- newColumn = new CellContent(tagName,
- writer.parseElementToField(cell.consumeSingleChildElement()));
- }
- matrix.get(matrix.size() - 1).add(newColumn);
- }
- }
-
- private void parseRows(XMLElement elem, String fieldName,
- UiBinderWriter writer, List<List<CellContent>> matrix)
- throws UnableToCompleteException {
-
- for (XMLElement child : elem.consumeChildElements()) {
- String tagName = child.getLocalName();
- if (!tagName.equals(ROW_TAG)
- || !elem.getPrefix().equals(child.getPrefix())) {
- writer.die(
- "%1$s:Grid elements must contain only %1$s:%2$s children, found %3$s:%4$s",
- elem.getPrefix(), ROW_TAG, child.getPrefix(), tagName);
- }
- List<CellContent> newRow = new ArrayList<CellContent>();
- matrix.add(newRow);
- parseColumns(fieldName, writer, matrix, child);
- }
- }
-}
diff --git a/user/src/com/google/gwt/uibinder/rebind/UiBinderWriter.java b/user/src/com/google/gwt/uibinder/rebind/UiBinderWriter.java
index 532f90e..592913a 100644
--- a/user/src/com/google/gwt/uibinder/rebind/UiBinderWriter.java
+++ b/user/src/com/google/gwt/uibinder/rebind/UiBinderWriter.java
@@ -980,7 +980,6 @@
addWidgetParser("TabLayoutPanel");
addWidgetParser("Image");
addWidgetParser("ListBox");
- addWidgetParser("Grid");
}
/**
diff --git a/user/src/com/google/gwt/user/client/ui/Grid.java b/user/src/com/google/gwt/user/client/ui/Grid.java
index 9cf3ef6..7f9e513 100644
--- a/user/src/com/google/gwt/user/client/ui/Grid.java
+++ b/user/src/com/google/gwt/user/client/ui/Grid.java
@@ -29,40 +29,6 @@
* <h3>Example</h3>
* {@example com.google.gwt.examples.GridExample}
* </p>
- *
- * <h3>Use in UiBinder Templates</h3>
- * <p>
- * Grid widget consists of <g:row> elements. Each <g:row> element
- * can contain one or more <g:cell> or <g:customCell> elements.
- * Using <g:cell> attribute it is possible to place pure HTML content.
- * <g:customCell> is used as a container for
- * {@link com.google.gwt.user.client.ui.Widget} type objects. (Note that the
- * tags of the row, cell and customCell elements are not capitalized. This
- * is meant to signal that the item is not a runtime object, and so cannot
- * have a <code>ui:field</code> attribute.)
- * <p>
- * For example:
- *
- * <pre>
- * <g:Grid>
- * <g:row>
- * <g:customCell>
- * <g:Label>foo</g:Label>
- * </g:customCell>
- * <g:customCell>
- * <g:Label>bar</g:Label>
- * </g:customCell>
- * </g:row>
- * <g:row>
- * <g:cell>
- * <div>foo</div>
- * </g:cell>
- * <g:cell>
- * <div>bar</div>
- * </g:cell>
- * </g:row>
- * </g:Grid>
- * </pre>
*/
public class Grid extends HTMLTable {
diff --git a/user/test/com/google/gwt/uibinder/UiBinderJreSuite.java b/user/test/com/google/gwt/uibinder/UiBinderJreSuite.java
index 4f95f38..9198de6 100644
--- a/user/test/com/google/gwt/uibinder/UiBinderJreSuite.java
+++ b/user/test/com/google/gwt/uibinder/UiBinderJreSuite.java
@@ -27,7 +27,6 @@
import com.google.gwt.uibinder.attributeparsers.VerticalAlignmentConstantParserTest;
import com.google.gwt.uibinder.elementparsers.DialogBoxParserTest;
import com.google.gwt.uibinder.elementparsers.DockLayoutPanelParserTest;
-import com.google.gwt.uibinder.elementparsers.GridParserTest;
import com.google.gwt.uibinder.elementparsers.ImageParserTest;
import com.google.gwt.uibinder.elementparsers.IsEmptyParserTest;
import com.google.gwt.uibinder.elementparsers.LayoutPanelParserTest;
@@ -83,7 +82,6 @@
// elementparsers
suite.addTestSuite(DialogBoxParserTest.class);
suite.addTestSuite(DockLayoutPanelParserTest.class);
- suite.addTestSuite(GridParserTest.class);
suite.addTestSuite(ImageParserTest.class);
suite.addTestSuite(IsEmptyParserTest.class);
suite.addTestSuite(LayoutPanelParserTest.class);
diff --git a/user/test/com/google/gwt/uibinder/elementparsers/GridParserTest.java b/user/test/com/google/gwt/uibinder/elementparsers/GridParserTest.java
deleted file mode 100644
index d2a23f2..0000000
--- a/user/test/com/google/gwt/uibinder/elementparsers/GridParserTest.java
+++ /dev/null
@@ -1,161 +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.uibinder.elementparsers;
-
-import com.google.gwt.core.ext.UnableToCompleteException;
-import com.google.gwt.uibinder.rebind.FieldWriter;
-
-import junit.framework.TestCase;
-
-import org.xml.sax.SAXException;
-
-import java.util.Iterator;
-
-/**
- * GridParser unit tests.
- */
-public class GridParserTest extends TestCase {
- private static final String PARSED_TYPE = "com.google.gwt.user.client.ui.Grid";
-
- private ElementParserTester tester;
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- tester = new ElementParserTester(PARSED_TYPE, new GridParser());
- }
-
- public void testCellWithWhitespaces() throws SAXException {
- StringBuffer b = new StringBuffer();
- b.append("<g:Grid>");
- b.append(" <g:row>");
- b.append(" <g:customCell> </g:customCell>");
- b.append(" </g:row>");
- b.append("</g:Grid>");
-
- try {
- tester.parse(b.toString());
- fail();
- } catch (UnableToCompleteException exception) {
- assertNotNull(tester.logger.died);
- }
- }
-
- public void testEmtpyChild() throws SAXException {
- StringBuffer b = new StringBuffer();
- b.append("<g:Grid>");
- b.append(" <g:row>");
- b.append(" <g:customCell></g:customCell>");
- b.append(" </g:row>");
- b.append("</g:Grid>");
-
- try {
- tester.parse(b.toString());
- fail();
- } catch (UnableToCompleteException exception) {
- assertNotNull(tester.logger.died);
- }
- }
-
- public void testInvalidChild() throws SAXException {
- StringBuffer b = new StringBuffer();
- b.append("<g:Grid>");
- b.append(" <foo/>");
- b.append("</g:Grid>");
-
- try {
- tester.parse(b.toString());
- fail();
- } catch (UnableToCompleteException exception) {
- assertNotNull(tester.logger.died);
- }
- }
-
- public void testValidChild() throws UnableToCompleteException, SAXException {
- StringBuffer b = new StringBuffer();
- b.append("<g:Grid>");
- b.append(" <g:row>");
- b.append(" <g:cell>");
- b.append(" <div>foo HTML element</div>");
- b.append(" </g:cell>");
- b.append(" <g:cell>");
- b.append(" <div>bar HTML element</div>");
- b.append(" </g:cell>");
- b.append(" </g:row>");
- b.append(" <g:row>");
- b.append(" <g:customCell>");
- b.append(" <g:Label/>");
- b.append(" </g:customCell>");
- b.append(" <g:customCell>");
- b.append(" <g:Label/>");
- b.append(" </g:customCell>");
- b.append(" </g:row>");
- b.append("</g:Grid>");
-
- String[] expected = {
- "fieldName.resize(2, 2);",
- "fieldName.setHTML(0, 0, \"<div>foo HTML element</div>\");",
- "fieldName.setHTML(0, 1, \"<div>bar HTML element</div>\");",
- "fieldName.setWidget(1, 0, <g:Label>);",
- "fieldName.setWidget(1, 1, <g:Label>);" };
-
- FieldWriter w = tester.parse(b.toString());
- assertNull(w.getInitializer());
-
- Iterator<String> i = tester.writer.statements.iterator();
- for (String e : expected) {
- assertEquals(e, i.next());
- }
- assertFalse(i.hasNext());
- assertNull(tester.logger.died);
- }
-
- public void testValidChildWithDifferentNumberOfElementsInRows() throws UnableToCompleteException, SAXException {
- StringBuffer b = new StringBuffer();
- b.append("<g:Grid>");
- b.append(" <g:row>");
- b.append(" <g:cell>");
- b.append(" <div>foo HTML element</div>");
- b.append(" </g:cell>");
- b.append(" </g:row>");
- b.append(" <g:row>");
- b.append(" <g:customCell>");
- b.append(" <g:Label/>");
- b.append(" </g:customCell>");
- b.append(" <g:customCell>");
- b.append(" <g:Label/>");
- b.append(" </g:customCell>");
- b.append(" </g:row>");
- b.append("</g:Grid>");
-
- String[] expected = {
- "fieldName.resize(2, 2);",
- "fieldName.setHTML(0, 0, \"<div>foo HTML element</div>\");",
- "fieldName.setWidget(1, 0, <g:Label>);",
- "fieldName.setWidget(1, 1, <g:Label>);" };
-
- FieldWriter w = tester.parse(b.toString());
- assertNull(w.getInitializer());
-
- Iterator<String> i = tester.writer.statements.iterator();
- for (String e : expected) {
- assertEquals(e, i.next());
- }
- assertFalse(i.hasNext());
- assertNull(tester.logger.died);
- }
-
-}
diff --git a/user/test/com/google/gwt/uibinder/test/UiJavaResources.java b/user/test/com/google/gwt/uibinder/test/UiJavaResources.java
index 2c5f426..c832935 100644
--- a/user/test/com/google/gwt/uibinder/test/UiJavaResources.java
+++ b/user/test/com/google/gwt/uibinder/test/UiJavaResources.java
@@ -106,17 +106,6 @@
return code;
}
};
- public static final MockJavaResource GRID = new MockJavaResource(
- "com.google.gwt.user.client.ui.Grid") {
- @Override
- protected CharSequence getContent() {
- StringBuffer code = new StringBuffer();
- code.append("package com.google.gwt.user.client.ui;\n");
- code.append("public class Grid extends Widget {\n");
- code.append("}\n");
- return code;
- }
- };
public static final MockJavaResource GWT_EVENT = new MockJavaResource(
"com.google.gwt.event.shared.GwtEvent") {
@Override
@@ -388,7 +377,6 @@
rtn.add(DIALOG_BOX);
rtn.add(DOCK_LAYOUT_PANEL);
rtn.add(EVENT_HANDLER);
- rtn.add(GRID);
rtn.add(GWT_EVENT);
rtn.add(IMAGE);
rtn.add(IMAGE_RESOURCE);
diff --git a/user/test/com/google/gwt/uibinder/test/client/UiBinderTest.java b/user/test/com/google/gwt/uibinder/test/client/UiBinderTest.java
index b2d0d8d..21d4f7c 100644
--- a/user/test/com/google/gwt/uibinder/test/client/UiBinderTest.java
+++ b/user/test/com/google/gwt/uibinder/test/client/UiBinderTest.java
@@ -26,7 +26,6 @@
import com.google.gwt.resources.client.CssResource.NotStrict;
import com.google.gwt.uibinder.test.client.EnumeratedLabel.Suffix;
import com.google.gwt.user.client.DOM;
-import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DisclosurePanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HTMLPanel;
@@ -294,13 +293,6 @@
assertEquals("named portions", widgetUi.spanInMsg.getInnerText());
}
- public void testGrid() {
- assertTrue(widgetUi.fooGrid.getWidget(0, 0) instanceof Label);
- assertTrue(widgetUi.fooGrid.getWidget(0, 1) instanceof Button);
- assertEquals(2, widgetUi.fooGrid.getColumnCount());
- assertEquals(1, widgetUi.fooGrid.getRowCount());
- }
-
public void testListBox() {
assertEquals(2, widgetUi.fooListBox.getItemCount());
assertEquals("bar", widgetUi.fooListBox.getItemText(0));
diff --git a/user/test/com/google/gwt/uibinder/test/client/WidgetBasedUi.java b/user/test/com/google/gwt/uibinder/test/client/WidgetBasedUi.java
index 26c605c..7d32103 100644
--- a/user/test/com/google/gwt/uibinder/test/client/WidgetBasedUi.java
+++ b/user/test/com/google/gwt/uibinder/test/client/WidgetBasedUi.java
@@ -33,7 +33,6 @@
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.DisclosurePanel;
-import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.HasHTML;
@@ -161,7 +160,6 @@
@UiField HTML styleLess;
@UiField FooDialog fooDialog;
@UiField ListBox fooListBox;
- @UiField Grid fooGrid;
public WidgetBasedUi() {
external.style().ensureInjected();
diff --git a/user/test/com/google/gwt/uibinder/test/client/WidgetBasedUi.ui.xml b/user/test/com/google/gwt/uibinder/test/client/WidgetBasedUi.ui.xml
index 4765035..b95743a 100644
--- a/user/test/com/google/gwt/uibinder/test/client/WidgetBasedUi.ui.xml
+++ b/user/test/com/google/gwt/uibinder/test/client/WidgetBasedUi.ui.xml
@@ -593,26 +593,19 @@
<tr><td>Lately, anyway.</td></tr>
</gwt:HTMLPanel>
- <gwt:DialogBox autoHide="true" modal="true">
- <gwt:caption>Hello, I <b>caption</b> you.</gwt:caption>
- <gwt:HTMLPanel>
- And your little dog, too!
- <gwt:Button ui:field='cancel'>Cancel</gwt:Button>
- <gwt:Button ui:field='ok'>Okay</gwt:Button>
- </gwt:HTMLPanel>
- </gwt:DialogBox>
+ <gwt:DialogBox autoHide="true" modal="true">
+ <gwt:caption>Hello, I <b>caption</b> you.</gwt:caption>
+ <gwt:HTMLPanel>
+ And your little dog, too!
+ <gwt:Button ui:field='cancel'>Cancel</gwt:Button>
+ <gwt:Button ui:field='ok'>Okay</gwt:Button>
+ </gwt:HTMLPanel>
+ </gwt:DialogBox>
- <gwt:ListBox ui:field='fooListBox'>
- <gwt:item>bar</gwt:item>
- <gwt:item value='bar2'>bar 2</gwt:item>
- </gwt:ListBox>
-
- <gwt:Grid ui:field='fooGrid'>
- <gwt:row>
- <gwt:customCell><gwt:Label>foo</gwt:Label></gwt:customCell>
- <gwt:customCell><gwt:Button>bar</gwt:Button></gwt:customCell>
- </gwt:row>
- </gwt:Grid>
+ <gwt:ListBox ui:field='fooListBox'>
+ <gwt:item>bar</gwt:item>
+ <gwt:item value='bar2'>bar 2</gwt:item>
+ </gwt:ListBox>
</gwt:HTMLPanel>
</gwt:Dock>