Reviewers: rjrjr,

Description:
Adding a missing addAndReplaceElement(IsWidget, Element) to HTMLPanel.

Review by: rj...@google.com

Please review this at http://gwt-code-reviews.appspot.com/1514805/

Affected files:
  M user/src/com/google/gwt/user/client/ui/HTMLPanel.java


Index: user/src/com/google/gwt/user/client/ui/HTMLPanel.java
===================================================================
--- user/src/com/google/gwt/user/client/ui/HTMLPanel.java       (revision 10510)
+++ user/src/com/google/gwt/user/client/ui/HTMLPanel.java       (working copy)
@@ -1,12 +1,12 @@
 /*
  * Copyright 2008 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
@@ -35,7 +35,7 @@
* A helper method for creating unique IDs for elements within dynamically- * generated HTML. This is important because no two elements in a document
    * should have the same id.
-   *
+   *
    * @return a new unique identifier
    */
   public static String createUniqueId() {
@@ -44,11 +44,11 @@

   /**
    * Creates an HTML panel that wraps an existing element.
-   *
+   *
* This element must already be attached to the document. If the element is
    * removed from the document, you must call
    * {@link RootPanel#detachNow(Widget)}.
-   *
+   *
    * @param element the element to be wrapped
    */
   public static HTMLPanel wrap(Element element) {
@@ -68,7 +68,7 @@
    * Creates an HTML panel with the specified HTML contents inside a DIV
* element. Any element within this HTML that has a specified id can contain a
    * child widget.
-   *
+   *
    * @param html the panel's HTML
    */
   public HTMLPanel(String html) {
@@ -80,12 +80,12 @@
     setElement(Document.get().createDivElement());
     getElement().setInnerHTML(html);
   }
-
+
   /**
    * Initializes the panel's HTML from a given {@link SafeHtml} object.
-   *
+   *
    * Similar to {@link #HTMLPanel(String)}
-   *
+   *
    * @param safeHtml the html to set.
    */
   public HTMLPanel(SafeHtml safeHtml) {
@@ -96,7 +96,7 @@
* Creates an HTML panel whose root element has the given tag, and with the * specified HTML contents. Any element within this HTML that has a specified
    * id can contain a child widget.
-   *
+   *
    * @param tag the tag of the root element
    * @param html the panel's HTML
    */
@@ -106,7 +106,7 @@
* innerHTML. <table> and <tbody> simply won't, the property is read only. * <p> will explode if you incorrectly try to put another <p> inside of it.
      * And who knows what else.
-     *
+     *
* However, if you cram a complete, possibly incorrect structure inside a * div, IE will swallow it gladly. So that's what we do here in the name of
      * IE robustification.
@@ -114,10 +114,10 @@
     StringBuilder b = new StringBuilder();
     b.append('<').append(tag).append('>').append(html);
     b.append("</").append(tag).append('>');
-
+
     // We could use the static hiddenDiv, but that thing is attached
     // to the document. The caller might not want that.
-
+
     DivElement scratchDiv = Document.get().createDivElement();
     scratchDiv.setInnerHTML(b.toString());
     setElement(scratchDiv.getFirstChildElement());
@@ -126,7 +126,7 @@

   /**
    * Construct a new {@link HTMLPanel} with the specified element.
-   *
+   *
    * @param elem the element at the root of the panel
    */
   private HTMLPanel(Element elem) {
@@ -135,7 +135,7 @@

   /**
    * Adds a child widget to the panel.
-   *
+   *
    * @param widget the widget to be added
    */
   @Override
@@ -146,7 +146,7 @@
   /**
    * Adds a child widget to the panel, contained within the HTML element
    * specified by a given id.
-   *
+   *
    * @param widget the widget to be added
    * @param id the id of the element within which it will be contained
    */
@@ -164,7 +164,7 @@
    * Adds a child widget to the panel, contained within an HTML
    * element.  It is up to the caller to ensure that the given element
    * is a child of this panel's root element.
-   *
+   *
    * @param widget the widget to be added
    * @param elem the element within which it will be contained
    */
@@ -175,7 +175,7 @@

   /**
    * Adds a child widget to the panel, replacing the HTML element.
-   *
+   *
    * @param widget the widget to be added
    * @param toReplace the element to be replaced by the widget
    */
@@ -183,10 +183,10 @@
     com.google.gwt.user.client.Element clientElem = toReplace.cast();
     addAndReplaceElement(widget, clientElem);
   }
-
+
   /**
    * Adds a child widget to the panel, replacing the HTML element.
-   *
+   *
    * @param widget the widget to be added
    * @param toReplace the element to be replaced by the widget
    * @deprecated use {@link #addAndReplaceElement(Widget, Element)}
@@ -245,21 +245,33 @@
     // Adopt.
     adopt(widget);
   }
-
+
   /**
    * Overloaded version for IsWidget.
-   *
+   *
    * @see #addAndReplaceElement(Widget,Element)
-   */
+   *
+   * @deprecated use {@link #addAndReplaceElement(IsWidget, Element)}
+   */
+  @Deprecated
   public void addAndReplaceElement(IsWidget widget,
       com.google.gwt.user.client.Element toReplace) {
-    this.addAndReplaceElement(widget.asWidget(),toReplace);
-  }
-
+    this.addAndReplaceElement(widget.asWidget(), toReplace);
+  }
+
+  /**
+   * Overloaded version for IsWidget.
+   *
+   * @see #addAndReplaceElement(Widget,Element)
+   */
+  public void addAndReplaceElement(IsWidget widget, Element toReplace) {
+    this.addAndReplaceElement(widget.asWidget(), toReplace);
+  }
+
   /**
* Adds a child widget to the panel, replacing the HTML element specified by a
    * given id.
-   *
+   *
    * @param widget the widget to be added
    * @param id the id of the element to be replaced by the widget
    */
@@ -269,26 +281,26 @@
     if (toReplace == null) {
       throw new NoSuchElementException(id);
     }
-
+
     addAndReplaceElement(widget, toReplace);
   }
-
+
   /**
    * Overloaded version for IsWidget.
-   *
+   *
    * @see #addAndReplaceElement(Widget,String)
    */
   public void addAndReplaceElement(IsWidget widget, String id) {
     this.addAndReplaceElement(widget.asWidget(), id);
   }
-
+
   /**
    * Finds an {@link Element element} within this panel by its id.
-   *
+   *
    * This method uses
* {@link com.google.gwt.dom.client.Document#getElementById(String)}, so the
    * id must still be unique within the document.
-   *
+   *
    * @param id the id of the element to be found
* @return the element with the given id, or <code>null</code> if none is found
    */
@@ -302,7 +314,7 @@
* element into a hidden DIV in the document's body. Attachment is necessary * to be able to use the native getElementById. The panel's element will be
    * re-attached to its original parent (if any) after the method returns.
-   *
+   *
    * @param id the id whose associated element is to be retrieved
    * @return the associated element, or <code>null</code> if none is found
    */


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

Reply via email to