|
@@ -1,123 +1,123 @@ |
1 |
|
- |
// This Source Code is in the Public Domain per: http://unlicense.org |
2 |
|
- |
package org.litesoft.GWT.forms.client.components.factories.others; |
3 |
|
- |
|
4 |
|
- |
import org.litesoft.GWT.client.widgets.nonpublic.*; |
5 |
|
- |
import org.litesoft.GWT.forms.client.components.*; |
6 |
|
- |
import org.litesoft.GWT.forms.client.components.factories.*; |
7 |
|
- |
import org.litesoft.GWT.forms.client.nonpublic.*; |
8 |
|
- |
import org.litesoft.ui.*; |
9 |
|
- |
import org.litesoft.ui.def.*; |
10 |
|
- |
import org.litesoft.ui.def.nonpublic.support.*; |
11 |
|
- |
|
12 |
|
- |
import com.google.gwt.user.client.ui.*; |
13 |
|
- |
|
14 |
|
- |
import java.io.*; |
15 |
|
- |
|
16 |
|
- |
public class UiViewWidgetFactory implements FormComponentFactory { |
17 |
|
- |
public static final FormComponentFactory INSTANCE = new UiViewWidgetFactory(); |
18 |
|
- |
|
19 |
|
- |
public Widget create( FormInstanceComponentHandler pComponentHandler, UiDef pUiDef, |
20 |
|
- |
FormMetaData pFormMetaData, boolean pHasHorizontalPeer ) { |
21 |
|
- |
UiAttributeNamedDef zDef = (UiAttributeNamedDef) pUiDef; |
22 |
|
- |
AttributeMetaData zMD = pFormMetaData.getAttribute( zDef ); |
23 |
|
- |
if ( zMD == null ) { |
24 |
|
- |
throw new IllegalStateException( "Metadata required for a " + zDef ); |
25 |
|
- |
} |
26 |
|
- |
return ApplyFont.to( zDef.getFont( zDef.getFontAttributeNames()[0] ), // |
27 |
|
- |
new MyFormAdapter( pComponentHandler, zMD, |
28 |
|
- |
new LabelFormComponent() ).init() ); |
29 |
|
- |
} |
30 |
|
- |
|
31 |
|
- |
private static final class MyFormAdapter extends AbstractFormAttributeAdapter { |
32 |
|
- |
public MyFormAdapter( FormInstanceComponentHandler pComponentHandler, // |
33 |
|
- |
AttributeMetaData pMD, IFormComponent pComponent ) { |
34 |
|
- |
super( pComponentHandler, pMD, pComponent ); |
35 |
|
- |
} |
36 |
|
- |
|
37 |
|
- |
protected Object convertSendableToComponentValue( Serializable pValue ) { |
38 |
|
- |
return pValue; |
39 |
|
- |
} |
40 |
|
- |
|
41 |
|
- |
protected String convertComponentValueToString( Object pValue ) { |
42 |
|
- |
return null; |
43 |
|
- |
} |
44 |
|
- |
|
45 |
|
- |
protected Object convertStringToComponentValue( String pValue ) { |
46 |
|
- |
return null; |
47 |
|
- |
} |
48 |
|
- |
} |
49 |
|
- |
|
50 |
|
- |
private static final class LabelFormComponent extends Label implements IFormComponent { |
51 |
|
- |
private Object mCurrentValue = null; |
52 |
|
- |
|
53 |
|
- |
public LabelFormComponent() { |
54 |
|
- |
super( "" ); |
55 |
|
- |
} |
56 |
|
- |
|
57 |
|
- |
public void relayout() { |
58 |
|
- |
Widget parent = getParent(); |
59 |
|
- |
if ( parent instanceof SizeManaged ) { |
60 |
|
- |
((SizeManaged) parent).relayout(); |
61 |
|
- |
} |
62 |
|
- |
} |
63 |
|
- |
|
64 |
|
- |
public Object getCurrentValue() { |
65 |
|
- |
return mCurrentValue; |
66 |
|
- |
} |
67 |
|
- |
|
68 |
|
- |
public void setCurrentValue( Object pNewValue ) { |
69 |
|
- |
mCurrentValue = pNewValue; |
70 |
|
- |
String text = (null == mCurrentValue) ? "" : mCurrentValue.toString(); |
71 |
|
- |
setText( (null == text) ? "" : text ); |
72 |
|
- |
} |
73 |
|
- |
|
74 |
|
- |
public boolean setFocus() { |
75 |
|
- |
return false; |
76 |
|
- |
} |
77 |
|
- |
|
78 |
|
- |
public void setError( String pError ) { |
79 |
|
- |
// No Errors |
80 |
|
- |
} |
81 |
|
- |
|
82 |
|
- |
public void setFocused( boolean pFocused ) { |
83 |
|
- |
// No Focus |
84 |
|
- |
} |
85 |
|
- |
|
86 |
|
- |
public void setValueChanged( boolean pChanged ) { |
87 |
|
- |
// No ValueChanged |
88 |
|
- |
} |
89 |
|
- |
|
90 |
|
- |
public boolean isEnabled() { |
91 |
|
- |
return false; |
92 |
|
- |
} |
93 |
|
- |
|
94 |
|
- |
public void setEnabled( boolean pEnabled ) { |
95 |
|
- |
// No Enableable |
96 |
|
- |
} |
97 |
|
- |
|
98 |
|
- |
public void publishAnyPendingChanges() { |
99 |
|
- |
// No Listeners |
100 |
|
- |
} |
101 |
|
- |
|
102 |
|
- |
public IFormComponent addFormComponentListener( Listener pFormComponentListener ) { |
103 |
|
- |
if ( pFormComponentListener != null ) { |
104 |
|
- |
pFormComponentListener.add( this ); |
105 |
|
- |
} |
106 |
|
- |
// Nothing to listen for... |
107 |
|
- |
return this; |
108 |
|
- |
} |
109 |
|
- |
|
110 |
|
- |
public IFormComponent removeFormComponentListener( Listener pFormComponentListener ) { |
111 |
|
- |
if ( pFormComponentListener != null ) { |
112 |
|
- |
pFormComponentListener.remove( this ); |
113 |
|
- |
} |
114 |
|
- |
// Nothing to listen for... |
115 |
|
- |
return this; |
116 |
|
- |
} |
117 |
|
- |
|
118 |
|
- |
@Override |
119 |
|
- |
public boolean hasError() { |
120 |
|
- |
return false; |
121 |
|
- |
} |
122 |
|
- |
} |
123 |
|
- |
} |
|
1 |
+ |
// This Source Code is in the Public Domain per: http://unlicense.org |
|
2 |
+ |
package org.litesoft.GWT.forms.client.components.factories.others; |
|
3 |
+ |
|
|
4 |
+ |
import org.litesoft.GWT.client.widgets.nonpublic.*; |
|
5 |
+ |
import org.litesoft.GWT.forms.client.components.*; |
|
6 |
+ |
import org.litesoft.GWT.forms.client.components.factories.*; |
|
7 |
+ |
import org.litesoft.GWT.forms.client.nonpublic.*; |
|
8 |
+ |
import org.litesoft.ui.*; |
|
9 |
+ |
import org.litesoft.ui.def.*; |
|
10 |
+ |
import org.litesoft.ui.def.nonpublic.support.*; |
|
11 |
+ |
|
|
12 |
+ |
import com.google.gwt.user.client.ui.*; |
|
13 |
+ |
|
|
14 |
+ |
import java.io.*; |
|
15 |
+ |
|
|
16 |
+ |
public class UiViewWidgetFactory implements FormComponentFactory { |
|
17 |
+ |
public static final FormComponentFactory INSTANCE = new UiViewWidgetFactory(); |
|
18 |
+ |
|
|
19 |
+ |
public Widget create( FormInstanceComponentHandler pComponentHandler, UiDef pUiDef, |
|
20 |
+ |
FormMetaData pFormMetaData, boolean pHasHorizontalPeer ) { |
|
21 |
+ |
UiAttributeNamedDef zDef = (UiAttributeNamedDef) pUiDef; |
|
22 |
+ |
AttributeMetaData zMD = pFormMetaData.getAttribute( zDef ); |
|
23 |
+ |
if ( zMD == null ) { |
|
24 |
+ |
throw new IllegalStateException( "Metadata required for a " + zDef ); |
|
25 |
+ |
} |
|
26 |
+ |
return ApplyFont.to( zDef.getFont( zDef.getFontAttributeNames()[0] ), // |
|
27 |
+ |
new MyFormAdapter( pComponentHandler, zMD, |
|
28 |
+ |
new LabelFormComponent() ).init() ); |
|
29 |
+ |
} |
|
30 |
+ |
|
|
31 |
+ |
private static final class MyFormAdapter extends AbstractFormAttributeAdapter { |
|
32 |
+ |
public MyFormAdapter( FormInstanceComponentHandler pComponentHandler, // |
|
33 |
+ |
AttributeMetaData pMD, IFormComponent pComponent ) { |
|
34 |
+ |
super( pComponentHandler, pMD, pComponent ); |
|
35 |
+ |
} |
|
36 |
+ |
|
|
37 |
+ |
protected Object convertSendableToComponentValue( Serializable pValue ) { |
|
38 |
+ |
return pValue; |
|
39 |
+ |
} |
|
40 |
+ |
|
|
41 |
+ |
protected String convertComponentValueToString( Object pValue ) { |
|
42 |
+ |
return null; |
|
43 |
+ |
} |
|
44 |
+ |
|
|
45 |
+ |
protected Object convertStringToComponentValue( String pValue ) { |
|
46 |
+ |
return null; |
|
47 |
+ |
} |
|
48 |
+ |
} |
|
49 |
+ |
|
|
50 |
+ |
private static final class LabelFormComponent extends Label implements IFormComponent { |
|
51 |
+ |
private Object mCurrentValue = null; |
|
52 |
+ |
|
|
53 |
+ |
public LabelFormComponent() { |
|
54 |
+ |
super( "" ); |
|
55 |
+ |
} |
|
56 |
+ |
|
|
57 |
+ |
public void relayout() { |
|
58 |
+ |
Widget parent = getParent(); |
|
59 |
+ |
if ( parent instanceof SizeManaged ) { |
|
60 |
+ |
((SizeManaged) parent).relayout(); |
|
61 |
+ |
} |
|
62 |
+ |
} |
|
63 |
+ |
|
|
64 |
+ |
public Object getCurrentValue() { |
|
65 |
+ |
return mCurrentValue; |
|
66 |
+ |
} |
|
67 |
+ |
|
|
68 |
+ |
public void setCurrentValue( Object pNewValue ) { |
|
69 |
+ |
mCurrentValue = pNewValue; |
|
70 |
+ |
String text = (null == mCurrentValue) ? "" : mCurrentValue.toString(); |
|
71 |
+ |
setText( (null == text) ? "" : text ); |
|
72 |
+ |
} |
|
73 |
+ |
|
|
74 |
+ |
public boolean setFocus() { |
|
75 |
+ |
return false; |
|
76 |
+ |
} |
|
77 |
+ |
|
|
78 |
+ |
public void setError( String pError ) { |
|
79 |
+ |
// No Errors |
|
80 |
+ |
} |
|
81 |
+ |
|
|
82 |
+ |
public void setFocused( boolean pFocused ) { |
|
83 |
+ |
// No Focus |
|
84 |
+ |
} |
|
85 |
+ |
|
|
86 |
+ |
public void setValueChanged( boolean pChanged ) { |
|
87 |
+ |
// No ValueChanged |
|
88 |
+ |
} |
|
89 |
+ |
|
|
90 |
+ |
public boolean isEnabled() { |
|
91 |
+ |
return false; |
|
92 |
+ |
} |
|
93 |
+ |
|
|
94 |
+ |
public void setEnabled( boolean pEnabled ) { |
|
95 |
+ |
// No Enableable |
|
96 |
+ |
} |
|
97 |
+ |
|
|
98 |
+ |
public void publishAnyPendingChanges() { |
|
99 |
+ |
// No Listeners |
|
100 |
+ |
} |
|
101 |
+ |
|
|
102 |
+ |
public IFormComponent addFormComponentListener( Listener pFormComponentListener ) { |
|
103 |
+ |
if ( pFormComponentListener != null ) { |
|
104 |
+ |
pFormComponentListener.add( this ); |
|
105 |
+ |
} |
|
106 |
+ |
// Nothing to listen for... |
|
107 |
+ |
return this; |
|
108 |
+ |
} |
|
109 |
+ |
|
|
110 |
+ |
public IFormComponent removeFormComponentListener( Listener pFormComponentListener ) { |
|
111 |
+ |
if ( pFormComponentListener != null ) { |
|
112 |
+ |
pFormComponentListener.remove( this ); |
|
113 |
+ |
} |
|
114 |
+ |
// Nothing to listen for... |
|
115 |
+ |
return this; |
|
116 |
+ |
} |
|
117 |
+ |
|
|
118 |
+ |
@Override |
|
119 |
+ |
public boolean hasError() { |
|
120 |
+ |
return false; |
|
121 |
+ |
} |
|
122 |
+ |
} |
|
123 |
+ |
} |