Subversion Repository Public Repository

litesoft

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

Diff revisions: vs.
  @@ -4,8 +4,9 @@
4 4
5 5 import com.google.gwt.core.client.*;
6 6 import com.google.gwt.event.dom.client.*;
7 + import com.google.gwt.user.client.Timer;
7 8 import com.google.gwt.user.client.ui.*;
8 - import com.temp.client.foundation.util.UtilsGwt;
9 + import com.temp.client.foundation.util.*;
9 10 import com.temp.client.foundation.widget.*;
10 11 import com.temp.client.foundation.widget.input.*;
11 12 import com.temp.shared.externalization.*;
  @@ -79,6 +80,11 @@
79 80 } );
80 81 private Button buttonValidate = new Button( "Validate" );
81 82
83 + private RadioButtonGroupInputField rbgif;
84 +
85 + private SimplePanel rootPanel;
86 + private VerticalPanel formPanel;
87 +
82 88 // Fake "View"
83 89 public void onModuleLoad()
84 90 {
  @@ -86,7 +92,7 @@
86 92 E13nResolver viewResolver = new OptionallyPrefixingE13nResolver( "BusinessUnitManager", globalResolver );
87 93
88 94 // Create Composite(s)
89 - RadioButtonGroupInputField rbgif = new RadioButtonGroupInputField(radioButtonContainer, rbif1, rbif2);
95 + rbgif = new RadioButtonGroupInputField(radioButtonContainer, rbif1, rbif2);
90 96
91 97 // Create FormEngine
92 98 FormEngine fe = new FormEngine( "Family" );
  @@ -115,22 +121,23 @@
115 121
116 122 // Below here is what would normally be handled by the "ui.xml" file.
117 123
118 - VerticalPanel zVPanel = new VerticalPanel();
119 - zVPanel.add( new HTML( " " ) );
120 - zVPanel.add( horizontalWithSpacers( tif, new HTML( " " ), obif, new HTML( " " ), cbif ) );
121 - zVPanel.add( new HTML( " " ) );
122 - zVPanel.add(rbif1);
123 - zVPanel.add(rbif2);
124 - zVPanel.add( new HTML( " " ) );
125 - zVPanel.add( horizontalWithSpacers( buttonSetValue, buttonSetValueAsUser, buttonValidate ) );
126 - zVPanel.add( new HTML( " " ) );
127 - zVPanel.add( new HTML( " " ) );
128 - zVPanel.add( new HTML( " " ) );
129 - zVPanel.add( new HTML( " " ) );
130 - zVPanel.add( createFormInteractionButtons( fe ) );
131 -
132 - RootPanel zRootPanel = RootPanel.get( "centeredWidget" );
133 - zRootPanel.add( zVPanel );
124 + formPanel = new VerticalPanel();
125 + formPanel.add( new HTML( " " ) );
126 + formPanel.add( horizontalWithSpacers( tif, new HTML( " " ), obif, new HTML( " " ), cbif ) );
127 + formPanel.add( new HTML( " " ) );
128 + formPanel.add( rbif1 );
129 + formPanel.add( rbif2 );
130 + formPanel.add( new HTML( " " ) );
131 + formPanel.add( horizontalWithSpacers( buttonSetValue, buttonSetValueAsUser, buttonValidate ) );
132 + formPanel.add( new HTML( " " ) );
133 + formPanel.add( new HTML( " " ) );
134 + formPanel.add( new HTML( " " ) );
135 + formPanel.add( new HTML( " " ) );
136 +
137 + VerticalPanel vp = new VerticalPanel();
138 + RootPanel.get( "centeredWidget" ).add( vp );
139 + vp.add( createFormInteractionButtons( fe ) );
140 + vp.add( rootPanel = new SimplePanel( formPanel ) );
134 141
135 142 complete( tif );
136 143 complete( obif );
  @@ -140,6 +147,16 @@
140 147 fe.setFocused();
141 148 }
142 149
150 + private void attachForm()
151 + {
152 + rootPanel.add( formPanel );
153 + }
154 +
155 + private void detachForm()
156 + {
157 + rootPanel.clear();
158 + }
159 +
143 160 private HorizontalPanel createFormInteractionButtons( final FormEngine fe )
144 161 {
145 162 return horizontalWithSpacers( new Button( "ServerStart", new ClickHandler()
  @@ -170,32 +187,66 @@
170 187 {
171 188 public void onClick( ClickEvent event )
172 189 {
173 - System.out.println("Form '"+fe.getName()+"' Changed: " + fe.isChanged());
190 + System.out.println( "Form '" + fe.getName() + "' Changed: " + fe.isChanged() );
174 191 }
175 192 } ), new Button( "IsErrored", new ClickHandler()
176 193 {
177 194 public void onClick( ClickEvent event )
178 195 {
179 - System.out.println("Form '"+fe.getName()+"' Errored: " + fe.isErrored());
196 + System.out.println( "Form '" + fe.getName() + "' Errored: " + fe.isErrored() );
180 197 }
181 198 } ), new Button( "Focus", new ClickHandler()
182 199 {
183 200 public void onClick( ClickEvent event )
184 201 {
185 - fe.setFocused();
202 + new Timer() {
203 + public void run() {
204 + fe.setFocused();
205 + }
206 + }.schedule( 100 );
207 + }
208 + } ), new Button( "Detach", new ClickHandler()
209 + {
210 + public void onClick( ClickEvent event )
211 + {
212 + detachForm();
186 213 }
187 - } ), new Button( "Disable", new ClickHandler()
214 + } ), new Button( "Attach", new ClickHandler()
215 + {
216 + public void onClick( ClickEvent event )
217 + {
218 + attachForm();
219 + }
220 + } ), new Button( "Disable Form", new ClickHandler()
188 221 {
189 222 public void onClick( ClickEvent event )
190 223 {
191 224 fe.setEnabled( false );
192 225 }
193 - } ), new Button( "Enable", new ClickHandler()
226 + } ), new Button( "Enable Form", new ClickHandler()
194 227 {
195 228 public void onClick( ClickEvent event )
196 229 {
197 230 fe.setEnabled( true );
198 231 }
232 + } ), new Button( "Disable Fields", new ClickHandler()
233 + {
234 + public void onClick( ClickEvent event )
235 + {
236 + tif.setEnabled( false );
237 + obif.setEnabled( false );
238 + cbif.setEnabled( false );
239 + rbgif.setEnabled( false );
240 + }
241 + } ), new Button( "Enable Fields", new ClickHandler()
242 + {
243 + public void onClick( ClickEvent event )
244 + {
245 + tif.setEnabled( true );
246 + obif.setEnabled( true );
247 + cbif.setEnabled( true );
248 + rbgif.setEnabled( true );
249 + }
199 250 } ) );
200 251 }
201 252