Java Code Examples for com.google.gwt.dom.client.OptionElement#setValue()

The following examples show how to use com.google.gwt.dom.client.OptionElement#setValue() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WebClient.java    From swellrt with Apache License 2.0 5 votes vote down vote up
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;
    }
  });
}
 
Example 2
Source File: GroupedListBox.java    From swcv with MIT License 5 votes vote down vote up
protected OptionElement createOption(String item, String value)
{
    OptionElement option = Document.get().createOptionElement();
    option.setText(item);
    option.setInnerText(item);
    option.setValue(value);
    return option;
}
 
Example 3
Source File: GroupedListBox.java    From gwt-traction with Apache License 2.0 5 votes vote down vote up
protected OptionElement createOption(String item, String value) {
    OptionElement option = Document.get().createOptionElement();
    option.setText(item);
    option.setInnerText(item);
    option.setValue(value);
    return option;
}
 
Example 4
Source File: WebClient.java    From incubator-retired-wave with Apache License 2.0 5 votes vote down vote up
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;
    }
  });
}
 
Example 5
Source File: MVTagsInput.java    From gwtbootstrap3-extras with Apache License 2.0 5 votes vote down vote up
@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);
    }
}
 
Example 6
Source File: GroupedListBox.java    From gwt-traction with Apache License 2.0 4 votes vote down vote up
@Override
public void setValue(int index, String value) {
    OptionElement option = getOption(index);
    option.setValue(value);
}