Subversion Repository Public Repository

litesoft

Diff Revisions 947 vs 948 for /trunk/GWT_Sandbox/FormEngine/src/org/litesoft/sampleapplication/sampleApplication/client/SampleApplication.java

Diff revisions: vs.
  @@ -15,8 +15,7 @@
15 15
16 16 import java.util.*;
17 17
18 - public class SampleApplication implements EntryPoint
19 - {
18 + public class SampleApplication implements EntryPoint {
20 19 String[] externalizedData = { //
21 20 "Fred_field-label", "Name", //
22 21 "Family_field-extendedLabel", "(Primary Key)", //
  @@ -32,50 +31,45 @@
32 31 "SetValue", "Set Value", //
33 32 };
34 33
35 - private E13nResolver globalResolver = new TemplateSourceE13nResolver( new TemplateSource()
36 - {
34 + private E13nResolver globalResolver = new TemplateSourceE13nResolver( new TemplateSource() {
37 35 private Map<String, String> dictionary = CollectionsUtils.newMap( externalizedData );
38 36
39 37 @Override
40 - public String get( String key )
41 - {
38 + public String get( String key ) {
42 39 System.out.println( "Template Get: " + key );
43 40 return dictionary.get( key );
44 41 }
45 42
46 43 @Override
47 - public String get( String key, String defaultValue )
48 - {
44 + public String get( String key, String defaultValue ) {
49 45 return StringUtils.deNull( get( key ), defaultValue );
50 46 }
51 47 } );
52 48
53 - enum Options
54 - {
49 + enum Options {
55 50 Red, Green, Blue
56 51 }
57 52
58 53 // Pretend "Injected" by the "ui.xml" file
59 54 private TextInputField tif = new TextInputField().name( "Fred" ).helpLink( "XX#Fred" ).required().maxLength( 9 ).extendedLabel().example().errorLabel();
60 - private OptionBoxInputField<Options> obif = new OptionBoxInputField<Options>().name( "Wilma" ).helpLink( "XX#YY" ).required().labelPosition( LabelPosition.Top ).errorLabel();
55 + private OptionBoxInputField<Options> obif =
56 + new OptionBoxInputField<Options>().name( "Wilma" ).helpLink( "XX#YY" ).required().labelPosition( LabelPosition.Top ).errorLabel();
61 57 private CheckBoxInputField cbif = new CheckBoxInputField().name( "Pebbles" ).helpLink( "XX#YY" ).labelPosition( LabelPosition.Right );
62 - private RadioButtonInputField rbif1 = new RadioButtonInputField().name( "Public" ).group( "Visibility" ).helpLink( "XX#YY" ).labelPosition( LabelPosition.Right );
63 - private RadioButtonInputField rbif2 = new RadioButtonInputField().name( "Private" ).group( "Visibility" ).helpLink( "XX#YY" ).labelPosition( LabelPosition.Right );
58 + private RadioButtonInputField rbif1 =
59 + new RadioButtonInputField().name( "Public" ).group( "Visibility" ).helpLink( "XX#YY" ).labelPosition( LabelPosition.Right );
60 + private RadioButtonInputField rbif2 =
61 + new RadioButtonInputField().name( "Private" ).group( "Visibility" ).helpLink( "XX#YY" ).labelPosition( LabelPosition.Right );
64 62
65 63 VerticalPanel radioButtonContainer = UtilsGwt.add( UtilsGwt.add( UtilsGwt.vertical( "radioButtonContainer" ), rbif1 ), rbif2 );
66 64
67 - private NamedTextButton buttonSetValue = new NamedTextButton( "SetValue", new ClickHandler()
68 - {
69 - public void onClick( ClickEvent event )
70 - {
65 + private NamedTextButton buttonSetValue = new NamedTextButton( "SetValue", new ClickHandler() {
66 + public void onClick( ClickEvent event ) {
71 67 tif.setCurrentValue( tif.getCurrentValue() );
72 68 System.out.println( "Set Value!" );
73 69 }
74 70 } );
75 - private Button buttonSetValueAsUser = new Button( "User Set Value", new ClickHandler()
76 - {
77 - public void onClick( ClickEvent event )
78 - {
71 + private Button buttonSetValueAsUser = new Button( "User Set Value", new ClickHandler() {
72 + public void onClick( ClickEvent event ) {
79 73 tif.getInput().setValueAsUser( tif.getCurrentValue() + "!" );
80 74 System.out.println( "User Set Value!" );
81 75 }
  @@ -88,8 +82,7 @@
88 82 private VerticalPanel formPanel;
89 83
90 84 // Fake "View"
91 - public void onModuleLoad()
92 - {
85 + public void onModuleLoad() {
93 86 // Initialize the "View" Resolver
94 87 E13nResolver viewResolver = new OptionallyPrefixingE13nResolver( "BusinessUnitManager", globalResolver );
95 88
  @@ -107,11 +100,9 @@
107 100 // Add the Managed Buttons
108 101 fe.addManaged( buttonSetValue, buttonSetValueAsUser );
109 102 // Add the Submit Button and its Callback
110 - fe.setSubmit( buttonValidate, new FormEngine.Callback()
111 - {
103 + fe.setSubmit( buttonValidate, new FormEngine.Callback() {
112 104 @Override
113 - public void submit( String name )
114 - {
105 + public void submit( String name ) {
115 106 System.out.println( "Form '" + name + "' says OK to Submit!" );
116 107 }
117 108 } );
  @@ -148,103 +139,72 @@
148 139 fe.setFocused();
149 140 }
150 141
151 - private void attachForm()
152 - {
142 + private void attachForm() {
153 143 rootPanel.add( formPanel );
154 144 }
155 145
156 - private void detachForm()
157 - {
146 + private void detachForm() {
158 147 rootPanel.clear();
159 148 }
160 149
161 - private HorizontalPanel createFormInteractionButtons( final FormEngine fe )
162 - {
163 - return horizontalWithSpacers( new Button( "ServerStart", new ClickHandler()
164 - {
165 - public void onClick( ClickEvent event )
166 - {
150 + private HorizontalPanel createFormInteractionButtons( final FormEngine fe ) {
151 + return horizontalWithSpacers( new Button( "ServerStart", new ClickHandler() {
152 + public void onClick( ClickEvent event ) {
167 153 fe.busyInteractingWithServer();
168 154 }
169 - } ), new Button( "ServerStop", new ClickHandler()
170 - {
171 - public void onClick( ClickEvent event )
172 - {
155 + } ), new Button( "ServerStop", new ClickHandler() {
156 + public void onClick( ClickEvent event ) {
173 157 fe.doneInteractingWithServer();
174 158 }
175 - } ), new Button( "Reset", new ClickHandler()
176 - {
177 - public void onClick( ClickEvent event )
178 - {
159 + } ), new Button( "Reset", new ClickHandler() {
160 + public void onClick( ClickEvent event ) {
179 161 fe.reset();
180 162 }
181 - } ), new Button( "Revert", new ClickHandler()
182 - {
183 - public void onClick( ClickEvent event )
184 - {
163 + } ), new Button( "Revert", new ClickHandler() {
164 + public void onClick( ClickEvent event ) {
185 165 fe.revert();
186 166 }
187 - } ), new Button( "IsChanged", new ClickHandler()
188 - {
189 - public void onClick( ClickEvent event )
190 - {
167 + } ), new Button( "IsChanged", new ClickHandler() {
168 + public void onClick( ClickEvent event ) {
191 169 System.out.println( "Form '" + fe.getName() + "' Changed: " + fe.isChanged() );
192 170 }
193 - } ), new Button( "IsErrored", new ClickHandler()
194 - {
195 - public void onClick( ClickEvent event )
196 - {
171 + } ), new Button( "IsErrored", new ClickHandler() {
172 + public void onClick( ClickEvent event ) {
197 173 System.out.println( "Form '" + fe.getName() + "' Errored: " + fe.isErrored() );
198 174 }
199 - } ), new Button( "Focus", new ClickHandler()
200 - {
201 - public void onClick( ClickEvent event )
202 - {
203 - new Timer()
204 - {
205 - public void run()
206 - {
175 + } ), new Button( "Focus", new ClickHandler() {
176 + public void onClick( ClickEvent event ) {
177 + new Timer() {
178 + public void run() {
207 179 fe.setFocused();
208 180 }
209 181 }.schedule( 100 );
210 182 }
211 - } ), new Button( "Detach", new ClickHandler()
212 - {
213 - public void onClick( ClickEvent event )
214 - {
183 + } ), new Button( "Detach", new ClickHandler() {
184 + public void onClick( ClickEvent event ) {
215 185 detachForm();
216 186 }
217 - } ), new Button( "Attach", new ClickHandler()
218 - {
219 - public void onClick( ClickEvent event )
220 - {
187 + } ), new Button( "Attach", new ClickHandler() {
188 + public void onClick( ClickEvent event ) {
221 189 attachForm();
222 190 }
223 - } ), new Button( "Disable Form", new ClickHandler()
224 - {
225 - public void onClick( ClickEvent event )
226 - {
191 + } ), new Button( "Disable Form", new ClickHandler() {
192 + public void onClick( ClickEvent event ) {
227 193 fe.setEnabled( false );
228 194 }
229 - } ), new Button( "Enable Form", new ClickHandler()
230 - {
231 - public void onClick( ClickEvent event )
232 - {
195 + } ), new Button( "Enable Form", new ClickHandler() {
196 + public void onClick( ClickEvent event ) {
233 197 fe.setEnabled( true );
234 198 }
235 - } ), new Button( "Disable Fields", new ClickHandler()
236 - {
237 - public void onClick( ClickEvent event )
238 - {
199 + } ), new Button( "Disable Fields", new ClickHandler() {
200 + public void onClick( ClickEvent event ) {
239 201 tif.setEnabled( false );
240 202 obif.setEnabled( false );
241 203 cbif.setEnabled( false );
242 204 rbgif.setEnabled( false );
243 205 }
244 - } ), new Button( "Enable Fields", new ClickHandler()
245 - {
246 - public void onClick( ClickEvent event )
247 - {
206 + } ), new Button( "Enable Fields", new ClickHandler() {
207 + public void onClick( ClickEvent event ) {
248 208 tif.setEnabled( true );
249 209 obif.setEnabled( true );
250 210 cbif.setEnabled( true );
  @@ -253,29 +213,23 @@
253 213 } ) );
254 214 }
255 215
256 - private <T> void complete( InputField<T> inputField )
257 - {
258 - inputField.add( new InputField.ChangeListener<T>()
259 - {
216 + private <T> void complete( InputField<T> inputField ) {
217 + inputField.add( new InputField.ChangeListener<T>() {
260 218 @Override
261 - public void changed( InputField<T> field )
262 - {
219 + public void changed( InputField<T> field ) {
263 220 T value = field.getCurrentValue();
264 221 System.out.println( "Change (" + field.getName() + "): " + field.isChanged() + " '" + value + "' | " + field.getErrorData() );
265 - if ( "OK".equals( value ) )
266 - {
222 + if ( "OK".equals( value ) ) {
267 223 field.setCurrentValue( value );
268 224 }
269 225 }
270 226 } );
271 227 }
272 228
273 - private HorizontalPanel horizontalWithSpacers( IsWidget... widgets )
274 - {
229 + private HorizontalPanel horizontalWithSpacers( IsWidget... widgets ) {
275 230 HorizontalPanel zPanel = new HorizontalPanel();
276 231 zPanel.add( widgets[0] );
277 - for ( int i = 1; i < widgets.length; i++ )
278 - {
232 + for ( int i = 1; i < widgets.length; i++ ) {
279 233 zPanel.add( new HTML( "&nbsp;&nbsp;" ) );
280 234 zPanel.add( widgets[i] );
281 235 }