Example usage for com.google.gwt.dom.client OptionElement as

List of usage examples for com.google.gwt.dom.client OptionElement as

Introduction

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

Prototype

public static OptionElement as(Element elem) 

Source Link

Document

Assert that the given Element is compatible with this class and automatically typecast it.

Usage

From source file:com.arcbees.chosen.client.gwt.ChosenListBox.java

License:Apache License

/**
 * Select all options with value present in <code>values</code> array and update the component.
 *
 * @param values the values to select//from www. jav a  2s.com
 */
public void setSelectedValue(String... values) {
    for (String value : values) {
        Element element = $("option[value='" + value + "']", this).get(0);

        if (element != null) {
            OptionElement.as(element).setSelected(true);
        }
    }
    update();
}

From source file:com.arcbees.chosen.client.gwt.ChosenListBox.java

License:Apache License

/**
 * Unselect all previously selected values.
 *//*from w  w  w  .j  av a2  s.co  m*/
public void unselectAll() {
    for (Element selected : $("option:selected", this).elements()) {
        OptionElement.as(selected).setSelected(false);
    }
}

From source file:com.arcbees.chosen.client.SelectParser.java

License:Apache License

private void addGroup(OptGroupElement group) {
    int position = parsed.size();

    GroupItem item = new GroupItem();
    item.arrayIndex = position;//  ww w.j  av a  2s .c  o  m
    item.label = group.getLabel();
    item.children = 0;
    item.disabled = group.isDisabled();

    parsed.add(item);

    NodeList<Node> children = group.getChildNodes();
    for (int i = 0; i < children.getLength(); i++) {
        Node n = children.getItem(i);
        if ("OPTION".equalsIgnoreCase(n.getNodeName())) {
            addOption(OptionElement.as((Element) n), position, group.isDisabled());
        }
    }
}

From source file:com.arcbees.chosen.client.SelectParser.java

License:Apache License

private void addNode(Node child) {
    if (!Element.is(child)) {
        return;// w w w.  ja  v  a 2 s  .co m
    }

    Element e = Element.as(child);

    if ("OPTGROUP".equalsIgnoreCase(e.getNodeName())) {
        addGroup(OptGroupElement.as(e));
    } else if ("OPTION".equalsIgnoreCase(e.getNodeName())) {
        addOption(OptionElement.as(e), -1, false);
    }
}

From source file:com.horaz.client.widgets.SelectMenu.java

License:Open Source License

/**
 * generates a new option element. see {@link #setOptions(OptionElement[])}
 * how to add options to a select element
 * @param text//w  w  w.  j av a 2  s .  c o m
 * @param value
 * @return
 */
public static OptionElement createOption(String text, String value) {
    OptionElement o = OptionElement.as(DOM.createOption());
    o.setText(text);
    o.setValue(value);
    return o;
}

From source file:com.tractionsoftware.gwt.user.client.ui.GroupedListBox.java

License:Apache License

private OptionElement option(Node node) {
    if (node == null)
        return null;
    return OptionElement.as(Element.as(node));
}

From source file:com.watopi.chosen.client.SelectParser.java

License:Open Source License

private void addGroup(OptGroupElement group) {
    int position = parsed.length();

    GroupItem item = new GroupItem();
    item.arrayIndex = position;/*from   www . j  a v  a  2s .c o m*/
    item.label = group.getLabel();
    item.children = 0;
    item.disabled = group.isDisabled();

    parsed.add(item);

    NodeList<Node> children = group.getChildNodes();
    for (int i = 0; i < children.getLength(); i++) {
        Node n = children.getItem(i);
        if ("OPTION".equalsIgnoreCase(n.getNodeName())) {
            addOption(OptionElement.as((Element) n), position, group.isDisabled());
        }
    }

}

From source file:gwt.material.design.client.ui.html.Option.java

License:Apache License

/**
 * The index of this OPTION in its parent SELECT, starting from 0.
 *//*from w w  w  . j a  va 2 s  . c  om*/
public int getIndex() {
    return OptionElement.as(this.getElement()).getIndex();
}

From source file:gwt.material.design.client.ui.html.Option.java

License:Apache License

/**
 * Option label for use in hierarchical menus.
 * //from w w  w  .  j av a 2 s. co  m
 * @see <a
 *      href="http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-label-OPTION">W3C
 *      HTML Specification</a>
 */
public String getLabel() {
    return OptionElement.as(this.getElement()).getLabel();
}

From source file:gwt.material.design.client.ui.html.Option.java

License:Apache License

/**
 * The text contained within the option element.
 */
public String getText() {
    return OptionElement.as(this.getElement()).getText();
}