Subversion Repository Public Repository

litesoft

Diff Revisions 947 vs 948 for /trunk/Java/GWT/Client/src/org/litesoft/GWT/forms/client/FormEngine.java

Diff revisions: vs.
  @@ -1,16 +1,13 @@
1 1 // This Source Code is in the Public Domain per: http://unlicense.org
2 2 package org.litesoft.GWT.forms.client;
3 3
4 - import org.litesoft.commonfoundation.typeutils.*;
5 -
6 - import java.util.*;
7 -
8 4 import org.litesoft.GWT.client.*;
9 5 import org.litesoft.GWT.client.widgets.*;
10 6 import org.litesoft.GWT.forms.client.components.*;
11 7 import org.litesoft.GWT.forms.client.components.nonpublic.*;
12 - import org.litesoft.core.simpletypes.*;
13 8 import org.litesoft.commonfoundation.typeutils.Objects;
9 + import org.litesoft.commonfoundation.typeutils.*;
10 + import org.litesoft.core.simpletypes.*;
14 11 import org.litesoft.core.util.*;
15 12 import org.litesoft.uispecification.*;
16 13
  @@ -20,17 +17,16 @@
20 17 import com.google.gwt.user.client.*;
21 18 import com.google.gwt.user.client.ui.*;
22 19
20 + import java.util.*;
21 +
23 22 import static org.litesoft.uispecification.FormWidgetAspectCtrl.*;
24 23 import static org.litesoft.uispecification.FormWidgetCtrl.*;
25 24
26 - public class FormEngine implements ClickHandler
27 - {
28 - public abstract static class CtrlProxy implements Enableable
29 - {
25 + public class FormEngine implements ClickHandler {
26 + public abstract static class CtrlProxy implements Enableable {
30 27 private FormWidgetCtrl mFormWidgetCtrl;
31 28
32 - protected CtrlProxy( FormWidgetCtrl pFormWidgetCtrl )
33 - {
29 + protected CtrlProxy( FormWidgetCtrl pFormWidgetCtrl ) {
34 30 mFormWidgetCtrl = pFormWidgetCtrl;
35 31 }
36 32
  @@ -38,139 +34,112 @@
38 34
39 35 abstract public void setHidden( boolean pHide );
40 36
41 - public boolean isVisible( FormState pFormState )
42 - {
37 + public boolean isVisible( FormState pFormState ) {
43 38 return mFormWidgetCtrl.getVisible().satisfiedBy( pFormState );
44 39 }
45 40
46 - public boolean isEnabled( FormState pFormState )
47 - {
41 + public boolean isEnabled( FormState pFormState ) {
48 42 return mFormWidgetCtrl.getEnable().satisfiedBy( pFormState );
49 43 }
50 44
51 - public boolean isSearchFilter()
52 - {
45 + public boolean isSearchFilter() {
53 46 return mFormWidgetCtrl.isSearchFilter();
54 47 }
55 48
56 - public boolean isEditRequired()
57 - {
49 + public boolean isEditRequired() {
58 50 return mFormWidgetCtrl.isEditRequired();
59 51 }
60 52 }
61 53
62 54 private static final String EDITING_SECTION_TITLE_TEXT = "Edit ";
63 55
64 - public enum Mode
65 - {
66 - Search( true, false, "Search for " )
67 - {
68 - @Override
69 - public void update( FormState pFormState )
70 - {
71 - pFormState.setModeSearch();
72 - }
56 + public enum Mode {
57 + Search( true, false, "Search for " ) {
58 + @Override
59 + public void update( FormState pFormState ) {
60 + pFormState.setModeSearch();
61 + }
73 62
74 - @Override
75 - public ButtonBase createSectionTitleRightButton( ClickHandler pClickHandler )
76 - {
77 - return ClearButton.factory().disabled().add( pClickHandler ).create();
78 - }
63 + @Override
64 + public ButtonBase createSectionTitleRightButton( ClickHandler pClickHandler ) {
65 + return ClearButton.factory().disabled().add( pClickHandler ).create();
66 + }
79 67
80 - @Override
81 - public boolean isEditRequired( CtrlProxy pCtrlProxy )
82 - {
83 - return false;
84 - }
85 - },
86 - NewFromSearch( true, false, "Create " )
87 - {
88 - @Override
89 - public void update( FormState pFormState )
90 - {
91 - pFormState.setModeEditNew();
92 - }
68 + @Override
69 + public boolean isEditRequired( CtrlProxy pCtrlProxy ) {
70 + return false;
71 + }
72 + },
73 + NewFromSearch( true, false, "Create " ) {
74 + @Override
75 + public void update( FormState pFormState ) {
76 + pFormState.setModeEditNew();
77 + }
93 78
94 - @Override
95 - public ButtonBase createSectionTitleRightButton( ClickHandler pClickHandler )
96 - {
97 - return SearchButton.factory().add( pClickHandler ).create();
98 - }
99 - },
100 - EditFromSearch( true, true, EDITING_SECTION_TITLE_TEXT )
101 - {
102 - @Override
103 - public void update( FormState pFormState )
104 - {
105 - pFormState.setModeEditExisting();
106 - }
79 + @Override
80 + public ButtonBase createSectionTitleRightButton( ClickHandler pClickHandler ) {
81 + return SearchButton.factory().add( pClickHandler ).create();
82 + }
83 + },
84 + EditFromSearch( true, true, EDITING_SECTION_TITLE_TEXT ) {
85 + @Override
86 + public void update( FormState pFormState ) {
87 + pFormState.setModeEditExisting();
88 + }
107 89
108 - @Override
109 - public ButtonBase createSectionTitleRightButton( ClickHandler pClickHandler )
110 - {
111 - return SearchButton.factory().add( pClickHandler ).create();
112 - }
113 - },
114 - EditRegular( false, true, EDITING_SECTION_TITLE_TEXT )
115 - {
116 - @Override
117 - public void update( FormState pFormState )
118 - {
119 - pFormState.setModeEditExisting();
120 - }
90 + @Override
91 + public ButtonBase createSectionTitleRightButton( ClickHandler pClickHandler ) {
92 + return SearchButton.factory().add( pClickHandler ).create();
93 + }
94 + },
95 + EditRegular( false, true, EDITING_SECTION_TITLE_TEXT ) {
96 + @Override
97 + public void update( FormState pFormState ) {
98 + pFormState.setModeEditExisting();
99 + }
121 100
122 - @Override
123 - public ButtonBase createSectionTitleRightButton( ClickHandler pClickHandler )
124 - {
125 - return null;
126 - }
127 - },
128 - ViewFromSearch( false, true, "Confirm " )
129 - {
130 - @Override
131 - public void update( FormState pFormState )
132 - {
133 - pFormState.setModeView();
134 - }
101 + @Override
102 + public ButtonBase createSectionTitleRightButton( ClickHandler pClickHandler ) {
103 + return null;
104 + }
105 + },
106 + ViewFromSearch( false, true, "Confirm " ) {
107 + @Override
108 + public void update( FormState pFormState ) {
109 + pFormState.setModeView();
110 + }
135 111
136 - @Override
137 - public ButtonBase createSectionTitleRightButton( ClickHandler pClickHandler )
138 - {
139 - return SearchButton.factory().add( pClickHandler ).create();
140 - }
112 + @Override
113 + public ButtonBase createSectionTitleRightButton( ClickHandler pClickHandler ) {
114 + return SearchButton.factory().add( pClickHandler ).create();
115 + }
141 116
142 - @Override
143 - public boolean isEditRequired( CtrlProxy pCtrlProxy )
144 - {
145 - return false;
146 - }
147 - },
148 - ViewRegular( false, true, "" )
149 - {
150 - @Override
151 - public void update( FormState pFormState )
152 - {
153 - pFormState.setModeView();
154 - }
117 + @Override
118 + public boolean isEditRequired( CtrlProxy pCtrlProxy ) {
119 + return false;
120 + }
121 + },
122 + ViewRegular( false, true, "" ) {
123 + @Override
124 + public void update( FormState pFormState ) {
125 + pFormState.setModeView();
126 + }
155 127
156 - @Override
157 - public ButtonBase createSectionTitleRightButton( ClickHandler pClickHandler )
158 - {
159 - return null;
160 - }
128 + @Override
129 + public ButtonBase createSectionTitleRightButton( ClickHandler pClickHandler ) {
130 + return null;
131 + }
161 132
162 - @Override
163 - public boolean isEditRequired( CtrlProxy pCtrlProxy )
164 - {
165 - return false;
166 - }
167 - };
133 + @Override
134 + public boolean isEditRequired( CtrlProxy pCtrlProxy ) {
135 + return false;
136 + }
137 + };
168 138
169 139 private boolean mMonitorSearchFields, mClearFields;
170 140 private String mSectionTitleText;
171 141
172 - Mode( boolean pMonitorSearchFields, boolean pClearFields, String pSectionTitleText )
173 - {
142 + Mode( boolean pMonitorSearchFields, boolean pClearFields, String pSectionTitleText ) {
174 143 mMonitorSearchFields = pMonitorSearchFields;
175 144 mClearFields = pClearFields;
176 145 mSectionTitleText = pSectionTitleText;
  @@ -178,43 +147,35 @@
178 147
179 148 abstract public void update( FormState pFormState );
180 149
181 - public boolean isEditing()
182 - {
150 + public boolean isEditing() {
183 151 return EDITING_SECTION_TITLE_TEXT.equals( mSectionTitleText );
184 152 }
185 153
186 - public boolean isVisible( CtrlProxy pCtrlProxy, FormState pFormState )
187 - {
154 + public boolean isVisible( CtrlProxy pCtrlProxy, FormState pFormState ) {
188 155 return pCtrlProxy.isVisible( pFormState );
189 156 }
190 157
191 - public boolean isEnabled( CtrlProxy pCtrlProxy, FormState pFormState )
192 - {
158 + public boolean isEnabled( CtrlProxy pCtrlProxy, FormState pFormState ) {
193 159 return pCtrlProxy.isEnabled( pFormState );
194 160 }
195 161
196 - public boolean isSearchFilter( CtrlProxy pCtrlProxy )
197 - {
162 + public boolean isSearchFilter( CtrlProxy pCtrlProxy ) {
198 163 return mMonitorSearchFields && pCtrlProxy.isSearchFilter();
199 164 }
200 165
201 - public boolean isEditRequired( CtrlProxy pCtrlProxy )
202 - {
166 + public boolean isEditRequired( CtrlProxy pCtrlProxy ) {
203 167 return pCtrlProxy.isEditRequired();
204 168 }
205 169
206 - public final boolean shouldMonitorSearchFields()
207 - {
170 + public final boolean shouldMonitorSearchFields() {
208 171 return mMonitorSearchFields;
209 172 }
210 173
211 - public final boolean shouldClearFields()
212 - {
174 + public final boolean shouldClearFields() {
213 175 return mClearFields;
214 176 }
215 177
216 - public final String getSectionTitleText()
217 - {
178 + public final String getSectionTitleText() {
218 179 return mSectionTitleText;
219 180 }
220 181
  @@ -235,41 +196,33 @@
235 196 protected Mode mMode;
236 197 private IFormComponent.Listener.Factory mListenerFactory;
237 198
238 - public FormEngine( WidgetCtrlMap pWidgetCtrlMap, Mode pInitialMode, IFormComponent.Listener.Factory pListenerFactory )
239 - {
199 + public FormEngine( WidgetCtrlMap pWidgetCtrlMap, Mode pInitialMode, IFormComponent.Listener.Factory pListenerFactory ) {
240 200 Objects.assertNotNull( "WidgetCtrlMap", mWidgetCtrlMap = pWidgetCtrlMap );
241 201 mMode = (pInitialMode != null) ? pInitialMode : Mode.ViewRegular;
242 202 mListenerFactory = (pListenerFactory != null) ? pListenerFactory : NoOpFormListenerFactory.INSTANCE;
243 203 }
244 204
245 - public boolean isEditRequired( String pName )
246 - {
205 + public boolean isEditRequired( String pName ) {
247 206 return mWidgetCtrlMap.get( pName ).isEditRequired();
248 207 }
249 208
250 - public boolean isSearchFilter( String pName )
251 - {
209 + public boolean isSearchFilter( String pName ) {
252 210 return mWidgetCtrlMap.get( pName ).isSearchFilter();
253 211 }
254 212
255 - public boolean isUnique( String pName )
256 - {
213 + public boolean isUnique( String pName ) {
257 214 return mWidgetCtrlMap.get( pName ).isUnique();
258 215 }
259 216
260 - public void setSectionTitleCustomText( Mode pMode, String pText )
261 - {
217 + public void setSectionTitleCustomText( Mode pMode, String pText ) {
262 218 Objects.assertNotNull( "Mode", pMode );
263 - if ( pText == null )
264 - {
265 - if ( mSectionTitleCustomText != null )
266 - {
219 + if ( pText == null ) {
220 + if ( mSectionTitleCustomText != null ) {
267 221 mSectionTitleCustomText.remove( pMode );
268 222 }
269 223 return;
270 224 }
271 - if ( mSectionTitleCustomText == null )
272 - {
225 + if ( mSectionTitleCustomText == null ) {
273 226 mSectionTitleCustomText = new HashMap<Mode, String>();
274 227 }
275 228 mSectionTitleCustomText.put( pMode, pText );
  @@ -278,8 +231,7 @@
278 231 /**
279 232 * May only create a SINGLE Section Title
280 233 */
281 - public Widget createSectionTitle( String pPrefix, String pSuffix )
282 - {
234 + public Widget createSectionTitle( String pPrefix, String pSuffix ) {
283 235 mSectionTitlePrefix = Strings.deNull( pPrefix );
284 236 mSectionTitleSuffix = Strings.deNull( pSuffix );
285 237 mSectionTitleLabel = new OurLabel( getSectionTitleText(), false );
  @@ -289,10 +241,8 @@
289 241 return mSectionTitlePanel;
290 242 }
291 243
292 - private void LLsectionTitleUpdate()
293 - {
294 - if ( mSectionTitlePanel != null )
295 - {
244 + private void LLsectionTitleUpdate() {
245 + if ( mSectionTitlePanel != null ) {
296 246 String zText = getSectionTitleText();
297 247 Widget zWidget = createSectionTitleModeButton();
298 248 mSectionTitleLabel.setText( zText );
  @@ -302,46 +252,37 @@
302 252 }
303 253 }
304 254
305 - private void LLsectionTitleOnChange( boolean pAnyChanges )
306 - {
307 - if ( Mode.Search.equals( mMode ) && (mSectionTitleButton != null) )
308 - {
255 + private void LLsectionTitleOnChange( boolean pAnyChanges ) {
256 + if ( Mode.Search.equals( mMode ) && (mSectionTitleButton != null) ) {
309 257 mSectionTitleButton.setEnabled( pAnyChanges );
310 258 }
311 259 }
312 260
313 261 @Override
314 - public void onClick( ClickEvent event )
315 - {
262 + public void onClick( ClickEvent event ) {
316 263 if ( Mode.Search.equals( mMode ) ) // Clear Button
317 264 {
318 265 resetForm();
319 266 LLsectionTitleOnChange( mFormState.hasChanges() );
320 - }
321 - else // Search Button
267 + } else // Search Button
322 268 {
323 269 setMode( Mode.Search );
324 270 }
325 271 }
326 272
327 - private Widget createSectionTitleModeButton()
328 - {
273 + private Widget createSectionTitleModeButton() {
329 274 mSectionTitleButton = mMode.createSectionTitleRightButton( this );
330 275 return (mSectionTitleButton != null) ? mSectionTitleButton : new TransparentImage();
331 276 }
332 277
333 - private String getSectionTitleText()
334 - {
278 + private String getSectionTitleText() {
335 279 return mSectionTitlePrefix + getSectionTitleModeText() + mSectionTitleSuffix;
336 280 }
337 281
338 - private String getSectionTitleModeText()
339 - {
340 - if ( mSectionTitleCustomText != null )
341 - {
282 + private String getSectionTitleModeText() {
283 + if ( mSectionTitleCustomText != null ) {
342 284 String rv = mSectionTitleCustomText.get( mMode );
343 - if ( rv != null )
344 - {
285 + if ( rv != null ) {
345 286 return rv;
346 287 }
347 288 }
  @@ -351,33 +292,25 @@
351 292 /**
352 293 * May only create a SINGLE Section Title
353 294 */
354 - public Widget createSectionTitle( String pSuffix )
355 - {
295 + public Widget createSectionTitle( String pSuffix ) {
356 296 return createSectionTitle( "", pSuffix );
357 297 }
358 298
359 - public final void resetForm()
360 - {
299 + public final void resetForm() {
361 300 LLresetForm( true );
362 301 }
363 302
364 - protected void LLresetForm( boolean pResetAllValues )
365 - {
303 + protected void LLresetForm( boolean pResetAllValues ) {
366 304 LLresetComponents( pResetAllValues );
367 305 setFocus();
368 306 }
369 307
370 - protected void LLresetComponents( boolean pResetAllValues )
371 - {
308 + protected void LLresetComponents( boolean pResetAllValues ) {
372 309 Collection<ProxyExtendedListener> zListeners = mListeners.values();
373 - for ( ProxyExtendedListener zListener : zListeners )
374 - {
375 - if ( pResetAllValues || !mMode.isSearchFilter( zListener ) )
376 - {
310 + for ( ProxyExtendedListener zListener : zListeners ) {
311 + if ( pResetAllValues || !mMode.isSearchFilter( zListener ) ) {
377 312 zListener.reset( Mode.Search == mMode ); // Search toOrig, everyone else toLastSetValue
378 - }
379 - else
380 - {
313 + } else {
381 314 zListener.makeNonOrigChanged();
382 315 }
383 316 }
  @@ -385,62 +318,48 @@
385 318 LLupdateControls();
386 319 }
387 320
388 - public void setFocus()
389 - {
321 + public void setFocus() {
390 322 Scheduler.get().scheduleDeferred( mFocusCommand );
391 323 }
392 324
393 - private Command mFocusCommand = new Command()
394 - {
325 + private Command mFocusCommand = new Command() {
395 326 @Override
396 - public void execute()
397 - {
398 - for ( IFormComponent zComponent : mComponents )
399 - {
327 + public void execute() {
328 + for ( IFormComponent zComponent : mComponents ) {
400 329 if ( !UtilsGwt.isHidden( (Widget) zComponent ) ) // todo: this does NOT check the Hierarchy for Visibility!!!
401 330 {
402 - if ( zComponent.isEnabled() )
403 - {
331 + if ( zComponent.isEnabled() ) {
404 332 zComponent.setFocus();
405 333 return;
406 334 }
407 335 }
408 336 }
409 - for ( ButtonBase zButton : mDefaultButtons )
410 - {
411 - if ( zButton.isEnabled() )
412 - {
337 + for ( ButtonBase zButton : mDefaultButtons ) {
338 + if ( zButton.isEnabled() ) {
413 339 zButton.setFocus( true );
414 340 return;
415 341 }
416 342 }
417 - if ( mSectionTitleButton != null )
418 - {
343 + if ( mSectionTitleButton != null ) {
419 344 mSectionTitleButton.setFocus( true );
420 345 }
421 346 }
422 347 };
423 348
424 - protected final void updateHiders( String pComponentName )
425 - {
349 + protected final void updateHiders( String pComponentName ) {
426 350 Hider zHider = mNamedHiders.get( pComponentName );
427 - if ( zHider != null )
428 - {
351 + if ( zHider != null ) {
429 352 zHider.update();
430 353 }
431 354 }
432 355
433 356 protected Map<String, Hider> mNamedHiders = new HashMap<String, Hider>();
434 357
435 - private void register( String pComponentName, HiderBridgeBridge pBridge )
436 - {
358 + private void register( String pComponentName, HiderBridgeBridge pBridge ) {
437 359 Hider zExistingHider = mNamedHiders.get( pComponentName );
438 - if ( zExistingHider == null )
439 - {
360 + if ( zExistingHider == null ) {
440 361 mNamedHiders.put( pComponentName, pBridge );
441 - }
442 - else
443 - {
362 + } else {
444 363 mNamedHiders.put( pComponentName, new HiderPair( pBridge, zExistingHider ) );
445 364 }
446 365 }
  @@ -448,11 +367,9 @@
448 367 protected List<CtrlProxy> mCtrlProxys = new ArrayList<CtrlProxy>();
449 368 protected Map<String, CtrlProxy> mNamedCtrlProxys = new HashMap<String, CtrlProxy>();
450 369
451 - private void register( String pName, CtrlProxy pCtrlProxy )
452 - {
370 + private void register( String pName, CtrlProxy pCtrlProxy ) {
453 371 mCtrlProxys.add( pCtrlProxy );
454 - if ( pName != null )
455 - {
372 + if ( pName != null ) {
456 373 mNamedCtrlProxys.put( pName, pCtrlProxy );
457 374 }
458 375 }
  @@ -462,66 +379,55 @@
462 379 protected Map<IFormComponent, String> mComponentNames = new HashMap<IFormComponent, String>();
463 380 protected Map<IFormComponent, ProxyExtendedListener> mListeners = new HashMap<IFormComponent, ProxyExtendedListener>();
464 381
465 - private void register( String pName, FormWidgetCtrl pFormWidgetCtrl, IFormComponent pComponent, IFormComponent.Listener pListener )
466 - {
382 + private void register( String pName, FormWidgetCtrl pFormWidgetCtrl, IFormComponent pComponent, IFormComponent.Listener pListener ) {
467 383 ProxyExtendedListener zExt = new ProxyExtendedListener( pName, pListener, pFormWidgetCtrl );
468 384 register( pName, zExt );
469 385 mComponents.add( pComponent );
470 386 mListeners.put( pComponent, zExt );
471 387 pComponent.addFormComponentListener( zExt );
472 - if ( pName != null )
473 - {
388 + if ( pName != null ) {
474 389 addNamedComponent( pName, pComponent );
475 390 }
476 391 }
477 392
478 - protected void addNamedComponent( String pName, IFormComponent pComponent )
479 - {
393 + protected void addNamedComponent( String pName, IFormComponent pComponent ) {
480 394 mNamedComponents.put( pName, pComponent );
481 395 mComponentNames.put( pComponent, pName );
482 396 }
483 397
484 - public Set<String> getNamedComponentNames()
485 - {
398 + public Set<String> getNamedComponentNames() {
486 399 return new HashSet<String>( mNamedComponents.keySet() );
487 400 }
488 401
489 - public String getComponentName( IFormComponent pComponent )
490 - {
402 + public String getComponentName( IFormComponent pComponent ) {
491 403 return mComponentNames.get( pComponent );
492 404 }
493 405
494 - public IFormComponent getNamedComponent( String pName )
495 - {
406 + public IFormComponent getNamedComponent( String pName ) {
496 407 return mNamedComponents.get( pName );
497 408 }
498 409
499 - public IFormComponent getRequiredNamedComponent( String pName )
500 - {
410 + public IFormComponent getRequiredNamedComponent( String pName ) {
501 411 IFormComponent zComponent = getNamedComponent( pName );
502 - if ( zComponent == null )
503 - {
412 + if ( zComponent == null ) {
504 413 throw new NoSuchElementException( "No Form Component w/ name: " + pName );
505 414 }
506 415 return zComponent;
507 416 }
508 417
509 418 public Object getNamedComponentValue( String pName )
510 - throws NoSuchElementException
511 - {
419 + throws NoSuchElementException {
512 420 return mListeners.get( getRequiredNamedComponent( pName ) ).getCurValue();
513 421 }
514 422
515 423 public void setNamedComponentValue( String pName, Object pValue )
516 - throws NoSuchElementException
517 - {
424 + throws NoSuchElementException {
518 425 mListeners.get( getRequiredNamedComponent( pName ) ).setCurValue( pValue );
519 426 updateControls();
520 427 }
521 428
522 429 public void setNamedComponentValueAsUser( String pName, Object pValue )
523 - throws NoSuchElementException
524 - {
430 + throws NoSuchElementException {
525 431 IFormComponent zComponent = getRequiredNamedComponent( pName );
526 432 ProxyExtendedListener zListener = mListeners.get( zComponent );
527 433 zListener.setCurValueAsUser( pValue );
  @@ -529,74 +435,60 @@
529 435 }
530 436
531 437 public void setNamedComponentError( String pName, String pError )
532 - throws NoSuchElementException
533 - {
438 + throws NoSuchElementException {
534 439 getRequiredNamedComponent( pName ).setError( pError );
535 440 updateControls();
536 441 }
537 442
538 443 public void setNamedComponentEnabled( String pName, boolean pEnabled )
539 - throws NoSuchElementException
540 - {
444 + throws NoSuchElementException {
541 445 getRequiredNamedComponent( pName ).setEnabled( pEnabled );
542 446 updateControls();
543 447 }
544 448
545 - public void setNamedComponentChanged( String pName, boolean pChanged )
546 - {
449 + public void setNamedComponentChanged( String pName, boolean pChanged ) {
547 450 IFormComponent zComponent = getRequiredNamedComponent( pName );
548 451 zComponent.setValueChanged( pChanged );
549 452 LLchangeOccurredOn( pName, zComponent, pChanged );
550 453 updateControls();
551 454 }
552 455
553 - private boolean updateControls()
554 - {
456 + private boolean updateControls() {
555 457 ErrorChangeState zOrigErrorChangeState = mFormState.getErrorChangeState();
556 458 ErrorChangeState zNewErrorChangeState = mFormState.setErrorChangeState( scanForErrorChangeState( mListeners.values() ) );
557 459
558 - if ( zOrigErrorChangeState != zNewErrorChangeState )
559 - {
460 + if ( zOrigErrorChangeState != zNewErrorChangeState ) {
560 461 LLupdateControls();
561 462 }
562 463 return (zOrigErrorChangeState.hasChanges() != zNewErrorChangeState.hasChanges());
563 464 }
564 465
565 - private void LLupdateControls()
566 - {
567 - for ( CtrlProxy zCtrlProxy : mCtrlProxys )
568 - {
569 - if ( mMode.isVisible( zCtrlProxy, mFormState ) )
570 - {
466 + private void LLupdateControls() {
467 + for ( CtrlProxy zCtrlProxy : mCtrlProxys ) {
468 + if ( mMode.isVisible( zCtrlProxy, mFormState ) ) {
571 469 zCtrlProxy.setHidden( false );
572 470 zCtrlProxy.setEnabled( mMode.isEnabled( zCtrlProxy, mFormState ) );
573 - }
574 - else
575 - {
471 + } else {
576 472 zCtrlProxy.setHidden( true );
577 473 zCtrlProxy.setEnabled( false );
578 474 }
579 475 }
580 476 }
581 477
582 - private Widget addHideable( String pName, FormWidgetCtrl pFormWidgetCtrl, Widget pWidget )
583 - {
478 + private Widget addHideable( String pName, FormWidgetCtrl pFormWidgetCtrl, Widget pWidget ) {
584 479 register( pName, new WidgetCtrlProxy( pWidget, pFormWidgetCtrl ) );
585 480 return pWidget;
586 481 }
587 482
588 - public Widget addHideable( String pName, Widget pWidget )
589 - {
483 + public Widget addHideable( String pName, Widget pWidget ) {
590 484 return addHideable( pName, mWidgetCtrlMap.get( pName ), pWidget );
591 485 }
592 486
593 - public Widget addHideable( FormWidgetCtrl pFormWidgetCtrl, Widget pWidget )
594 - {
487 + public Widget addHideable( FormWidgetCtrl pFormWidgetCtrl, Widget pWidget ) {
595 488 return addHideable( null, pFormWidgetCtrl, pWidget );
596 489 }
597 490
598 - public Widget addComponentDrivenHideable( Widget pWidget, String pComponentName, HiderBridge pHiderBridge )
599 - {
491 + public Widget addComponentDrivenHideable( Widget pWidget, String pComponentName, HiderBridge pHiderBridge ) {
600 492 Objects.assertNotNull( "Widget", pWidget );
601 493 Objects.assertNotNull( "ComponentName", pComponentName );
602 494 Objects.assertNotNull( "HiderBridge", pHiderBridge );
  @@ -604,283 +496,227 @@
604 496 return pWidget;
605 497 }
606 498
607 - private FocusWidget addControlled( String pName, FormWidgetCtrl pFormWidgetCtrl, FocusWidget pWidget )
608 - {
499 + private FocusWidget addControlled( String pName, FormWidgetCtrl pFormWidgetCtrl, FocusWidget pWidget ) {
609 500 register( pName, new FocusWidgetCtrlProxy( pWidget, pFormWidgetCtrl ) );
610 501 return pWidget;
611 502 }
612 503
613 - public FocusWidget addControlled( FormWidgetCtrl pFormWidgetCtrl, FocusWidget pWidget )
614 - {
504 + public FocusWidget addControlled( FormWidgetCtrl pFormWidgetCtrl, FocusWidget pWidget ) {
615 505 return addControlled( null, pFormWidgetCtrl, pWidget );
616 506 }
617 507
618 - public FocusWidget addControlled( String pName, FocusWidget pWidget )
619 - {
508 + public FocusWidget addControlled( String pName, FocusWidget pWidget ) {
620 509 return addControlled( pName, mWidgetCtrlMap.get( pName ), pWidget );
621 510 }
622 511
623 - private ButtonBase addButton( String pName, FormWidgetCtrl pFormWidgetCtrl, ButtonBase pButton )
624 - {
512 + private ButtonBase addButton( String pName, FormWidgetCtrl pFormWidgetCtrl, ButtonBase pButton ) {
625 513 addControlled( pName, pFormWidgetCtrl, pButton );
626 514 return pButton;
627 515 }
628 516
629 - public ButtonBase addButton( FormWidgetCtrl pFormWidgetCtrl, ButtonBase pButton )
630 - {
517 + public ButtonBase addButton( FormWidgetCtrl pFormWidgetCtrl, ButtonBase pButton ) {
631 518 return addButton( null, pFormWidgetCtrl, pButton );
632 519 }
633 520
634 - public ButtonBase addButton( boolean pDefault, FormWidgetCtrl pFormWidgetCtrl, ButtonBase pButton )
635 - {
636 - if ( pDefault )
637 - {
521 + public ButtonBase addButton( boolean pDefault, FormWidgetCtrl pFormWidgetCtrl, ButtonBase pButton ) {
522 + if ( pDefault ) {
638 523 mDefaultButtons.add( pButton );
639 524 }
640 525 return addButton( pFormWidgetCtrl, pButton );
641 526 }
642 527
643 - public ButtonBase addButton( String pName, ButtonBase pButton )
644 - {
528 + public ButtonBase addButton( String pName, ButtonBase pButton ) {
645 529 return addButton( pName, mWidgetCtrlMap.get( pName ), pButton );
646 530 }
647 531
648 - public ButtonBase addEditChangeButton( ButtonBase pButton )
649 - {
532 + public ButtonBase addEditChangeButton( ButtonBase pButton ) {
650 533 return addButton( Visible( Edit ).enable( Edit_Changes ), pButton );
651 534 }
652 535
653 - public ButtonBase addEditRevertButton( ButtonBase pButton )
654 - {
655 - pButton.addClickHandler( new ClickHandler()
656 - {
536 + public ButtonBase addEditRevertButton( ButtonBase pButton ) {
537 + pButton.addClickHandler( new ClickHandler() {
657 538 @Override
658 - public void onClick( ClickEvent event )
659 - {
539 + public void onClick( ClickEvent event ) {
660 540 resetForm();
661 541 }
662 542 } );
663 543 return addButton( Visible( Edit_Existing ).enable( Edit_Existing_Changes ), pButton );
664 544 }
665 545
666 - public ButtonBase addEditSubmitButton( ButtonBase pButton )
667 - {
546 + public ButtonBase addEditSubmitButton( ButtonBase pButton ) {
668 547 return addEditSubmitButton( false, pButton );
669 548 }
670 549
671 - public ButtonBase addEditSubmitButton( boolean pDefault, ButtonBase pButton )
672 - {
550 + public ButtonBase addEditSubmitButton( boolean pDefault, ButtonBase pButton ) {
673 551 return addButton( pDefault, Visible( Edit ).enable( Edit_NoErrors_Changes ), pButton );
674 552 }
675 553
676 - public ButtonBase addEditSubmitNextButton( boolean pDefault, ViewDef pTarget, UriFragmentIdParams.ScreenParamsFactory pFactory )
677 - {
554 + public ButtonBase addEditSubmitNextButton( boolean pDefault, ViewDef pTarget, UriFragmentIdParams.ScreenParamsFactory pFactory ) {
678 555 return addEditSubmitButton( pDefault, NextButton.factory().add( pTarget, pFactory ).create() );
679 556 }
680 557
681 - public ButtonBase addExistingUnchangedButton( boolean pDefault, ButtonBase pButton )
682 - {
558 + public ButtonBase addExistingUnchangedButton( boolean pDefault, ButtonBase pButton ) {
683 559 return addButton( pDefault, Visible( Existing ).enable( Existing_NoChanges ), pButton );
684 560 }
685 561
686 - public ButtonBase addExistingUnchangedNextButton( boolean pDefault, ViewDef pTarget )
687 - {
562 + public ButtonBase addExistingUnchangedNextButton( boolean pDefault, ViewDef pTarget ) {
688 563 return addExistingUnchangedButton( pDefault, NextButton.factory().add( pTarget ).create() );
689 564 }
690 565
691 - public ButtonBase addExistingUnchangedNextButton( boolean pDefault, ViewDef pTarget, UriFragmentIdParams.ScreenParamsFactory pFactory )
692 - {
566 + public ButtonBase addExistingUnchangedNextButton( boolean pDefault, ViewDef pTarget, UriFragmentIdParams.ScreenParamsFactory pFactory ) {
693 567 return addExistingUnchangedButton( pDefault, NextButton.factory().add( pTarget, pFactory ).create() );
694 568 }
695 569
696 - private AbstractFormElement add( String pName, FormWidgetCtrl pFormWidgetCtrl, AbstractFormElement pField )
697 - {
570 + private AbstractFormElement add( String pName, FormWidgetCtrl pFormWidgetCtrl, AbstractFormElement pField ) {
698 571 register( pName, pFormWidgetCtrl, pField, mListenerFactory.createListenerFor( pName, pField ) );
699 572 return pField;
700 573 }
701 574
702 - public AbstractFormElement add( FormWidgetCtrl pFormWidgetCtrl, AbstractFormElement pField )
703 - {
575 + public AbstractFormElement add( FormWidgetCtrl pFormWidgetCtrl, AbstractFormElement pField ) {
704 576 return add( null, pFormWidgetCtrl, pField );
705 577 }
706 578
707 - public AbstractFormElement add( String pName, boolean pRequired, AbstractFormElement pField )
708 - {
579 + public AbstractFormElement add( String pName, boolean pRequired, AbstractFormElement pField ) {
709 580 FormWidgetCtrl zFormWidgetCtrl = mWidgetCtrlMap.get( pName );
710 - if ( pRequired )
711 - {
581 + if ( pRequired ) {
712 582 zFormWidgetCtrl = zFormWidgetCtrl.required();
713 583 }
714 584 return add( pName, zFormWidgetCtrl, pField );
715 585 }
716 586
717 - public AbstractFormElement add( String pName, AbstractFormElement pField )
718 - {
587 + public AbstractFormElement add( String pName, AbstractFormElement pField ) {
719 588 return add( pName, false, pField );
720 589 }
721 590
722 - public AbstractFormElement add( AbstractFormElement pField )
723 - {
591 + public AbstractFormElement add( AbstractFormElement pField ) {
724 592 return add( null, false, pField );
725 593 }
726 594
727 - public void initialize()
728 - {
595 + public void initialize() {
729 596 setMode( mMode );
730 597 }
731 598
732 - public Mode getMode()
733 - {
599 + public Mode getMode() {
734 600 return mMode;
735 601 }
736 602
737 - public void setMode( Mode pMode )
738 - {
603 + public void setMode( Mode pMode ) {
739 604 (mMode = (pMode != null) ? pMode : Mode.ViewRegular).update( mFormState );
740 605 LLsectionTitleUpdate();
741 606 LLresetForm( mMode.shouldClearFields() );
742 607 LLsectionTitleOnChange( mFormState.hasChanges() );
743 608 }
744 609
745 - private void LLchangeOccurredOn( String pName, IFormComponent pComponent, boolean pChanged )
746 - {
610 + private void LLchangeOccurredOn( String pName, IFormComponent pComponent, boolean pChanged ) {
747 611 changeOccurredOn( pName, pComponent, pChanged );
748 612 updateHiders( pName );
749 - if ( updateControls() )
750 - {
613 + if ( updateControls() ) {
751 614 LLsectionTitleOnChange( mFormState.hasChanges() );
752 615 }
753 616 }
754 617
755 - protected void changeOccurredOn( String pName, IFormComponent pComponent, boolean pChanged )
756 - {
618 + protected void changeOccurredOn( String pName, IFormComponent pComponent, boolean pChanged ) {
757 619 }
758 620
759 - protected void blurOccurredOn( String pName, IFormComponent pComponent )
760 - {
621 + protected void blurOccurredOn( String pName, IFormComponent pComponent ) {
761 622 }
762 623
763 - protected void focusOccuredOn( String pName, IFormComponent pComponent )
764 - {
624 + protected void focusOccuredOn( String pName, IFormComponent pComponent ) {
765 625 }
766 626
767 - protected void enterPressedOn( String pName, IFormComponent pComponent, KeyboardKeyModifier pModifiers )
768 - {
769 - for ( ButtonBase zButton : mDefaultButtons )
770 - {
771 - if ( zButton.isEnabled() )
772 - {
627 + protected void enterPressedOn( String pName, IFormComponent pComponent, KeyboardKeyModifier pModifiers ) {
628 + for ( ButtonBase zButton : mDefaultButtons ) {
629 + if ( zButton.isEnabled() ) {
773 630 DomEvent.fireNativeEvent( Document.get().createClickEvent( 0, 0, 0, 0, 0, false, false, false, false ), zButton );
774 631 }
775 632 }
776 633 }
777 634
778 - public ErrorChangeState scanForErrorChangeState( Collection<ProxyExtendedListener> pListeners )
779 - {
635 + public ErrorChangeState scanForErrorChangeState( Collection<ProxyExtendedListener> pListeners ) {
780 636 ErrorChangeState zErrorChangeState = ErrorChangeState.NoErrors_NoChanges;
781 - for ( ProxyExtendedListener zListener : pListeners )
782 - {
783 - if ( ErrorChangeState.Errors_Changes == (zErrorChangeState = zErrorChangeState.mergeToTrueFrom( zListener )) )
784 - {
637 + for ( ProxyExtendedListener zListener : pListeners ) {
638 + if ( ErrorChangeState.Errors_Changes == (zErrorChangeState = zErrorChangeState.mergeToTrueFrom( zListener )) ) {
785 639 break;
786 640 }
787 641 }
788 642 return zErrorChangeState;
789 643 }
790 644
791 - private static class WidgetCtrlProxy extends CtrlProxy
792 - {
645 + private static class WidgetCtrlProxy extends CtrlProxy {
793 646 protected Widget mWidget;
794 647
795 - public WidgetCtrlProxy( Widget pWidget, FormWidgetCtrl pFormWidgetCtrl )
796 - {
648 + public WidgetCtrlProxy( Widget pWidget, FormWidgetCtrl pFormWidgetCtrl ) {
797 649 super( pFormWidgetCtrl );
798 650 mWidget = pWidget;
799 651 }
800 652
801 653 @Override
802 - public boolean isHidden()
803 - {
654 + public boolean isHidden() {
804 655 return (mWidget != null) && UtilsGwt.isHidden( mWidget );
805 656 }
806 657
807 658 @Override
808 - public void setHidden( boolean pHide )
809 - {
810 - if ( mWidget != null )
811 - {
659 + public void setHidden( boolean pHide ) {
660 + if ( mWidget != null ) {
812 661 UtilsGwt.setHidden( mWidget, pHide );
813 662 }
814 663 }
815 664
816 665 @Override
817 - public boolean isEnabled()
818 - {
666 + public boolean isEnabled() {
819 667 return false;
820 668 }
821 669
822 670 @Override
823 - public void setEnabled( boolean pEnabled )
824 - {
671 + public void setEnabled( boolean pEnabled ) {
825 672 }
826 673
827 674 @Override
828 - public String toString()
829 - {
675 + public String toString() {
830 676 return "Widget: " + Objects.justClassNameOf( mWidget );
831 677 }
832 678 }
833 679
834 - private static class FocusWidgetCtrlProxy extends CtrlProxy
835 - {
680 + private static class FocusWidgetCtrlProxy extends CtrlProxy {
836 681 private FocusWidget mWidget;
837 682
838 - public FocusWidgetCtrlProxy( FocusWidget pWidget, FormWidgetCtrl pFormWidgetCtrl )
839 - {
683 + public FocusWidgetCtrlProxy( FocusWidget pWidget, FormWidgetCtrl pFormWidgetCtrl ) {
840 684 super( pFormWidgetCtrl );
841 685 mWidget = pWidget;
842 686 }
843 687
844 688 @Override
845 - public boolean isHidden()
846 - {
689 + public boolean isHidden() {
847 690 return (mWidget != null) && UtilsGwt.isHidden( mWidget );
848 691 }
849 692
850 693 @Override
851 - public void setHidden( boolean pHide )
852 - {
853 - if ( mWidget != null )
854 - {
694 + public void setHidden( boolean pHide ) {
695 + if ( mWidget != null ) {
855 696 UtilsGwt.setHidden( mWidget, pHide );
856 697 }
857 698 }
858 699
859 700 @Override
860 - public boolean isEnabled()
861 - {
701 + public boolean isEnabled() {
862 702 return (mWidget != null) && mWidget.isEnabled();
863 703 }
864 704
865 705 @Override
866 - public void setEnabled( boolean pEnabled )
867 - {
868 - if ( mWidget != null )
869 - {
706 + public void setEnabled( boolean pEnabled ) {
707 + if ( mWidget != null ) {
870 708 mWidget.setEnabled( pEnabled );
871 709 }
872 710 }
873 711
874 712 @Override
875 - public String toString()
876 - {
713 + public String toString() {
877 714 return "FocusWidget: " + Objects.justClassNameOf( mWidget );
878 715 }
879 716 }
880 717
881 718 protected class ProxyExtendedListener extends CtrlProxy implements IFormComponent.Listener,
882 - ErrorChangeProvider
883 - {
719 + ErrorChangeProvider {
884 720 private String mName;
885 721 private IFormComponent.Listener mProxied;
886 722 private IFormComponent mComponent;
  @@ -888,105 +724,84 @@
888 724 boolean mLSVvalid = false;
889 725 private boolean mChanged = false;
890 726
891 - public ProxyExtendedListener( String pName, IFormComponent.Listener pProxied, FormWidgetCtrl pFormWidgetCtrl )
892 - {
727 + public ProxyExtendedListener( String pName, IFormComponent.Listener pProxied, FormWidgetCtrl pFormWidgetCtrl ) {
893 728 super( pFormWidgetCtrl );
894 729 mName = pName;
895 730 mProxied = (pProxied != null) ? pProxied : NoOpFormListener.INSTANCE;
896 731 }
897 732
898 - private void clearLSV()
899 - {
733 + private void clearLSV() {
900 734 mLSVvalid = false;
901 735 mLastSetValue = null;
902 736 }
903 737
904 - private void setLSV( Object pLastSetValue )
905 - {
738 + private void setLSV( Object pLastSetValue ) {
906 739 mLSVvalid = true;
907 740 mLastSetValue = pLastSetValue;
908 741 }
909 742
910 - private Object getBaseValue()
911 - {
743 + private Object getBaseValue() {
912 744 return mLSVvalid ? mLastSetValue : mOrigValue;
913 745 }
914 746
915 - public boolean isChanged()
916 - {
747 + public boolean isChanged() {
917 748 return mChanged;
918 749 }
919 750
920 - public boolean isErrored()
921 - {
751 + public boolean isErrored() {
922 752 return (mComponent != null) && mComponent.hasError();
923 753 }
924 754
925 - public Object getCurValue()
926 - {
755 + public Object getCurValue() {
927 756 return mCurValue;
928 757 }
929 758
930 - public Object getOrigValue()
931 - {
759 + public Object getOrigValue() {
932 760 return mOrigValue;
933 761 }
934 762
935 763 @Override
936 - public void add( IFormComponent pComponent )
937 - {
764 + public void add( IFormComponent pComponent ) {
938 765 mProxied.add( mComponent = pComponent );
939 766 mOrigValue = mCurValue = getComponentCurrentValue();
940 767 mChanged = false;
941 768 }
942 769
943 770 @Override
944 - public void remove( IFormComponent pComponent )
945 - {
771 + public void remove( IFormComponent pComponent ) {
946 772 mProxied.remove( pComponent );
947 - if ( pComponent == mComponent )
948 - {
773 + if ( pComponent == mComponent ) {
949 774 mComponent = null;
950 775 }
951 776 }
952 777
953 - public void reset( boolean pToOrig )
954 - {
955 - if ( pToOrig )
956 - {
778 + public void reset( boolean pToOrig ) {
779 + if ( pToOrig ) {
957 780 clearLSV();
958 781 LLreset( mOrigValue );
959 - }
960 - else
961 - {
782 + } else {
962 783 LLreset( getBaseValue() );
963 784 }
964 785 }
965 786
966 - private void LLreset( Object pResetToValue )
967 - {
968 - if ( mComponent != null )
969 - {
787 + private void LLreset( Object pResetToValue ) {
788 + if ( mComponent != null ) {
970 789 mComponent.setCurrentValue( mCurValue = pResetToValue );
971 790 adjustComponentState();
972 791 updateHiders( mName );
973 792 }
974 793 }
975 794
976 - public void makeNonOrigChanged()
977 - {
795 + public void makeNonOrigChanged() {
978 796 clearLSV();
979 - if ( mComponent != null )
980 - {
797 + if ( mComponent != null ) {
981 798 adjustComponentState();
982 799 }
983 800 }
984 801
985 802 @Override
986 - public void changeOccurred()
987 - {
988 - if ( mComponent != null )
989 - {
803 + public void changeOccurred() {
804 + if ( mComponent != null ) {
990 805 mCurValue = getComponentCurrentValue();
991 806 adjustComponentState();
992 807 mProxied.changeOccurred();
  @@ -995,10 +810,8 @@
995 810 }
996 811
997 812 @Override
998 - public void blurOccurred()
999 - {
1000 - if ( mComponent != null )
1001 - {
813 + public void blurOccurred() {
814 + if ( mComponent != null ) {
1002 815 mComponent.setFocused( false );
1003 816 mProxied.blurOccurred();
1004 817 blurOccurredOn( mName, mComponent );
  @@ -1006,10 +819,8 @@
1006 819 }
1007 820
1008 821 @Override
1009 - public void focusOccured()
1010 - {
1011 - if ( mComponent != null )
1012 - {
822 + public void focusOccured() {
823 + if ( mComponent != null ) {
1013 824 mComponent.setFocused( true );
1014 825 mProxied.focusOccured();
1015 826 focusOccuredOn( mName, mComponent );
  @@ -1017,19 +828,15 @@
1017 828 }
1018 829
1019 830 @Override
1020 - public void enterPressed( KeyboardKeyModifier pModifiers )
1021 - {
1022 - if ( mComponent != null )
1023 - {
831 + public void enterPressed( KeyboardKeyModifier pModifiers ) {
832 + if ( mComponent != null ) {
1024 833 mProxied.enterPressed( pModifiers );
1025 834 enterPressedOn( mName, mComponent, pModifiers );
1026 835 }
1027 836 }
1028 837
1029 - public void setCurValue( Object pNewValue )
1030 - {
1031 - if ( mComponent != null )
1032 - {
838 + public void setCurValue( Object pNewValue ) {
839 + if ( mComponent != null ) {
1033 840 mComponent.setCurrentValue( pNewValue );
1034 841 setLSV( mCurValue = getComponentCurrentValue() );
1035 842 adjustComponentState();
  @@ -1037,72 +844,57 @@
1037 844 }
1038 845 }
1039 846
1040 - public void setCurValueAsUser( Object pNewValue )
1041 - {
1042 - if ( mComponent != null )
1043 - {
847 + public void setCurValueAsUser( Object pNewValue ) {
848 + if ( mComponent != null ) {
1044 849 mComponent.setCurrentValue( pNewValue );
1045 850 changeOccurred();
1046 851 }
1047 852 }
1048 853
1049 854 @Override
1050 - public boolean isHidden()
1051 - {
855 + public boolean isHidden() {
1052 856 return (mComponent != null) && UtilsGwt.isHidden( (Widget) mComponent );
1053 857 }
1054 858
1055 859 @Override
1056 - public void setHidden( boolean pHide )
1057 - {
1058 - if ( mComponent != null )
1059 - {
860 + public void setHidden( boolean pHide ) {
861 + if ( mComponent != null ) {
1060 862 UtilsGwt.setHidden( (Widget) mComponent, pHide );
1061 863 }
1062 864 }
1063 865
1064 866 @Override
1065 - public boolean isEnabled()
1066 - {
867 + public boolean isEnabled() {
1067 868 return (mComponent != null) && mComponent.isEnabled();
1068 869 }
1069 870
1070 871 @Override
1071 - public void setEnabled( boolean pEnabled )
1072 - {
1073 - if ( mComponent != null )
1074 - {
872 + public void setEnabled( boolean pEnabled ) {
873 + if ( mComponent != null ) {
1075 874 mComponent.setEnabled( pEnabled );
1076 875 }
1077 876 }
1078 877
1079 - private Object getComponentCurrentValue()
1080 - {
878 + private Object getComponentCurrentValue() {
1081 879 Object zValue = mComponent.getCurrentValue();
1082 - if ( zValue instanceof SimpleKeyValuePair )
1083 - {
880 + if ( zValue instanceof SimpleKeyValuePair ) {
1084 881 zValue = ((SimpleKeyValuePair) zValue).getKey();
1085 882 }
1086 883 return zValue;
1087 884 }
1088 885
1089 - private void adjustComponentState()
1090 - {
886 + private void adjustComponentState() {
1091 887 mComponent.setValueChanged( mChanged = !Objects.areNonArraysEqual( getBaseValue(), mCurValue ) );
1092 888 mComponent.setError( errorIfRequired() );
1093 889 }
1094 890
1095 - private String errorIfRequired()
1096 - {
891 + private String errorIfRequired() {
1097 892 return (mMode.isEditRequired( this ) && isEmpty()) ? "Required Field" : null;
1098 893 }
1099 894
1100 - public boolean isEmpty()
1101 - {
1102 - if ( mCurValue != null )
1103 - {
1104 - if ( !(mCurValue instanceof String) || (mCurValue.toString().trim().length() != 0) )
1105 - {
895 + public boolean isEmpty() {
896 + if ( mCurValue != null ) {
897 + if ( !(mCurValue instanceof String) || (mCurValue.toString().trim().length() != 0) ) {
1106 898 return false;
1107 899 }
1108 900 }
  @@ -1110,43 +902,36 @@
1110 902 }
1111 903
1112 904 @Override
1113 - public String toString()
1114 - {
905 + public String toString() {
1115 906 return "Field: " + mName;
1116 907 }
1117 908 }
1118 909
1119 - private interface Hider
1120 - {
910 + private interface Hider {
1121 911 public void update();
1122 912 }
1123 913
1124 - private static class HiderPair implements Hider
1125 - {
914 + private static class HiderPair implements Hider {
1126 915 private Hider mHider1, mHider2;
1127 916
1128 - private HiderPair( Hider pHider1, Hider pHider2 )
1129 - {
917 + private HiderPair( Hider pHider1, Hider pHider2 ) {
1130 918 mHider1 = pHider1;
1131 919 mHider2 = pHider2;
1132 920 }
1133 921
1134 922 @Override
1135 - public void update()
1136 - {
923 + public void update() {
1137 924 mHider1.update();
1138 925 mHider2.update();
1139 926 }
1140 927 }
1141 928
1142 - private static class HiderBridgeBridge implements Hider
1143 - {
929 + private static class HiderBridgeBridge implements Hider {
1144 930 private Widget mWidget;
1145 931 private HiderBridge mHiderBridge;
1146 932 private IFormComponent mComponent;
1147 933
1148 - private HiderBridgeBridge( Widget pWidget, HiderBridge pHiderBridge, IFormComponent pComponent )
1149 - {
934 + private HiderBridgeBridge( Widget pWidget, HiderBridge pHiderBridge, IFormComponent pComponent ) {
1150 935 mWidget = pWidget;
1151 936 mHiderBridge = pHiderBridge;
1152 937 mComponent = pComponent;
  @@ -1154,8 +939,7 @@
1154 939 }
1155 940
1156 941 @Override
1157 - public void update()
1158 - {
942 + public void update() {
1159 943 Object zCurrentValue = mComponent.getCurrentValue();
1160 944 boolean zHide = mHiderBridge.shouldBeHidden( zCurrentValue );
1161 945 UtilsGwt.setHidden( mWidget, zHide );