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

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

Introduction

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

Prototype

public static void insertChild(Element parent, Element child, int index) 

Source Link

Document

Inserts an element as a child of the given parent element.

Usage

From source file:asquare.gwt.sb.client.fw.ListWidgetBasic.java

License:Apache License

@Override
public Element insertCellStructure(int index) {
    Element child = DOM.createElement(m_itemElementType);
    DOM.insertChild(getElement(), child, index);
    m_elements.add(index, child);//from   www  . j  a  v a  2 s.  co m
    return child;
}

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

License:Apache License

public static Element createInsertTr(Element tBody, int trIndex) {
    Element tr = DOM.createTR();//from ww w . jav  a2  s .  c  o  m
    DOM.insertChild(tBody, tr, trIndex);
    return tr;
}

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

License:Apache License

public static Element createInsertTd(Element tr, int tdIndex) {
    Element td = DOM.createTD();/*from  w  ww.j  ava2s.  co  m*/
    DOM.insertChild(tr, td, tdIndex);
    return td;
}

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

License:Apache License

/**
 * Inserts a widget before the specified index.
 * /*from  w ww  .  j a  va2s  .  co  m*/
 * @param w
 *            the widget to be inserted
 * @param beforeIndex
 *            the index before which it will be inserted
 * @throws IndexOutOfBoundsException
 *             if <code>beforeIndex</code> is out of range
 */
public void insert(Widget w, int beforeIndex) {
    Element tdh = createHeaderElem();
    Element tdb = DOM.createDiv();
    // DOM indices are 2x logical indices; 2 dom elements per stack item
    beforeIndex = adjustIndex(w, beforeIndex);
    int effectiveIndex = beforeIndex * 2;
    // this ordering puts the body below the header
    DOM.insertChild(getElement(), tdb, effectiveIndex);
    DOM.insertChild(getElement(), tdh, effectiveIndex);
    // header styling
    setStyleName(tdh, DEFAULT_ITEM_STYLENAME, true);
    DOM.setElementPropertyInt(tdh, "__owner", hashCode());
    DOM.setElementProperty(tdh, "height", "1px");
    // body styling
    setStyleName(tdb, DEFAULT_STYLENAME + "Content", true);
    DOM.setElementProperty(tdb, "height", "100%");
    DOM.setElementProperty(tdb, "vAlign", "top");
    // Now that the DOM is connected, call insert (this ensures that
    // onLoad() is
    // not fired until the child widget is attached to the DOM).
    super.insert(w, tdb, beforeIndex, false);
    // Update indices of all elements to the right.
    updateIndicesFrom(beforeIndex);
    // Correct visible stack for new location.
    if (visibleStack == -1) {
        showStack(0);
    } else {
        setStackVisible(beforeIndex, false);
        if (visibleStack >= beforeIndex) {
            ++visibleStack;
        }
        // Reshow the stack to apply style names
        setStackVisible(visibleStack, true);
    }
}

From source file:com.ait.toolkit.sencha.touch.client.core.ComplexContainer.java

License:Open Source License

/**
 * Insert a new child Widget into this Panel at a specified index, attaching
 * its Element to the specified container Element. The child Element will
 * either be attached to the container at the same index, or simply appended
 * to the container, depending on the value of <code>domInsert</code>.
 * //from w ww  .ja v a2  s  . c om
 * @param child
 *            the child Widget to be added
 * @param container
 *            the Element within which <code>child</code> will be contained
 * @param beforeIndex
 *            the index before which <code>child</code> will be inserted
 * @param domInsert
 *            if <code>true</code>, insert <code>child</code> into
 *            <code>container</code> at <code>beforeIndex</code>; otherwise
 *            append <code>child</code> to the end of <code>container</code>
 *            .
 */
protected void insert(Widget child, Element container, int beforeIndex, boolean domInsert) {
    // Validate index; adjust if the widget is already a child of this
    // panel.
    beforeIndex = adjustIndex(child, beforeIndex);

    // Detach new child.
    child.removeFromParent();

    // Logical attach.
    getChildren().insert(child, beforeIndex);

    // Physical attach.
    if (domInsert) {
        DOM.insertChild(container, child.getElement(), beforeIndex);
    } else {
        DOM.appendChild(container, child.getElement());
    }

    // Adopt.
    adopt(child);
}

From source file:com.alkacon.geranium.client.ui.Popup.java

License:Open Source License

/**
 * Insert a new child Widget into this Panel at a specified index, attaching
 * its Element to the specified container Element. The child Element will
 * either be attached to the container at the same index, or simply appended
 * to the container, depending on the value of <code>domInsert</code>.
 * /*from  w  w  w.  j  a  v a 2s. c o m*/
 * @param child the child Widget to be added
 * @param container the Element within which <code>child</code> will be
 *          contained
 * @param beforeIndex the index before which <code>child</code> will be
 *          inserted
 * @param domInsert if <code>true</code>, insert <code>child</code> into
 *          <code>container</code> at <code>beforeIndex</code>; otherwise
 *          append <code>child</code> to the end of <code>container</code>.
 */
protected void insert(Widget child, Element container, int beforeIndex, boolean domInsert) {

    // Validate index; adjust if the widget is already a child of this panel.
    beforeIndex = adjustIndex(child, beforeIndex);

    // Detach new child.
    child.removeFromParent();

    // Logical attach.
    getChildren().insert(child, beforeIndex);

    // Physical attach.
    if (domInsert) {
        DOM.insertChild(container, child.getElement(), beforeIndex);
    } else {
        DOM.appendChild(container, child.getElement());
    }

    // Adopt.
    adopt(child);
}

From source file:com.apress.progwt.client.college.gui.ext.TableWithHeaders.java

License:Apache License

/**
 * /*from  w  w w  . j av a 2  s .  c  o  m*/
 * @param rows
 * 
 * @param columns -
 *            Variable number of header columns
 * 
 */
public TableWithHeaders(int rows, String... columns) {

    super(rows, columns.length);

    Log.debug("TableWithHeaders.NEW GRID " + columns.length + " " + rows);

    // use DOM to create thead element....
    Element thead = DOM.createElement("thead");
    Element tr = DOM.createTR();

    // add columns
    DOM.appendChild(thead, tr);
    for (String columnName : columns) {
        Element th = DOM.createTH();
        DOM.appendChild(tr, th);

        // add some text to the header...
        DOM.setInnerText(th, columnName);
    }

    // get the table element
    Element table = this.getElement();

    // and add the thead before the tbody
    DOM.insertChild(table, thead, 0);
}

From source file:com.cubusmail.client.widgets.ImageHyperlink.java

License:Open Source License

public ImageHyperlink(Image img, String text, String targetHistoryToken) {

    super();/* w ww. j  av a 2  s.co  m*/
    setText(text);
    setStyleName("gwt-Hyperlink");
    // DOM.setStyleAttribute( getElement(), "whiteSpace", "nowrap" );
    if (img != null) {
        DOM.insertChild(getElement(), img.getElement(), 0);
        DOM.setStyleAttribute(img.getElement(), "verticalAlign", "middle");
        img.unsinkEvents(Event.ONCLICK | Event.MOUSEEVENTS);
    }
    setTargetHistoryToken(targetHistoryToken);

    sinkEvents(Event.ONCLICK | Event.ONMOUSEDOWN);
    GWTUtil.disableContextMenu(getElement());
}

From source file:com.cubusmail.gwtui.client.widgets.ImageHyperlink.java

License:Open Source License

public ImageHyperlink(Image img, String targetHistoryToken) {

    super();/* w w  w  . ja  v  a 2  s. c o  m*/
    setStyleName("gwt-Hyperlink");
    if (img != null) {
        DOM.insertChild(getElement(), img.getElement(), 0);
        img.unsinkEvents(Event.ONCLICK | Event.MOUSEEVENTS);
    }
    setTargetHistoryToken(targetHistoryToken);

    sinkEvents(Event.ONCLICK | Event.ONMOUSEDOWN);
    GWTUtil.disableContextMenu(getElement());
}

From source file:com.edgenius.wiki.gwt.client.widgets.Button.java

License:Open Source License

public void setText(String text) {
    Element child = DOM.getChild(this.getElement(), 0);
    int txtIdx = 0;
    if (child != null && child.toString().indexOf("img") != -1) {
        //first is image, then try to put text after it
        txtIdx = 1;//from w  w  w.j  av a 2s  .  c  o  m
        txtSpan = DOM.getChild(this.getElement(), txtIdx);
    }

    if (txtSpan == null) {
        txtSpan = DOM.createSpan();
        DOM.setInnerHTML(txtSpan, text);
    }
    DOM.insertChild(this.getElement(), txtSpan, txtIdx);
}