List of usage examples for com.google.gwt.dom.client NodeList getLength
public int getLength()
From source file:com.xemantic.tadedon.gwt.user.client.ui.TablePanel.java
License:Apache License
public void addRow(IsWidget rowWidget) { if (!(rowWidget.asWidget().getElement().cast() instanceof TableRowElement)) { throw new IllegalArgumentException("rowWidget's root element must be instance of TableRowElement"); }/*from w w w . j a v a 2 s .c om*/ TableElement table = getElement().cast(); NodeList<TableSectionElement> tBodies = table.getTBodies(); if ((tBodies != null) && (tBodies.getLength() > 0)) { TableSectionElement tbody = tBodies.getItem(0); add(rowWidget.asWidget(), tbody); } else { add(rowWidget.asWidget(), getElement()); } }
From source file:com.xpn.xwiki.wysiwyg.client.widget.RadioButton.java
License:Open Source License
/** * Sets the value attribute of this radio button. * //from w w w.java2s .c o m * @param value the value to set for this radio button. */ public void setValue(String value) { NodeList<Element> innerInputList = this.getElement().getElementsByTagName(INPUT_TAG_NAME); if (innerInputList.getLength() > 0) { Element wrappedInput = innerInputList.getItem(0); wrappedInput.setAttribute(VALUE_ATTR_NAME, value); } }
From source file:com.xpn.xwiki.wysiwyg.client.widget.RadioButton.java
License:Open Source License
/** * @return the value attribute of this radio button. *//*from w w w . j av a 2 s .co m*/ public String getValue() { NodeList<Element> innerInputList = this.getElement().getElementsByTagName(INPUT_TAG_NAME); if (innerInputList.getLength() > 0) { Element wrappedInput = innerInputList.getItem(0); return wrappedInput.getAttribute(VALUE_ATTR_NAME); } return ""; }
From source file:cz.cas.lib.proarc.webapp.client.ClientUtils.java
License:Open Source License
/** * 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!!! * /*from www.j av a 2 s.co m*/ * @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; }
From source file:de.catma.ui.client.ui.tagger.editor.TaggerEditor.java
License:Open Source License
public void removeTagInstance(String tagInstanceID, boolean reportToServer) { int currentPartID = 1; Element taggedSpan = Document.get().getElementById(tagInstanceID + "_" + currentPartID++); while (taggedSpan != null) { Element parent = taggedSpan.getParentElement(); DebugUtil.printNode(taggedSpan); NodeList<Node> children = taggedSpan.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node child = children.getItem(i); parent.insertBefore(child.cloneNode(true), taggedSpan); }//from w ww . ja v a 2 s.c om parent.removeChild(taggedSpan); taggedSpan = Document.get().getElementById(tagInstanceID + "_" + currentPartID++); } tagInstances.remove(tagInstanceID); lastTagInstanceIDs.remove(tagInstanceID); taggerEditorListener.tagChanged(TaggerEditorEventType.REMOVE, tagInstanceID, reportToServer); }
From source file:de.catma.ui.client.ui.tagger.editor.TaggerEditor.java
License:Open Source License
public void setHTML(HTML pageHtmlContent) { if (getElement().hasChildNodes()) { NodeList<Node> children = getElement().getChildNodes(); for (int i = 0; i < children.getLength(); i++) { getElement().removeChild(children.getItem(i)); }// ww w. j av a 2s .c o m } getElement().appendChild(pageHtmlContent.getElement()); tagInstances.clear(); }
From source file:de.eckhartarnold.client.ImageCollectionReader.java
License:Apache License
/** * Reads the information about the image collection from several json files * contained in the <code>baseURL</code> directory. * When the json files have finished loading <code>readyReport</code> is * issued. If any error occurs it is reported via <code>errorReport</code>. * For error reporting the class <code>ImageCollectionInfo</code> offers * two stock objects: <code>ERROR_DIALOG</code> and <code>ERROR_SILET</code>, * the first of which reports the error in a pop up dialog, while the other * simply ignores the error (dangerous!). * /* www .j a v a 2s . c o m*/ * @param baseURL the base URL of the image collection * @param readyReport the callback that is to be issued when loading the * information about the image collection is ready. * @param errorReport the callback for reporting errors. */ public ImageCollectionReader(String baseURL, ICallback readyReport, IMessage errorReport) { // Element info = DOM.getElementById("info"); NodeList<Element> metaTags = Document.get().getElementsByTagName("meta"); this.infoFileName = "info.json"; int length = metaTags.getLength(); for (int i = 0; i < length; i++) { Element item = metaTags.getItem(i); if (item.getAttribute("name").equalsIgnoreCase(METANAME_INFO)) { this.infoFileName = item.getAttribute("content"); break; } } retrieveSequentially(baseURL, readyReport, errorReport); }
From source file:de.ga_ap.cirrus.newcloud.client.TheCloud.java
License:Open Source License
public TheCloud(final Element cloudContainer) { final NodeList<Element> aElements = cloudContainer.getElementsByTagName("A"); final int height = cloudContainer.getOffsetHeight(); final int width = cloudContainer.getOffsetWidth(); final Canvas canvas = Canvas.createIfSupported(); canvas.setCoordinateSpaceHeight(height); canvas.setCoordinateSpaceWidth(width); final Context2d context2d = canvas.getContext2d(); final double radius = canvas.getCanvasElement().getHeight() / 3; final int refreshrate = 30; final List<CloudItem> itemList = new ArrayList<CloudItem>(aElements.getLength()); for (int i = 0; i < aElements.getLength(); i++) { final Element el = aElements.getItem(i); final CloudItem ci = new CloudItem(); ci.text = el.getInnerText();//from w w w.j a v a 2 s . co m itemList.add(ci); } cloudContainer.setInnerText(""); final int itemListSize = itemList.size(); for (int i = 1; i <= itemListSize; i++) { final CloudItem ci = itemList.get(i - 1); ci.theta = Math.acos(-1.0 + (2.0 * (double) i - 1.0) / itemListSize); ci.phi = Math.sqrt(itemListSize * Math.PI) * ci.theta; ci.z = radius * Math.cos(ci.theta); ci.y = radius * Math.sin(ci.theta) * Math.cos(ci.phi); ci.x = radius * Math.sin(ci.theta) * Math.sin(ci.phi); // TODO heightOfAllItems ?! // TODO font size context2d.fillText(ci.text, ci.y, ci.z); System.out.println(ci.x + " " + ci.y + " " + ci.z + " - " + ci.theta + " " + ci.phi); } Scheduler.get().scheduleFixedPeriod(new RepeatingCommand() { @Override public boolean execute() { canvas.setCoordinateSpaceHeight(height); canvas.setCoordinateSpaceWidth(width); final double cosPsi = Math.cos(psi); final double sinPsi = Math.sin(psi); final double cosTheta = Math.cos(theta); final double sinTheta = Math.sin(theta); final double sinThetaCosPsi = sinTheta * cosPsi; final double sinThetaSinPsi = sinTheta * sinPsi; for (final CloudItem ci : itemList) { final double x, y, z; x = ci.x * cosTheta * cosPsi + ci.y * cosTheta * sinPsi - ci.z * sinTheta; y = ci.x * (-sinPsi) + ci.y * cosPsi; z = ci.x * sinThetaCosPsi + ci.y * sinThetaSinPsi + ci.z * cosTheta; ci.x = x; ci.y = y; ci.z = z; context2d.setGlobalAlpha(0.7 + ci.x / radius / 3.0); context2d.setFont("20pt Arial"); context2d.fillText(ci.text, radius + ci.y, radius + ci.z); // System.out.println(ci.x + " " + ci.y + " " + ci.z + " - " // + ci.theta + " " + ci.phi + " " + ci.text); } theta += ySteps; psi += xSteps; // System.out.println(theta); if (theta > Math.PI * 2.0) { theta = 0.0; } if (psi > Math.PI * 2.0) { psi = 0.0; } return true; } }, refreshrate); // final EventListener listener = new EventListener() { // // @Override // public void onBrowserEvent(final Event event) { // if (event.getTypeInt() == Event.ONMOUSEMOVE) { // moveSteps(event); // } else if (event.getTypeInt() == Event.ONTOUCHMOVE) { // event.preventDefault(); // prevents the default behavior of // // a page when touching // moveSteps(event); // } // } // // private void moveSteps(final Event event) { // ySteps = -((event.getClientY() + Window.getScrollTop()) // / canvas.getCoordinateSpaceHeight() * 0.000002 - 0.1) / 2.0; // xSteps = ((event.getClientX() + Window.getScrollLeft()) // / canvas.getCoordinateSpaceWidth() * 0.000002 - 0.1) / 2.0; // } // }; // // DOM.setEventListener( // (com.google.gwt.user.client.Element) cloudContainer, listener); // DOM.sinkEvents((com.google.gwt.user.client.Element) cloudContainer, // Event.ONMOUSEMOVE + Event.ONTOUCHMOVE); System.out.println(radius); cloudContainer.appendChild(canvas.getCanvasElement()); }
From source file:de.swm.commons.mobile.client.SWMMobile.java
License:Apache License
/** * Returns the head./*from w ww. j a v a2 s . c o m*/ * * @return the head of the host page. */ private static Element getHead() { NodeList<Element> elementsByTagName = Document.get().getElementsByTagName("head"); if (elementsByTagName.getLength() != 1) { throw new RuntimeException("there is no head element"); } return elementsByTagName.getItem(0); }
From source file:de.swm.commons.mobile.client.widgets.scroll.ScrollPanel.java
License:Apache License
/** * Returns the height of the given element. If the element has a height of 0 it searches * recursively for the height of the next visible child (e.g. the next visible slide of a * SliderPanel).//w w w . ja va2 s .c om * * @param element parent element * @return height of the element of a visible child */ private int getHeightOfElementOrChildElements(Element element) { if (this.offsetHeight > 0) { return this.offsetHeight; } // current element has height? Return this height. if (element.getOffsetHeight() != 0) { return element.getOffsetHeight(); } // current element is hidden? no height for this element. if (element.getStyle().getVisibility().equals("hidden") || element.getStyle().getDisplay().equals("none")) { return 0; } // search children for height NodeList<Node> children = element.getChildNodes(); if (children.getLength() == 0) { return 0; } int height = 0; for (int i = 0; i < children.getLength(); i++) { Node currentNode = children.getItem(i); if (currentNode instanceof Element) { height = getHeightOfElementOrChildElements((Element) currentNode); } if (height != 0) { return height; } } return 0; }