/** * Return the nth non null attached widget from the matched elements or null if there isn't any. */ public <W extends Widget> W widget(int n) { for (Element e : elements) { @SuppressWarnings("unchecked") W w = (W) getAssociatedWidget(e); if (w != null) { if (n == 0) { return w; } n--; } } return null; }
/** * return the list of attached widgets matching the query. */ public List<Widget> widgets() { List<Widget> widgets = new ArrayList<Widget>(); for (Element e : elements) { Widget w = getAssociatedWidget(e); if (w != null) { widgets.add(w); } } return widgets; }
@Deprecated public void f(com.google.gwt.user.client.Element e) { setElement(e); Widget w = e != null ? GQuery.getAssociatedWidget(e) : null; if (w != null) { loop = true; f(w); } else { f(); } }
/** * Override this for GQuery methods which loop over matched elements and * invoke a callback on each element. * * @param e takes a com.google.gwt.user.client.Element. * */ @Deprecated public Object f(com.google.gwt.user.client.Element e, int i) { setElement(e); setIndex(i); Widget w = GQuery.getAssociatedWidget(e); if (w != null) { f(w, i); } else { f(e.<com.google.gwt.dom.client.Element> cast()); } return null; }
/** * Removes all matched elements from the DOM and cleans their data and bound events if the value * of <code>clean</code> parameter is set to true. The <code> filter</code> parameter allows to * filter the matched set to remove. */ protected GQuery remove(String filter, boolean clean) { for (Element e : elements) { if (filter == null || $(e).filter(filter).length() == 1) { if (clean) { // clean data linked to the children // TODO: "*" fails in queryselectorall (webkit mobile) cleanGQData($("*", e).elements()); // clean data linked to the element itself cleanGQData(e); } Widget w = getAssociatedWidget(e); if (w != null) { w.removeFromParent(); } else { e.removeFromParent(); } } } return this; }
/** * Remove all child nodes from the set of matched elements. In the case of a document element, it * removes all the content You should call this method whenever you create a new iframe and you * want to add dynamic content to it. */ public GQuery empty() { for (Element e : elements) { if (e.getNodeType() == Element.DOCUMENT_NODE) { getStyleImpl().emptyDocument(e.<Document> cast()); } else { Node c = e.getFirstChild(); while (c != null) { removeData(c.<Element> cast(), null); WidgetsUtils.detachWidget(getAssociatedWidget(e)); EventsListener.clean(c.<Element> cast()); e.removeChild(c); c = e.getFirstChild(); } } } return this; }