Revision: 9245
Author: [email protected]
Date: Wed Nov 17 02:54:09 2010
Log: Roll back HasAlignmentParser change due to test failures.
Patch by: bobv
Review by: jgw, sbrubaker (TBR)

http://code.google.com/p/google-web-toolkit/source/detail?r=9245

Deleted:
/trunk/user/src/com/google/gwt/uibinder/elementparsers/HasAlignmentParser.java /trunk/user/test/com/google/gwt/uibinder/elementparsers/HasAlignmentParserTest.java
Modified:
 /trunk/user/src/com/google/gwt/uibinder/rebind/UiBinderWriter.java
 /trunk/user/test/com/google/gwt/uibinder/test/client/UiBinderTest.java
 /trunk/user/test/com/google/gwt/uibinder/test/client/WidgetBasedUi.java
 /trunk/user/test/com/google/gwt/uibinder/test/client/WidgetBasedUi.ui.xml

=======================================
--- /trunk/user/src/com/google/gwt/uibinder/elementparsers/HasAlignmentParser.java Tue Nov 16 10:15:45 2010
+++ /dev/null
@@ -1,79 +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 com.google.gwt.user.client.ui.HasHorizontalAlignment.HorizontalAlignmentConstant; -import com.google.gwt.user.client.ui.HasVerticalAlignment.VerticalAlignmentConstant;
-
-/**
- * Parses widgets that inherit from {...@link com.google.gwt.user.client.ui.HasAlignment}. - * This class is needed to resolve the parse order of alignment attributes for these
- * classes.
- * <p>
- *
- * See {...@link "http://code.google.com/p/google-web-toolkit/issues/detail?id=5518"} for
- * issue details.
- */
-public class HasAlignmentParser implements ElementParser {
-
-  /**
- * Parses widgets that inherit from {...@link com.google.gwt.user.client.ui.HasHorizontalAlignment}.
-   */
-  private class HasHorizontalAlignmentParser implements ElementParser {
-
-    public void parse(XMLElement elem, String fieldName, JClassType type,
-        UiBinderWriter writer) throws UnableToCompleteException {
-      JClassType hAlignConstantType = writer.getOracle().findType(
-          HorizontalAlignmentConstant.class.getCanonicalName());
-
- String horizontalAlignment = elem.consumeAttributeWithDefault("horizontalAlignment",
-          null, hAlignConstantType);
-
-      if (horizontalAlignment != null) {
- writer.addStatement("%s.setHorizontalAlignment(%s);", fieldName, horizontalAlignment);
-      }
-    }
-  }
-
-  /**
- * Parses widgets that inherit from {...@link com.google.gwt.user.client.ui.HasVerticalAlignment}.
-   */
-  private class HasVerticalAlignmentParser implements ElementParser {
-
-    public void parse(XMLElement elem, String fieldName, JClassType type,
-        UiBinderWriter writer) throws UnableToCompleteException {
-      JClassType vAlignConstantType = writer.getOracle().findType(
-          VerticalAlignmentConstant.class.getCanonicalName());
-
- String verticalAlignment = elem.consumeAttributeWithDefault("verticalAlignment",
-          null, vAlignConstantType);
-
-      if (verticalAlignment != null) {
- writer.addStatement("%s.setVerticalAlignment(%s);", fieldName, verticalAlignment);
-      }
-    }
-  }
-
-  public void parse(XMLElement elem, String fieldName, JClassType type,
-      UiBinderWriter writer) throws UnableToCompleteException {
-    new HasVerticalAlignmentParser().parse(elem, fieldName, type, writer);
- new HasHorizontalAlignmentParser().parse(elem, fieldName, type, writer);
-  }
-}
=======================================
--- /trunk/user/test/com/google/gwt/uibinder/elementparsers/HasAlignmentParserTest.java Tue Nov 16 10:15:45 2010
+++ /dev/null
@@ -1,97 +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 junit.framework.TestCase;
-
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-
-import java.io.IOException;
-import java.util.Iterator;
-
-/**
- * A unit test. Guess what of.
- */
-public class HasAlignmentParserTest extends TestCase {
- private static final String PARSED_TYPE = "com.google.gwt.user.client.ui.DockLayoutPanel";
-
-  private ElementParserTester tester;
-
-  @Override
-  public void setUp() throws Exception {
-    super.setUp();
- tester = new ElementParserTester(PARSED_TYPE, new HasAlignmentParser());
-  }
-
- public void testInvalidVerticalAlignment() throws SAXException, IOException {
-    StringBuffer b = new StringBuffer();
-    b.append("<g:DockLayoutPanel verticalAlignment='FOO'>");
-    b.append("</g:DockLayoutPanel>");
-
-    try {
-      tester.parse(b.toString());
-      fail();
-    } catch (UnableToCompleteException e) {
-      assertTrue("Expect vertical alignment parse error",
-          tester.logger.died.contains("Cannot parse value: \"FOO\""));
-    }
-  }
-
- public void testInvalidHorizontalAlignment() throws SAXException, IOException {
-    StringBuffer b = new StringBuffer();
-    b.append("<g:DockLayoutPanel horizontalAlignment='BAR'>");
-    b.append("</g:DockLayoutPanel>");
-
-    try {
-      tester.parse(b.toString());
-      fail();
-    } catch (UnableToCompleteException e) {
-      assertTrue("Expect horizontal alignment parse error",
-          tester.logger.died.contains("Cannot parse value: \"BAR\""));
-    }
-  }
-
- public void testNoAlignmentArgs() throws UnableToCompleteException, SAXParseException {
-    StringBuffer b = new StringBuffer();
-    b.append("<g:DockLayoutPanel>");
-    b.append("</g:DockLayoutPanel>");
-
-    tester.parse(b.toString());
-    assertTrue(tester.writer.statements.isEmpty());
-  }
-
- public void testValidArgs() throws UnableToCompleteException, SAXParseException {
-    StringBuffer b = new StringBuffer();
- b.append("<g:DockLayoutPanel verticalAlignment='ALIGN_MIDDLE' horizontalAlignment='ALIGN_LEFT'>");
-    b.append("</g:DockLayoutPanel>");
-
-    tester.parse(b.toString());
- assertStatements("fieldName.setVerticalAlignment(com.google.gwt.user.client.ui.HasVerticalAlignment.ALIGN_MIDDLE);",
-       
"fieldName.setHorizontalAlignment(com.google.gwt.user.client.ui.HasHorizontalAlignment.ALIGN_LEFT);");
-  }
-
-  private void assertStatements(String... expected) {
-    Iterator<String> i = tester.writer.statements.iterator();
-    for (String e : expected) {
-      assertEquals(e, i.next());
-    }
-    assertFalse(i.hasNext());
-    assertNull(tester.logger.died);
-  }
-}
=======================================
--- /trunk/user/src/com/google/gwt/uibinder/rebind/UiBinderWriter.java Tue Nov 16 10:15:45 2010 +++ /trunk/user/src/com/google/gwt/uibinder/rebind/UiBinderWriter.java Wed Nov 17 02:54:09 2010
@@ -997,7 +997,6 @@
     addWidgetParser("Image");
     addWidgetParser("ListBox");
     addWidgetParser("Grid");
-    addWidgetParser("HasAlignment");
   }

   /**
=======================================
--- /trunk/user/test/com/google/gwt/uibinder/test/client/UiBinderTest.java Tue Nov 16 10:15:45 2010 +++ /trunk/user/test/com/google/gwt/uibinder/test/client/UiBinderTest.java Wed Nov 17 02:54:09 2010
@@ -573,12 +573,6 @@
         "<td>Lately, anyway.</td>");
   }

-  public void testAlignmentAttributes() {
-    assertInOrder(widgetUi.myHorizontalPanel.getElement().getInnerHTML(),
-        "<td style=\"vertical-align: middle;\" align=\"left\">",
-        "class=\"gwt-StackPanelItem");
-  }
-
   /**
* Assert that the expect strings are found in body, and in the order given. * WARNING: both body and expected are normalized to lower case, to get around
=======================================
--- /trunk/user/test/com/google/gwt/uibinder/test/client/WidgetBasedUi.java Tue Nov 16 10:15:45 2010 +++ /trunk/user/test/com/google/gwt/uibinder/test/client/WidgetBasedUi.java Wed Nov 17 02:54:09 2010
@@ -38,7 +38,6 @@
 import com.google.gwt.user.client.ui.HTML;
 import com.google.gwt.user.client.ui.HTMLPanel;
 import com.google.gwt.user.client.ui.HasHTML;
-import com.google.gwt.user.client.ui.HorizontalPanel;
 import com.google.gwt.user.client.ui.Image;
 import com.google.gwt.user.client.ui.Label;
 import com.google.gwt.user.client.ui.ListBox;
@@ -98,7 +97,6 @@
   @UiField RadioButton myRadioAble;
   @UiField RadioButton myRadioBaker;
   @UiField StackPanel myStackPanel;
-  @UiField HorizontalPanel myHorizontalPanel;
   @UiField Widget myStackPanelItem;
   @UiField DisclosurePanel myDisclosurePanel;
   @UiField Widget myDisclosurePanelItem;
=======================================
--- /trunk/user/test/com/google/gwt/uibinder/test/client/WidgetBasedUi.ui.xml Tue Nov 16 10:15:45 2010 +++ /trunk/user/test/com/google/gwt/uibinder/test/client/WidgetBasedUi.ui.xml Wed Nov 17 02:54:09 2010
@@ -303,7 +303,7 @@
         <ui:attribute name="text" description="radio button name"/>
       </demo:PointlessRadioButtonSubclass>

- <gwt:HorizontalPanel ui:field="myHorizontalPanel" horizontalAlignment="ALIGN_LEFT" verticalAlignment="ALIGN_MIDDLE">
+        <gwt:HorizontalPanel horizontalAlignment="ALIGN_LEFT">
           <gwt:Cell><gwt:HTMLPanel>
       <p> ... a StackPanel ... </p>

--
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to