List of usage examples for com.google.gwt.dom.client SelectElement add
public final void add(OptionElement option, OptionElement before)
From source file:net.urlgrey.mythpodcaster.client.StyledListBox.java
License:Open Source License
public void addItemWithStyle(String item, String value) { final SelectElement select = getElement().cast(); final OptionElement option = Document.get().createOptionElement(); option.setText(item);//from w w w .ja v a 2 s. c o m option.setValue(value); option.setClassName(styleName); select.add(option, null); }
From source file:org.pentaho.mantle.client.ui.custom.ListBoxTitle.java
License:Open Source License
@Override public void insertItem(String item, HasDirection.Direction dir, String value, int index) { SelectElement select = (SelectElement) this.getElement().cast(); OptionElement option = Document.get().createOptionElement(); this.setOptionText(option, item, dir); option.setValue(value);/*from w w w.ja v a 2 s.co m*/ option.setTitle(value); int itemCount = select.getLength(); if (index < 0 || index > itemCount) { index = itemCount; } if (index == itemCount) { select.add(option, (OptionElement) null); } else { OptionElement before = (OptionElement) select.getOptions().getItem(index); select.add(option, before); } }
From source file:org.swellrt.webclient.WebClientMod.java
License:Apache License
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);/*from www. j av a2 s . com*/ 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; } }); }