Revision: 9982
Author:   rj...@google.com
Date:     Tue Apr 12 13:51:55 2011
Log: Cherry picking r9980 into releases/2.3, remove half baked HtmlElementFactory

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

Deleted:
/releases/2.3/user/src/com/google/gwt/uibinder/rebind/GwtDomHtmlElementFactory.java /releases/2.3/user/src/com/google/gwt/uibinder/rebind/HtmlElementFactory.java
Modified:
 /releases/2.3/user/src/com/google/gwt/uibinder/UiBinder.gwt.xml
/releases/2.3/user/src/com/google/gwt/uibinder/rebind/UiBinderGenerator.java
 /releases/2.3/user/src/com/google/gwt/uibinder/rebind/UiBinderWriter.java
/releases/2.3/user/test/com/google/gwt/uibinder/elementparsers/ElementParserTester.java /releases/2.3/user/test/com/google/gwt/uibinder/elementparsers/MockUiBinderWriter.java

=======================================
--- /releases/2.3/user/src/com/google/gwt/uibinder/rebind/GwtDomHtmlElementFactory.java Wed Feb 9 13:31:48 2011
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright 2011 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.rebind;
-
-import com.google.gwt.core.ext.typeinfo.JClassType;
-import com.google.gwt.core.ext.typeinfo.TypeOracle;
-import com.google.gwt.dom.client.TagName;
-
-/**
- * Looks up implementation of DOM elements via @TagName interface in GWT DOM
- * package.
- */
-public class GwtDomHtmlElementFactory implements HtmlElementFactory {
-
- public JClassType findElementTypeForTag(String htmlTag, TypeOracle oracle) { - JClassType elementClass = oracle.findType("com.google.gwt.dom.client.Element");
-    JClassType[] types = elementClass.getSubtypes();
-    for (JClassType type : types) {
-      TagName annotation = type.getAnnotation(TagName.class);
-      if (annotation != null) {
-        for (String annotationTag : annotation.value()) {
-          if (annotationTag.equals(htmlTag)) {
-            return type;
-          }
-        }
-      }
-    }
-    return elementClass;
-  }
-}
=======================================
--- /releases/2.3/user/src/com/google/gwt/uibinder/rebind/HtmlElementFactory.java Wed Feb 9 13:31:48 2011
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright 2011 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.rebind;
-
-import com.google.gwt.core.ext.typeinfo.JClassType;
-import com.google.gwt.core.ext.typeinfo.TypeOracle;
-
-/**
- * Looks up html tag names and returns corresponding type used to represent
- * its bindings.
- */
-public interface HtmlElementFactory {
-   JClassType findElementTypeForTag(String htmlTag, TypeOracle oracle);
-}
=======================================
--- /releases/2.3/user/src/com/google/gwt/uibinder/UiBinder.gwt.xml Thu Apr 7 08:40:59 2011 +++ /releases/2.3/user/src/com/google/gwt/uibinder/UiBinder.gwt.xml Tue Apr 12 13:51:55 2011
@@ -19,10 +19,6 @@
   <source path="client"/>
   <source path="resources"/>

-  <!-- Pluggable factory for creating field types for HTML elements -->
- <define-configuration-property name="uibinder.html.elementfactory" is-multi-valued="false"/> - <set-configuration-property name="uibinder.html.elementfactory" value="com.google.gwt.uibinder.rebind.GwtDomHtmlElementFactory"/>
-
   <!-- Set this property to true to turn on UiBinder's new
   SafeHtmlTemplates integration. The default value will be true in
   future releases of GWT -->
=======================================
--- /releases/2.3/user/src/com/google/gwt/uibinder/rebind/UiBinderGenerator.java Thu Apr 7 08:40:59 2011 +++ /releases/2.3/user/src/com/google/gwt/uibinder/rebind/UiBinderGenerator.java Tue Apr 12 13:51:55 2011
@@ -16,7 +16,6 @@
 package com.google.gwt.uibinder.rebind;

 import com.google.gwt.core.ext.BadPropertyValueException;
-import com.google.gwt.core.ext.ConfigurationProperty;
 import com.google.gwt.core.ext.Generator;
 import com.google.gwt.core.ext.GeneratorContext;
 import com.google.gwt.core.ext.PropertyOracle;
@@ -145,7 +144,7 @@

UiBinderWriter uiBinderWriter = new UiBinderWriter(interfaceType, implName,
         templatePath, oracle, logger, new FieldManager(oracle, logger),
- messages, designTime, uiBinderCtx, getElementFactory(propertyOracle),
+        messages, designTime, uiBinderCtx,
         useSafeHtmlTemplates(logger, propertyOracle));

Document doc = getW3cDoc(logger, designTime, resourceOracle, templatePath);
@@ -162,20 +161,6 @@

     writerManager.commit();
   }
-
- private HtmlElementFactory getElementFactory(PropertyOracle propertyOracle) {
-    Class<?> elementFactoryClass;
-
-    try {
-      // TODO(cromwellian) finish this or get it out of here
-      ConfigurationProperty factoryProperty = propertyOracle
-          .getConfigurationProperty(ELEMENT_FACTORY_PROPERTY);
- elementFactoryClass = Class.forName(factoryProperty.getValues().get(0));
-      return (HtmlElementFactory) elementFactoryClass.newInstance();
-    } catch (Exception e) {
-      throw new RuntimeException(e);
-    }
-  }

private Document getW3cDoc(MortalLogger logger, DesignTimeUtils designTime,
       ResourceOracle resourceOracle, String templatePath)
=======================================
--- /releases/2.3/user/src/com/google/gwt/uibinder/rebind/UiBinderWriter.java Thu Apr 7 03:48:02 2011 +++ /releases/2.3/user/src/com/google/gwt/uibinder/rebind/UiBinderWriter.java Tue Apr 12 13:51:55 2011
@@ -19,6 +19,7 @@
 import com.google.gwt.core.ext.typeinfo.JClassType;
 import com.google.gwt.core.ext.typeinfo.JPackage;
 import com.google.gwt.core.ext.typeinfo.TypeOracle;
+import com.google.gwt.dom.client.TagName;
 import com.google.gwt.resources.client.ClientBundle;
 import com.google.gwt.uibinder.attributeparsers.AttributeParser;
 import com.google.gwt.uibinder.attributeparsers.AttributeParsers;
@@ -183,8 +184,6 @@
    */
   private final JClassType baseClass;

-  private final HtmlElementFactory elementFactory;
-
   /**
    * The name of the class we're creating, e.g. MyUiBinderImpl
    */
@@ -234,7 +233,7 @@
       String templatePath, TypeOracle oracle, MortalLogger logger,
       FieldManager fieldManager, MessagesWriter messagesWriter,
       DesignTimeUtils designTime, UiBinderContext uiBinderCtx,
-      HtmlElementFactory elementFactory, boolean useSafeHtmlTemplates)
+      boolean useSafeHtmlTemplates)
       throws UnableToCompleteException {
     this.baseClass = baseClass;
     this.implClassName = implClassName;
@@ -245,7 +244,6 @@
     this.messages = messagesWriter;
     this.designTime = designTime;
     this.uiBinderCtx = uiBinderCtx;
-    this.elementFactory = elementFactory;
     this.useSafeHtmlTemplates = useSafeHtmlTemplates;

     // Check for possible misuse 'GWT.create(UiBinder.class)'
@@ -817,7 +815,19 @@
    * Given a DOM tag name, return the corresponding JSO subclass.
    */
   private JClassType findDomElementTypeForTag(String tag) {
-    return elementFactory.findElementTypeForTag(tag, oracle);
+ JClassType elementClass = oracle.findType("com.google.gwt.dom.client.Element");
+    JClassType[] types = elementClass.getSubtypes();
+    for (JClassType type : types) {
+      TagName annotation = type.getAnnotation(TagName.class);
+      if (annotation != null) {
+        for (String annotationTag : annotation.value()) {
+          if (annotationTag.equals(tag)) {
+            return type;
+          }
+        }
+      }
+    }
+    return elementClass;
   }

   /**
=======================================
--- /releases/2.3/user/test/com/google/gwt/uibinder/elementparsers/ElementParserTester.java Wed Feb 9 13:31:48 2011 +++ /releases/2.3/user/test/com/google/gwt/uibinder/elementparsers/ElementParserTester.java Tue Apr 12 13:51:55 2011
@@ -30,8 +30,6 @@
 import com.google.gwt.uibinder.rebind.FieldManager;
 import com.google.gwt.uibinder.rebind.FieldWriter;
 import com.google.gwt.uibinder.rebind.MockMortalLogger;
-import com.google.gwt.uibinder.rebind.HtmlElementFactory;
-import com.google.gwt.uibinder.rebind.GwtDomHtmlElementFactory;
 import com.google.gwt.uibinder.rebind.W3cDomHelper;
 import com.google.gwt.uibinder.rebind.XMLElement;
 import com.google.gwt.uibinder.rebind.XMLElementProvider;
@@ -115,9 +113,8 @@
     MessagesWriter messages = new MessagesWriter(BINDER_URI, logger,
         templatePath, baseType.getPackage().getName(), implName);

-    HtmlElementFactory elementFactory = new GwtDomHtmlElementFactory();
writer = new MockUiBinderWriter(baseType, implName, templatePath, types,
-        logger, fieldManager, messages, elementFactory);
+        logger, fieldManager, messages);
     fieldManager.registerField(types.findType(parsedTypeName), FIELD_NAME);
     parsedType = types.findType(parsedTypeName);
   }
=======================================
--- /releases/2.3/user/test/com/google/gwt/uibinder/elementparsers/MockUiBinderWriter.java Thu Apr 7 03:48:02 2011 +++ /releases/2.3/user/test/com/google/gwt/uibinder/elementparsers/MockUiBinderWriter.java Tue Apr 12 13:51:55 2011
@@ -21,7 +21,6 @@
 import com.google.gwt.uibinder.rebind.DesignTimeUtilsStub;
 import com.google.gwt.uibinder.rebind.FieldManager;
 import com.google.gwt.uibinder.rebind.MortalLogger;
-import com.google.gwt.uibinder.rebind.HtmlElementFactory;
 import com.google.gwt.uibinder.rebind.UiBinderContext;
 import com.google.gwt.uibinder.rebind.UiBinderWriter;
 import com.google.gwt.uibinder.rebind.XMLElement;
@@ -32,31 +31,29 @@

 class MockUiBinderWriter extends UiBinderWriter {
   final List<String> statements = new ArrayList<String>();
-
-  public MockUiBinderWriter(JClassType baseClass, String implClassName,
-      String templatePath, TypeOracle oracle, MortalLogger logger,
-      FieldManager fieldManager, MessagesWriter messagesWriter,
-      HtmlElementFactory factory) throws UnableToCompleteException {
- super(baseClass, implClassName, templatePath, oracle, logger, fieldManager,
-          messagesWriter, DesignTimeUtilsStub.EMPTY, new UiBinderContext(),
-          factory, true);
+
+ public MockUiBinderWriter(JClassType baseClass, String implClassName, String templatePath,
+      TypeOracle oracle, MortalLogger logger, FieldManager fieldManager,
+      MessagesWriter messagesWriter) throws UnableToCompleteException {
+ super(baseClass, implClassName, templatePath, oracle, logger, fieldManager, messagesWriter,
+        DesignTimeUtilsStub.EMPTY, new UiBinderContext(), true);
   }

   @Override
   public void addStatement(String format, Object... args) {
     statements.add(String.format(format, args));
   }
-
+
   /**
-   * Mocked out version of the template declaration. Returns
-   * the template prefixed with "@mockToken-"
+   * Mocked out version of the template declaration. Returns the template
+   * prefixed with "@mockToken-"
    */
   public String declareTemplateCall(String html) {
     return "\"@mockToken-" + html + "\"";
   }
-
+
   @Override
   public String parseElementToField(XMLElement elem) {
     return elem.consumeOpeningTag();
-  }
-}
+  }
+}

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

Reply via email to