litesoft
@ 939
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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
package org.litesoft.mgwt.client.widgets; import org.litesoft.GWT.client.widgets.*; import org.litesoft.commonfoundation.annotations.*; import org.litesoft.commonfoundation.typeutils.*; import org.litesoft.core.util.*; import com.google.gwt.dom.client.*; import com.google.gwt.editor.client.*; import com.google.gwt.event.logical.shared.*; import com.google.gwt.event.shared.*; import com.google.gwt.user.client.*; import com.google.gwt.user.client.ui.*; import com.googlecode.mgwt.ui.client.*; import com.googlecode.mgwt.ui.client.theme.base.*; import com.googlecode.mgwt.ui.client.widget.*; /** * */ public class MLabeledCheckBox extends Composite implements HasText, HasValue<Boolean>, IsEditor<LeafValueEditor<Boolean>> { private final LabelElement labelElement = LabelElement.as( DOM.createLabel() ); private final MCheckBox mCheckBox; private String mText; public MLabeledCheckBox( @Nullable String pText, @NotNull CheckBoxCss pCheckBoxCss, @NotNull InputCss pInputCss ) { SpanPanel zPanel = new SpanPanel(); zPanel.add( labelElement ); zPanel.add( mCheckBox = new MCheckBox( pCheckBoxCss ) ); initWidget( zPanel ); addStyleName( pInputCss.radioButton() ); setText( pText ); } public MLabeledCheckBox( @Nullable String pText ) { this( pText, MGWTStyle.getTheme().getMGWTClientBundle().getCheckBoxCss(), MGWTStyle.getTheme().getMGWTClientBundle().getInputCss() ); } @Override public String getText() { return mText; } @Override public void setText( @Nullable String pText ) { labelElement.setInnerHTML( HTMLize.escapeNoWrap( Strings.noEmpty( mText = pText, " " ) ) ); } @Override public Boolean getValue() { return mCheckBox.getValue(); } @Override public void setValue( Boolean value ) { mCheckBox.setValue( value ); } @Override public void setValue( Boolean value, boolean fireEvents ) { mCheckBox.setValue( value, fireEvents ); } @Override public HandlerRegistration addValueChangeHandler( ValueChangeHandler<Boolean> handler ) { return mCheckBox.addValueChangeHandler( handler ); } @Override public LeafValueEditor<Boolean> asEditor() { return mCheckBox.asEditor(); } } |