/** * Inserts the node newChild after the existing child node refChild. If * refChild is <code>null</code>, insert newChild at the end of the list of children. * * @param newChild The node to insert * @param refChild The reference node (that is, the node after which the new * node must be inserted), or <code>null</code> * @return The node being inserted */ public final Node insertAfter(Node newChild, Node refChild) { assert (newChild != null) : "Cannot add a null child node"; Node next = (refChild == null) ? null : refChild.getNextSibling(); if (next == null) { return appendChild(newChild); } else { return insertBefore(newChild, next); } }
getHeadElement().appendChild(script);
/** * Adds the node <code>newChild</code> to the end of the list of children * of this node. If the <code>newChild</code> is already in the tree, it * is first removed. * @param newChild The node to add.If it is a * <code>DocumentFragment</code> object, the entire contents of the * document fragment are moved into the child list of this node * @return The node added. * @exception DOMException * HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not * allow children of the type of the <code>newChild</code> node, or if * the node to append is one of this node's ancestors or this node * itself, or if this node is of type <code>Document</code> and the * DOM application attempts to append a second * <code>DocumentType</code> or <code>Element</code> node. * <br>WRONG_DOCUMENT_ERR: Raised if <code>newChild</code> was created * from a different document than the one that created this node. * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly or * if the previous parent of the node being inserted is readonly. * <br>NOT_SUPPORTED_ERR: if the <code>newChild</code> node is a child * of the <code>Document</code> node, this exception might be raised * if the DOM implementation doesn't support the removal of the * <code>DocumentType</code> child or <code>Element</code> child. */ public final OMNode appendChild(OMNode newChild) throws JavaScriptException { ot.appendChild(newChild.ot); return newChild; }
public void characters(char[] ch, int start, int length) throws SAXException { String text = String.valueOf(ch, start, length).trim(); if (text.length() > 0) { currentNode.appendChild(document.createTextNode(text)); } }
public void characters(char[] ch, int start, int length) throws SAXException { String text = String.valueOf(ch, start, length).trim(); if (text.length() > 0) { currentNode.appendChild(document.createTextNode(text)); } }
@Override public void characters(char[] ch, int start, int length) { String string = String.valueOf(ch, start, length).replaceAll("\\u00A0", " "); if (string.length() > 0) { Text text = Document.get().createTextNode(string); if (currentNode != null) { currentNode.appendChild(text); } else { // root text node nodes.add(text); } } }
@Override public void characters(char[] ch, int start, int length) { String string = String.valueOf(ch, start, length).replaceAll("\\u00A0", " "); if (string.length() > 0) { Text text = Document.get().createTextNode(string); if (currentNode != null) { currentNode.appendChild(text); } else { // root text node nodes.add(text); } } }
public void startElement(String nameSpaceURI, String localName, String rawName, Attributes attributes) throws SAXException { Element element = document.createElement(localName); JavaScriptObjects.setProperty(element, JsoProperties.NODE_NAMESPACE_URI, nameSpaceURI); currentNode.appendChild(element); currentNode = element; Set<String> attrs = new LinkedHashSet<String>(); JavaScriptObjects.setProperty(element, JsoProperties.XML_ATTR_SET, attrs); for (int index = 0; index < attributes.getLength(); index++) { String attrName = attributes.getLocalName(index); String attrValue = attributes.getValue(index); element.setAttribute(attrName, attrValue); attrs.add(attrName); } }
public void startElement(String nameSpaceURI, String localName, String rawName, Attributes attributes) throws SAXException { Element element = document.createElement(localName); JavaScriptObjects.setProperty(element, JsoProperties.NODE_NAMESPACE_URI, nameSpaceURI); currentNode.appendChild(element); currentNode = element; Set<String> attrs = new LinkedHashSet<String>(); JavaScriptObjects.setProperty(element, JsoProperties.XML_ATTR_SET, attrs); for (int index = 0; index < attributes.getLength(); index++) { String attrName = attributes.getLocalName(index); String attrValue = attributes.getValue(index); element.setAttribute(attrName, attrValue); attrs.add(attrName); } }
/** * Inserts the node newChild after the existing child node refChild. If * refChild is <code>null</code>, insert newChild at the end of the list of children. * * @param newChild The node to insert * @param refChild The reference node (that is, the node after which the new * node must be inserted), or <code>null</code> * @return The node being inserted */ public final Node insertAfter(Node newChild, Node refChild) { assert (newChild != null) : "Cannot add a null child node"; Node next = (refChild == null) ? null : refChild.getNextSibling(); if (next == null) { return appendChild(newChild); } else { return insertBefore(newChild, next); } }
/** * Inserts the node newChild after the existing child node refChild. If * refChild is <code>null</code>, insert newChild at the end of the list of children. * * @param newChild The node to insert * @param refChild The reference node (that is, the node after which the new * node must be inserted), or <code>null</code> * @return The node being inserted */ public final Node insertAfter(Node newChild, Node refChild) { assert (newChild != null) : "Cannot add a null child node"; Node next = (refChild == null) ? null : refChild.getNextSibling(); if (next == null) { return appendChild(newChild); } else { return insertBefore(newChild, next); } }
@PatchMethod static JavaScriptObject appendChild(JavaScriptObject jsObject, JavaScriptObject newChildJs) { Node n = jsObject.cast(); Node newChildNode = newChildJs.cast(); return n.appendChild(newChildNode); }
@PatchMethod static JavaScriptObject appendChild(JavaScriptObject jsObject, JavaScriptObject newChildJs) { Node n = jsObject.cast(); Node newChildNode = newChildJs.cast(); return n.appendChild(newChildNode); }
getHeadElement().appendChild(script);
public void startElement(String nameSpaceURI, String localName, String rawName, Attributes attributes) throws SAXException { Element element = Document.get().createElement(localName); if (currentNode != null) { currentNode.appendChild(element); } else { // root node nodes.add(element); } currentNode = element; for (int index = 0; index < attributes.getLength(); index++) { String attrName = attributes.getLocalName(index); String attrValue = attributes.getValue(index); if ("style".equalsIgnoreCase(attrName)) { GwtStyleUtils.overrideStyle(element.getStyle(), attrValue); } else if ("class".equalsIgnoreCase(attrName)) { element.setClassName(attrValue); } else { element.setAttribute(attrName, attrValue); } } }
public void startElement(String nameSpaceURI, String localName, String rawName, Attributes attributes) throws SAXException { Element element = Document.get().createElement(localName); if (currentNode != null) { currentNode.appendChild(element); } else { // root node nodes.add(element); } currentNode = element; for (int index = 0; index < attributes.getLength(); index++) { String attrName = attributes.getLocalName(index); String attrValue = attributes.getValue(index); if ("style".equalsIgnoreCase(attrName)) { GwtStyleUtils.overrideStyle(element.getStyle(), attrValue); } else if ("class".equalsIgnoreCase(attrName)) { element.setClassName(attrValue); } else { element.setAttribute(attrName, attrValue); } } }
private static void cloneChildNodes(Node newNode, Node oldNode, boolean deep) { List<Node> childs = getChildNodeInnerList(oldNode); if (deep) { // copy all child nodes for (Node child : childs) { newNode.appendChild(child.cloneNode(deep)); } } else { // only copy the TextNode if exists for (Node child : childs) { if (Node.TEXT_NODE == child.getNodeType()) { newNode.appendChild(Document.get().createTextNode(child.getNodeValue())); break; } } } }
private static void cloneChildNodes(Node newNode, Node oldNode, boolean deep) { List<Node> childs = getChildNodeInnerList(oldNode); if (deep) { // copy all child nodes for (Node child : childs) { newNode.appendChild(child.cloneNode(deep)); } } else { // only copy the TextNode if exists for (Node child : childs) { if (Node.TEXT_NODE == child.getNodeType()) { newNode.appendChild(Document.get().createTextNode(child.getNodeValue())); break; } } } }
/** * Work around Firefox bug * https://bugzilla.mozilla.org/show_bug.cgi?id=519028 * (change location.hash leads to location bar icon (favicon) disappearance). * Simply detach and re-attach the favicon link tag on hashchange. */ @Override public void onValueChange(ValueChangeEvent<String> event) { super.onValueChange(event); if (clientAgentType.isFirefox()) { Scheduler.get().scheduleDeferred(() -> { Node favicon = DOM.getElementById("id-link-favicon"); //$NON-NLS-1$ if (favicon != null) { Node parent = favicon.getParentNode(); favicon.removeFromParent(); parent.appendChild(favicon); } }); } }
protected void onAdd(List<M> models, int index) { if (rendered) { if (all.getCount() == 0) { refresh(); 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); } }