litesoft
@ 948
litesoft / trunk / GWT_Sandbox / FormEngine / src / com / temp / client / foundation / widget / input / support / CheckBoxValueAdapter.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
package com.temp.client.foundation.widget.input.support; import com.google.gwt.event.dom.client.*; import com.google.gwt.event.logical.shared.*; import com.google.gwt.event.shared.*; import com.google.gwt.user.client.ui.*; import com.temp.client.foundation.widget.input.fieldsupport.*; import com.temp.client.foundation.widget.input.support.events.*; import com.temp.shared.utils.*; public class CheckBoxValueAdapter implements InputWidgetValueAdapter<Boolean> { private final CheckBox inputWidget; private final NonDomChangeEvent changeEvent = new NonDomChangeEvent( this ); public CheckBoxValueAdapter( CheckBox inputWidget ) { Validate.notNull( "inputWidget", this.inputWidget = inputWidget ); } @Override public HandlerRegistration addChangeHandler( final ChangeHandler handler ) { return inputWidget.addValueChangeHandler( new ValueChangeHandler<Boolean>() { @Override public void onValueChange( ValueChangeEvent<Boolean> booleanValueChangeEvent ) { changeEvent.dispatch( handler ); } } ); } @Override public Boolean getValue() { return ObjectUtils.deNull( inputWidget.getValue(), Boolean.FALSE ); } @Override public void setValue( Boolean value ) { inputWidget.setValue( ObjectUtils.deNull( value, Boolean.FALSE ) ); } } |