Example usage for com.google.gwt.dom.client NodeList getItem

List of usage examples for com.google.gwt.dom.client NodeList getItem

Introduction

In this page you can find the example usage for com.google.gwt.dom.client NodeList getItem.

Prototype

public T getItem(int index) 

Source Link

Usage

From source file:com.sencha.gxt.core.client.dom.XElement.java

License:sencha.com license

/**
 * Inserts the elements before this element.
 * /*  w  w w . jav a2s .c o m*/
 * @param elements the elements to insert
 */
public final void insertBefore(NodeList<Element> elements) {
    Element parent = getParentElement();
    assert parent != null : "cannot insertBefore with null parent";
    for (int i = 0, len = elements.getLength(); i < len; i++) {
        parent.insertBefore(elements.getItem(0), this);
    }
}

From source file:com.sencha.gxt.core.client.dom.XElement.java

License:sencha.com license

/**
 * Replace one class name with another.// ww  w.j  a  va 2  s . c  o m
 * 
 * @param oldClassName the class name to be replaced
 * @param newClassName the class name to replace it
 * @param deep true to class names on child elements
 */
public final void replaceClassName(String oldClassName, String newClassName, boolean deep) {
    removeClassName(oldClassName);
    addClassName(newClassName);
    NodeList<Element> nodes = select("." + oldClassName);
    for (int i = 0; i < nodes.getLength(); i++) {
        nodes.getItem(i).replaceClassName(oldClassName, newClassName);
    }
}

From source file:com.sencha.gxt.core.client.util.Util.java

License:sencha.com license

/**
 * Converts a node list to an element array.
 * //  ww w  .  java  2 s  .c om
 * @param nodes the nodes
 * @return the element array
 */
public static Element[] toElementArray(NodeList<Element> nodes) {
    Element[] e = new Element[nodes.getLength()];
    for (int i = 0; i < nodes.getLength(); i++) {
        e[i] = nodes.getItem(i);
    }
    return e;
}

From source file:com.sencha.gxt.dnd.core.client.DropTarget.java

License:sencha.com license

private XElement elementFromPoint(XElement element, int x, int y) {
    if (!element.getBounds().contains(x, y)) {
        return null;
    }/*from w w  w  . j  a v a 2  s  .c o  m*/
    if (!element.hasChildNodes()) {
        return element;
    }

    NodeList<Node> childNodes = element.getChildNodes();
    for (int i = 0; i < childNodes.getLength(); i++) {
        Node node = childNodes.getItem(i);
        if (node.getNodeType() == Node.ELEMENT_NODE) {
            XElement child = node.cast();
            if (child.getBounds().contains(x, y)) {
                return elementFromPoint(child, x, y);
            }
        }
    }

    // children are not within bounds, return this
    return element;
}

From source file:com.sencha.gxt.fx.client.Shim.java

License:sencha.com license

protected void shim(NodeList<Element> elements) {
    for (int i = 0; i < elements.getLength(); i++) {
        XElement e = elements.getItem(i).<XElement>cast();
        Rectangle bounds = e.getBounds(true);
        if (bounds.getHeight() > 0 && bounds.getWidth() > 0 && e.isVisible()) {
            shims.add(createShim(e, bounds.getX(), bounds.getY(), bounds.getWidth(), bounds.getHeight()));
        }/*from  w  w  w. ja  va  2 s.co  m*/
    }
}

From source file:com.sencha.gxt.theme.base.client.colorpalette.ColorPaletteBaseAppearance.java

License:sencha.com license

private static int indexOf(NodeList<Element> elements, Element elem) {
    for (int i = 0; i < elements.getLength(); i++) {
        if (elements.getItem(i) == elem) {
            return i;
        }// ww  w.ja  v a 2 s  .c om
    }
    return -1;
}

From source file:com.sencha.gxt.theme.base.client.colorpalette.ColorPaletteBaseAppearance.java

License:sencha.com license

@Override
public String getAboveColor(XElement parent, String value) {
    if (value == null) {
        return null;
    }/*from ww  w.j  ava 2s .  c o  m*/

    Element a = getChildElement(XElement.as(parent), value);
    int row = getRow(a);
    if (row > 0) {
        NodeList<Element> colorElements = getColorElements(parent);
        int idx = indexOf(colorElements, a);
        idx = idx - getColumnCount();
        if (idx >= 0 && idx < colorElements.getLength()) {
            a = colorElements.getItem(idx);
            return stripColorName(a.getClassName());
        }
    }
    return null;
}

From source file:com.sencha.gxt.theme.base.client.colorpalette.ColorPaletteBaseAppearance.java

License:sencha.com license

@Override
public String getBelowColor(XElement parent, String value) {
    NodeList<Element> colorElements = getColorElements(parent);

    if (value == null) {
        return stripColorName(colorElements.getItem(0).getClassName());
    }/*from   w  w  w. j av a2 s. c o  m*/

    Element a = getChildElement(parent, value);
    int row = getRow(a);
    if (row < (getRowCount(parent) - 1)) {
        int idx = indexOf(colorElements, a);
        idx = idx + getColumnCount();

        if (idx >= 0 && idx < colorElements.getLength()) {
            a = colorElements.getItem(idx);
            return stripColorName(a.getClassName());
        }
    }
    return null;
}

From source file:com.sencha.gxt.theme.base.client.colorpalette.ColorPaletteBaseAppearance.java

License:sencha.com license

@Override
public String getLeftColor(XElement parent, String value) {
    if (value == null) {
        return null;
    }/* w  ww  .  j av a 2s.c o m*/

    Element a = getChildElement(XElement.as(parent), value);
    int col = getCol(a);
    if (col == 0) {
        return null;
    }
    NodeList<Element> colorElements = getColorElements(parent);
    int idx = indexOf(colorElements, a);
    if (idx > 0 && idx < colorElements.getLength()) {
        a = colorElements.getItem(idx - 1);
        return stripColorName(a.getClassName());
    }
    return null;
}

From source file:com.sencha.gxt.theme.base.client.colorpalette.ColorPaletteBaseAppearance.java

License:sencha.com license

@Override
public String getRightColor(XElement parent, String value) {
    NodeList<Element> colorElements = getColorElements(parent);
    if (value == null) {
        return stripColorName(colorElements.getItem(0).getClassName());
    }/*  www  .ja va 2  s.  c  o m*/

    Element a = getChildElement(XElement.as(parent), value);
    int col = getCol(a);
    if (col == getColumnCount() - 1) {
        return null;
    }
    int idx = indexOf(colorElements, a);
    if (idx < colorElements.getLength() - 1) {
        a = colorElements.getItem(idx + 1);
        return stripColorName(a.getClassName());
    }
    return null;
}