Java 类com.google.gwt.dom.client.OptGroupElement 实例源码

项目:swcv    文件:GroupedListBox.java   
protected boolean isMatchingGroup(Node child, String group)
{
    if (isGroup(child))
    {
        OptGroupElement optgroup = optgroup(child);
        return group.equals(optgroup.getLabel());
    }
    else
    {
        return false;
    }
}
项目:swcv    文件:GroupedListBox.java   
protected OptGroupElement findOptGroupElement(String name)
{
    if (name == null)
        return null;
    NodeList<Element> optgroups = getElement().getElementsByTagName("OPTGROUP");
    for (int i = 0; i < optgroups.getLength(); i++)
    {
        Element optgroup = optgroups.getItem(i);
        if (isMatchingGroup(optgroup, name))
        {
            return OptGroupElement.as(optgroup);
        }
    }
    return null;
}
项目:swcv    文件:GroupedListBox.java   
private OptGroupElement optgroup(Node node)
{
    if (node == null)
        return null;
    return OptGroupElement.as(Element.as(node));
}
项目:swcv    文件:GroupedListBox.java   
@Override
public void insertItem(String item, String value, int index)
{
    // find the delimiter if there is one
    int pipe = (item != null) ? item.indexOf('|') : -1;
    while (pipe != -1 && pipe + 1 != item.length() && item.charAt(pipe + 1) == '|')
    {
        pipe = item.indexOf('|', pipe + 2);
    }

    // extract the group if we found a delimiter
    String group = null;
    if (pipe != -1)
    {
        group = item.substring(0, pipe).trim();
        item = item.substring(pipe + 1).trim();

        // make sure we convert || -> | in the group name
        group = group.replace("||", "|");
    }

    Element parent = getSelectElement();
    Node before = null;

    if (group != null)
    {
        OptGroupElement optgroup = findOptGroupElement(group);
        if (optgroup != null)
        {
            // add it to this optgroup
            parent = optgroup;

            // adjust the index to inside the group
            int adjusted = getIndexInGroup(group, index);

            // we had a real index (wasn't negative which means
            // add to the end), but it was too low for this group.
            // put it at the beginning of the group.
            if (adjusted < 0 && index >= 0)
            {
                adjusted = 0;
            }

            // check the range and if it's out of range, we'll
            // just add it to the end
            // of the group (before == null)
            if (0 <= adjusted && adjusted < optgroup.getChildCount())
            {
                before = optgroup.getChild(adjusted);
            }
        }
        else
        {
            // add a new group and add the item to it
            optgroup = Document.get().createOptGroupElement();
            optgroup.setLabel(group);
            parent.appendChild(optgroup);
            parent = optgroup;
            before = null;
        }
    }
    else
    {
        // make sure we're not past the initial "group" of
        // ungrouped options
        int max = getIndexOfFirstGroup();
        if (index < 0 || index > max)
        {
            before = (max < parent.getChildCount()) ? parent.getChild(max) : null;
        }
        else if (0 <= index && index < parent.getChildCount())
        {
            before = parent.getChild(index);
        }
    }

    OptionElement option = createOption(item, value);
    parent.insertBefore(option, before);
}
项目:gwt-material    文件:OptGroup.java   
/**
 * Option label for use in hierarchical menus.
 *
 * @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 OptGroupElement.as(this.getElement()).getLabel();
}
项目:gwt-material    文件:OptGroup.java   
/**
 * The control is unavailable in this context.
 *
 * @see <a
 * href="http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-disabled">W3C
 * HTML Specification</a>
 */
public boolean isDisabled() {
    return OptGroupElement.as(this.getElement()).isDisabled();
}
项目:gwt-material    文件:OptGroup.java   
/**
 * The control is unavailable in this context.
 *
 * @see <a
 * href="http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-disabled">W3C
 * HTML Specification</a>
 */
public void setDisabled(boolean disabled) {
    OptGroupElement.as(this.getElement()).setDisabled(disabled);
}
项目:gwt-material    文件:OptGroup.java   
/**
 * Option label for use in hierarchical menus.
 *
 * @see <a
 * href="http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-label-OPTION">W3C
 * HTML Specification</a>
 */
public void setLabel(String label) {
    OptGroupElement.as(this.getElement()).setLabel(label);
}