From ae0f39d4abe15ed9690ac51c7e8e8a22fcf4a2db Mon Sep 17 00:00:00 2001 From: Manolo Carrasco Date: Thu, 17 Mar 2011 10:31:39 +0000 Subject: [PATCH] adding a new method to widgets utils --- .../client/plugins/widgets/WidgetsUtils.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) 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); + } } -- 2.39.5