Example usage for com.google.gwt.user.client.ui ValueListBox addValueChangeHandler

List of usage examples for com.google.gwt.user.client.ui ValueListBox addValueChangeHandler

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui ValueListBox addValueChangeHandler.

Prototype

public HandlerRegistration addValueChangeHandler(ValueChangeHandler<T> handler) 

Source Link

Usage

From source file:jdramaix.client.ScrollListSample.java

License:Apache License

private Widget createEffectSelector() {
    ValueListBox<Effect> listBox = new ValueListBox<Effect>(new AbstractRenderer<Effect>() {
        @Override/*from   w  ww . java 2  s  .  c  o  m*/
        public String render(Effect object) {
            return object != null ? object.name().toLowerCase() : "";
        }
    });

    listBox.setValue(currentEffect);
    listBox.setAcceptableValues(Arrays.asList(Effect.values()));
    listBox.addValueChangeHandler(new ValueChangeHandler<Effect>() {
        @Override
        public void onValueChange(ValueChangeEvent<Effect> event) {
            Effect effect = event.getValue();

            if (currentEffect != Effect.NONE) {
                effectContainer.removeClassName(currentEffect.getEffectStyle());
            }

            if (effect != Effect.NONE) {
                effectContainer.addClassName(effect.getEffectStyle());
            }

            currentEffect = effect;
        }
    });
    return listBox;
}