Revision: 10126
Author: [email protected]
Date: Mon May 2 12:51:01 2011
Log: Makes some private info from AttachableHTMLPanel accessible to
subclasses.
http://gwt-code-reviews.appspot.com/1423813/
http://code.google.com/p/google-web-toolkit/source/detail?r=10126
Modified:
/trunk/user/src/com/google/gwt/user/client/ui/AttachableHTMLPanel.java
=======================================
--- /trunk/user/src/com/google/gwt/user/client/ui/AttachableHTMLPanel.java
Fri Apr 29 05:43:32 2011
+++ /trunk/user/src/com/google/gwt/user/client/ui/AttachableHTMLPanel.java
Mon May 2 12:51:01 2011
@@ -62,7 +62,7 @@
public Command wrapInitializationCallback = null;
public Command detachedInitializationCallback = null;
- private SafeHtml html = null;
+ protected SafeHtml html = null;
private String styleName = null;
/**
@@ -140,7 +140,7 @@
@Override
public com.google.gwt.user.client.Element getElement() {
- if (html != null) {
+ if (!isFullyInitialized()) {
// In case we haven't finished initialization yet, finish it now.
buildAndInitDivContainer();
html = null;
@@ -182,16 +182,16 @@
@Override
public void render(String id, SafeHtmlBuilder builder) {
if (styleName != null) {
- builder.append(TEMPLATE.renderWithIdAndClass(id, styleName, html));
+ builder.append(TEMPLATE.renderWithIdAndClass(id, styleName,
getInnerHtml()));
styleName = null;
} else {
- builder.append(TEMPLATE.renderWithId(id, html));
+ builder.append(TEMPLATE.renderWithId(id, getInnerHtml()));
}
}
@Override
public void setStyleName(String styleName) {
- if (html != null) {
+ if (!isFullyInitialized()) {
// If we haven't built the actual HTML element yet, we save the style
// to apply later on.
this.styleName = styleName;
@@ -202,7 +202,7 @@
@Override
public void wrapElement(Element element) {
- if (html == null) {
+ if (!isFullyInitialized()) {
// NOTE(rdcastro): This code is only run when Attachable is in
active use.
element.getParentNode().replaceChild(getElement(), element);
} else {
@@ -215,6 +215,21 @@
wrapInitializationCallback = null;
}
}
+
+ /**
+ * Returns the HTML to be set as the innerHTML of the container.
+ */
+ protected SafeHtml getInnerHtml() {
+ return html;
+ }
+
+ /**
+ * Whether the initilization of the panel is finished (i.e., the
corresponding
+ * DOM element has been built).
+ */
+ protected boolean isFullyInitialized() {
+ return html == null;
+ }
/**
* Method that finishes the initialization of HTMLPanel instances built
from
@@ -224,7 +239,7 @@
private void buildAndInitDivContainer() {
// Build the div that'll container the panel's HTML.
Element element = Document.get().createDivElement();
- element.setInnerHTML(html.asString());
+ element.setInnerHTML(getInnerHtml().asString());
setElement(element);
// If there's any wrap callback to call, we have to attach the div
before
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors