List of usage examples for com.google.gwt.dom.client OptionElement setClassName
@Override
public void setClassName(String className)
From source file:burrito.client.widgets.selection.SelectionList.java
License:Apache License
/** * Call this method after having called setModel and setLabelCreator *//*from w ww. j a va 2s . c o m*/ public void render() { pleaseWaitLabel.removeFromParent(); if (model == null) { throw new IllegalStateException("No model set. Make sure you call setModel() before render()"); } if (labelCreator == null) { throw new IllegalStateException( "No labelCreator set. Make sure you call setLabelCreator() before render()"); } listBox.clear(); if (nullSelectLabel != null) { listBox.addItem(nullSelectLabel); } for (T obj : model) { String label = labelCreator.createLabel(obj); listBox.addItem(label); String style = labelCreator.getStyleName(obj); if (style != null) { OptionElement elem = (OptionElement) listBox.getElement().getLastChild(); elem.setClassName(style); } } if (waitingToBeSet != null) { try { setValue(waitingToBeSet); } finally { // if something goes wrong (unexpected exception) we still need // to reset the waitingToBeSet value. Otherwise we might end up // in a situation where the value can't be changed at all. waitingToBeSet = null; } } }
From source file:com.bearsoft.gwt.ui.widgets.StyledListBox.java
public void setItemStyleName(int aIndex, String aValue) { checkIndex(aIndex);// w w w.j a va 2 s . c om OptionElement option = getElement().<SelectElement>cast().getOptions().getItem(aIndex); option.setClassName(aValue); }
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 .j a v a 2 s. c om option.setValue(value); option.setClassName(styleName); select.add(option, null); }
From source file:org.kaaproject.avro.ui.gwt.client.widget.ExtendedValueListBox.java
License:Apache License
private void updateOptionsStyle() { if (Utils.isNotBlank(promptText)) { SelectElement select = getSelectElement(); int index = select.getSelectedIndex(); if (index > -1) { OptionElement selectedOption = getOptionElement(index); if (Utils.isBlank(selectedOption.getValue())) { selectedOption.setClassName(style.prompt()); selectedOption.setText(promptText); addStyleName(style.prompt()); NodeList<OptionElement> options = getSelectElement().getOptions(); for (int i = 0; i < options.getLength(); i++) { if (index != i) { OptionElement option = options.getItem(i); option.setClassName(style.noPrompt()); }//from w ww . j av a2 s . co m } } else { NodeList<OptionElement> options = getSelectElement().getOptions(); for (int i = 0; i < options.getLength(); i++) { OptionElement option = options.getItem(i); if (Utils.isBlank(option.getValue())) { option.setClassName(""); option.setText(""); } } removeStyleName(style.prompt()); } } } }