Example usage for com.google.gwt.dom.client Node insertFirst

List of usage examples for com.google.gwt.dom.client Node insertFirst

Introduction

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

Prototype

@Override
    public Node insertFirst(Node child) 

Source Link

Usage

From source file:jetbrains.jetpad.mapper.gwt.DomUtil.java

License:Apache License

public static List<Node> nodeChildren(final Node n) {
    return new AbstractList<Node>() {
        @Override/*from  w  w w.j a v  a  2 s . c  om*/
        public Node get(int index) {
            return n.getChild(index);
        }

        @Override
        public Node set(int index, Node element) {
            if (element.getParentElement() != null) {
                throw new IllegalStateException();
            }

            Node child = get(index);
            n.replaceChild(child, element);
            return child;
        }

        @Override
        public void add(int index, Node element) {
            if (element.getParentElement() != null) {
                throw new IllegalStateException();
            }

            if (index == 0) {
                n.insertFirst(element);
            } else {
                Node prev = n.getChild(index - 1);
                n.insertAfter(element, prev);
            }
        }

        @Override
        public Node remove(int index) {
            Node child = n.getChild(index);
            n.removeChild(child);
            return child;
        }

        @Override
        public int size() {
            return n.getChildCount();
        }
    };
}

From source file:org.eclipse.che.ide.ui.radiobuttongroup.RadioButtonGroup.java

License:Open Source License

/**
 * Adds the new button to the group./*from w  w w  .  ja v  a2  s .  c  om*/
 *
 * @param label
 *         button's label
 * @param title
 *         button's tooltip
 * @param icon
 *         button's icon
 * @param clickHandler
 *         click handler
 */
public void addButton(String label, String title, @Nullable SVGResource icon, ClickHandler clickHandler) {
    final RadioButton radioButton = new RadioButton(GROUP_NAME, label);
    radioButton.setTitle(title);
    radioButton.setStyleName(resources.getCSS().button());
    radioButton.addClickHandler(clickHandler);

    final Node child = radioButton.getElement().getLastChild();

    if (icon != null) {
        final SVGImage svgImage = new SVGImage(icon);
        child.insertFirst(svgImage.getElement());
    }
    mainPanel.add(radioButton);

    buttons.add(radioButton);
}