Search in sources :

Example 1 with Node

use of org.gwtproject.dom.client.Node in project gwtproject by treblereel.

the class DOMImplStandard method getChild.

@Override
public Element getChild(Element elem, int index) {
    int count = 0;
    Node child = elem.getFirstChild();
    while (child != null) {
        if (child.getNodeType() == 1) {
            if (index == count) {
                return (Element) child;
            }
            ++count;
        }
        child = child.getNextSibling();
    }
    return null;
}
Also used : Node(org.gwtproject.dom.client.Node) Element(org.gwtproject.dom.client.Element)

Example 2 with Node

use of org.gwtproject.dom.client.Node in project gwtproject by treblereel.

the class DOMImplStandard method getChildIndex.

@Override
public int getChildIndex(Element parent, Element toFind) {
    int count = 0;
    Node child = parent.getFirstChild();
    while (child != null) {
        if (child == toFind) {
            return count;
        }
        if (child.getNodeType() == 1) {
            ++count;
        }
        child = child.getNextSibling();
    }
    return -1;
}
Also used : Node(org.gwtproject.dom.client.Node)

Example 3 with Node

use of org.gwtproject.dom.client.Node in project gwtproject by treblereel.

the class Grid method addRows.

/**
 * Native method to add rows into a table with a given number of columns.
 *
 * @param table the table element
 * @param rows number of rows to add
 * @param columns the number of columns per row
 */
private static void addRows(Element table, int rows, int columns) {
    TableCellElement td = Document.get().createTDElement();
    td.setInnerHTML(" ");
    TableRowElement row = Document.get().createTRElement();
    for (int cellNum = 0; cellNum < columns; cellNum++) {
        Node cell = td.cloneNode(true);
        row.appendChild(cell);
    }
    table.appendChild(row);
    for (int rowNum = 1; rowNum < rows; rowNum++) {
        table.appendChild(row.cloneNode(true));
    }
}
Also used : TableRowElement(org.gwtproject.dom.client.TableRowElement) Node(org.gwtproject.dom.client.Node) TableCellElement(org.gwtproject.dom.client.TableCellElement)

Example 4 with Node

use of org.gwtproject.dom.client.Node in project gwtproject by treblereel.

the class DOMImplStandard method getChildCount.

@Override
public int getChildCount(Element elem) {
    int count = 0;
    Node child = elem.getFirstChild();
    while (child != null) {
        if (child.getNodeType() == 1) {
            ++count;
        }
        child = child.getNextSibling();
    }
    return count;
}
Also used : Node(org.gwtproject.dom.client.Node)

Example 5 with Node

use of org.gwtproject.dom.client.Node in project gwtproject by treblereel.

the class UIObject method replaceNode.

private void replaceNode(Element node, Element newNode) {
    Node p = node.getParentNode();
    if (p == null) {
        return;
    }
    p.insertBefore(newNode, node);
    p.removeChild(node);
}
Also used : Node(org.gwtproject.dom.client.Node)

Aggregations

Node (org.gwtproject.dom.client.Node)7 Element (org.gwtproject.dom.client.Element)1 TableCellElement (org.gwtproject.dom.client.TableCellElement)1 TableRowElement (org.gwtproject.dom.client.TableRowElement)1