|
@@ -1,60 +1,60 @@ |
1 |
|
- |
// This Source Code is in the Public Domain per: http://unlicense.org |
2 |
|
- |
package org.litesoft.GWT.forms.client.components.factories.input; |
3 |
|
- |
|
4 |
|
- |
import org.litesoft.GWT.forms.client.components.factories.*; |
5 |
|
- |
import org.litesoft.GWT.forms.client.components.impls.input.*; |
6 |
|
- |
import org.litesoft.GWT.forms.client.nonpublic.*; |
7 |
|
- |
import org.litesoft.commonfoundation.typeutils.*; |
8 |
|
- |
import org.litesoft.ui.def.nonpublic.*; |
9 |
|
- |
import org.litesoft.ui.def.nonpublic.support.*; |
10 |
|
- |
import org.litesoft.uispecification.*; |
11 |
|
- |
|
12 |
|
- |
import com.google.gwt.user.client.ui.*; |
13 |
|
- |
|
14 |
|
- |
import java.io.*; |
15 |
|
- |
|
16 |
|
- |
public class UiCheckBoxWidgetFactory implements InputWidgetFactory { |
17 |
|
- |
public Widget create( FormInstanceComponentHandler pComponentHandler, // |
18 |
|
- |
UiInputDef pUiDef, AttributeMetaData pMetaData, |
19 |
|
- |
boolean pHasHorizontalPeer ) { |
20 |
|
- |
CheckBoxMetaData zMD = (CheckBoxMetaData) pMetaData; |
21 |
|
- |
|
22 |
|
- |
String zLabelText = !pUiDef.isLabelLess() ? zMD.getExternalText() : null; |
23 |
|
- |
UiFont zLabelFont = pUiDef.getLabelFont(); |
24 |
|
- |
String zTooltip = zMD.getTooltip(); |
25 |
|
- |
|
26 |
|
- |
// Todo: Hint for Alignment? |
27 |
|
- |
FormCheckBox zFC = new FormCheckBox( zLabelText, zLabelFont, zTooltip, pHasHorizontalPeer ); |
28 |
|
- |
|
29 |
|
- |
return new MyFormAdapter( pComponentHandler, zMD, zFC ).init(); |
30 |
|
- |
} |
31 |
|
- |
|
32 |
|
- |
private static final class MyFormAdapter extends AbstractFormAttributeAdapter { |
33 |
|
- |
public MyFormAdapter( FormInstanceComponentHandler pComponentHandler, // |
34 |
|
- |
CheckBoxMetaData pMD, FormCheckBox pFC ) { |
35 |
|
- |
super( pComponentHandler, pMD, pFC ); |
36 |
|
- |
} |
37 |
|
- |
|
38 |
|
- |
protected void publishChangedState( boolean pChangedState ) { |
39 |
|
- |
super.publishChangedState( pChangedState ); |
40 |
|
- |
optionallyPublishUpdatedValue(); |
41 |
|
- |
} |
42 |
|
- |
|
43 |
|
- |
protected Serializable convertComponentValueToSendable( Object pValue ) { |
44 |
|
- |
return (Boolean) pValue; |
45 |
|
- |
} |
46 |
|
- |
|
47 |
|
- |
protected Object convertSendableToComponentValue( Serializable pValue ) { |
48 |
|
- |
return Boolean.TRUE.equals( pValue ); |
49 |
|
- |
} |
50 |
|
- |
|
51 |
|
- |
protected String convertComponentValueToString( Object pValue ) { |
52 |
|
- |
|
53 |
|
- |
return (pValue == null) ? "null" : "" + pValue; |
54 |
|
- |
} |
55 |
|
- |
|
56 |
|
- |
protected Object convertStringToComponentValue( String pValue ) { |
57 |
|
- |
return !"null".equals( pValue ) ? Booleans.fromString( pValue ) : null; |
58 |
|
- |
} |
59 |
|
- |
} |
60 |
|
- |
} |
|
1 |
+ |
// This Source Code is in the Public Domain per: http://unlicense.org |
|
2 |
+ |
package org.litesoft.GWT.forms.client.components.factories.input; |
|
3 |
+ |
|
|
4 |
+ |
import org.litesoft.GWT.forms.client.components.factories.*; |
|
5 |
+ |
import org.litesoft.GWT.forms.client.components.impls.input.*; |
|
6 |
+ |
import org.litesoft.GWT.forms.client.nonpublic.*; |
|
7 |
+ |
import org.litesoft.commonfoundation.typeutils.*; |
|
8 |
+ |
import org.litesoft.ui.def.nonpublic.*; |
|
9 |
+ |
import org.litesoft.ui.def.nonpublic.support.*; |
|
10 |
+ |
import org.litesoft.uispecification.*; |
|
11 |
+ |
|
|
12 |
+ |
import com.google.gwt.user.client.ui.*; |
|
13 |
+ |
|
|
14 |
+ |
import java.io.*; |
|
15 |
+ |
|
|
16 |
+ |
public class UiCheckBoxWidgetFactory implements InputWidgetFactory { |
|
17 |
+ |
public Widget create( FormInstanceComponentHandler pComponentHandler, // |
|
18 |
+ |
UiInputDef pUiDef, AttributeMetaData pMetaData, |
|
19 |
+ |
boolean pHasHorizontalPeer ) { |
|
20 |
+ |
CheckBoxMetaData zMD = (CheckBoxMetaData) pMetaData; |
|
21 |
+ |
|
|
22 |
+ |
String zLabelText = !pUiDef.isLabelLess() ? zMD.getExternalText() : null; |
|
23 |
+ |
UiFont zLabelFont = pUiDef.getLabelFont(); |
|
24 |
+ |
String zTooltip = zMD.getTooltip(); |
|
25 |
+ |
|
|
26 |
+ |
// Todo: Hint for Alignment? |
|
27 |
+ |
FormCheckBox zFC = new FormCheckBox( zLabelText, zLabelFont, zTooltip, pHasHorizontalPeer ); |
|
28 |
+ |
|
|
29 |
+ |
return new MyFormAdapter( pComponentHandler, zMD, zFC ).init(); |
|
30 |
+ |
} |
|
31 |
+ |
|
|
32 |
+ |
private static final class MyFormAdapter extends AbstractFormAttributeAdapter { |
|
33 |
+ |
public MyFormAdapter( FormInstanceComponentHandler pComponentHandler, // |
|
34 |
+ |
CheckBoxMetaData pMD, FormCheckBox pFC ) { |
|
35 |
+ |
super( pComponentHandler, pMD, pFC ); |
|
36 |
+ |
} |
|
37 |
+ |
|
|
38 |
+ |
protected void publishChangedState( boolean pChangedState ) { |
|
39 |
+ |
super.publishChangedState( pChangedState ); |
|
40 |
+ |
optionallyPublishUpdatedValue(); |
|
41 |
+ |
} |
|
42 |
+ |
|
|
43 |
+ |
protected Serializable convertComponentValueToSendable( Object pValue ) { |
|
44 |
+ |
return (Boolean) pValue; |
|
45 |
+ |
} |
|
46 |
+ |
|
|
47 |
+ |
protected Object convertSendableToComponentValue( Serializable pValue ) { |
|
48 |
+ |
return Boolean.TRUE.equals( pValue ); |
|
49 |
+ |
} |
|
50 |
+ |
|
|
51 |
+ |
protected String convertComponentValueToString( Object pValue ) { |
|
52 |
+ |
|
|
53 |
+ |
return (pValue == null) ? "null" : "" + pValue; |
|
54 |
+ |
} |
|
55 |
+ |
|
|
56 |
+ |
protected Object convertStringToComponentValue( String pValue ) { |
|
57 |
+ |
return !"null".equals( pValue ) ? Booleans.fromString( pValue ) : null; |
|
58 |
+ |
} |
|
59 |
+ |
} |
|
60 |
+ |
} |