private void notifyIfChanged(int index) { if (hasListeners() && selectionIndex != index) { Object oldValue = valueAtIndex(selectionIndex); Object newValue = valueAtIndex(index); selectionIndex = index; fireValueChange(Diffs.createValueDiff(oldValue, newValue)); } }
protected Object doGetValue() { return hasListeners() ? valueAtIndex(selectionIndex) : getLiveValue(); }
/** * Adds an option to this SelectObservableValue. If the observable contains * Boolean.TRUE then the selection changes immediately to the given value. * * @param value * The value associated with the provided observable * @param observable * an observable of value type Boolean.class or Boolean.TYPE */ public void addOption(Object value, IObservableValue observable) { checkRealm(); Option option = new Option(value, observable); addOption(option); if (hasListeners()) { observable.addValueChangeListener(listener); if (Boolean.TRUE.equals(observable.getValue())) { notifyIfChanged(indexOfObservable(observable)); } } }
protected void doSetValue(Object value) { int index = indexOfValue(value); try { updating = true; for (int i = 0; i < options.length; i++) { options[i].observable.setValue(i == index ? Boolean.TRUE : Boolean.FALSE); } } finally { updating = false; } notifyIfChanged(index); }
protected void firstListenerAdded() { super.firstListenerAdded(); selectionIndex = indexOfValue(getLiveValue()); for (int i = 0; i < options.length; i++) { options[i].observable.addValueChangeListener(listener); } }