类com.google.gwt.dom.client.OptionElement源码实例Demo

下面列出了怎么用com.google.gwt.dom.client.OptionElement的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: gwt-traction   文件: GroupedListBox.java
protected OptionElement getOption(int index) {
    checkIndex(index);

    int childIndex = index;
    for (OptGroup group : groups) {
        int count = group.getCount();
        if (childIndex < count) {
            return group.getChildOption(childIndex);
        }
        else {
            childIndex -= count;
        }
    }

    throw new IndexOutOfBoundsException("problem in getOption: index="+index+" range=[0-"+(getItemCount()-1)+"]");
}
 
源代码2 项目: gwtbootstrap3-extras   文件: SelectBase.java
void updateItemMap(Widget widget, boolean toAdd) {
    // Option ==> update with this option
    if (widget instanceof Option) {
        Option option = (Option) widget;
        if (toAdd)
            itemMap.put(option.getSelectElement(), option);
        else
            itemMap.remove(option.getSelectElement());
    } else if (widget instanceof OptGroup) {
        // OptGroup ==> update with all optGroup options
        OptGroup optGroup = (OptGroup) widget;
        if (toAdd)
            itemMap.putAll(optGroup.getItemMap());
        else
            for (Entry<OptionElement, Option> entry : optGroup.getItemMap().entrySet()) {
                OptionElement optElem = entry.getKey();
                itemMap.remove(optElem);
            }
    }
}
 
源代码3 项目: gwtbootstrap3-extras   文件: MultipleSelect.java
@Override
protected void setSelectedValue(List<String> value) {
    if (isAttached()) {
        final JsArrayString arr = JavaScriptObject.createArray().cast();
        for (final String val : value) {
            arr.push(val);
        }
        setValue(getElement(), arr);
    } else {
        for (Entry<OptionElement, Option> entry : itemMap.entrySet()) {
            Option opt = entry.getValue();
            boolean selected = value.contains(opt.getValue());
            opt.setSelected(selected);
        }
    }
}
 
源代码4 项目: cuba   文件: CubaTwinColSelectWidget.java
public List<String> getItems() {
    List<String> items = new ArrayList<>();
    for (int i = 0; i < getItemCount(); i++) {
        OptionElement optionElement = (OptionElement) getOptionElement(i);
        items.add(getOptionText(optionElement));
    }
    return items;
}
 
源代码5 项目: cuba   文件: CubaListSelectWidget.java
public CubaListSelectWidget() {
    getOptionsContainer().addDoubleClickHandler(event -> {
        if (!isEnabled() || isReadonly()) {
            return;
        }

        Element element = WidgetUtil.getElementUnderMouse(event.getNativeEvent());

        if (OptionElement.is(element)) {
            doubleClickListener.accept(((OptionElement) element).getIndex());
        }
    });
}
 
源代码6 项目: gwt-material   文件: MaterialListValueBox.java
protected void removeEmptyPlaceHolder() {
    // indeed the first item/value is emptyPlaceHolder
    listBox.removeItem(0);
    values.remove(0);

    OptionElement currentPlaceholder = getOptionElement(0);
    if (currentPlaceholder != null) {
        currentPlaceholder.setDisabled(false);
    }
}
 
源代码7 项目: swellrt   文件: WebClient.java
private void setupLocaleSelect() {
  final SelectElement select = (SelectElement) Document.get().getElementById("lang");
  String currentLocale = LocaleInfo.getCurrentLocale().getLocaleName();
  String[] localeNames = LocaleInfo.getAvailableLocaleNames();
  for (String locale : localeNames) {
    if (!DEFAULT_LOCALE.equals(locale)) {
      String displayName = LocaleInfo.getLocaleNativeDisplayName(locale);
      OptionElement option = Document.get().createOptionElement();
      option.setValue(locale);
      option.setText(displayName);
      select.add(option, null);
      if (locale.equals(currentLocale)) {
        select.setSelectedIndex(select.getLength() - 1);
      }
    }
  }
  EventDispatcherPanel.of(select).registerChangeHandler(null, new WaveChangeHandler() {

    @Override
    public boolean onChange(ChangeEvent event, Element context) {
      UrlBuilder builder = Location.createUrlBuilder().setParameter(
              "locale", select.getValue());
      Window.Location.replace(builder.buildString());
      localeService.storeLocale(select.getValue());
      return true;
    }
  });
}
 
源代码8 项目: swcv   文件: GroupedListBox.java
protected OptionElement getOption(int index)
{
    checkIndex(index);

    // first check ungrouped
    Element elm = getElement();
    int sz = elm.getChildCount();
    int firstGroup = getIndexOfFirstGroup();
    if (index >= 0 && index < firstGroup && index < sz)
    {
        return option(elm.getChild(index));
    }

    // then go through the groups
    int childIndex = index - firstGroup;
    for (int i = firstGroup; i <= index && i < sz; i++)
    {
        Node child = elm.getChild(i);
        if (isGroup(child))
        {
            if (childIndex < child.getChildCount())
            {
                return option(child.getChild(childIndex));
            }
            else
            {
                childIndex -= child.getChildCount();
            }
        }
    }
    return null;
}
 
源代码9 项目: swcv   文件: GroupedListBox.java
protected OptionElement createOption(String item, String value)
{
    OptionElement option = Document.get().createOptionElement();
    option.setText(item);
    option.setInnerText(item);
    option.setValue(value);
    return option;
}
 
源代码10 项目: gwt-traction   文件: GroupedListBox.java
@Override
public void removeItem(int index) {

    int childIndex = index;
    for (int i=0; i<groups.size(); i++) {
        OptGroup group = groups.get(i);
        int count = group.getCount();
        if (childIndex < count) {

            // do the remove
            OptionElement element = group.getChildOption(childIndex);
            element.removeFromParent();

            group.decrement();

            // remove empty groups
            if (group.getCount() <= 0) {
                group.remove();
                groups.remove(i);
            }

            return;
        }
        else {
            childIndex -= count;
        }
    }

    throw new IndexOutOfBoundsException("problem in removeItem: index="+index+" range=[0-"+(getItemCount()-1)+"]");
}
 
源代码11 项目: gwt-traction   文件: GroupedListBox.java
@Override
public void setItemText(int index, String text) {
    if (text == null) {
        throw new NullPointerException("Cannot set an option to have null text");
    }
    OptionElement option = getOption(index);
    option.setText(text);
}
 
源代码12 项目: gwt-traction   文件: GroupedListBox.java
protected OptionElement createOption(String item, String value) {
    OptionElement option = Document.get().createOptionElement();
    option.setText(item);
    option.setInnerText(item);
    option.setValue(value);
    return option;
}
 
源代码13 项目: dashbuilder   文件: SelectorDisplayerView.java
protected void showHint(String hint) {
    if (hintEnabled) {
        SelectElement selectElement = SelectElement.as(listBox.getElement());
        NodeList<OptionElement> options = selectElement.getOptions();
        options.getItem(0).setText(hint);
    } else {
        listBox.addItem(hint);
        hintEnabled = true;
    }
}
 
源代码14 项目: dashbuilder   文件: SelectorDisplayerView.java
@Override
public void setItemTitle(int index, String title) {
    SelectElement selectElement = SelectElement.as(listBox.getElement());
    NodeList<OptionElement> options = selectElement.getOptions();
    OptionElement optionElement = options.getItem(index + (hintEnabled ? 1: 0));
    if (optionElement != null) {
        optionElement.setTitle(title);
    }
}
 
源代码15 项目: incubator-retired-wave   文件: WebClient.java
private void setupLocaleSelect() {
  final SelectElement select = (SelectElement) Document.get().getElementById("lang");
  String currentLocale = LocaleInfo.getCurrentLocale().getLocaleName();
  String[] localeNames = LocaleInfo.getAvailableLocaleNames();
  for (String locale : localeNames) {
    if (!DEFAULT_LOCALE.equals(locale)) {
      String displayName = LocaleInfo.getLocaleNativeDisplayName(locale);
      OptionElement option = Document.get().createOptionElement();
      option.setValue(locale);
      option.setText(displayName);
      select.add(option, null);
      if (locale.equals(currentLocale)) {
        select.setSelectedIndex(select.getLength() - 1);
      }
    }
  }
  EventDispatcherPanel.of(select).registerChangeHandler(null, new WaveChangeHandler() {

    @Override
    public boolean onChange(ChangeEvent event, Element context) {
      UrlBuilder builder = Location.createUrlBuilder().setParameter(
              "locale", select.getValue());
      Window.Location.replace(builder.buildString());
      localeService.storeLocale(select.getValue());
      return true;
    }
  });
}
 
源代码16 项目: gwtbootstrap3-extras   文件: Select.java
private String getSelectedValue() {
    for (Entry<OptionElement, Option> entry : itemMap.entrySet()) {
        Option opt = entry.getValue();
        if (opt.isSelected())
            return opt.getValue();
    }
    return null;
}
 
源代码17 项目: gwtbootstrap3-extras   文件: Select.java
@Override
protected void setSelectedValue(String value) {
    if (isAttached()) {
        setValue(getElement(), value);
    } else {
        for (Entry<OptionElement, Option> entry : itemMap.entrySet()) {
            Option opt = entry.getValue();
            opt.setSelected(opt.getValue().equals(value));
        }
    }
}
 
源代码18 项目: gwtbootstrap3-extras   文件: Select.java
/**
 * Returns the selected item or <code>null</code> if no item is selected.
 *
 * @return the selected items list
 */
public Option getSelectedItem() {
    for (Entry<OptionElement, Option> entry : itemMap.entrySet()) {
        Option opt = entry.getValue();
        if (opt.isSelected())
            return opt;
    }
    return null;
}
 
源代码19 项目: gwtbootstrap3-extras   文件: SelectBase.java
/**
 * Returns the item list.
 *
 * @return the item list
 */
public List<Option> getItems() {
    List<Option> selectedItems = new ArrayList<>(0);
    NodeList<OptionElement> items = selectElement.getOptions();
    for (int i = 0; i < items.getLength(); i++) {
        OptionElement item = items.getItem(i);
        Option option = itemMap.get(item);
        if (option != null)
            selectedItems.add(option);
    }
    return selectedItems;
}
 
源代码20 项目: gwtbootstrap3-extras   文件: MultipleSelect.java
private List<String> getSelectedValues() {
    final List<String> allSelected = new ArrayList<>(0);
    for (Entry<OptionElement, Option> entry : itemMap.entrySet()) {
        Option opt = entry.getValue();
        if (opt.isSelected())
            allSelected.add(opt.getValue());
    }
    return allSelected;
}
 
源代码21 项目: gwtbootstrap3-extras   文件: MultipleSelect.java
/**
 * Returns the selected items list. If no item is selected, this method
 * returns an empty list.
 *
 * @return the selected items list
 */
public List<Option> getSelectedItems() {
    final List<Option> items = new ArrayList<>(0);
    for (Entry<OptionElement, Option> entry : itemMap.entrySet()) {
        Option opt = entry.getValue();
        if (opt.isSelected())
            items.add(opt);
    }
    return items;
}
 
源代码22 项目: gwtbootstrap3-extras   文件: MultipleSelect.java
private void setSelectAll(boolean selected) {
    if (isAttached()) {
        String cmd = selected ? SelectCommand.SELECT_ALL : SelectCommand.DESELECT_ALL;
        command(getElement(), cmd);
    } else {
        for (Entry<OptionElement, Option> entry : itemMap.entrySet()) {
            entry.getValue().setSelected(selected);
        }
    }
}
 
源代码23 项目: gwtbootstrap3-extras   文件: MVTagsInput.java
@Override
public void add(String tag) {
    if (isAttached())
        super.add(tag);
    else {
        OptionElement option = Document.get().createOptionElement();
        option.setValue(tag);
        option.setInnerText(tag);
        getElement().appendChild(option);
    }
}
 
源代码24 项目: gwt-material   文件: MaterialListBox.java
public void add(Option option) {
    getSelectElement().add(OptionElement.as(option.getElement()), null);
    values.add(option.getValue());
}
 
源代码25 项目: gwt-material   文件: MaterialListValueBox.java
public OptionElement getOptionElement(int index) {
    return getSelectElement().getOptions().getItem(index);
}
 
源代码26 项目: gwt-material   文件: Option.java
public Option() {
    super(Document.get().createElement(OptionElement.TAG));
}
 
源代码27 项目: gwt-material   文件: Option.java
/**
 * The index of this OPTION in its parent SELECT, starting from 0.
 */
public int getIndex() {
    return OptionElement.as(this.getElement()).getIndex();
}
 
源代码28 项目: gwt-material   文件: Option.java
/**
 * The text contained within the option element.
 */
public String getText() {
    return OptionElement.as(this.getElement()).getText();
}
 
源代码29 项目: gwt-material   文件: Option.java
/**
 * The text contained within the option element.
 */
public void setText(String text) {
    OptionElement.as(this.getElement()).setText(text);
}
 
源代码30 项目: swcv   文件: GroupedListBox.java
private OptionElement option(Node node)
{
    if (node == null)
        return null;
    return OptionElement.as(Element.as(node));
}
 
 类方法