List of usage examples for com.google.gwt.dom.client NodeList getItem
public T getItem(int index)
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 ww w.j a va 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)); }// w w w . j ava 2 s.co 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!). * /*ww w . j av 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();/* w ww . j a v a 2 s . com*/ 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./* w w w. j a v a 2 s . c om*/ * * @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)./*from w w w . j av a 2s . 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; }
From source file:edu.arizona.biosemantics.gxt.theme.green.client.base.widget.Css3DatePickerAppearance.java
License:sencha.com license
@Override public void onUpdateDayOfWeeks(XElement parent, List<String> values) { NodeList<Element> elems = parent.select("." + style.columnHeaderInner()); for (int i = 0; i < elems.getLength(); i++) { elems.getItem(i).setInnerHTML(values.get(i)); }// w ww.jav a 2s .c o m }
From source file:edu.arizona.biosemantics.gxt.theme.green.client.sliced.tabs.SlicedTabPanelAppearance.java
License:sencha.com license
@Override public void onMouseOut(XElement parent, XElement target) { NodeList<Element> nodeList = parent.select("." + resources.style().tabStripOver()); for (int i = 0; i < nodeList.getLength(); i++) { nodeList.getItem(i).removeClassName(resources.style().tabStripOver()); }//from w w w. jav a 2 s . co m if (target.is("." + resources.style().tabScrollerLeft())) { target.removeClassName(resources.style().tabScrollerLeftOver()); } else if (target.is("." + resources.style().tabScrollerRight())) { target.removeClassName(resources.style().tabScrollerRightOver()); } }
From source file:edu.caltech.ipac.firefly.ui.GwtUtil.java
public static String getGwtProperty(String name) { final NodeList<com.google.gwt.dom.client.Element> meta = Document.get().getElementsByTagName("meta"); for (int i = 0; i < meta.getLength(); i++) { final MetaElement m = MetaElement.as(meta.getItem(i)); if (m != null && "gwt:property".equals(m.getName())) { String[] kv = m.getContent().split("=", 2); if (kv[0] != null && kv[0].equals(name)) { return kv.length > 1 ? kv[1] : ""; }/*from ww w.j ava 2s .c o m*/ } } return null; }
From source file:edu.caltech.ipac.firefly.ui.table.BasicPagingTable.java
private Element findElement(Element el, String value) { NodeList<com.google.gwt.dom.client.Element> nl = el.getElementsByTagName("td"); for (int i = 0; i < nl.getLength(); i++) { if (nl.getItem(i).getInnerText().equals(value)) { return (Element) nl.getItem(i); }//from w w w. j a v a2 s . c o m } return null; }