List of usage examples for com.google.gwt.dom.client Node appendChild
@Override
public <T extends Node> T appendChild(T newChild)
From source file:com.dom_distiller.client.NodeTree.java
License:Open Source License
public Node cloneSubtree() { Node clone = node.cloneNode(false); for (NodeTree child : children) { clone.appendChild(child.cloneSubtree()); }//from w ww. j a v a 2 s . com return clone; }
From source file:com.dom_distiller.client.NodeTree.java
License:Open Source License
/** * Clone this subtree while retaining text directionality from its computed style. The * "dir" attribute for each node will be set for each node. * * @return The root node of the cloned tree *//*from ww w .jav a 2s. co m*/ public Node cloneSubtreeRetainDirection() { Node clone = node.cloneNode(false); if (node.getNodeType() == Node.ELEMENT_NODE) { String direction = DomUtil.getComputedStyle(Element.as(node)).getProperty("direction"); Element.as(clone).setAttribute("dir", direction); } for (NodeTree child : children) { clone.appendChild(child.cloneSubtreeRetainDirection()); } return clone; }
From source file:com.extjs.gxt.ui.client.widget.ListView.java
License:sencha.com license
protected void onAdd(List<M> models, int index) { if (rendered) { if (all.getCount() == 0) { refresh();/*from ww w.j a v a 2 s . c o m*/ return; } NodeList<Element> nodes = bufferRender(models); Element[] elements = Util.toElementArray(nodes); all.insert(elements, index); Element ref = index == 0 ? all.getElement(elements.length) : all.getElement(index - 1); for (int i = elements.length - 1; i >= 0; i--) { Node n = ref.getParentNode(); if (index == 0) { n.insertBefore(elements[i], n.getFirstChild()); } else { Node next = ref == null ? null : ref.getNextSibling(); if (next == null) { n.appendChild(elements[i]); } else { n.insertBefore(elements[i], next); } } if (GXT.isAriaEnabled()) { elements[i].setId(XDOM.getUniqueId()); } } updateIndexes(index, -1); } }
From source file:com.horaz.client.widgets.Button.java
License:Open Source License
public void appendTo(Node lastChild) { lastChild.appendChild(getElement()); _init(getElement()); }
From source file:com.vaadin.client.ui.window.WindowConnector.java
License:Apache License
private Node cloneNodeFilteringMedia(Node node) { if (node instanceof Element) { Element old = (Element) node; if ("audio".equalsIgnoreCase(old.getTagName()) || "video".equalsIgnoreCase(old.getTagName())) { if (!old.hasAttribute("controls") && "audio".equalsIgnoreCase(old.getTagName())) { return null; // nothing to animate, so we won't add this to // the clone }//ww w .j a v a 2 s . com Element newEl = DOM.createElement(old.getTagName()); if (old.hasAttribute("controls")) { newEl.setAttribute("controls", old.getAttribute("controls")); } if (old.hasAttribute("style")) { newEl.setAttribute("style", old.getAttribute("style")); } if (old.hasAttribute("class")) { newEl.setAttribute("class", old.getAttribute("class")); } return newEl; } } Node res = node.cloneNode(false); if (node.hasChildNodes()) { NodeList<Node> nl = node.getChildNodes(); for (int i = 0; i < nl.getLength(); i++) { Node clone = cloneNodeFilteringMedia(nl.getItem(i)); if (clone != null) { res.appendChild(clone); } } } return res; }
From source file:com.vaadin.client.WidgetUtil.java
License:Apache License
/** * Detaches and re-attaches the element from its parent. The element is * reattached at the same position in the DOM as it was before. * //w w w . ja v a2 s .c o m * Does nothing if the element is not attached to the DOM. * * @param element * The element to detach and re-attach */ public static void detachAttach(Element element) { if (element == null) { return; } Node nextSibling = element.getNextSibling(); Node parent = element.getParentNode(); if (parent == null) { return; } parent.removeChild(element); if (nextSibling == null) { parent.appendChild(element); } else { parent.insertBefore(element, nextSibling); } }
From source file:de.swm.commons.mobile.client.widgets.CheckBox.java
License:Apache License
/** * Sets an image to be displayed as a label for the checkbox. * * @param imgRes ImageResource for the image to be displayed *///w w w . ja va 2s .c o m public void setImage(ImageResource imgRes) { Node labelElem = findLabelElement(); if (labelElem == null) { return; } if (imageNode != null) { labelElem.removeChild(imageNode); } Image img = new Image(imgRes); imageNode = img.getElement(); labelElem.appendChild(imageNode); }
From source file:org.chromium.distiller.NodeTree.java
License:Open Source License
/** * Clone this subtree while retaining text directionality from its computed style. The * "dir" attribute for each node will be set for each node. * * @return The root node of the cloned tree *//* w ww .j av a 2 s.co m*/ public Node cloneSubtreeRetainDirection() { Node clone = node.cloneNode(false); if (node.getNodeType() == Node.ELEMENT_NODE) { String direction = DomUtil.getComputedStyle(Element.as(node)).getProperty("direction"); if (direction.isEmpty()) { direction = "auto"; } Element.as(clone).setAttribute("dir", direction); } for (NodeTree child : children) { clone.appendChild(child.cloneSubtreeRetainDirection()); } return clone; }
From source file:org.chromium.distiller.TreeCloneBuilder.java
License:Open Source License
private static Node cloneChild(Node clone, Node newChild) { Node cl = cloneNode(newChild); clone.appendChild(cl); return cl;/*from w ww . j a v a 2s . co m*/ }
From source file:org.chromium.distiller.TreeCloneBuilder.java
License:Open Source License
private static Node cloneParent(Node clone, Node newParent) { Node p = clone.getParentNode(); if (p == null) { p = cloneNode(newParent);// www. jav a 2 s . c o m p.appendChild(clone); } return p; }