com.google.gwt.dom.client.SelectElement Java Examples

The following examples show how to use com.google.gwt.dom.client.SelectElement. 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: SelectorDisplayerView.java    From dashbuilder with Apache License 2.0 5 votes vote down vote up
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;
    }
}
 
Example #3
Source File: SelectorDisplayerView.java    From dashbuilder with Apache License 2.0 5 votes vote down vote up
@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);
    }
}
 
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: MultiValueTagsInput.java    From gwtbootstrap3-extras with Apache License 2.0 5 votes vote down vote up
public MultiValueTagsInput(final Collection<? extends Dataset<T>> datasets) {
    SelectElement tagsSelect = Document.get().createSelectElement();
    tagsSelect.setMultiple(true);
    tagsSelect.setAttribute("data-role", "tagsinput");

    setElement(tagsSelect);
    
    setDatasets(datasets);
}
 
Example #6
Source File: MaterialListValueBox.java    From gwt-material with Apache License 2.0 4 votes vote down vote up
protected SelectElement getSelectElement() {
    return listBox.getElement().cast();
}
 
Example #7
Source File: GroupedListBox.java    From swcv with MIT License 4 votes vote down vote up
protected SelectElement getSelectElement()
{
    return getElement().cast();
}
 
Example #8
Source File: GroupedListBox.java    From gwt-traction with Apache License 2.0 4 votes vote down vote up
protected SelectElement getSelectElement() {
    return getElement().cast();
}