当前位置: 首页>>代码示例>>Java>>正文


Java OptionElement类代码示例

本文整理汇总了Java中com.google.gwt.dom.client.OptionElement的典型用法代码示例。如果您正苦于以下问题:Java OptionElement类的具体用法?Java OptionElement怎么用?Java OptionElement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


OptionElement类属于com.google.gwt.dom.client包,在下文中一共展示了OptionElement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: insertItem

import com.google.gwt.dom.client.OptionElement; //导入依赖的package包/类
/**
 * Inserts an item into the list box, specifying its direction and an initial value for the item. If the index is less than zero, or greater than or equal
 * to the length of the list, then the item will be appended to the end of the list.
 *
 * @param item  the text of the item to be inserted
 * @param dir   the item's direction. If {@code null}, the item is displayed in the widget's overall direction, or, if a direction estimator has been set, in
 *              the item's estimated direction.
 * @param value the item's value, to be submitted if it is part of a {@link FormPanel}.
 * @param index the index at which to insert it
 */
public void insertItem(String item, Direction dir, String value, int index) {
    SelectElement select = getSelectElement();
    OptionElement option = Document.get().createOptionElement();
    setOptionText(option, item, dir);
    option.setValue(value);

    int itemCount = select.getLength();
    if (index < 0 || index > itemCount) {
        index = itemCount;
    }
    if (index == itemCount) {
        select.add(option, null);
    } else {
        OptionElement before = select.getOptions().getItem(index);
        select.add(option, before);
    }
}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:28,代码来源:AccessibleListBox.java

示例2: setOptionText

import com.google.gwt.dom.client.OptionElement; //导入依赖的package包/类
/**
 * Sets the text of an option element. If the direction of the text is opposite to the page's direction, also wraps it with Unicode bidi formatting
 * characters to prevent garbling, and indicates that this was done by setting the option's <code>BIDI_ATTR_NAME</code> custom attribute.
 *
 * @param option an option element
 * @param text   text to be set to the element
 * @param dir    the text's direction. If {@code null} and direction estimation is turned off, direction is ignored.
 */
protected void setOptionText(OptionElement option, String text, Direction dir) {
    if (dir == null && estimator != null) {
        dir = estimator.estimateDirection(text);
    }
    if (dir == null) {
        option.setText(text);
        option.removeAttribute(BIDI_ATTR_NAME);
    } else {
        String formattedText = BidiFormatter.getInstanceForCurrentLocale().unicodeWrapWithKnownDir(dir, text, false /* isHtml */, false /* dirReset */);
        option.setText(formattedText);
        if (formattedText.length() > text.length()) {
            option.setAttribute(BIDI_ATTR_NAME, "");
        } else {
            option.removeAttribute(BIDI_ATTR_NAME);
        }
    }
}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:26,代码来源:AccessibleListBox.java

示例3: getOption

import com.google.gwt.dom.client.OptionElement; //导入依赖的package包/类
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)+"]");
}
 
开发者ID:tractionsoftware,项目名称:gwt-traction,代码行数:17,代码来源:GroupedListBox.java

示例4: insertItem

import com.google.gwt.dom.client.OptionElement; //导入依赖的package包/类
@Override
public void insertItem(String item, Direction dir, String value, int index) {
    SelectElement select = getElement().cast();
    OptionElement option = Document.get().createOptionElement();
    setOptionText(option, item, dir);
    option.setValue(value);
    option.setTitle(item);

    int itemCount = select.getLength();
    if (index < 0 || index > itemCount) {
        index = itemCount;
    }
    if (index == itemCount) {
        select.add(option, null);
    } else {
        OptionElement before = select.getOptions().getItem(index);
        select.add(option, before);
    }
}
 
开发者ID:rkfg,项目名称:gwtutil,代码行数:20,代码来源:ListBoxWithTooltip.java

示例5: updateItemMap

import com.google.gwt.dom.client.OptionElement; //导入依赖的package包/类
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);
            }
    }
}
 
开发者ID:gwtbootstrap3,项目名称:gwtbootstrap3-extras,代码行数:21,代码来源:SelectBase.java

示例6: setSelectedValue

import com.google.gwt.dom.client.OptionElement; //导入依赖的package包/类
@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);
        }
    }
}
 
开发者ID:gwtbootstrap3,项目名称:gwtbootstrap3-extras,代码行数:17,代码来源:MultipleSelect.java

示例7: getOptionText

import com.google.gwt.dom.client.OptionElement; //导入依赖的package包/类
/**
 * Retrieves the text of an option element. If the text was set by {@link #setOptionText} and was wrapped with Unicode bidi formatting characters, also
 * removes those additional formatting characters.
 *
 * @param option an option element
 * @return the element's text
 */
protected String getOptionText(OptionElement option) {
    String text = option.getText();
    if (option.hasAttribute(BIDI_ATTR_NAME) && text.length() > 1) {
        text = text.substring(1, text.length() - 1);
    }
    return text;
}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:15,代码来源:AccessibleListBox.java

示例8: createChildOption

import com.google.gwt.dom.client.OptionElement; //导入依赖的package包/类
private OptionElement createChildOption(Document document, SelectElement select, String value, String label) {
	OptionElement option = document.createOptionElement();
	option.setValue(value);
	option.setInnerText(label);

	select.add(option, null);

	return option;
}
 
开发者ID:WhitesteinTechnologies,项目名称:wt-pdf-viewer,代码行数:10,代码来源:WTPdfViewerWidget.java

示例9: setupLocaleSelect

import com.google.gwt.dom.client.OptionElement; //导入依赖的package包/类
private void setupLocaleSelect() {
  final SelectElement select = (SelectElement) Document.get().getElementById(LANG_ELEMENT_ID);
  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_URLBUILDER_PARAMETER, select.getValue());
      Window.Location.replace(builder.buildString());
      localeService.storeLocale(select.getValue());
      return true;
    }
  });
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:30,代码来源:WebClient.java

示例10: showHint

import com.google.gwt.dom.client.OptionElement; //导入依赖的package包/类
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;
    }
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:11,代码来源:SelectorDisplayerView.java

示例11: setItemTitle

import com.google.gwt.dom.client.OptionElement; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:10,代码来源:SelectorDisplayerView.java

示例12: getOption

import com.google.gwt.dom.client.OptionElement; //导入依赖的package包/类
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;
}
 
开发者ID:spupyrev,项目名称:swcv,代码行数:33,代码来源:GroupedListBox.java

示例13: createOption

import com.google.gwt.dom.client.OptionElement; //导入依赖的package包/类
protected OptionElement createOption(String item, String value)
{
    OptionElement option = Document.get().createOptionElement();
    option.setText(item);
    option.setInnerText(item);
    option.setValue(value);
    return option;
}
 
开发者ID:spupyrev,项目名称:swcv,代码行数:9,代码来源:GroupedListBox.java

示例14: removeItem

import com.google.gwt.dom.client.OptionElement; //导入依赖的package包/类
@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)+"]");
}
 
开发者ID:tractionsoftware,项目名称:gwt-traction,代码行数:31,代码来源:GroupedListBox.java

示例15: setItemText

import com.google.gwt.dom.client.OptionElement; //导入依赖的package包/类
@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);
}
 
开发者ID:tractionsoftware,项目名称:gwt-traction,代码行数:9,代码来源:GroupedListBox.java


注:本文中的com.google.gwt.dom.client.OptionElement类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。