Revision: 10205
Author: rdcas...@google.com
Date: Mon May 23 17:23:56 2011
Log: Attachable->IsRenderable rename step 1: Renaming the base
interface.
Review at http://gwt-code-reviews.appspot.com/1447806
http://code.google.com/p/google-web-toolkit/source/detail?r=10205
Added:
/trunk/user/src/com/google/gwt/uibinder/elementparsers/IsRenderableInterpreter.java
/trunk/user/src/com/google/gwt/user/client/ui/IsRenderable.java
Deleted:
/trunk/user/src/com/google/gwt/uibinder/elementparsers/AttachableInterpreter.java
/trunk/user/src/com/google/gwt/user/client/ui/Attachable.java
Modified:
/trunk/user/src/com/google/gwt/uibinder/elementparsers/AttachableHTMLPanelParser.java
/trunk/user/src/com/google/gwt/uibinder/rebind/UiBinderWriter.java
/trunk/user/src/com/google/gwt/user/client/ui/AttachableComposite.java
/trunk/user/src/com/google/gwt/user/client/ui/AttachableHTMLPanel.java
=======================================
--- /dev/null
+++
/trunk/user/src/com/google/gwt/uibinder/elementparsers/IsRenderableInterpreter.java
Mon May 23 17:23:56 2011
@@ -0,0 +1,79 @@
+/*
+ * 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.elementparsers;
+
+import com.google.gwt.core.ext.UnableToCompleteException;
+import com.google.gwt.uibinder.rebind.FieldManager;
+import com.google.gwt.uibinder.rebind.FieldWriter;
+import com.google.gwt.uibinder.rebind.UiBinderWriter;
+import com.google.gwt.uibinder.rebind.XMLElement;
+
+/**
+ * Used by {@link AttachableHTMLPanelParser} to interpret renderable
elements.
+ * Declares the appropriate {@link IsRenderable}, and returns the correct
HTML
+ * to be inlined in the AttachableHTMLPanel.
+ */
+class IsRenderableInterpreter implements XMLElement.Interpreter<String> {
+
+ private final String fieldName;
+
+ private final UiBinderWriter uiWriter;
+
+ public IsRenderableInterpreter(String fieldName, UiBinderWriter writer) {
+ this.fieldName = fieldName;
+ this.uiWriter = writer;
+ assert writer.useLazyWidgetBuilders();
+ }
+
+ public String interpretElement(XMLElement elem)
+ throws UnableToCompleteException {
+ if (!uiWriter.isRenderableElement(elem)) {
+ return null;
+ }
+
+ String idHolder = uiWriter.declareDomIdHolder();
+ FieldManager fieldManager = uiWriter.getFieldManager();
+ FieldWriter fieldWriter = fieldManager.require(fieldName);
+
+ FieldWriter childFieldWriter =
uiWriter.parseElementToFieldWriter(elem);
+
+ String elementPointer = idHolder + "Element";
+ fieldWriter.addAttachStatement(
+ "com.google.gwt.user.client.Element %s = " +
+ "com.google.gwt.dom.client.Document.get().getElementById(%s).cast();",
+ elementPointer, fieldManager.convertFieldToGetter(idHolder));
+ fieldWriter.addAttachStatement(
+ "%s.wrapElement(%s);",
+ fieldManager.convertFieldToGetter(childFieldWriter.getName()),
+ elementPointer);
+
+ // Some operations are more efficient when the Widget isn't attached to
+ // the document. Perform them here.
+ fieldWriter.addDetachStatement(
+ "%s.performDetachedInitialization();",
+ fieldManager.convertFieldToGetter(childFieldWriter.getName()));
+
+ fieldWriter.addDetachStatement(
+ "%s.logicalAdd(%s);",
+ fieldManager.convertFieldToGetter(fieldName),
+ fieldManager.convertFieldToGetter(childFieldWriter.getName()));
+
+ // TODO(rdcastro): use the render() call that receives the
SafeHtmlBuilder
+ String elementHtml =
fieldManager.convertFieldToGetter(childFieldWriter.getName()) + ".render("
+ + fieldManager.convertFieldToGetter(idHolder) + ")";
+ return uiWriter.tokenForSafeHtmlExpression(elementHtml);
+ }
+}
=======================================
--- /dev/null
+++ /trunk/user/src/com/google/gwt/user/client/ui/IsRenderable.java Mon May
23 17:23:56 2011
@@ -0,0 +1,43 @@
+/*
+ * 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.user.client.ui;
+
+import com.google.gwt.dom.client.Element;
+import com.google.gwt.text.shared.SafeHtmlRenderer;
+
+/**
+ * An interface for UI elements that can be built by first generating a
piece
+ * of HTML and afterwards wrapping a root widget.
+ *
+ * This interface is very experimental and in active development, so the
exact
+ * API is likely to change. Very likely. In fact, it will definitely
change.
+ * You've been warned.
+ */
+public interface IsRenderable extends SafeHtmlRenderer<String> {
+
+ /**
+ * Replace the previous contents of the receiver with the given element,
+ * presumed to have been created via a previous call to {@link #render}.
+ * Assumes the element is attached to the document.
+ */
+ void wrapElement(Element element);
+
+ /**
+ * Perform any initialization needed when the widget is not attached to
+ * the document. Assumed to be called after {@link #wrapElement}.
+ */
+ void performDetachedInitialization();
+}
=======================================
---
/trunk/user/src/com/google/gwt/uibinder/elementparsers/AttachableInterpreter.java
Fri May 13 08:01:50 2011
+++ /dev/null
@@ -1,80 +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.elementparsers;
-
-import com.google.gwt.core.ext.UnableToCompleteException;
-import com.google.gwt.uibinder.rebind.FieldManager;
-import com.google.gwt.uibinder.rebind.FieldWriter;
-import com.google.gwt.uibinder.rebind.UiBinderWriter;
-import com.google.gwt.uibinder.rebind.XMLElement;
-
-/**
- * Used by {@link AttachableHTMLPanelParser} to interpret Attachable
elements.
- * Declares the appropriate Attachable, and returns the correct HTML
- * to be inlined in the AttachableHTMLPanel. If the Attachable happens to
be a
- * Widget, also adds that widget to the AttachableHTMLPanel.
- */
-class AttachableInterpreter implements XMLElement.Interpreter<String> {
-
- private final String fieldName;
-
- private final UiBinderWriter uiWriter;
-
- public AttachableInterpreter(String fieldName, UiBinderWriter writer) {
- this.fieldName = fieldName;
- this.uiWriter = writer;
- assert writer.useLazyWidgetBuilders();
- }
-
- public String interpretElement(XMLElement elem)
- throws UnableToCompleteException {
- if (!uiWriter.isAttachableElement(elem)) {
- return null;
- }
-
- String idHolder = uiWriter.declareDomIdHolder();
- FieldManager fieldManager = uiWriter.getFieldManager();
- FieldWriter fieldWriter = fieldManager.require(fieldName);
-
- FieldWriter childFieldWriter =
uiWriter.parseElementToFieldWriter(elem);
-
- String elementPointer = idHolder + "Element";
- fieldWriter.addAttachStatement(
- "com.google.gwt.user.client.Element %s = " +
- "com.google.gwt.dom.client.Document.get().getElementById(%s).cast();",
- elementPointer, fieldManager.convertFieldToGetter(idHolder));
- fieldWriter.addAttachStatement(
- "%s.wrapElement(%s);",
- fieldManager.convertFieldToGetter(childFieldWriter.getName()),
- elementPointer);
-
- // Some operations are more efficient when the Widget isn't attached to
- // the document. Perform them here.
- fieldWriter.addDetachStatement(
- "%s.performDetachedInitialization();",
- fieldManager.convertFieldToGetter(childFieldWriter.getName()));
-
- fieldWriter.addDetachStatement(
- "%s.logicalAdd(%s);",
- fieldManager.convertFieldToGetter(fieldName),
- fieldManager.convertFieldToGetter(childFieldWriter.getName()));
-
- // TODO(rdcastro): use the render() call that receives the
SafeHtmlBuilder
- String elementHtml =
fieldManager.convertFieldToGetter(childFieldWriter.getName()) + ".render("
- + fieldManager.convertFieldToGetter(idHolder) + ")";
- return uiWriter.tokenForSafeHtmlExpression(elementHtml);
- }
-}
=======================================
--- /trunk/user/src/com/google/gwt/user/client/ui/Attachable.java Wed Apr
27 13:54:04 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.user.client.ui;
-
-import com.google.gwt.dom.client.Element;
-import com.google.gwt.text.shared.SafeHtmlRenderer;
-
-/**
- * An interface for UI elements that can be built by first generating a
piece
- * of HTML and afterwards wrapping a root widget.
- *
- * This interface is very experimental and in active development, so the
exact
- * API is likely to change. Very likely. In fact, it will definitely
change.
- * You've been warned.
- */
-public interface Attachable extends SafeHtmlRenderer<String> {
-
- /**
- * Replace the previous contents of the receiver with the given element,
- * presumed to have been created via a previous call to {@link #render}.
- * Assumes the element is attached to the document.
- */
- void wrapElement(Element element);
-
- /**
- * Perform any initialization needed when the widget is not attached to
- * the document. Assumed to be called after {@link #wrapElement}.
- */
- void performDetachedInitialization();
-}
=======================================
---
/trunk/user/src/com/google/gwt/uibinder/elementparsers/AttachableHTMLPanelParser.java
Wed Apr 27 11:32:54 2011
+++
/trunk/user/src/com/google/gwt/uibinder/elementparsers/AttachableHTMLPanelParser.java
Mon May 23 17:23:56 2011
@@ -34,10 +34,10 @@
assert writer.useLazyWidgetBuilders();
/*
- * Gathers up elements that indicate nested Attachable objects.
+ * Gathers up elements that indicate nested IsRenderable objects.
*/
- AttachableInterpreter attachableInterpreter = null;
- attachableInterpreter = new AttachableInterpreter(
+ IsRenderableInterpreter isRenderableInterpreter = null;
+ isRenderableInterpreter = new IsRenderableInterpreter(
fieldName, writer);
/*
@@ -58,7 +58,7 @@
final InterpreterPipe interpreters;
interpreters = InterpreterPipe.newPipe(
- attachableInterpreter, widgetInterpreter, htmlInterpreter);
+ isRenderableInterpreter, widgetInterpreter, htmlInterpreter);
String html = elem.consumeInnerHtml(interpreters);
writer.endAttachedSection();
=======================================
--- /trunk/user/src/com/google/gwt/uibinder/rebind/UiBinderWriter.java Wed
May 4 09:28:35 2011
+++ /trunk/user/src/com/google/gwt/uibinder/rebind/UiBinderWriter.java Mon
May 23 17:23:56 2011
@@ -40,7 +40,7 @@
import com.google.gwt.uibinder.rebind.model.ImplicitCssResource;
import com.google.gwt.uibinder.rebind.model.OwnerClass;
import com.google.gwt.uibinder.rebind.model.OwnerField;
-import com.google.gwt.user.client.ui.Attachable;
+import com.google.gwt.user.client.ui.IsRenderable;
import com.google.gwt.user.client.ui.IsWidget;
import org.w3c.dom.Document;
@@ -199,7 +199,7 @@
private final JClassType uiRootType;
- private final JClassType attachableClassType;
+ private final JClassType isRenderableClassType;
private final JClassType lazyDomElementClass;
@@ -283,7 +283,7 @@
uiRootType = typeArgs[0];
uiOwnerType = typeArgs[1];
- attachableClassType =
oracle.findType(Attachable.class.getCanonicalName());
+ isRenderableClassType =
oracle.findType(IsRenderable.class.getCanonicalName());
lazyDomElementClass =
oracle.findType(LazyDomElement.class.getCanonicalName());
ownerClass = new OwnerClass(uiOwnerType, logger, uiBinderCtx);
@@ -691,9 +691,9 @@
return gwtPrefix + ":field";
}
- public boolean isAttachableElement(XMLElement elem)
+ public boolean isRenderableElement(XMLElement elem)
throws UnableToCompleteException {
- return findFieldType(elem).isAssignableTo(attachableClassType);
+ return findFieldType(elem).isAssignableTo(isRenderableClassType);
}
public boolean isBinderElement(XMLElement elem) {
=======================================
--- /trunk/user/src/com/google/gwt/user/client/ui/AttachableComposite.java
Thu May 5 12:19:19 2011
+++ /trunk/user/src/com/google/gwt/user/client/ui/AttachableComposite.java
Mon May 23 17:23:56 2011
@@ -32,8 +32,10 @@
* itself, but is still under active development.
* The only reason why this isn't a subclass of {@link Composite} is to
avoid
* messing up it's API, since {@link Composite} is very often subclassed.
+ *
+ * TODO(rdcastro): Rename this RenderableComposite.
*/
-public abstract class AttachableComposite extends Widget implements
Attachable {
+public abstract class AttachableComposite extends Widget implements
IsRenderable {
interface HTMLTemplates extends SafeHtmlTemplates {
@Template("<span id=\"{0}\"></span>")
@@ -44,7 +46,7 @@
private Widget widget;
- private Attachable attachable;
+ private IsRenderable attachable;
private Element elementToWrap;
@@ -156,10 +158,10 @@
// Logical attach.
this.widget = widget;
- if (widget instanceof Attachable) {
- // In case the Widget being wrapped is an Attachable, we delay
finishing
+ if (widget instanceof IsRenderable) {
+ // In case the Widget being wrapped is an IsRenderable, we delay
finishing
// the initialization until the performDetachedInitialization() is
called.
- this.attachable = (Attachable) widget;
+ this.attachable = (IsRenderable) widget;
return;
}
=======================================
--- /trunk/user/src/com/google/gwt/user/client/ui/AttachableHTMLPanel.java
Thu May 12 14:09:51 2011
+++ /trunk/user/src/com/google/gwt/user/client/ui/AttachableHTMLPanel.java
Mon May 23 17:23:56 2011
@@ -31,8 +31,10 @@
* should be merged into {@link HTMLPanel}.
* The only reason this class doesn't extend {@link HTMLPanel} is because
it
* doesn't provide any way to build the panel lazily (which is needed
here).
+ *
+ * TODO(rdcastro): Rename this RenderablePanel.
*/
-public class AttachableHTMLPanel extends ComplexPanel implements
Attachable {
+public class AttachableHTMLPanel extends ComplexPanel implements
IsRenderable {
private static Element hiddenDiv;
@@ -160,7 +162,7 @@
* No-op if called with an Attachable that isn't also IsWidget,
* but safe to call with such as a convenience.
*/
- public void logicalAdd(Attachable attachable) {
+ public void logicalAdd(IsRenderable attachable) {
if (!(attachable instanceof IsWidget)) {
// Nothing to do if not a Widget.
return;
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors