Refine search
/** * Get the {@link TableColElement} at the specified index, creating it if * necessary. * * @param index the column index * @return the {@link TableColElement} */ public TableColElement ensureTableColElement(int index) { // Ensure that we have enough columns. for (int i = colgroup.getChildCount(); i <= index; i++) { colgroup.appendChild(Document.get().createColElement()); } return colgroup.getChild(index).cast(); }
/** * Inserts the given child as the first child of this node. * * @param child the child to be inserted * @return The node being inserted */ public final Node insertFirst(Node child) { assert (child != null) : "Cannot add a null child node"; return insertBefore(child, getFirstChild()); }
private void updateVisibility(Element container) { // If this element has an associated layer, re-run layout for it. Layer layer = getLayer(container); if (layer != null) { layout(layer); } // Walk all children, looking for elements with a '__layer' property. If one // exists, call layout() for that element. This is not cheap, but it's the // only way to correctly ensure that layout units get translated correctly. NodeList<Node> nodes = container.getChildNodes(); for (int i = 0; i < nodes.getLength(); ++i) { Node node = nodes.getItem(i); if (node.getNodeType() == Node.ELEMENT_NODE) { updateVisibility(node.<Element>cast()); } } } }
private static void orphan(Node node) { node.getParentNode().removeChild(node); }
/** * Gets the child node at the given index. * * @param index the index of the node to be retrieved * @return the child node at the given index */ public final Node getChild(int index) { assert (index >= 0) && (index < getChildCount()) : "Child index out of bounds"; return getChildNodes().getItem(index); }
/** * Ensures that a row at the given index exists. * @param rowIndex */ private Element ensureRow(int rowIndex) { NodeList<Node> childNodes = this.tbody.getChildNodes(); int numTRs = childNodes.getLength(); if (rowIndex < numTRs) { return childNodes.getItem(rowIndex).cast(); } Element tr = null; for (int r = numTRs; r <= rowIndex; r++) { tr = Document.get().createTRElement().cast(); DOM.appendChild(this.tbody, tr); this.rowElements.add(tr); } return tr; }
/** Improves splitter visibility. */ public void tuneSplitter(SplitLayoutPanel splitLayoutPanel) { NodeList<Node> nodes = splitLayoutPanel.getElement().getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { Node node = nodes.getItem(i); if (node.hasChildNodes()) { com.google.gwt.dom.client.Element el = node.getFirstChild().cast(); if ("gwt-SplitLayoutPanel-HDragger".equals(el.getClassName())) { tuneSplitter(el); } } } }
private void loadAnalyticsScript() { ScriptElement script = Document.get().createScriptElement(); script.setSrc(GoogleAnalyticsImpl.SCRIPT_URL); script.setType("text/javascript"); script.setAttribute("async", "true"); Element firstScript = Document.get().getElementsByTagName("script").getItem(0); firstScript.getParentNode().insertBefore(script, firstScript); }
private void updateGroupWidths() { if (!enableGrouping || ds.getCount() < 1) { return; } String tw = Math.max(cm.getTotalWidth(), el.dom.getOffsetWidth() - getScrollAdjust()) + "px"; NodeList<Element> gs = getGroups(); for (int i = 0, len = gs.getLength(); i < len; i++) { Element e = gs.getItem(i).getFirstChild().cast(); e.getStyle().setProperty("width", tw); } }
public Element getDescendantsContainer(NodeDescriptor node) { if (node.getDescendantsContainerElement() == null) { Element element = getRootContainer(node).getChildNodes().getItem(1).cast(); node.setDescendantsContainerElement(element); } return node.getDescendantsContainerElement(); }
private void scrollSelectedItemIntoView() { NodeList<Node> items = getSuggestionMenu().getElement().getChild(1).getChild(0).getChildNodes(); for (int i = 0; i < items.getLength(); i++) { Element element = (Element) items.getItem(i); if (((Element) element.getChild(0)).getClassName().equals("item item-selected")) { element.scrollIntoView(); break; } } } }
@PatchMethod static String getNodeValue(JavaScriptObject o) { Node n = o.cast(); switch (n.getNodeType()) { case com.google.gwt.xml.client.Node.ATTRIBUTE_NODE: return JavaScriptObjects.getString(n, XML_ATTR_VALUE); case Node.ELEMENT_NODE: Element e = n.cast(); return e.getInnerText(); default: return n.getNodeValue(); } }
@PatchMethod static int getDOMCellCount(HTMLTable table, com.google.gwt.user.client.Element element, int row) { return element.getChildNodes().getItem(row).getChildNodes().getLength(); }
@Override public String getText() { String text = ""; NodeList<Node> nodes = consoleLines.getElement().getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { Node node = nodes.getItem(i); Element element = node.cast(); text += element.getInnerText() + "\r\n"; } return text; }
public VDDTabSheet() { super(); newTab.setClassName(CLASSNAME_NEW_TAB); // Get the tabBar tabBar = (ComplexPanel) getChildren().get(0); // Get the content tabPanel = (VTabsheetPanel) getChildren().get(1); // Get the spacer Element tBody = tabBar.getElement(); spacer = tBody.getChild(tBody.getChildCount() - 1).getChild(0) .getChild(0).cast(); }
private void cloneAndAppendRow(VScrollTableRow row) { Element clonedTR = null; clonedTR = row.getElement().cloneNode(true).cast(); clonedTR.getStyle().setVisibility(Visibility.VISIBLE); cloneTable.appendChild(clonedTR); }
@PatchMethod static Element getRow(RowFormatter rowFormatter, Element elem, int row) { return elem.getChildNodes().getItem(row).cast(); }
@PatchMethod static int getDOMCellCount(HTMLTable table, Element element, int row) { return element.getChildNodes().getItem(row).getChildNodes().getLength(); }
@PatchMethod static JavaScriptObject createCDATASection(JavaScriptObject jsObject, String data) { Document document = jsObject.cast(); Text text = JsoUtils.newNode(com.google.gwt.xml.client.Node.CDATA_SECTION_NODE).cast(); JavaScriptObjects.setProperty(text, JsoProperties.NODE_OWNER_DOCUMENT, document); text.setData(data); return text; }
/** * Removes all child nodes from the given element. */ protected void removeAllChildNodes(Node elem) { NodeList<Node> childNodes = elem.getChildNodes(); for (int i = childNodes.getLength() - 1; i >= 0; i--) { elem.removeChild(childNodes.getItem(i)); } }