Revision: 8726
Author: m...@google.com
Date: Tue Sep  7 12:42:09 2010
Log: Change UiBinder Message generation to use consistent examples for HTML and Widget placeholders to facilitate sharing of messages with embedded HTML elements or widgets.

Review at http://gwt-code-reviews.appspot.com/838801

Review by: rj...@google.com
http://code.google.com/p/google-web-toolkit/source/detail?r=8726

Modified:
/trunk/user/src/com/google/gwt/uibinder/elementparsers/HtmlPlaceholderInterpreter.java /trunk/user/src/com/google/gwt/uibinder/elementparsers/WidgetPlaceholderInterpreter.java

=======================================
--- /trunk/user/src/com/google/gwt/uibinder/elementparsers/HtmlPlaceholderInterpreter.java Fri Apr 2 06:00:38 2010 +++ /trunk/user/src/com/google/gwt/uibinder/elementparsers/HtmlPlaceholderInterpreter.java Tue Sep 7 12:42:09 2010
@@ -31,6 +31,10 @@
  * {...@link XMLElement#consumeInnerHtml}.)
  */
 class HtmlPlaceholderInterpreter extends PlaceholderInterpreter {
+
+  private static final String EXAMPLE_OPEN_TAG = "<tag>";
+  private static final String EXAMPLE_CLOSE_TAG = "</tag>";
+
   private int serial = 0;
   private final XMLElement.Interpreter<String> fieldAndComputed;

@@ -57,8 +61,7 @@

       String openTag = elem.consumeOpeningTag();
       String openPlaceholder =
-          nextPlaceholder(name + "Begin", stripTokens(openTag),
-              uiWriter.detokenate(openTag));
+ nextOpenPlaceholder(name + "Begin", uiWriter.detokenate(openTag));

       /*
* This recursive innerHtml call has already been escaped. Hide it in a
@@ -67,8 +70,7 @@
       String body = tokenator.nextToken(elem.consumeInnerHtml(this));

       String closeTag = elem.getClosingTag();
-      String closePlaceholder =
-          nextPlaceholder(name + "End", closeTag, closeTag);
+ String closePlaceholder = nextClosePlaceholder(name + "End", closeTag);

       return openPlaceholder + body + closePlaceholder;
     }
@@ -81,6 +83,24 @@
       throws UnableToCompleteException {
     return elem.consumeInnerHtml(fieldAndComputed);
   }
+
+  /**
+ * Returns the {...@link #nextPlaceholder(String, String, String)}, using the + * given {...@code name} and {...@code value} and a standard opening tag as example
+   * text.
+   */
+  protected String nextOpenPlaceholder(String name, String value) {
+    return nextPlaceholder(name, EXAMPLE_OPEN_TAG, value);
+  }
+
+  /**
+ * Returns the {...@link #nextPlaceholder(String, String, String)}, using the + * given {...@code name} and {...@code value} and a standard closing tag as example
+   * text.
+   */
+  protected String nextClosePlaceholder(String name, String value) {
+    return nextPlaceholder(name, EXAMPLE_CLOSE_TAG, value);
+  }

   /**
* An element will require a placeholder if the user has called it out with a
=======================================
--- /trunk/user/src/com/google/gwt/uibinder/elementparsers/WidgetPlaceholderInterpreter.java Fri Apr 2 06:00:38 2010 +++ /trunk/user/src/com/google/gwt/uibinder/elementparsers/WidgetPlaceholderInterpreter.java Tue Sep 7 12:42:09 2010
@@ -127,15 +127,13 @@
   }

   private String genCloseTag(String name) {
-    String closePlaceholder =
-        nextPlaceholder(name + "End", "</span>", "</span>");
+ String closePlaceholder = nextClosePlaceholder(name + "End", "</span>");
     return closePlaceholder;
   }

   private String genOpenTag(String name, String idHolder) {
     String openTag = String.format("<span id='\" + %s + \"'>", idHolder);
-    String openPlaceholder =
-        nextPlaceholder(name + "Begin", "<span>", openTag);
+    String openPlaceholder = nextOpenPlaceholder(name + "Begin", openTag);
     return openPlaceholder;
   }

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

Reply via email to