Example usage for com.google.gwt.dom.client OptGroupElement getLabel

List of usage examples for com.google.gwt.dom.client OptGroupElement getLabel

Introduction

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

Prototype

public String getLabel() 

Source Link

Document

Assigns a label to this option group.

Usage

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;//from ww  w. ja  va2 s .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.uni.hs13.visupoll.client.OptGroupListBox.java

License:Apache License

/**
 * Adds a new OPTGROUP item to the ListBox. If the name of the group already exists, the group
 * item will <strong>not</strong> be created.
 * //  w  ww .j  a v a 2  s.  c  o  m
 * @param groupName The name of the group.
 * @return {@code true}, if the name does not already exist, otherwise {@code false}.
 */
public boolean addGroup(final String groupName) {
    // check if this group already exists
    SelectElement selectElement = this.getElement().cast();
    NodeList<Element> elementsByTagName = selectElement.getElementsByTagName("*");

    for (int i = 0; i < elementsByTagName.getLength(); i++) {
        Element item = elementsByTagName.getItem(i);

        if (OptGroupListBoxItemType.GROUP.getItemNodeName().equals(item.getNodeName())) {
            OptGroupElement castedElement = (OptGroupElement) item;
            if (castedElement.getLabel().equals(groupName)) {
                return false;
            }
        }
    }

    // okay, it does not already exist... create it
    OptGroupElement groupElement = Document.get().createOptGroupElement();
    groupElement.setLabel(groupName);
    SelectElement select = this.getElement().cast();
    select.appendChild(groupElement);
    latestOptGroupElement = groupElement;
    return true;
}

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  w w w  .  ja  v  a2  s .  co  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());
        }
    }

}