From: Manolo Carrasco Date: Thu, 17 Mar 2011 10:31:39 +0000 (+0000) Subject: adding a new method to widgets utils X-Git-Tag: release-1.3.2~454 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ae0f39d4abe15ed9690ac51c7e8e8a22fcf4a2db;p=gwtquery.git adding a new method to widgets utils --- diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/WidgetsUtils.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/WidgetsUtils.java index a4d35ed6..ef247fac 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/WidgetsUtils.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/WidgetsUtils.java @@ -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); + } }