Roll back HasAlignmentParser change due to test failures.
Patch by: bobv
Review by: jgw, sbrubaker (TBR)


git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@9245 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/uibinder/elementparsers/HasAlignmentParser.java b/user/src/com/google/gwt/uibinder/elementparsers/HasAlignmentParser.java
deleted file mode 100644
index 031088f..0000000
--- a/user/src/com/google/gwt/uibinder/elementparsers/HasAlignmentParser.java
+++ /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);
-  }
-}
diff --git a/user/src/com/google/gwt/uibinder/rebind/UiBinderWriter.java b/user/src/com/google/gwt/uibinder/rebind/UiBinderWriter.java
index e807ac6..2ae08f1 100644
--- a/user/src/com/google/gwt/uibinder/rebind/UiBinderWriter.java
+++ b/user/src/com/google/gwt/uibinder/rebind/UiBinderWriter.java
@@ -997,7 +997,6 @@
     addWidgetParser("Image");
     addWidgetParser("ListBox");
     addWidgetParser("Grid");
-    addWidgetParser("HasAlignment");
   }
 
   /**
diff --git a/user/test/com/google/gwt/uibinder/elementparsers/HasAlignmentParserTest.java b/user/test/com/google/gwt/uibinder/elementparsers/HasAlignmentParserTest.java
deleted file mode 100644
index 39bc0f4..0000000
--- a/user/test/com/google/gwt/uibinder/elementparsers/HasAlignmentParserTest.java
+++ /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);
-  }
-}
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 56ba5c4..7eee4f4 100644
--- a/user/test/com/google/gwt/uibinder/test/client/UiBinderTest.java
+++ b/user/test/com/google/gwt/uibinder/test/client/UiBinderTest.java
@@ -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
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 766ce98..b076e93 100644
--- a/user/test/com/google/gwt/uibinder/test/client/WidgetBasedUi.java
+++ b/user/test/com/google/gwt/uibinder/test/client/WidgetBasedUi.java
@@ -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;
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 b4d3710..f210d36 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
@@ -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>