Revision: 7180
Author: [email protected]
Date: Wed Nov 25 08:09:45 2009
Log: Merges trunk @7178 into releases/2.0
   Fixes CustomButton's ability to have body text in UiBinder
   merge --ignore-ancestry -c 7178  
https://google-web-toolkit.googlecode.com/svn/trunk .


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

Modified:
  /releases/2.0/branch-info.txt
   
/releases/2.0/user/src/com/google/gwt/uibinder/elementparsers/CustomButtonParser.java
   
/releases/2.0/user/test/com/google/gwt/uibinder/test/client/UiBinderTest.java
   
/releases/2.0/user/test/com/google/gwt/uibinder/test/client/WidgetBasedUi.java
   
/releases/2.0/user/test/com/google/gwt/uibinder/test/client/WidgetBasedUi.ui.xml

=======================================
--- /releases/2.0/branch-info.txt       Wed Nov 25 06:03:18 2009
+++ /releases/2.0/branch-info.txt       Wed Nov 25 08:09:45 2009
@@ -1067,3 +1067,7 @@
  trunk @7173 was merged into this branch
    Changing mentions of SOYC to Compile Report (in comments,
    documentation, and compiler output).
+
+trunk @7178 was merged into this branch
+  Fixes CustomButton's ability to have body text in UiBinder
+  merge --ignore-ancestry -c 7178  
https://google-web-toolkit.googlecode.com/svn/trunk .
=======================================
---  
/releases/2.0/user/src/com/google/gwt/uibinder/elementparsers/CustomButtonParser.java
    
Wed Nov 11 22:32:37 2009
+++  
/releases/2.0/user/src/com/google/gwt/uibinder/elementparsers/CustomButtonParser.java
    
Wed Nov 25 08:09:45 2009
@@ -1,12 +1,12 @@
  /*
   * Copyright 2007 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
@@ -19,6 +19,7 @@
  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.uibinder.rebind.XMLElement.Interpreter;
  import com.google.gwt.user.client.ui.Image;

  import java.util.HashSet;
@@ -41,39 +42,49 @@
      faceNames.add("downDisabledFace");
    }

-  public void parse(XMLElement elem, String fieldName, JClassType type,
-      UiBinderWriter writer) throws UnableToCompleteException {
-
-    // Parse children.
-    for (XMLElement child : elem.consumeChildElements()) {
-      // CustomButton can only contain Face elements.
-      String ns = child.getNamespaceUri();
-      String faceName = child.getLocalName();
-
-      if (!ns.equals(elem.getNamespaceUri())) {
-        writer.die("In %s, invalid child namespace: %s", elem, ns);
-      }
-      if (!faceNames.contains(faceName)) {
-        writer.die("In %s, invalid CustomButton face: %s:%s", elem, ns,  
faceName);
-      }
-
-      HtmlInterpreter interpreter =  
HtmlInterpreter.newInterpreterForUiObject(
-          writer, fieldName);
-      String innerHtml = child.consumeInnerHtml(interpreter);
-      if (innerHtml.length() > 0) {
-        writer.addStatement("%s.%s().setHTML(\"%s\");", fieldName,
-            faceNameGetter(faceName), innerHtml);
-      }
-
-      if (child.hasAttribute("image")) {
-        String image = child.consumeImageResourceAttribute("image");
-        writer.addStatement("%s.%s().setImage(new %s(%s));",
-            fieldName, faceNameGetter(faceName), IMAGE_CLASS, image);
-      }
-    }
+  public void parse(final XMLElement elem, final String fieldName,
+      JClassType type, final UiBinderWriter writer)
+      throws UnableToCompleteException {
+
+    /*
+     * Parse children. Use an interpreter to leave text in place for
+     * HasHTMLParser to find.
+     */
+    elem.consumeChildElements(new Interpreter<Boolean>() {
+      public Boolean interpretElement(XMLElement child)
+          throws UnableToCompleteException {
+        // CustomButton can only contain Face elements.
+        String ns = child.getNamespaceUri();
+        String faceName = child.getLocalName();
+
+        if (!ns.equals(elem.getNamespaceUri())) {
+          writer.die("In %s, invalid child namespace: %s", elem, ns);
+        }
+        if (!faceNames.contains(faceName)) {
+          writer.die("In %s, invalid CustomButton face: %s:%s", elem, ns,
+              faceName);
+        }
+
+        HtmlInterpreter interpreter =  
HtmlInterpreter.newInterpreterForUiObject(
+            writer, fieldName);
+        String innerHtml = child.consumeInnerHtml(interpreter);
+        if (innerHtml.length() > 0) {
+          writer.addStatement("%s.%s().setHTML(\"%s\");", fieldName,
+              faceNameGetter(faceName), innerHtml);
+        }
+
+        if (child.hasAttribute("image")) {
+          String image = child.consumeImageResourceAttribute("image");
+          writer.addStatement("%s.%s().setImage(new %s(%s));", fieldName,
+              faceNameGetter(faceName), IMAGE_CLASS, image);
+        }
+        return true; // We consumed it
+      }
+    });
    }

    private String faceNameGetter(String faceName) {
-    return "get" + faceName.substring(0, 1).toUpperCase() +  
faceName.substring(1);
+    return "get" + faceName.substring(0, 1).toUpperCase()
+        + faceName.substring(1);
    }
  }
=======================================
---  
/releases/2.0/user/test/com/google/gwt/uibinder/test/client/UiBinderTest.java   
 
Fri Nov 20 16:14:24 2009
+++  
/releases/2.0/user/test/com/google/gwt/uibinder/test/client/UiBinderTest.java   
 
Wed Nov 25 08:09:45 2009
@@ -178,6 +178,10 @@
      WidgetBasedUiExternalResources resources =  
GWT.create(WidgetBasedUiExternalResources.class);
      assertEquals(resources.style().tmText(),  
widgetUi.tmElement.getClassName());
    }
+
+  public void testCustomButtonBody() {
+    assertEquals("Hi mom", widgetUi.toggle.getText());
+  }

    public void testDomAccessAndComputedAttributeOnPlaceholderedElement() {
      WidgetBasedUiExternalResources resources =  
GWT.create(WidgetBasedUiExternalResources.class);
=======================================
---  
/releases/2.0/user/test/com/google/gwt/uibinder/test/client/WidgetBasedUi.java  
 
Mon Nov 16 11:27:22 2009
+++  
/releases/2.0/user/test/com/google/gwt/uibinder/test/client/WidgetBasedUi.java  
 
Wed Nov 25 08:09:45 2009
@@ -43,6 +43,7 @@
  import com.google.gwt.user.client.ui.PushButton;
  import com.google.gwt.user.client.ui.RadioButton;
  import com.google.gwt.user.client.ui.StackPanel;
+import com.google.gwt.user.client.ui.ToggleButton;
  import com.google.gwt.user.client.ui.Tree;
  import com.google.gwt.user.client.ui.Widget;

@@ -148,7 +149,8 @@
    FakeBundle3 legacyValuesForHtml = new FakeBundle3();
    @UiField Label bundledLabelLegacy;
    @UiField DivElement bundledDivLegacy;
-
+  @UiField ToggleButton toggle;
+
    public WidgetBasedUi() {
      external.style().ensureInjected();
      initWidget(binder.createAndBindUi(this));
=======================================
---  
/releases/2.0/user/test/com/google/gwt/uibinder/test/client/WidgetBasedUi.ui.xml
         
Tue Nov 17 15:22:47 2009
+++  
/releases/2.0/user/test/com/google/gwt/uibinder/test/client/WidgetBasedUi.ui.xml
         
Wed Nov 25 08:09:45 2009
@@ -533,6 +533,8 @@
          <gwt:downDisabledFace image='{prettyImage}'/>
        </gwt:PushButton>

+       <gwt:ToggleButton ui:field='toggle'>Hi mom</gwt:ToggleButton>
+
      <h2>How to use the debugId, addStyleNames, addDependentStyleNames  
attributes</h2>
      <p>You can use the <strong>debugId</strong>,  
<strong>addStyleNames</strong>, and <strong>addDependentStyleNames</strong>
         attributes on any widget that extends UIObject.

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

Reply via email to