List of usage examples for com.google.gwt.user.client.ui RootPanel detachOnWindowClose
public static void detachOnWindowClose(Widget widget)
From source file:com.akjava.gwt.html5.client.input.ColorBox.java
License:Apache License
/** * Creates a color widget that wraps an existing <input type='color'> * element./*from w w w . jav a2 s.c o m*/ * * 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 ColorBox wrap(Element element) { // Assert that the element is attached. assert Document.get().getBody().isOrHasChild(element); ColorBox color = new ColorBox(element); // Mark it attached and remember it for cleanup. color.onAttach(); RootPanel.detachOnWindowClose(color); return color; }
From source file:com.arcbees.chosen.client.gwt.ChosenListBox.java
License:Apache License
/** * Creates a ChosenListBox widget that wraps an existing <select> * element./*from w w w . j a v a2s. c o m*/ * <p/> * 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 * @return list box */ public static ChosenListBox wrap(Element element) { assert Document.get().getBody().isOrHasChild(element); ChosenListBox listBox = new ChosenListBox(element); listBox.onAttach(); RootPanel.detachOnWindowClose(listBox); return listBox; }
From source file:com.arcbees.gquery.tooltip.client.TooltipImpl.java
License:Apache License
private void attachWidget() { RootPanel.get().add(widget);//from ww w .j ava 2 s. c o m if (options.getWidgetContentProvider() != null) { RootPanel.detachOnWindowClose(widget.asWidget()); } RootPanel.get().getElement().removeChild(widget.asWidget().getElement()); }
From source file:com.cgxlib.xq.client.plugins.widgets.WidgetsUtils.java
License:Apache License
/** * Attach a widget to the GWT widget list. Normally used when XQ * creates widgets wrapping existing dom elements. * It does nothing if the widget is already attached to another widget. * * @param widget to attach/*from www . ja va2s .c om*/ * @param firstParentWidget the parent widget, * If it is null and it is not inside any other widget, we just add * the widget to the gwt detach list */ public static void attachWidget(Widget widget, Widget firstParentWidget) { if (widget != null && widget.getParent() == null) { if (firstParentWidget == null) { firstParentWidget = getFirstParentWidget(widget); if (firstParentWidget == null) { RootPanel.detachOnWindowClose(widget); widgetOnAttach(widget); } else { attachWidget(widget, firstParentWidget); } } else if (firstParentWidget instanceof HTMLPanel) { HTMLPanel h = (HTMLPanel) firstParentWidget; Element p = widget.getElement().getParentElement(); if (p != null) { h.add(widget, p); } else { h.add(widget); } } else if (firstParentWidget instanceof HasOneWidget) { ((HasOneWidget) firstParentWidget).setWidget(widget); } else if (firstParentWidget instanceof HasWidgets) { try { ((HasWidgets) firstParentWidget).add(widget); } catch (UnsupportedOperationException e) { // Some widgets like 'table' has no implementation of 'add(widget)' widgetSetParent(widget, firstParentWidget); } } else { widgetSetParent(widget, firstParentWidget); } } }
From source file:com.dianaui.universal.core.client.ui.gwt.SimpleCheckBox.java
License:Apache License
/** * Creates a SimpleCheckBox widget that wraps an existing <input * type='checkbox'> element./*from w ww. j a v a 2 s .co m*/ * This element must already be attached to the document. If the element is * removed from the document, you must call * {@link RootPanel#detachNow(com.google.gwt.user.client.ui.Widget)}. * * @param element the element to be wrapped */ public static SimpleCheckBox wrap(Element element) { // Assert that the element is attached. assert Document.get().getBody().isOrHasChild(element); SimpleCheckBox checkBox = new SimpleCheckBox(InputElement.as(element)); // Mark it attached and remember it for cleanup. checkBox.onAttach(); RootPanel.detachOnWindowClose(checkBox); return checkBox; }
From source file:com.dianaui.universal.core.client.ui.gwt.SimpleRadioButton.java
License:Apache License
/** * Creates a SimpleRadioButton widget that wraps an existing <input * type='radio'> element.//www .ja v a 2s. c o m * This element must already be attached to the document. If the element is * removed from the document, you must call * {@link RootPanel#detachNow(com.google.gwt.user.client.ui.Widget)}. * * @param element the element to be wrapped */ public static SimpleRadioButton wrap(Element element) { // Assert that the element is attached. assert Document.get().getBody().isOrHasChild(element); SimpleRadioButton radioButton = new SimpleRadioButton(InputElement.as(element)); // Mark it attached and remember it for cleanup. radioButton.onAttach(); RootPanel.detachOnWindowClose(radioButton); return radioButton; }
From source file:com.dianaui.universal.core.client.ui.TextArea.java
License:Apache License
/** * Creates a TextArea widget that wraps an existing <textarea> * element./*from www. ja v a 2s . co m*/ * 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 * @return TextArea object */ public static TextArea wrap(final Element element) { // Assert that the element is attached. assert Document.get().getBody().isOrHasChild(element); final TextArea textArea = new TextArea(element); // Mark it attached and remember it for cleanup. textArea.onAttach(); RootPanel.detachOnWindowClose(textArea); return textArea; }
From source file:com.extjs.gxt.ui.client.widget.Document.java
License:sencha.com license
/** * Returns the singleton instance.// ww w. j a va2 s .com * * @return the document */ public static Document get() { if (instance == null) { instance = new Document(); instance.setElement(XDOM.getDocument()); ComponentHelper.doAttach(instance); RootPanel.detachOnWindowClose(instance); } return instance; }
From source file:com.github.gwtbootstrap.client.ui.PasswordTextBox.java
License:Apache License
/** * Creates a PasswordTextBox widget that wraps an existing <input * type='password'> element./*from ww w. ja v a 2 s . c o m*/ * * 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 PasswordTextBox wrap(Element element) { // Assert that the element is attached. assert Document.get().getBody().isOrHasChild(element); PasswordTextBox textBox = new PasswordTextBox(element); // Mark it attached and remember it for cleanup. textBox.onAttach(); RootPanel.detachOnWindowClose(textBox); return textBox; }
From source file:com.github.gwtbootstrap.client.ui.TextArea.java
License:Apache License
/** * Creates a TextArea widget that wraps an existing <textarea> * element.//from w ww . j av a2 s. c o m * * 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 TextArea wrap(Element element) { // Assert that the element is attached. assert Document.get().getBody().isOrHasChild(element); TextArea textArea = new TextArea(element); // Mark it attached and remember it for cleanup. textArea.onAttach(); RootPanel.detachOnWindowClose(textArea); return textArea; }