Subversion Repository Public Repository

litesoft

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

Diff revisions: vs.
  @@ -4,77 +4,89 @@
4 4 import com.google.gwt.event.dom.client.*;
5 5 import com.google.gwt.user.client.ui.*;
6 6 import com.temp.foundation.widgets.*;
7 + import com.temp.foundation.widgets.inputfieldsupport.*;
7 8 import com.temp.foundation.widgets.support.*;
8 9 import com.temp.shared.validators.*;
9 10
10 - public class SampleApplication implements EntryPoint {
11 - public void onModuleLoad() {
12 -
13 - Label fieldLabel = new Label("Name:");
14 - Label errorLabel = new Label("Error");
15 - HTML stateLabel = new HTML(" ");
11 + public class SampleApplication implements EntryPoint
12 + {
13 + public void onModuleLoad()
14 + {
15 + Label fieldLabel = new Label( "Name:" );
16 + Label errorLabel = new Label( "Error" );
17 + HTML stateLabel = new HTML( " " );
16 18 ActiveTextBox field = new ActiveTextBox();
17 19
18 - final InputWidgetValidator<String> validator = new InputWidgetValidator<String>(new TextBoxBaseValueAdapter(field));
19 - final InputWidgetChangeFilter<String> input = new InputWidgetChangeFilter<String>(validator);
20 + final InputWidgetValidator<String> validator = new InputWidgetValidator<String>( new TextBoxBaseValueAdapter( field ) );
21 + final InputWidgetChangeFilter<String> input = new InputWidgetChangeFilter<String>( validator );
20 22
21 - input.addChangeHandler(new ChangeHandler() {
23 + input.addChangeHandler( new ChangeHandler()
24 + {
22 25 @Override
23 - public void onChange(ChangeEvent event) {
26 + public void onChange( ChangeEvent event )
27 + {
24 28 String value = input.getValue();
25 - System.out.println("Change: " + input.isChanged() + " '" + value + "'");
26 - if ("OK".equals(value)) {
27 - input.setValue(value);
29 + System.out.println( "Change: " + input.isChanged() + " '" + value + "'" );
30 + if ( "OK".equals( value ) )
31 + {
32 + input.setValue( value );
28 33 }
29 34 }
30 - });
35 + } );
31 36
32 - validator.addChangeHandler(new ChangeHandler() {
37 + validator.addErrorStateChangeHandler( new ChangeHandler()
38 + {
33 39 @Override
34 - public void onChange(ChangeEvent event) {
40 + public void onChange( ChangeEvent event )
41 + {
35 42 String value = input.getValue();
36 - System.out.println("Valid: '" + value + "' | "+ validator.getErrorData() );
43 + System.out.println( "Valid: '" + value + "' | " + validator.getErrorData() );
37 44 }
38 - });
39 -
40 -
41 -
42 - validator.addValidators(RequiredValueValidator.INSTANCE, //
43 - AlphaNumericUnderScore7bitAsciiValueValidator.INSTANCE);
45 + } );
44 46
45 - Button buttonSetValue = new Button("Set Value", new ClickHandler() {
46 - public void onClick(ClickEvent event) {
47 - input.setValue(input.getValue());
48 - System.out.println("Set Value!");
47 + validator.addValidators( RequiredValueValidator.INSTANCE, //
48 + new MaxLengthValueValidator( 9 ), //
49 + IdentifierValueValidator.INSTANCE );
50 +
51 + Button buttonSetValue = new Button( "Set Value", new ClickHandler()
52 + {
53 + public void onClick( ClickEvent event )
54 + {
55 + input.setValue( input.getValue() );
56 + System.out.println( "Set Value!" );
49 57 }
50 - });
51 - Button buttonSetValueAsUser = new Button("User Set Value", new ClickHandler() {
52 - public void onClick(ClickEvent event) {
53 - input.setValueAsUser(input.getValue() + "!");
54 - System.out.println("User Set Value!");
58 + } );
59 + Button buttonSetValueAsUser = new Button( "User Set Value", new ClickHandler()
60 + {
61 + public void onClick( ClickEvent event )
62 + {
63 + input.setValueAsUser( input.getValue() + "!" );
64 + System.out.println( "User Set Value!" );
55 65 }
56 - });
66 + } );
57 67
58 68 VerticalPanel zFieldErrorPanel = new VerticalPanel();
59 - zFieldErrorPanel.add(field);
60 - zFieldErrorPanel.add(errorLabel);
69 + zFieldErrorPanel.add( field );
70 + zFieldErrorPanel.add( errorLabel );
61 71
62 72 VerticalPanel zVPanel = new VerticalPanel();
63 - zVPanel.add(new HTML("&nbsp;"));
64 - zVPanel.add(horizontalWithSpacers(fieldLabel, zFieldErrorPanel, stateLabel));
65 - zVPanel.add(new HTML("&nbsp;"));
66 - zVPanel.add(horizontalWithSpacers(buttonSetValue, buttonSetValueAsUser));
73 + zVPanel.add( new HTML( "&nbsp;" ) );
74 + zVPanel.add( horizontalWithSpacers( fieldLabel, zFieldErrorPanel, stateLabel ) );
75 + zVPanel.add( new HTML( "&nbsp;" ) );
76 + zVPanel.add( horizontalWithSpacers( buttonSetValue, buttonSetValueAsUser ) );
67 77
68 - RootPanel zRootPanel = RootPanel.get("centeredWidget");
69 - zRootPanel.add(zVPanel);
78 + RootPanel zRootPanel = RootPanel.get( "centeredWidget" );
79 + zRootPanel.add( zVPanel );
70 80 }
71 81
72 - private HorizontalPanel horizontalWithSpacers(Widget... widgets) {
82 + private HorizontalPanel horizontalWithSpacers( Widget... widgets )
83 + {
73 84 HorizontalPanel zPanel = new HorizontalPanel();
74 - zPanel.add(widgets[0]);
75 - for (int i = 1; i < widgets.length; i++) {
76 - zPanel.add(new HTML("&nbsp;&nbsp;"));
77 - zPanel.add(widgets[i]);
85 + zPanel.add( widgets[0] );
86 + for ( int i = 1; i < widgets.length; i++ )
87 + {
88 + zPanel.add( new HTML( "&nbsp;&nbsp;" ) );
89 + zPanel.add( widgets[i] );
78 90 }
79 91 return zPanel;
80 92 }