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

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

Introduction

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

Prototype

public void setLabel(String label) 

Source Link

Document

Assigns a label to this option group.

Usage

From source file:com.ponysdk.core.terminal.ui.PTListBox.java

License:Apache License

@Override
public boolean update(final ReaderBuffer buffer, final BinaryModel binaryModel) {
    final ServerToClientModel model = binaryModel.getModel();
    if (ServerToClientModel.CLEAR == model) {
        uiObject.clear();//ww w .  ja v a 2  s .c om
        return true;
    } else if (ServerToClientModel.ITEM_INSERTED == model) {
        final String item = binaryModel.getStringValue() != null ? binaryModel.getStringValue() : "";
        final BinaryModel indexModel = buffer.readBinaryModel();
        if (ServerToClientModel.INDEX == indexModel.getModel()) {
            uiObject.insertItem(item, indexModel.getIntValue());
        } else {
            buffer.rewind(indexModel);
            uiObject.addItem(item);
        }
        return true;
    } else if (ServerToClientModel.ITEM_ADD == model) {
        final String items = binaryModel.getStringValue();
        // ServerToClientModel.ITEM_GROUP
        final String groupName = buffer.readBinaryModel().getStringValue();
        final SelectElement select = uiObject.getElement().cast();

        final OptGroupElement groupElement = Document.get().createOptGroupElement();
        groupElement.setLabel(groupName);

        final String[] tokens = items.split(";");

        for (final String token : tokens) {
            final OptionElement optElement = Document.get().createOptionElement();
            optElement.setInnerText(token);
            groupElement.appendChild(optElement);
        }
        select.appendChild(groupElement);
        return true;
    } else if (ServerToClientModel.ITEM_UPDATED == model) {
        final String item = binaryModel.getStringValue() != null ? binaryModel.getStringValue() : "";
        // ServerToClientModel.INDEX
        final int index = buffer.readBinaryModel().getIntValue();
        uiObject.setItemText(index, item);
        return true;
    } else if (ServerToClientModel.ITEM_REMOVED == model) {
        uiObject.removeItem(binaryModel.getIntValue());
        return true;
    } else if (ServerToClientModel.SELECTED == model) {
        final boolean selected = binaryModel.getBooleanValue();
        // ServerToClientModel.INDEX
        final int index = buffer.readBinaryModel().getIntValue();
        if (index == -1)
            uiObject.setSelectedIndex(index);
        else
            uiObject.setItemSelected(index, selected);
        return true;
    } else if (ServerToClientModel.VISIBLE_ITEM_COUNT == model) {
        uiObject.setVisibleItemCount(binaryModel.getIntValue());
        return true;
    } else if (ServerToClientModel.MULTISELECT == model) {
        uiObject.setMultipleSelect(binaryModel.getBooleanValue());
        return true;
    } else {
        return super.update(buffer, binaryModel);
    }
}

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.
 * //from  w  w  w  .  j  a v a  2  s  .co  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:org.xwiki.gwt.wysiwyg.client.plugin.style.StylePlugin.java

License:Open Source License

/**
 * Group the given style names under the specified group.
 * //from  ww w  . j ava  2s.c om
 * @param groupLabel the group label
 * @param styleNames the style names to group
 */
private void groupStyleNames(String groupLabel, List<OptionElement> styleNames) {
    OptGroupElement group = styleNamePicker.getElement().getOwnerDocument().createOptGroupElement();
    group.setLabel(groupLabel);
    styleNamePicker.getElement().appendChild(group);
    for (OptionElement styleName : styleNames) {
        group.appendChild(styleName);
    }
}