]> source.dussan.org Git - gwtquery.git/commitdiff
adding a new method to widgets utils
authorManolo Carrasco <manolo@apache.org>
Thu, 17 Mar 2011 10:31:39 +0000 (10:31 +0000)
committerManolo Carrasco <manolo@apache.org>
Thu, 17 Mar 2011 10:31:39 +0000 (10:31 +0000)
gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/WidgetsUtils.java

index a4d35ed633677b015e488deb831765ff456aa0ae..ef247fac348223d65f23f07d9b9cbd9efc8f77da 100644 (file)
@@ -76,6 +76,16 @@ public class WidgetsUtils {
     }
    }
    
+   private static void hideAndAppend(Element oldElement, Element newElement) {
+     assert oldElement != null && newElement != null;
+     GQuery.$(oldElement).hide().after(newElement);
+     String c = oldElement.getClassName();
+     if (!c.isEmpty()) {
+       newElement.addClassName(c);
+     }
+    }
+
+   
    /**
     * Replace a dom element by a widget.
     * Old element classes will be copied to the new widget.
@@ -86,5 +96,16 @@ public class WidgetsUtils {
      replaceOrAppend(e, widget.getElement());
      GqUi.attachWidget(widget);
    }
+
+   /**
+    * Append a widget to a dom element, and hide it.
+    * Element classes will be copied to the new widget.
+    */
+   public static void hideAndAppend(Element e, Widget widget)  {
+     assert e != null && widget != null;
+     GqUi.detachWidget(widget);
+     hideAndAppend(e, widget.getElement());
+     GqUi.attachWidget(widget);
+   }
   
 }