Subversion Repository Public Repository

litesoft

Diff Revisions 947 vs 948 for /trunk/Java/GWT/OldClient/src/org/litesoft/GWT/forms/client/nonpublic/RenderedFormHandlerImpl.java

Diff revisions: vs.
  @@ -1,8 +1,6 @@
1 1 // This Source Code is in the Public Domain per: http://unlicense.org
2 2 package org.litesoft.GWT.forms.client.nonpublic;
3 3
4 - import java.io.*;
5 -
6 4 import org.litesoft.GWT.client.*;
7 5 import org.litesoft.GWT.eventbus.client.*;
8 6 import org.litesoft.GWT.forms.client.*;
  @@ -11,10 +9,11 @@
11 9 import org.litesoft.core.simpletypes.*;
12 10 import org.litesoft.ui.def.nonpublic.support.*;
13 11
12 + import java.io.*;
13 +
14 14 public class RenderedFormHandlerImpl implements RenderedFormHandler,
15 15 UberFormInstanceComponentHandler,
16 - AsyncFormServicePeerChannel.OperationalListener
17 - {
16 + AsyncFormServicePeerChannel.OperationalListener {
18 17 private UiFormHandler mUiFormHandler;
19 18 private UiFormListener mListener;
20 19 private String mRootType, mRootObjectKey = null;
  @@ -30,8 +29,7 @@
30 29 private BaseFormComponentHandlerImpl mBaseComponentHandler = null;
31 30
32 31 public RenderedFormHandlerImpl( UiFormHandler pUiFormHandler, UiFormListener pListener, String pRootType,
33 - AsyncFormServicePeerChannel pFormServicePeerChannel )
34 - {
32 + AsyncFormServicePeerChannel pFormServicePeerChannel ) {
35 33 mUiFormHandler = pUiFormHandler;
36 34 mListener = pListener;
37 35 mRootType = pRootType;
  @@ -39,64 +37,53 @@
39 37 mManager = new RFHMessageManager( mFormServicePeerChannel, LOGGER );
40 38 }
41 39
42 - public void formRendered( AbstractFormContainer pFormContainer, Serializable pServicePeerXtra )
43 - {
40 + public void formRendered( AbstractFormContainer pFormContainer, Serializable pServicePeerXtra ) {
44 41 chkMethodOK( "formRendered", pServicePeerXtra );
45 42 mFormContainer = pFormContainer;
46 43 massUpdateComplete();
47 44 mListener.formRendered( mUiFormHandler, pServicePeerXtra );
48 45 }
49 46
50 - private boolean isDisposed()
51 - {
47 + private boolean isDisposed() {
52 48 return (mFormServicePeerChannel == null);
53 49 }
54 50
55 - private void chkMethodOK( String pMethod, String pLogData, boolean pDisabled )
56 - {
51 + private void chkMethodOK( String pMethod, String pLogData, boolean pDisabled ) {
57 52 LOGGER.debug.log( pMethod, ":", pLogData, "-", pDisabled ? "Disabled" : "Enabled" );
58 53 LLchkMethodOK( pMethod );
59 54 }
60 55
61 - private void chkMethodOK( String pMethod, Object pLogData1, Object pLogData2 )
62 - {
56 + private void chkMethodOK( String pMethod, Object pLogData1, Object pLogData2 ) {
63 57 LOGGER.debug.log( pMethod, ":", pLogData1, "=", pLogData2 );
64 58 LLchkMethodOK( pMethod );
65 59 }
66 60
67 - private void chkMethodOK( String pMethod, Object pPlusLogData )
68 - {
61 + private void chkMethodOK( String pMethod, Object pPlusLogData ) {
69 62 LOGGER.debug.log( pMethod, ":", pPlusLogData );
70 63 LLchkMethodOK( pMethod );
71 64 }
72 65
73 - private void chkMethodOK( String pMethod )
74 - {
66 + private void chkMethodOK( String pMethod ) {
75 67 LOGGER.debug.log( pMethod );
76 68 LLchkMethodOK( pMethod );
77 69 }
78 70
79 - private void LLchkMethodOK( String pMethod )
80 - {
81 - if ( isDisposed() )
82 - {
71 + private void LLchkMethodOK( String pMethod ) {
72 + if ( isDisposed() ) {
83 73 throw new IllegalStateException( pMethod + " unavailable. This form has been disposed" );
84 74 }
85 75 }
86 76
87 - private void clearContainerErrorsAndWarnings()
88 - {
77 + private void clearContainerErrorsAndWarnings() {
89 78 LOGGER.debug.log( "clearContainerErrorsAndWarnings" );
90 - if ( mFormContainer != null )
91 - {
79 + if ( mFormContainer != null ) {
92 80 mFormContainer.clearErrorOrWarning();
93 81 }
94 82 }
95 83
96 84 // RenderedFormHandler:
97 85
98 - public void requestValues( String pRootTypeKeyOrNullForNew )
99 - {
86 + public void requestValues( String pRootTypeKeyOrNullForNew ) {
100 87 Integer zAsyncMessageNumber = mManager.getNextAsyncMessageNumber();
101 88 chkMethodOK( "requestValues", zAsyncMessageNumber, pRootTypeKeyOrNullForNew );
102 89 mRootObjectKey = pRootTypeKeyOrNullForNew;
  @@ -104,86 +91,72 @@
104 91 mFormServicePeerChannel.requestValues( zAsyncMessageNumber, pRootTypeKeyOrNullForNew );
105 92 }
106 93
107 - public String getCurrentRootType()
108 - {
94 + public String getCurrentRootType() {
109 95 return mRootType;
110 96 }
111 97
112 - public String getCurrentRootTypeKey()
113 - {
98 + public String getCurrentRootTypeKey() {
114 99 return mRootObjectKey;
115 100 }
116 101
117 - public void dispose()
118 - {
102 + public void dispose() {
119 103 LOGGER.debug.log( "dispose" );
120 - if ( mFormServicePeerChannel != null )
121 - {
104 + if ( mFormServicePeerChannel != null ) {
122 105 mFormServicePeerChannel.dispose();
123 106 mFormServicePeerChannel = null;
124 107 mUiFormHandler = null;
125 108 mListener = null;
126 109 mFormContainer = null;
127 110 }
128 - if ( mManager != null )
129 - {
111 + if ( mManager != null ) {
130 112 mManager.dispose();
131 113 mManager = null;
132 114 }
133 - if ( mBaseComponentHandler != null )
134 - {
115 + if ( mBaseComponentHandler != null ) {
135 116 mBaseComponentHandler.dispose( this );
136 117 mBaseComponentHandler = null;
137 118 }
138 119 }
139 120
140 - public boolean setFocus()
141 - {
121 + public boolean setFocus() {
142 122 chkMethodOK( "setFocus" );
143 123 return mBaseComponentHandler.setFocus();
144 124 }
145 125
146 - public void setInputDisabled( FormDataRowKey pFormDataRowKey, String pAttributeName, boolean pDisabled )
147 - {
126 + public void setInputDisabled( FormDataRowKey pFormDataRowKey, String pAttributeName, boolean pDisabled ) {
148 127 chkMethodOK( "setInputDisabled", pAttributeName, pDisabled );
149 128 mBaseComponentHandler.setInputDisabled( pFormDataRowKey, pAttributeName, pDisabled );
150 129 }
151 130
152 - public void setActionDisabled( FormDataRowKey pFormDataRowKey, String pActionID, boolean pDisabled )
153 - {
131 + public void setActionDisabled( FormDataRowKey pFormDataRowKey, String pActionID, boolean pDisabled ) {
154 132 chkMethodOK( "setActionDisabled", pActionID, pDisabled );
155 133 mBaseComponentHandler.setActionDisabled( pFormDataRowKey, pActionID, pDisabled );
156 134 }
157 135
158 - public void clearErrorsAndWarnings()
159 - {
136 + public void clearErrorsAndWarnings() {
160 137 chkMethodOK( "clearErrorsAndWarnings" );
161 138 clearContainerErrorsAndWarnings();
162 139 }
163 140
164 141 public void sendAttibuteValue( FormDataRowKey pFormDataRowKey, Integer pAttributeUniqueID,
165 - String pAttributeReference, Serializable pCurrentValue )
166 - {
142 + String pAttributeReference, Serializable pCurrentValue ) {
167 143 chkMethodOK( "sendAttibuteValue", pAttributeReference, pCurrentValue );
168 144 LLsendAttibuteValue( new ValueUpdatedFormData( pFormDataRowKey, //
169 145 pAttributeUniqueID, pAttributeReference, //
170 146 pCurrentValue ) );
171 147 }
172 148
173 - public void sendActionRequest( FormDataRowKey pFormDataRowKey, String pActionID )
174 - {
149 + public void sendActionRequest( FormDataRowKey pFormDataRowKey, String pActionID ) {
175 150 chkMethodOK( "sendActionRequest", pActionID );
176 151 LLsendActionRequest( new ActionRequestFormData( pFormDataRowKey, pActionID, false, null ) );
177 152 }
178 153
179 - public void captureUserState( ParamMap pParamMap )
180 - {
154 + public void captureUserState( ParamMap pParamMap ) {
181 155 chkMethodOK( "captureUserState" );
182 156 mBaseComponentHandler.captureUserState( mRootType, pParamMap );
183 157 }
184 158
185 - public void restoreUserState( ParamMap pParamMap )
186 - {
159 + public void restoreUserState( ParamMap pParamMap ) {
187 160 chkMethodOK( "restoreUserState" );
188 161 mBaseComponentHandler.restoreUserState( mRootType, pParamMap );
189 162 }
  @@ -192,39 +165,28 @@
192 165
193 166 // Component Handler Management
194 167
195 - public void setBaseComponentHandler( BaseFormComponentHandlerImpl pComponentHandler )
196 - {
168 + public void setBaseComponentHandler( BaseFormComponentHandlerImpl pComponentHandler ) {
197 169 mBaseComponentHandler = pComponentHandler;
198 170 }
199 171
200 172 // Bridge to Rendered Form Button State Management
201 - public void componentErrorState( boolean pErrorState )
202 - {
173 + public void componentErrorState( boolean pErrorState ) {
203 174 LOGGER.trace.log( "componentErrorState:", pErrorState );
204 - if ( !isDisposed() && (mAnyAttributesInError != pErrorState) )
205 - {
206 - if ( mMassUpdateInError )
207 - {
175 + if ( !isDisposed() && (mAnyAttributesInError != pErrorState) ) {
176 + if ( mMassUpdateInError ) {
208 177 mMassUpdateStaleInError = true;
209 - }
210 - else
211 - {
178 + } else {
212 179 updateAnyAttributesInError();
213 180 }
214 181 }
215 182 }
216 183
217 - public void componentChangedState( boolean pChangedState )
218 - {
184 + public void componentChangedState( boolean pChangedState ) {
219 185 LOGGER.trace.log( "componentChangedState:", pChangedState );
220 - if ( !isDisposed() && (mAnyAttributesChanged != pChangedState) )
221 - {
222 - if ( mMassUpdateChanged )
223 - {
186 + if ( !isDisposed() && (mAnyAttributesChanged != pChangedState) ) {
187 + if ( mMassUpdateChanged ) {
224 188 mMassUpdateStaleChanged = true;
225 - }
226 - else
227 - {
189 + } else {
228 190 updateAnyAttributesChanged();
229 191 }
230 192 }
  @@ -232,12 +194,10 @@
232 194
233 195 // Bridge to FormServicePeer
234 196 public void componentUpdatedValue( FormDataRowKey pFormDataRowKey, FormAttributeAdapter pAttributeAdapter,
235 - Serializable pCurrentValue )
236 - {
197 + Serializable pCurrentValue ) {
237 198 LOGGER.debug.log( "componentUpdatedValue[", pFormDataRowKey, "]:", pAttributeAdapter, "=",
238 199 pCurrentValue );
239 - if ( !isDisposed() )
240 - {
200 + if ( !isDisposed() ) {
241 201 LLsendAttibuteValue( new ValueUpdatedFormData( pFormDataRowKey, //
242 202 pAttributeAdapter.getUniqueID(),
243 203 pAttributeAdapter.getAttributeReference(),
  @@ -247,11 +207,9 @@
247 207
248 208 public void requestResourceKeyNameURLs( FormDataRowKey pFormDataRowKey,
249 209 FormAttributeAdapter pAttributeAdapter,
250 - ResourceKeyNameURLsAvailableCallback pCallback )
251 - {
210 + ResourceKeyNameURLsAvailableCallback pCallback ) {
252 211 LOGGER.debug.log( "requestResourceKeyNameURLs[", pFormDataRowKey, "]:", pAttributeAdapter );
253 - if ( !isDisposed() )
254 - {
212 + if ( !isDisposed() ) {
255 213 mFormServicePeerChannel.requestResources( pCallback, //
256 214 new AttributeResourceOptionsRequestData( pFormDataRowKey, //
257 215 pAttributeAdapter.getUniqueID(), //
  @@ -260,20 +218,15 @@
260 218 }
261 219
262 220 public void actionRequested( FormDataRowKey pFormDataRowKey, FormActionAdapter pActionAdapter,
263 - boolean pInputAction, FormDataRowKey pParentFormDataRow )
264 - {
221 + boolean pInputAction, FormDataRowKey pParentFormDataRow ) {
265 222 LOGGER.debug.log( "actionRequested[", pFormDataRowKey, "]:", pActionAdapter,
266 223 pInputAction ? ",Input" : "" );
267 - if ( !isDisposed() && pActionAdapter.isEnabled() )
268 - {
224 + if ( !isDisposed() && pActionAdapter.isEnabled() ) {
269 225 getCollector();
270 226 String actionID = pActionAdapter.getActionID();
271 - if ( mListener.formActionRequested( mUiFormHandler, actionID ) )
272 - {
227 + if ( mListener.formActionRequested( mUiFormHandler, actionID ) ) {
273 228 sendCollector( "actionRequested" );
274 - }
275 - else
276 - {
229 + } else {
277 230 clearContainerErrorsAndWarnings();
278 231 LLsendActionRequest( new ActionRequestFormData( pFormDataRowKey, actionID, pInputAction,
279 232 pParentFormDataRow ) );
  @@ -283,35 +236,28 @@
283 236
284 237 // OperationalListener:
285 238
286 - public void responseFromRequestValues( ServicePeerToFormData pFormData )
287 - {
239 + public void responseFromRequestValues( ServicePeerToFormData pFormData ) {
288 240 LOGGER.debug.log( "responseFromRequestValues:", pFormData );
289 - if ( !isDisposed() )
290 - {
241 + if ( !isDisposed() ) {
291 242 process( pFormData );
292 243 mListener.formValuesApplied( mUiFormHandler, pFormData.getServicePeerXtra() );
293 244 // an action may have been triggered programmatically on the server
294 - if ( pFormData.getSuccessfulTriggeringActionID() != null )
295 - {
245 + if ( pFormData.getSuccessfulTriggeringActionID() != null ) {
296 246 mListener.formActionSucceeded( mUiFormHandler, pFormData.getSuccessfulTriggeringActionID(),
297 247 pFormData.getServicePeerXtra() );
298 248 }
299 249 }
300 250 }
301 251
302 - public void unsolicitedData( ServicePeerToFormData pFormData )
303 - {
252 + public void unsolicitedData( ServicePeerToFormData pFormData ) {
304 253 LOGGER.debug.log( "unsolicitedData:", pFormData );
305 - if ( !isDisposed() )
306 - {
254 + if ( !isDisposed() ) {
307 255 process( pFormData );
308 - if ( pFormData.getSuccessfulTriggeringActionID() != null )
309 - {
256 + if ( pFormData.getSuccessfulTriggeringActionID() != null ) {
310 257 mListener.formActionSucceeded( mUiFormHandler, pFormData.getSuccessfulTriggeringActionID(),
311 258 pFormData.getServicePeerXtra() );
312 259 }
313 - if ( pFormData.isCloseRequested() )
314 - {
260 + if ( pFormData.isCloseRequested() ) {
315 261 mListener.formCloseRequested( mUiFormHandler, pFormData.getServicePeerXtra() );
316 262 }
317 263 }
  @@ -319,19 +265,16 @@
319 265
320 266 // Impl:
321 267
322 - private void LLsendAttibuteValue( ValueUpdatedFormData pValueUpdatedFormData )
323 - {
268 + private void LLsendAttibuteValue( ValueUpdatedFormData pValueUpdatedFormData ) {
324 269 LOGGER.debug.log( "LLsendAttibuteValue:", pValueUpdatedFormData );
325 270 boolean collecting = isCollecting();
326 271 getCollector().add( pValueUpdatedFormData );
327 - if ( !collecting )
328 - {
272 + if ( !collecting ) {
329 273 sendCollector( "LLsendAttibuteValue" );
330 274 }
331 275 }
332 276
333 - private void LLsendActionRequest( ActionRequestFormData pActionRequest )
334 - {
277 + private void LLsendActionRequest( ActionRequestFormData pActionRequest ) {
335 278 LOGGER.debug.log( "LLsendActionRequest:", pActionRequest );
336 279 getCollector().setActionRequest( pActionRequest );
337 280
  @@ -340,33 +283,27 @@
340 283 sendCollector( "LLsendActionRequest" );
341 284 }
342 285
343 - private void process( ServicePeerToFormData pFormData )
344 - {
345 - if ( pFormData == null )
346 - {
286 + private void process( ServicePeerToFormData pFormData ) {
287 + if ( pFormData == null ) {
347 288 System.out.println( "process null ServicePeerToFormData" );
348 289 return;
349 290 }
350 291 receivedAsyncMessageNumber( pFormData.getAsyncMessageNumber() );
351 - if ( pFormData.getRootType() != null )
352 - {
292 + if ( pFormData.getRootType() != null ) {
353 293 mRootType = pFormData.getRootType();
354 294 }
355 - if ( pFormData.getRootObjectKey() != null )
356 - {
295 + if ( pFormData.getRootObjectKey() != null ) {
357 296 mRootObjectKey = pFormData.getRootObjectKey();
358 297 }
359 298 setContainerErrorsAndWarnings( pFormData.getFormErrors(), pFormData.getFormWarnings() );
360 - if ( mBaseComponentHandler != null )
361 - {
299 + if ( mBaseComponentHandler != null ) {
362 300 mBaseComponentHandler.apply( pFormData.getActionUpdates() );
363 301
364 302 RelSubFormRowKeys[] zRelSubFormRowKeysList = pFormData.getRelSubFormRowKeysList();
365 303 AttributeUpdateFormData[] zAttributeUpdates = pFormData.getAttributeUpdates();
366 304
367 305 if ( Objects.isNotNullOrEmpty( zRelSubFormRowKeysList ) ||
368 - Objects.isNotNullOrEmpty( zAttributeUpdates ) )
369 - {
306 + Objects.isNotNullOrEmpty( zAttributeUpdates ) ) {
370 307 mMassUpdateChanged = mMassUpdateInError = true;
371 308 boolean zUserInitiatedAddOrRemoveRow = //
372 309 "AddRow".equals( pFormData.getSuccessfulTriggeringActionID() ) || //
  @@ -379,12 +316,12 @@
379 316 }
380 317
381 318 FormPopupMessage[] popups = pFormData.getPopups();
382 - if( popups != null ) {
383 - for( int i = 0; i < popups.length; i ++ ) {
319 + if ( popups != null ) {
320 + for ( int i = 0; i < popups.length; i++ ) {
384 321 // the title and message are used together as the key that the popup manager
385 322 // will use to filter duplicate messages
386 323 String combined = popups[i].getTitle() + popups[i].getMessage();
387 - if( popups[i].isAlert() ) {
324 + if ( popups[i].isAlert() ) {
388 325 AlertManager.alert( combined, popups[i].getTitle(), popups[i].getMessage() );
389 326 } else {
390 327 InfoManager.info( combined, popups[i].getTitle(), popups[i].getMessage() );
  @@ -393,14 +330,11 @@
393 330 }
394 331 }
395 332
396 - private void updateAnyAttributesChanged()
397 - {
398 - if ( mBaseComponentHandler != null )
399 - {
333 + private void updateAnyAttributesChanged() {
334 + if ( mBaseComponentHandler != null ) {
400 335 boolean zAnyChanged = mBaseComponentHandler.anyUserInitiatedRowChange() ||
401 336 mBaseComponentHandler.recalcAnyAttributes( FormAttributeAdapter.CHANGED );
402 - if ( zAnyChanged != mAnyAttributesChanged )
403 - {
337 + if ( zAnyChanged != mAnyAttributesChanged ) {
404 338 mBaseComponentHandler.updateInputState( mAnyAttributesChanged = zAnyChanged,
405 339 mAnyAttributesInError );
406 340 mListener.formChangeState( mUiFormHandler, mAnyAttributesChanged );
  @@ -408,13 +342,10 @@
408 342 }
409 343 }
410 344
411 - private void updateAnyAttributesInError()
412 - {
413 - if ( mBaseComponentHandler != null )
414 - {
345 + private void updateAnyAttributesInError() {
346 + if ( mBaseComponentHandler != null ) {
415 347 boolean zAnyInError = mBaseComponentHandler.recalcAnyAttributes( FormAttributeAdapter.ERRORED );
416 - if ( zAnyInError != mAnyAttributesInError )
417 - {
348 + if ( zAnyInError != mAnyAttributesInError ) {
418 349 mBaseComponentHandler.updateInputState( mAnyAttributesChanged,
419 350 mAnyAttributesInError = zAnyInError );
420 351 mListener.formErrorState( mUiFormHandler, mAnyAttributesInError );
  @@ -422,40 +353,29 @@
422 353 }
423 354 }
424 355
425 - private void massUpdateComplete()
426 - {
356 + private void massUpdateComplete() {
427 357 mMassUpdateChanged = false;
428 - if ( mMassUpdateStaleChanged )
429 - {
358 + if ( mMassUpdateStaleChanged ) {
430 359 mMassUpdateStaleChanged = false;
431 360 updateAnyAttributesChanged();
432 361 }
433 362 mMassUpdateInError = false;
434 - if ( mMassUpdateStaleInError )
435 - {
363 + if ( mMassUpdateStaleInError ) {
436 364 mMassUpdateStaleInError = false;
437 365 updateAnyAttributesInError();
438 366 }
439 367 }
440 368
441 - private void setContainerErrorsAndWarnings( String[] pFormErrors, String[] pFormWarnings )
442 - {
443 - if ( mFormContainer != null )
444 - {
369 + private void setContainerErrorsAndWarnings( String[] pFormErrors, String[] pFormWarnings ) {
370 + if ( mFormContainer != null ) {
445 371 String formErrors = Strings.noEmpty( Strings.linesToString( pFormErrors ) );
446 - if ( formErrors != null )
447 - {
372 + if ( formErrors != null ) {
448 373 mFormContainer.setError( formErrors );
449 - }
450 - else
451 - {
374 + } else {
452 375 String formWarnings = Strings.noEmpty( Strings.linesToString( pFormWarnings ) );
453 - if ( formWarnings != null )
454 - {
376 + if ( formWarnings != null ) {
455 377 mFormContainer.setWarning( formWarnings );
456 - }
457 - else
458 - {
378 + } else {
459 379 mFormContainer.clearErrorOrWarning();
460 380 }
461 381 }
  @@ -464,29 +384,24 @@
464 384
465 385 private FormToServicePeerDataCollector mCollector = null;
466 386
467 - private boolean isCollecting()
468 - {
387 + private boolean isCollecting() {
469 388 return (mCollector != null);
470 389 }
471 390
472 - private FormToServicePeerDataCollector getCollector()
473 - {
474 - if ( mCollector == null )
475 - {
391 + private FormToServicePeerDataCollector getCollector() {
392 + if ( mCollector == null ) {
476 393 mCollector = new FormToServicePeerDataCollector( mManager.getNextAsyncMessageNumber() );
477 394 }
478 395 return mCollector;
479 396 }
480 397
481 - private void sendCollector( String pWho )
482 - {
398 + private void sendCollector( String pWho ) {
483 399 FormToServicePeerDataCollector zCollector = mCollector;
484 400 mCollector = null;
485 401 mManager.sendCollector( pWho, zCollector );
486 402 }
487 403
488 - private void receivedAsyncMessageNumber( Integer pAsyncMessageNumber )
489 - {
404 + private void receivedAsyncMessageNumber( Integer pAsyncMessageNumber ) {
490 405 mManager.receivedAsyncMessageNumber( pAsyncMessageNumber );
491 406 }
492 407 }