Example usage for com.google.gwt.user.client DOM getChild

List of usage examples for com.google.gwt.user.client DOM getChild

Introduction

In this page you can find the example usage for com.google.gwt.user.client DOM getChild.

Prototype

public static Element getChild(Element parent, int index) 

Source Link

Document

Gets an element's n-th child element.

Usage

From source file:asquare.gwt.tk.client.ui.ColumnPanel.java

License:Apache License

@Override
public Element getCellElement(int cellIndex) {
    GwtUtil.rangeCheck(0, getCellCount(), cellIndex, false);

    return DOM.getChild(m_tr, cellIndex);
}

From source file:asquare.gwt.tk.client.ui.RowPanel.java

License:Apache License

@Override
protected void removeCellStructure(int cellIndex) {
    Element tr = DOM.getChild(getBody(), cellIndex);
    Element td = getCellElement(cellIndex);
    DOM.removeChild(getBody(), tr);//w w  w.  ja  va2  s. co  m
    DOM.removeChild(tr, td);
}

From source file:asquare.gwt.tk.client.ui.RowPanel.java

License:Apache License

@Override
public Element getCellElement(int cellIndex) {
    GwtUtil.rangeCheck(0, getCellCount(), cellIndex, false);

    Element tr = DOM.getChild(getBody(), cellIndex);
    Element td = DOM.getFirstChild(tr);
    return td;//from  w  ww.  j ava  2  s.  c  o  m
}

From source file:asquare.gwt.tk.client.util.DomUtil.java

License:Apache License

/**
 * Creates a list of all elements contained by the specified element
 * (inclusive) which have the specified CSS class (in GWT terms
 * <em>stylename</em>)./* w  w  w .j av a 2s  .  co m*/
 * 
 * @param element the element which is at the root of the hierarchy that you wish to search
 * @param className the name of the CSS class to search for
 * @param result a writable list which will be returned as the result (for recursion).
 *            Typically, you pass <code>null</code> and the list will
 *            be created on the fly.
 * @return <b>result</b> a list containing 0 or more HTML elements
 */
public static List<Element> findElementsWithClass(Element element, String className, List<Element> result) {
    if (result == null) {
        result = new ArrayList<Element>();
    }

    String cls = DOM.getElementProperty(element, "className");
    if (cls != null && cls.indexOf(className) >= 0) {
        result.add(element);
    }

    int childCount = DOM.getChildCount(element);
    for (int i = 0; i < childCount; i++) {
        findElementsWithClass(DOM.getChild(element, i), className, result);
    }

    return result;
}

From source file:at.ait.dme.yuma.client.colorpicker.TransparencyImpl.java

License:Artistic License

public static void setTransparency(Element elem, int alpha) {
    float ieVersion = getIEVersion();

    if (ieVersion >= 5.5 && ieVersion < 7.0) {
        elem = DOM.getChild(elem, 0);

        // Cache existing filters on the image, then re-apply everything with our Alpha filter
        // stacked on the end.
        if (map.containsKey(elem)) {
            if (alpha == 100) {
                DOM.setStyleAttribute(elem, "filter", map.get(elem) + "");
            } else {
                DOM.setStyleAttribute(elem, "filter",
                        map.get(elem) + ", progid:DXImageTransform.Microsoft.Alpha(opacity=" + alpha + ");");
            }/*from   ww  w . ja va 2  s  .c om*/
        } else {
            map.put(elem, DOM.getStyleAttribute(elem, "filter"));

            if (alpha == 100) {
                DOM.setStyleAttribute(elem, "filter", map.get(elem) + "");
            } else {
                DOM.setStyleAttribute(elem, "filter",
                        map.get(elem) + ", progid:DXImageTransform.Microsoft.Alpha(opacity=" + alpha + ");");
            }
        }
    }
    // If IE 7 (or better)
    else if (ieVersion >= 7.0) {
        DOM.setStyleAttribute(elem, "filter", "alpha(opacity=" + alpha + ")");
    } else // Everyone else
    {
        DOM.setStyleAttribute(elem, "opacity", "" + (new Integer(alpha).floatValue() / 100) + "");
    }
}

From source file:at.researchstudio.dme.imageannotation.client.colorpicker.TransparencyImpl.java

License:Artistic License

public static void setTransparency(Element elem, int alpha) {
    float ieVersion = getIEVersion();

    if (ieVersion >= 5.5 && ieVersion < 7.0) {
        elem = DOM.getChild(elem, 0);

        // Cache existing filters on the image, then re-apply everything with our Alpha filter
        // stacked on the end.
        if (map.containsKey(elem)) {
            if (alpha == 100) {
                DOM.setStyleAttribute(elem, "filter", map.get(elem) + "");
            } else {
                DOM.setStyleAttribute(elem, "filter",
                        map.get(elem) + ", progid:DXImageTransform.Microsoft.Alpha(opacity=" + alpha + ");");
            }//ww  w.  ja  va2s. c o m
        } else {
            map.put(elem, DOM.getStyleAttribute(elem, "filter"));

            if (alpha == 100) {
                DOM.setStyleAttribute(elem, "filter", map.get(elem) + "");
            } else {
                DOM.setStyleAttribute(elem, "filter",
                        map.get(elem) + ", progid:DXImageTransform.Microsoft.Alpha(opacity=" + alpha + ");");
            }
        }
    }
    // If IE 7 (or better)
    else if (ieVersion >= 7.0) {
        DOM.setStyleAttribute(elem, "filter", "alpha(opacity=" + alpha + ")");
    } else // Everyone else
    {
        DOM.setStyleAttribute(elem, "-moz-opacity", "" + (new Integer(alpha).floatValue() / 100) + "");
        DOM.setStyleAttribute(elem, "opacity", "" + (new Integer(alpha).floatValue() / 100) + "");
    }
}

From source file:cc.alcina.framework.gwt.client.widget.dialog.DecoratorPanel.java

License:Apache License

/**
 * Creates a new panel using the specified style names to apply to each row.
 * Each row will contain three cells (Left, Center, and Right). The Center
 * cell in the containerIndex row will contain the {@link Widget}.
 * //w  w  w .  j a v  a  2  s. co m
 * @param rowStyles
 *            an array of style names to apply to each row
 * @param containerIndex
 *            the index of the container row
 */
DecoratorPanel(String[] rowStyles, int containerIndex) {
    super(DOM.createTable());
    // Add a tbody
    Element table = getElement();
    tbody = DOM.createTBody();
    DOM.appendChild(table, tbody);
    DOM.setElementPropertyInt(table, "cellSpacing", 0);
    DOM.setElementPropertyInt(table, "cellPadding", 0);
    // Add each row
    for (int i = 0; i < rowStyles.length; i++) {
        Element row = createTR(rowStyles[i]);
        DOM.appendChild(tbody, row);
        if (i == containerIndex) {
            containerElem = DOM.getFirstChild(DOM.getChild(row, 1));
        }
    }
    // Set the overall style name
    setStyleName(DEFAULT_STYLENAME);
}

From source file:cc.alcina.framework.gwt.client.widget.dialog.DecoratorPanel.java

License:Apache License

/**
 * Get a specific Element from the panel.
 * //from ww w .  j a v a 2  s. c  om
 * @param row
 *            the row index
 * @param cell
 *            the cell index
 * @return the Element at the given row and cell
 */
protected Element getCellElement(int row, int cell) {
    Element tr = DOM.getChild(tbody, row);
    Element td = DOM.getChild(tr, cell);
    return DOM.getFirstChild(td);
}

From source file:cc.alcina.framework.gwt.client.widget.DivStackPanel.java

License:Apache License

/**
 * Sets the text associated with a child by its index.
 * //from ww  w .  j a v  a2 s .c  om
 * @param index
 *            the index of the child whose text is to be set
 * @param text
 *            the text to be associated with it
 * @param asHTML
 *            <code>true</code> to treat the specified text as HTML
 */
public void setStackText(int index, String text, boolean asHTML) {
    if (index >= getWidgetCount()) {
        return;
    }
    Element tdWrapper = DOM.getChild(body, index * 2);
    Element headerElem = tdWrapper;
    rowTexts.put(index, new StackTextRow(text, asHTML));
    if (asHTML) {
        DOM.setInnerHTML(getHeaderTextElem(headerElem), text);
    } else {
        DOM.setInnerText(getHeaderTextElem(headerElem), text);
    }
}

From source file:cc.alcina.framework.gwt.client.widget.DivStackPanel.java

License:Apache License

private boolean remove(Widget child, int index) {
    // Make sure to call this before disconnecting the DOM.
    boolean removed = super.remove(child);
    if (removed) {
        // Calculate which internal table elements to remove.
        int rowIndex = 2 * index;
        Element tr = DOM.getChild(body, rowIndex);
        DOM.removeChild(body, tr);/*from   w w  w  .  j  a  v a 2 s  .c  om*/
        tr = DOM.getChild(body, rowIndex);
        DOM.removeChild(body, tr);
        // Correct visible stack for new location.
        if (visibleStack == index) {
            visibleStack = -1;
        } else if (visibleStack > index) {
            --visibleStack;
        }
        // Update indices of all elements to the right.
        updateIndicesFrom(index);
    }
    return removed;
}