Java Code Examples for com.google.gwt.user.client.DOM#insertChild()

The following examples show how to use com.google.gwt.user.client.DOM#insertChild() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VDDAccordion.java    From cuba with Apache License 2.0 6 votes vote down vote up
private void insertSpacer(Widget spacer,
        com.google.gwt.dom.client.Element container, int beforeIndex) {
    // Validate index; adjust if the widget is already a child of this
    // panel.
    beforeIndex = adjustIndex(spacer, beforeIndex);

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

    // We don't add the spacer to the children otherwise we mess the
    // accordion logic.

    // Physical attach.
    DOM.insertChild(container, spacer.getElement(), beforeIndex);

    // Adopt.
    adopt(spacer);
}
 
Example 2
Source File: CubaTreeTableWidget.java    From cuba with Apache License 2.0 5 votes vote down vote up
public CubaTreeTableTableHead() {
    Element iconElement = presentationsEditIcon.getElement();
    iconElement.setClassName("c-table-prefs-icon");
    iconElement.getStyle().setDisplay(Style.Display.NONE);

    Element columnSelector = (Element) getElement().getLastChild();
    DOM.insertChild(getElement(), iconElement, DOM.getChildIndex(getElement(), columnSelector));

    DOM.sinkEvents(iconElement, Event.ONCLICK);
}
 
Example 3
Source File: CubaScrollTableWidget.java    From cuba with Apache License 2.0 5 votes vote down vote up
public CubaScrollTableHead() {
    Element iconElement = presentationsEditIcon.getElement();
    iconElement.setClassName("c-table-prefs-icon");
    iconElement.getStyle().setDisplay(Style.Display.NONE);

    Element columnSelector = (Element) getElement().getLastChild();
    DOM.insertChild(getElement(), iconElement, DOM.getChildIndex(getElement(), columnSelector));

    DOM.sinkEvents(iconElement, Event.ONCLICK);
}
 
Example 4
Source File: CubaGroupBoxWidget.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public void setIconUri(String iconUri, ApplicationConnection client) {
    if (icon != null) {
        captionNode.removeChild(icon.getElement());
    }
    icon = client.getIcon(iconUri);
    if (icon != null) {
        DOM.insertChild(captionNode, icon.getElement(), 1);
    }
}
 
Example 5
Source File: UniTimeTable.java    From unitime with Apache License 2.0 5 votes vote down vote up
private void swapRows(int r0, int r1) {
	if (r0 == r1) return;
	if (r0 > r1) {
		swapRows(r1, r0);
	} else { // r0 < r1
		Element body = getBodyElement();
		Element a = DOM.getChild(body, r0);
		Element b = DOM.getChild(body, r1);
		body.removeChild(a);
		body.removeChild(b);
		DOM.insertChild(body, b, r0);
		DOM.insertChild(body, a, r1);
	}
}
 
Example 6
Source File: GanttWidget.java    From gantt with Apache License 2.0 5 votes vote down vote up
/**
 * @param child
 *            Child widget.
 * @param container
 *            Parent element.
 * @param beforeIndex
 *            Target index of element in DOM.
 * @param domInsert
 *            true: Insert at specific position. false: append at the end.
 */
@Override
protected void insert(Widget child, Element container, int beforeIndex, boolean domInsert) {
    GWT.log("Count content elements: " + content.getChildCount() + " ("
            + getAdditionalNonWidgetContentElementCount() + " non-widget non-step elements, "
            + (getAdditonalContentElementCount() - getAdditionalNonWidgetContentElementCount())
            + " non-step widgets.)");

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

    // Detach new child. Might also remove additional widgets like
    // predecessor arrows. May affect contentHeight.
    child.removeFromParent();

    // Logical attach.
    getChildren().insert(child, adjustedBeforeStepIndex + getAdditionalWidgetContentElementCount());

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

    // Adopt.
    adopt(child);
}