com.google.gwt.dom.client.NodeList Java Examples
The following examples show how to use
com.google.gwt.dom.client.NodeList.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NaluPluginGWT.java From nalu with Apache License 2.0 | 6 votes |
@Override public void updateMetaNameContent(String name, String content) { NodeList<Element> metaTagList = Document.get() .getElementsByTagName("meta"); for (int i = 0; i < metaTagList.getLength(); i++) { if (metaTagList.getItem(i) instanceof MetaElement) { MetaElement nodeListElement = (MetaElement) metaTagList.getItem(i); if (!Objects.isNull(nodeListElement.getName())) { if (nodeListElement.getName() .equals(name)) { nodeListElement.removeFromParent(); break; } } } } MetaElement metaElement = Document.get() .createMetaElement(); metaElement.setName("name"); metaElement.setContent("content"); Element headerElement = getHeaderNode(); if (!Objects.isNull(headerElement)) { headerElement.appendChild(metaElement); } }
Example #2
Source File: DomHelper.java From swellrt with Apache License 2.0 | 6 votes |
/** * Gets a list of descendants of e that match the given class name. * * If the browser has the native method, that will be called. Otherwise, it * traverses descendents of the given element and returns the list of elements * with matching classname. * * @param e * @param className */ public static NodeList<Element> getElementsByClassName(Element e, String className) { if (QuirksConstants.SUPPORTS_GET_ELEMENTS_BY_CLASSNAME) { return getElementsByClassNameNative(e, className); } else { NodeList<Element> all = e.getElementsByTagName("*"); if (all == null) { return null; } JsArray<Element> ret = JavaScriptObject.createArray().cast(); for (int i = 0; i < all.getLength(); ++i) { Element item = all.getItem(i); if (className.equals(item.getClassName())) { ret.push(item); } } return ret.cast(); } }
Example #3
Source File: DefaultThemeController.java From putnami-web-toolkit with GNU Lesser General Public License v3.0 | 6 votes |
/** * Removes all link tags in the head if not initialized. */ private void removeCssLinks() { if (this.isInit) { return; } this.isInit = true; // Remove all existing link element NodeList<Element> links = this.getHead().getElementsByTagName(LinkElement.TAG); int size = links.getLength(); for (int i = 0; i < size; i++) { LinkElement elem = LinkElement.as(links.getItem(0)); if ("stylesheet".equals(elem.getRel())) { elem.removeFromParent(); } } }
Example #4
Source File: TimelineWidget.java From gantt with Apache License 2.0 | 6 votes |
private Element getLastResolutionElement() { DivElement div = getResolutionDiv(); if (div == null) { return null; } NodeList<Node> nodeList = div.getChildNodes(); if (nodeList == null) { return null; } int blockCount = nodeList.getLength(); if (blockCount < 1) { return null; } if (containsResBlockSpacer()) { int index = blockCount - 2; if (blockCount > 1 && index >= 0) { return Element.as(getResolutionDiv().getChild(index)); } return null; } return Element.as(getResolutionDiv().getLastChild()); }
Example #5
Source File: HtmlAttributesExtensionConnector.java From cuba with Apache License 2.0 | 6 votes |
protected void withElement(String querySelector, Consumer<Element> action) { ServerConnector parent = getParent(); if (parent instanceof AbstractComponentConnector) { Widget widget = ((AbstractComponentConnector) parent).getWidget(); if (widget != null) { Element element = widget.getElement(); if (DEFAULT_SELECTOR.equals(querySelector)) { action.accept(element); } else { NodeList<Element> subElements = findSubElements(element, querySelector); for (int i = 0; i < subElements.getLength(); i++) { action.accept(subElements.getItem(i)); } } } } }
Example #6
Source File: DomHelper.java From incubator-retired-wave with Apache License 2.0 | 6 votes |
/** * Gets a list of descendants of e that match the given class name. * * If the browser has the native method, that will be called. Otherwise, it * traverses descendents of the given element and returns the list of elements * with matching classname. * * @param e * @param className */ public static NodeList<Element> getElementsByClassName(Element e, String className) { if (QuirksConstants.SUPPORTS_GET_ELEMENTS_BY_CLASSNAME) { return getElementsByClassNameNative(e, className); } else { NodeList<Element> all = e.getElementsByTagName("*"); if (all == null) { return null; } JsArray<Element> ret = JavaScriptObject.createArray().cast(); for (int i = 0; i < all.getLength(); ++i) { Element item = all.getItem(i); if (className.equals(item.getClassName())) { ret.push(item); } } return ret.cast(); } }
Example #7
Source File: CubaGridLayoutSlot.java From cuba with Apache License 2.0 | 6 votes |
@Nullable protected Element findElementByClassName(Element element, String className) { if (element == null) { return null; } if (element.getClassName().contains(className)) { return element; } NodeList<Node> childNodes = element.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { Node child = childNodes.getItem(i); if (child instanceof Element) { Element childElement = findElementByClassName((Element) child, className); if (childElement != null) { return childElement; } } } return null; }
Example #8
Source File: DateCell.java From calendar-component with Apache License 2.0 | 6 votes |
private void clearSelectionRange() { if (eventRangeStart > -1) { // clear all "selected" class names Element main = getElement(); NodeList<Node> nodes = main.getChildNodes(); for (int i = 0; i <= 47; i++) { Element c = (Element) nodes.getItem(i); if (c == null) { continue; } c.removeClassName("v-daterange"); } eventRangeStart = -1; } }
Example #9
Source File: Clipboard.java From incubator-retired-wave with Apache License 2.0 | 5 votes |
private String maybeGetAttributeFromContainer(Element srcContainer, String attribName) { NodeList<Element> elementsByClassName = DomHelper.getElementsByClassName(srcContainer, MAGIC_CLASSNAME); if (elementsByClassName != null && elementsByClassName.getLength() > 0) { return elementsByClassName.getItem(0).getAttribute(attribName); } return null; }
Example #10
Source File: TDialog.java From openchemlib-js with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void setStyle(String clz, String value) { NodeList<Element> list; list = querySelector(clz); for (int i = 0; i < list.getLength(); i++) { Element n = list.getItem(i); n.setAttribute("style", value); } }
Example #11
Source File: SelectBase.java From gwtbootstrap3-extras with Apache License 2.0 | 5 votes |
/** * Returns the item list. * * @return the item list */ public List<Option> getItems() { List<Option> selectedItems = new ArrayList<>(0); NodeList<OptionElement> items = selectElement.getOptions(); for (int i = 0; i < items.getLength(); i++) { OptionElement item = items.getItem(i); Option option = itemMap.get(item); if (option != null) selectedItems.add(option); } return selectedItems; }
Example #12
Source File: ContentBox.java From core with GNU Lesser General Public License v2.1 | 5 votes |
private void setIconClassname(String styleName) { NodeList<Element> i = dp.getElement().getElementsByTagName("i"); if (i.getLength() == 1) { Element iconElem = i.getItem(0); iconElem.setClassName(styleName); } }
Example #13
Source File: Header.java From core with GNU Lesser General Public License v2.1 | 5 votes |
public void highlight(String name) { toggleSubnavigation(name); com.google.gwt.user.client.Element target = linksPane.getElementById("header-links-ref"); if(target!=null) // TODO: i think this cannot happen, does it? { NodeList<Node> childNodes = target.getChildNodes(); for(int i=0; i<childNodes.getLength(); i++) { Node n = childNodes.getItem(i); if(Node.ELEMENT_NODE == n.getNodeType()) { Element element = (Element) n; if(element.getId().equals("header-"+name)) { element.addClassName("header-link-selected"); element.setAttribute("aria-selected", "true"); } else { element.removeClassName("header-link-selected"); element.setAttribute("aria-selected", "false"); } } } } }
Example #14
Source File: CsrfController.java From putnami-web-toolkit with GNU Lesser General Public License v3.0 | 5 votes |
private void init() { NodeList<Element> tags = Document.get().getElementsByTagName("meta"); for (int i = 0; i < tags.getLength(); i++) { MetaElement metaTag = (MetaElement) tags.getItem(i); String metaName = metaTag.getName(); String metaContent = metaTag.getContent(); if (META_NAME_CSRF_TOKEN.equals(metaName) && !Strings.isNullOrEmpty(metaContent)) { this.token = metaContent; } if (META_NAME_CSRF_HEADER.equals(META_NAME_CSRF_HEADER) && !Strings.isNullOrEmpty(metaContent)) { this.header = metaContent; } } }
Example #15
Source File: SelectorDisplayerView.java From dashbuilder with Apache License 2.0 | 5 votes |
@Override public void setItemTitle(int index, String title) { SelectElement selectElement = SelectElement.as(listBox.getElement()); NodeList<OptionElement> options = selectElement.getOptions(); OptionElement optionElement = options.getItem(index + (hintEnabled ? 1: 0)); if (optionElement != null) { optionElement.setTitle(title); } }
Example #16
Source File: SelectorDisplayerView.java From dashbuilder with Apache License 2.0 | 5 votes |
protected void showHint(String hint) { if (hintEnabled) { SelectElement selectElement = SelectElement.as(listBox.getElement()); NodeList<OptionElement> options = selectElement.getOptions(); options.getItem(0).setText(hint); } else { listBox.addItem(hint); hintEnabled = true; } }
Example #17
Source File: GroupedListBox.java From swcv with MIT License | 5 votes |
protected OptGroupElement findOptGroupElement(String name) { if (name == null) return null; NodeList<Element> optgroups = getElement().getElementsByTagName("OPTGROUP"); for (int i = 0; i < optgroups.getLength(); i++) { Element optgroup = optgroups.getItem(i); if (isMatchingGroup(optgroup, name)) { return OptGroupElement.as(optgroup); } } return null; }
Example #18
Source File: Clipboard.java From swellrt with Apache License 2.0 | 5 votes |
private String maybeGetAttributeFromContainer(Element srcContainer, String attribName) { NodeList<Element> elementsByClassName = DomHelper.getElementsByClassName(srcContainer, MAGIC_CLASSNAME); if (elementsByClassName != null && elementsByClassName.getLength() > 0) { return elementsByClassName.getItem(0).getAttribute(attribName); } return null; }
Example #19
Source File: NaluPluginGWT.java From nalu with Apache License 2.0 | 5 votes |
@Override public void updateMetaPropertyContent(String property, String content) { NodeList<Element> metaTagList = Document.get() .getElementsByTagName("meta"); for (int i = 0; i < metaTagList.getLength(); i++) { if (metaTagList.getItem(i) instanceof MetaElement) { MetaElement nodeListElement = (MetaElement) metaTagList.getItem(i); if (!Objects.isNull(nodeListElement.getAttribute("property"))) { if (nodeListElement.getAttribute("property") .equals(property)) { nodeListElement.removeFromParent(); break; } } } } MetaElement metaElement = Document.get() .createMetaElement(); metaElement.setAttribute("property", property); metaElement.setContent("content"); Element headerElement = getHeaderNode(); if (!Objects.isNull(headerElement)) { headerElement.appendChild(metaElement); } }
Example #20
Source File: WrappingGridConnector.java From GridExtensionPack with Apache License 2.0 | 5 votes |
private Element[] getGridParts(String elem) { NodeList<Element> elems = grid.getElement().getElementsByTagName(elem); Element[] ary = new Element[elems.getLength()]; for (int i = 0; i < ary.length; ++i) { ary[i] = elems.getItem(i); } return ary; }
Example #21
Source File: WrappingGridConnector.java From GridExtensionPack with Apache License 2.0 | 5 votes |
private Element[] getGridParts(String elem, Element parent) { NodeList<Element> elems = parent.getElementsByTagName(elem); Element[] ary = new Element[elems.getLength()]; for (int i = 0; i < ary.length; ++i) { ary[i] = elems.getItem(i); } return ary; }
Example #22
Source File: ClientUtils.java From proarc with GNU General Public License v3.0 | 5 votes |
/** * Dumps Element content and traverse its children. * <p/><b>WARNING:</b> it is com.google.gwt.dom.client.Element not com.google.gwt.xml.client.Element!!! * * @param elm an element to dump * @param indent row indentation for current level * @param indentIncrement increment for next level * @param sb dumped content * @return dumped content */ public static StringBuilder dump(Element elm, String indent, String indentIncrement, StringBuilder sb) { int childCount = elm.getChildCount(); String innerText = elm.getInnerText(); String lang = elm.getLang(); String nodeName = elm.getNodeName(); short nodeType = elm.getNodeType(); String getString = elm.getString(); String tagNameWithNS = elm.getTagName(); String xmlLang = elm.getAttribute("xml:lang"); sb.append(ClientUtils.format("%sElement {nodeName: %s, nodeType: %s, tagNameWithNS: %s, lang: %s," + " childCount: %s, getString: %s, xmlLang: %s}\n", indent, nodeName, nodeType, tagNameWithNS, lang, childCount, getString, xmlLang)); NodeList<Node> childNodes = elm.getChildNodes(); indent += indentIncrement; for (int i = 0; i < childNodes.getLength(); i++) { Node child = childNodes.getItem(i); if (Element.is(child)) { dump(Element.as(child), indent, indentIncrement, sb); } else { sb.append(ClientUtils.format("%sNode: nodeType: %s, nodeName: %s, childCount: %s, nodeValue: %s\n", indent, child.getNodeType(), child.getNodeName(), child.getChildCount(), child.getNodeValue())); } } return sb; }
Example #23
Source File: DOMHelper.java From gwt-material with Apache License 2.0 | 5 votes |
public static Element getElementByAttribute(NodeList<Element> elems, String attr, String value) { if (elems != null) { for (int i = 0; i < elems.getLength(); i++) { Element child = elems.getItem(i); if (child.getAttribute(attr).equals(value)) { return child; } } } return null; }
Example #24
Source File: IframeCoverUtility.java From cuba with Apache License 2.0 | 5 votes |
/** * Adds iframe covers for all child iframe elements * * @param rootElement * The parent element * @return A set of elements with the iframe covers */ private static Set<Element> addIframeCovers(Element rootElement) { Set<Element> coveredIframes = new HashSet<Element>(); NodeList<com.google.gwt.dom.client.Element> iframes = rootElement .getElementsByTagName("iframe"); for (int i = 0; i < iframes.getLength(); i++) { Element iframe = (Element) iframes.getItem(i); addIframeCover(iframe); coveredIframes.add(iframe); } return coveredIframes; }
Example #25
Source File: CubaFieldGroupLayoutConnector.java From cuba with Apache License 2.0 | 5 votes |
@Nullable protected com.google.gwt.dom.client.Element findCaptionTextChildElement(Element captionElement) { NodeList<Node> childNodes = captionElement.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { Node child = childNodes.getItem(i); if (child instanceof com.google.gwt.dom.client.Element && ((com.google.gwt.dom.client.Element) child).getClassName().contains(CAPTIONTEXT_STYLENAME)) { return (com.google.gwt.dom.client.Element) child; } } return null; }
Example #26
Source File: DemoGwtWebApp.java From demo-gwt-springboot with Apache License 2.0 | 5 votes |
private void addMetaElements() { logger.info("Add viewport"); MetaElement element = Document.get().createMetaElement(); element.setName("viewport"); element.setContent("width=device-width, initial-scale=1.0"); NodeList<Element> node = Document.get().getElementsByTagName("head"); Element elementHead = node.getItem(0); elementHead.appendChild(element); }
Example #27
Source File: DomHelper.java From swellrt with Apache License 2.0 | 4 votes |
private static native NodeList<Element> getElementsByClassNameNative( Element e, String className) /*-{ return e.getElementsByClassName(className); }-*/;
Example #28
Source File: Client.java From unitime with Apache License 2.0 | 4 votes |
public final native static NodeList<Element> getElementsByName(String name) /*-{ return $doc.getElementsByName(name); }-*/;
Example #29
Source File: Client.java From unitime with Apache License 2.0 | 4 votes |
public void onModuleLoadDeferred() { // register triggers GWT.runAsync(new RunAsyncCallback() { @Override public void onSuccess() { for (Triggers t: Triggers.values()) t.register(); callGwtOnLoadIfExists(); } @Override public void onFailure(Throwable reason) { } }); // load page if (RootPanel.get("UniTimeGWT:Body") != null) { LoadingWidget.getInstance().show(MESSAGES.waitLoadingPage()); Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override public void execute() { initPageAsync(Window.Location.getParameter("page")); } }); } // load components for (final Components c: Components.values()) { final RootPanel p = RootPanel.get(c.id()); if (p != null) { Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override public void execute() { initComponentAsync(p, c); } }); } if (p == null && c.isMultiple()) { NodeList<Element> x = getElementsByName(c.id()); if (x != null && x.getLength() > 0) for (int i = 0; i < x.getLength(); i++) { Element e = x.getItem(i); e.setId(DOM.createUniqueId()); final RootPanel q = RootPanel.get(e.getId()); Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override public void execute() { initComponentAsync(q, c); } }); } } } Window.addWindowClosingHandler(new Window.ClosingHandler() { @Override public void onWindowClosing(Window.ClosingEvent event) { if (isLoadingDisplayed() || LoadingWidget.getInstance().isShowing()) return; LoadingWidget.showLoading(MESSAGES.waitPlease()); iPageLoadingTimer = new Timer() { @Override public void run() { RPC.execute(new IsSessionBusyRpcRequest(), new AsyncCallback<GwtRpcResponseBoolean>() { @Override public void onFailure(Throwable caught) { LoadingWidget.hideLoading(); } @Override public void onSuccess(GwtRpcResponseBoolean result) { if (result.getValue()) { iPageLoadingTimer.schedule(500); } else { LoadingWidget.hideLoading(); } } }); } }; iPageLoadingTimer.schedule(500); } }); }
Example #30
Source File: HtmlAttributesExtensionConnector.java From cuba with Apache License 2.0 | 4 votes |
private static native NodeList<Element> findSubElements(Element parent, String querySelector) /*-{ return parent.querySelectorAll(querySelector); }-*/;