Subversion Repository Public Repository

litesoft

Diff Revisions 947 vs 948 for /trunk/Java/KeyHole/src/org/litesoft/aokeyhole/AbstractMain.java

Diff revisions: vs.
  @@ -1,14 +1,6 @@
1 1 // This Source Code is in the Public Domain per: http://unlicense.org
2 2 package org.litesoft.aokeyhole;
3 3
4 - import java.io.*;
5 -
6 - import org.litesoft.commonfoundation.typeutils.*;
7 -
8 - import java.util.*;
9 - import java.util.concurrent.*;
10 - import javax.swing.*;
11 -
12 4 import org.litesoft.aokeyhole.objects.*;
13 5 import org.litesoft.aokeyhole.objects.attributes.*;
14 6 import org.litesoft.aokeyhole.objects.factories.*;
  @@ -16,13 +8,18 @@
16 8 import org.litesoft.aokeyhole.persist.*;
17 9 import org.litesoft.aokeyhole.toolkit.*;
18 10 import org.litesoft.aokeyhole.toolkit.editorviewer.*;
11 + import org.litesoft.commonfoundation.typeutils.*;
12 +
13 + import javax.swing.*;
14 + import java.io.*;
15 + import java.util.*;
16 + import java.util.concurrent.*;
19 17
20 18 public abstract class AbstractMain implements ActionsListener,
21 19 NewAttributeTypeSelectionListener,
22 20 NameValueChangedByUserListener,
23 21 NewObjectTypeSelectionListener,
24 - ChangeCallback
25 - {
22 + ChangeCallback {
26 23 private static final String BASE_VERSION = "1.30";
27 24
28 25 private BlockingQueue<Runnable> mNonUIrunnables = new LinkedBlockingQueue<Runnable>();
  @@ -57,12 +54,10 @@
57 54 private AttributeSet mNewAttributeSet;
58 55
59 56 protected AbstractMain( SubSystemFactory pSubSystemFactory, EditViewPanelFactory pEditViewPanelFactory, boolean pReadOnly, SubSystemPersister... pPersisters )
60 - throws IOException
61 - {
57 + throws IOException {
62 58 mSubSystemFactory = pSubSystemFactory;
63 59 mEditViewPanelFactory = pEditViewPanelFactory;
64 - if ( (mPersisters = pPersisters).length == 0 )
65 - {
60 + if ( (mPersisters = pPersisters).length == 0 ) {
66 61 throw new IllegalArgumentException( "No Data Sources Provided" );
67 62 }
68 63 mEditable = !(pReadOnly || getLastPersister().isReadOnly());
  @@ -73,57 +68,48 @@
73 68 }
74 69
75 70 @SuppressWarnings({"UnusedDeclaration"})
76 - public String getVersion()
77 - {
71 + public String getVersion() {
78 72 return mVersion;
79 73 }
80 74
81 - public SystemMetaData getSystemMetaData()
82 - {
75 + public SystemMetaData getSystemMetaData() {
83 76 return mSystemMetaData;
84 77 }
85 78
86 79 @SuppressWarnings({"UnusedDeclaration"})
87 - public SubSystemMetaData getSubSystemForSaving()
88 - {
80 + public SubSystemMetaData getSubSystemForSaving() {
89 81 return mSubSystemForSaving;
90 82 }
91 83
92 84 public void persistSubSystem( SubSystemWriter pSubSystemWriter )
93 - throws IOException
94 - {
95 - if ( mEditable )
96 - {
85 + throws IOException {
86 + if ( mEditable ) {
97 87 pSubSystemWriter.write();
98 88 }
99 89 }
100 90
101 - private SubSystemPersister getLastPersister()
102 - {
91 + private SubSystemPersister getLastPersister() {
103 92 return mPersisters[mPersisters.length - 1];
104 93 }
105 94
106 95 /**
107 96 * Called during Construction on the "main" Thread
108 97 */
109 - protected ObjectListClickListener createObjectListClickListener()
110 - {
98 + protected ObjectListClickListener createObjectListClickListener() {
111 99 return new OurObjectListClickListener();
112 100 }
113 101
114 102 /**
115 103 * Called during Construction on the "main" Thread
116 104 */
117 - protected BoxedTextClickListener createBoxedTextClickListener()
118 - {
105 + protected BoxedTextClickListener createBoxedTextClickListener() {
119 106 return new OurBoxedTextClickListener();
120 107 }
121 108
122 109 /**
123 110 * Called during Construction on the "main" Thread
124 111 */
125 - protected void setObjectListUpdater( ObjectListUpdater pObjectListUpdater )
126 - {
112 + protected void setObjectListUpdater( ObjectListUpdater pObjectListUpdater ) {
127 113 mObjectListUpdater = pObjectListUpdater;
128 114 }
129 115
  @@ -131,21 +117,18 @@
131 117 * Should be called on the "main" Thread!
132 118 */
133 119 private void unpersistAllObjects()
134 - throws IOException
135 - {
120 + throws IOException {
136 121 SystemMetaData zSMD = new SystemMetaData( mEditable, BASE_VERSION, mSubSystemFactory );
137 122
138 123 SubSystemMetaData lastSS = null;
139 - for ( int i = 0; i < mPersisters.length; i++ )
140 - {
124 + for ( int i = 0; i < mPersisters.length; i++ ) {
141 125 SubSystemPersister zPersister = mPersisters[i];
142 126 lastSS = zSMD.unpersistSubSystemMetaData( i, zPersister ).loadObjects();
143 127 }
144 128 zSMD.setRehydrated();
145 129
146 130 mSystemMetaData = zSMD;
147 - if ( mEditable )
148 - {
131 + if ( mEditable ) {
149 132 mSubSystemForSaving = lastSS;
150 133 }
151 134 }
  @@ -153,8 +136,7 @@
153 136 /**
154 137 * Running on the "main" Thread
155 138 */
156 - public void start()
157 - {
139 + public void start() {
158 140 mEditViewPanelController = mEditViewPanelFactory
159 141 .createEditViewPanelController( mEditable, getLastPersister().getName(), mSystemMetaData.getObjectSets(), mSystemMetaData.getAttributeSets(),
160 142 this, this, this, this );
  @@ -173,16 +155,12 @@
173 155 /**
174 156 * Running on the "main" Thread
175 157 */
176 - public synchronized void runMainThreadLoop()
177 - {
178 - for ( Runnable zRunnable; null != (zRunnable = waitForMainThreadRunnable()); )
179 - {
180 - try
181 - {
158 + public synchronized void runMainThreadLoop() {
159 + for ( Runnable zRunnable; null != (zRunnable = waitForMainThreadRunnable()); ) {
160 + try {
182 161 zRunnable.run();
183 162 }
184 - catch ( RuntimeException e )
185 - {
163 + catch ( RuntimeException e ) {
186 164 e.printStackTrace();
187 165 updateStatus( e.getMessage() );
188 166 }
  @@ -192,48 +170,37 @@
192 170 /**
193 171 * Running on the "main" Thread
194 172 */
195 - private Runnable waitForMainThreadRunnable()
196 - {
197 - while ( true )
198 - {
199 - try
200 - {
173 + private Runnable waitForMainThreadRunnable() {
174 + while ( true ) {
175 + try {
201 176 Runnable zRunnable = mNonUIrunnables.take();
202 - if ( zRunnable != null )
203 - {
177 + if ( zRunnable != null ) {
204 178 return zRunnable;
205 179 }
206 180 }
207 - catch ( InterruptedException e )
208 - {
181 + catch ( InterruptedException e ) {
209 182 return null;
210 183 }
211 184 }
212 185 }
213 186
214 187 // Called by Either ("main" or "UI" Event) Thread...
215 - private void postMainThreadRunnable( String pWhat, Runnable pRunnable )
216 - {
217 - try
218 - {
188 + private void postMainThreadRunnable( String pWhat, Runnable pRunnable ) {
189 + try {
219 190 mNonUIrunnables.put( pRunnable );
220 191 }
221 - catch ( InterruptedException e )
222 - {
192 + catch ( InterruptedException e ) {
223 193 e.printStackTrace();
224 194 updateStatus( "Time out / Interruption attempting to " + pWhat );
225 195 }
226 196 }
227 197
228 198 // Called by Either ("main" or "UI" Event) Thread...
229 - private void postUiThreadRunnable( String pWhat, Runnable pRunnable )
230 - {
231 - try
232 - {
199 + private void postUiThreadRunnable( String pWhat, Runnable pRunnable ) {
200 + try {
233 201 SwingUtilities.invokeLater( pRunnable );
234 202 }
235 - catch ( RuntimeException e )
236 - {
203 + catch ( RuntimeException e ) {
237 204 e.printStackTrace();
238 205 updateStatus( "Exception attempting to " + pWhat + " of: " + e.getMessage() );
239 206 }
  @@ -242,33 +209,24 @@
242 209 /**
243 210 * Called on the "UI" Event Thread
244 211 */
245 - protected void save( final SubSystemWriter pSubSystemWriter )
246 - {
247 - postMainThreadRunnable( "Save Changes", new Runnable()
248 - {
212 + protected void save( final SubSystemWriter pSubSystemWriter ) {
213 + postMainThreadRunnable( "Save Changes", new Runnable() {
249 214 // Called on the "main" Thread
250 215 @Override
251 - public void run()
252 - {
253 - if ( !mEditable )
254 - {
216 + public void run() {
217 + if ( !mEditable ) {
255 218 updateStatus( "No Persistable" );
256 - }
257 - else
258 - {
259 - try
260 - {
219 + } else {
220 + try {
261 221 persistSubSystem( pSubSystemWriter );
262 222 getSystemMetaData().clearChangeIndicators();
263 223 updateStatus( "Save Complete" );
264 224 }
265 - catch ( IOException e )
266 - {
225 + catch ( IOException e ) {
267 226 e.printStackTrace();
268 227 updateStatus( e.getMessage() );
269 228 }
270 - catch ( RuntimeException e )
271 - {
229 + catch ( RuntimeException e ) {
272 230 e.printStackTrace();
273 231 updateStatus( e.getMessage() );
274 232 }
  @@ -277,34 +235,25 @@
277 235 } );
278 236 }
279 237
280 - private class CurrentDisplayState
281 - {
238 + private class CurrentDisplayState {
282 239 private ObjectMetaData mCurrentSelectedObject = null;
283 240 private AttributeMetaData mCurrentSelectedAttribute = null;
284 241
285 - private CurrentDisplayState()
286 - {
287 - if ( !mNewObject )
288 - {
242 + private CurrentDisplayState() {
243 + if ( !mNewObject ) {
289 244 mCurrentSelectedObject = mSelectedObject;
290 - if ( !mNewAttribute )
291 - {
245 + if ( !mNewAttribute ) {
292 246 mCurrentSelectedAttribute = mSelectedAttribute;
293 247 }
294 248 }
295 249 }
296 250
297 - public void restore()
298 - {
299 - if ( mCurrentSelectedObject != null )
300 - {
301 - if ( null != (mSelectedObject = mSystemMetaData.getObject( mCurrentSelectedObject.getName() )) )
302 - {
251 + public void restore() {
252 + if ( mCurrentSelectedObject != null ) {
253 + if ( null != (mSelectedObject = mSystemMetaData.getObject( mCurrentSelectedObject.getName() )) ) {
303 254 selectObjectExisting();
304 - if ( mCurrentSelectedAttribute != null )
305 - {
306 - if ( null != (mSelectedAttribute = mSelectedObject.getAttribute( mCurrentSelectedAttribute.getName() )) )
307 - {
255 + if ( mCurrentSelectedAttribute != null ) {
256 + if ( null != (mSelectedAttribute = mSelectedObject.getAttribute( mCurrentSelectedAttribute.getName() )) ) {
308 257 selectAttribExisting();
309 258 }
310 259 }
  @@ -316,18 +265,15 @@
316 265 /**
317 266 * Called on the "UI" Event Thread
318 267 */
319 - protected void refresh()
320 - {
268 + protected void refresh() {
321 269 final CurrentDisplayState mCurrentState = new CurrentDisplayState();
322 270 clearSelections(); // Show Nothing...
323 271 updateStatus( "Refreshing..." );
324 272
325 - postMainThreadRunnable( "Refresh", new Runnable()
326 - {
273 + postMainThreadRunnable( "Refresh", new Runnable() {
327 274 // Called on the "main" Thread
328 275 @Override
329 - public void run()
330 - {
276 + public void run() {
331 277 refreshStep2( mCurrentState );
332 278 }
333 279 } );
  @@ -336,33 +282,26 @@
336 282 /**
337 283 * Called on the "main" Thread
338 284 */
339 - protected void refreshStep2( final CurrentDisplayState pCurrentState )
340 - {
341 - try
342 - {
285 + protected void refreshStep2( final CurrentDisplayState pCurrentState ) {
286 + try {
343 287 List<ChangeCallback> zCallbacks = mSystemMetaData.getChangeCallbacks();
344 288 unpersistAllObjects();
345 - for ( ChangeCallback zCallback : zCallbacks )
346 - {
289 + for ( ChangeCallback zCallback : zCallbacks ) {
347 290 mSystemMetaData.add( zCallback );
348 291 }
349 - postUiThreadRunnable( "Refresh", new Runnable()
350 - {
292 + postUiThreadRunnable( "Refresh", new Runnable() {
351 293 // Called on the "UI" Event Thread
352 294 @Override
353 - public void run()
354 - {
295 + public void run() {
355 296 refreshStep3( pCurrentState );
356 297 }
357 298 } );
358 299 }
359 - catch ( IOException e )
360 - {
300 + catch ( IOException e ) {
361 301 e.printStackTrace();
362 302 updateStatus( e.getMessage() );
363 303 }
364 - catch ( RuntimeException e )
365 - {
304 + catch ( RuntimeException e ) {
366 305 e.printStackTrace();
367 306 updateStatus( e.getMessage() );
368 307 }
  @@ -371,8 +310,7 @@
371 310 /**
372 311 * Called on the "UI" Event Thread
373 312 */
374 - protected void refreshStep3( CurrentDisplayState pCurrentState )
375 - {
313 + protected void refreshStep3( CurrentDisplayState pCurrentState ) {
376 314 mObjectListUpdater.updateObjectList( mSystemMetaData.getSortedObjectMetaDatas() );
377 315 pCurrentState.restore();
378 316 clearStatus();
  @@ -416,16 +354,13 @@
416 354 * Called on the UI Event Thread
417 355 */
418 356 @Override
419 - public void namedValueChangedByUser( String pName )
420 - {
421 - if ( mCurrentEditViewPanel != null )
422 - {
357 + public void namedValueChangedByUser( String pName ) {
358 + if ( mCurrentEditViewPanel != null ) {
423 359 mCurrentEditViewPanel.actionEnable( ACTION_SAVE, true );
424 360 mCurrentEditViewPanel.actionEnable( ACTION_REVERT, true );
425 361 mCurrentEditViewPanel.actionEnable( ACTION_DELETE, false );
426 362
427 - if ( AttribNamesRelated.RELATED_TO.equals( pName ) )
428 - {
363 + if ( AttribNamesRelated.RELATED_TO.equals( pName ) ) {
429 364 boolean zToManys = !currentAttributeIsToMany();
430 365 ObjectMetaData object = mSystemMetaData.getObject( mCurrentEditViewPanel.getValue( pName ) );
431 366 String[] options = (object == null) ? new String[0] : object.getSortedRelatedPersistedAttributeNamesTo( zToManys, mSelectedObject );
  @@ -435,8 +370,7 @@
435 370 // System.out.println( "Hook for special behavior on namedValueChangedByUser: " + pName );
436 371 }
437 372
438 - private boolean currentAttributeIsToMany()
439 - {
373 + private boolean currentAttributeIsToMany() {
440 374 AttributeSet zSet = mNewAttribute ? mNewAttributeSet : mSelectedAttribute.getAttributeSet();
441 375 return A_ToMany.TYPE.equals( zSet.getType() );
442 376 }
  @@ -444,8 +378,7 @@
444 378 /**
445 379 * Called on the UI Event Thread
446 380 */
447 - private void clearSelections()
448 - {
381 + private void clearSelections() {
449 382 mSelectedObject = null;
450 383 mSelectedAttribute = null;
451 384 mCurrentEditViewPanel = null;
  @@ -458,15 +391,12 @@
458 391 /**
459 392 * Called on the UI Event Thread
460 393 */
461 - private void clearStatus()
462 - {
463 - if ( mSelectedObject != null )
464 - {
394 + private void clearStatus() {
395 + if ( mSelectedObject != null ) {
465 396 updateStatus( mSelectedObject.getOwner().getName() );
466 397 return;
467 398 }
468 - if ( mNewObject )
469 - {
399 + if ( mNewObject ) {
470 400 updateStatus( mSubSystemForSaving.getName() );
471 401 return;
472 402 }
  @@ -476,8 +406,7 @@
476 406 /**
477 407 * Called on the UI Event Thread
478 408 */
479 - private void selectObjectNew()
480 - {
409 + private void selectObjectNew() {
481 410 setObjectAndAttributesWithOneDegreeSeperationView( null );
482 411 mObjectListUpdater.clearSelectedObject();
483 412 clearSelections();
  @@ -489,8 +418,7 @@
489 418 /**
490 419 * Called on the UI Event Thread
491 420 */
492 - private void selectObjectExisting()
493 - {
421 + private void selectObjectExisting() {
494 422 mSelectedAttribute = null;
495 423 mCurrentEditViewPanel = mEditViewPanelController.showObjectExisting( mSelectedObject );
496 424 setUpViewSupportable( mSelectedObject );
  @@ -499,11 +427,9 @@
499 427 /**
500 428 * Called on the UI Event Thread
501 429 */
502 - private void selectObjectFromList( String pName )
503 - {
430 + private void selectObjectFromList( String pName ) {
504 431 clearSelections();
505 - if ( showObjectGraph( pName ) )
506 - {
432 + if ( showObjectGraph( pName ) ) {
507 433 selectObjectExisting();
508 434 }
509 435 }
  @@ -511,16 +437,13 @@
511 437 /**
512 438 * Called on the UI Event Thread
513 439 */
514 - private void selectObjectRelated( String pName )
515 - {
516 - if ( ObjectNames.VARIES_RELATED_TO.equals( pName ) )
517 - {
440 + private void selectObjectRelated( String pName ) {
441 + if ( ObjectNames.VARIES_RELATED_TO.equals( pName ) ) {
518 442 updateStatus( "Can NOT navigate to a 'variable' relationship" );
519 443 return;
520 444 }
521 445 clearSelections();
522 - if ( showObjectGraph( pName ) )
523 - {
446 + if ( showObjectGraph( pName ) ) {
524 447 mObjectListUpdater.setSelectedObject( mSystemMetaData.getObject( pName ) );
525 448 selectObjectExisting();
526 449 }
  @@ -529,31 +452,25 @@
529 452 /**
530 453 * Called on the UI Event Thread
531 454 */
532 - private void selectObjectMain()
533 - {
455 + private void selectObjectMain() {
534 456 selectObjectExisting();
535 457 }
536 458
537 459 /**
538 460 * Called on the UI Event Thread
539 461 */
540 - private void selectAttribExisting( String pName )
541 - {
542 - if ( pName != null )
543 - {
462 + private void selectAttribExisting( String pName ) {
463 + if ( pName != null ) {
544 464 pName = pName.trim();
545 - if ( pName.startsWith( "*" ) )
546 - {
465 + if ( pName.startsWith( "*" ) ) {
547 466 pName = pName.substring( 1 ).trim();
548 467 }
549 - if ( pName.endsWith( "*" ) )
550 - {
468 + if ( pName.endsWith( "*" ) ) {
551 469 pName = pName.substring( 0, pName.length() - 1 ).trim();
552 470 }
553 471 }
554 472 mSelectedAttribute = mSelectedObject.getAttribute( pName );
555 - if ( mSelectedAttribute == null )
556 - {
473 + if ( mSelectedAttribute == null ) {
557 474 mCurrentEditViewPanel = null;
558 475 mEditViewPanelController.showBlank();
559 476 System.err.println( "selectAttribExisting ?: " + pName );
  @@ -565,23 +482,18 @@
565 482 /**
566 483 * Called on the UI Event Thread
567 484 */
568 - private void selectAttribExisting()
569 - {
485 + private void selectAttribExisting() {
570 486 mNewAttribute = false;
571 487 mCurrentEditViewPanel = mEditViewPanelController.showAttribExisting( mSelectedAttribute );
572 488 NameValuesComponent zValuesComponent = setUpViewSupportable( mSelectedAttribute );
573 - if ( mSelectedAttribute instanceof AttributeMetaDataRelatedPersisted && mSelectedAttribute.isEditable() )
574 - {
489 + if ( mSelectedAttribute instanceof AttributeMetaDataRelatedPersisted && mSelectedAttribute.isEditable() ) {
575 490 AttributeMetaDataRelatedPersisted zMDR = (AttributeMetaDataRelatedPersisted) mSelectedAttribute;
576 491 String zRelatedTo = zMDR.getRelatedTo();
577 492 String zBackAttrib = zMDR.getBackAttrib();
578 - if ( Strings.isNotNullOrEmpty( zRelatedTo ) && Strings.isNotNullOrEmpty( zBackAttrib ) )
579 - {
493 + if ( Strings.isNotNullOrEmpty( zRelatedTo ) && Strings.isNotNullOrEmpty( zBackAttrib ) ) {
580 494 ObjectMetaData zObjectMetaData = mSystemMetaData.getObject( zRelatedTo );
581 - if ( zObjectMetaData != null )
582 - {
583 - if ( zObjectMetaData.getAttribute( zBackAttrib ) == null )
584 - {
495 + if ( zObjectMetaData != null ) {
496 + if ( zObjectMetaData.getAttribute( zBackAttrib ) == null ) {
585 497 zMDR.unpersistBackAttrib( null );
586 498 zValuesComponent.setValue( AttribNamesRelatedPersisted.BACK_REF, "!" + zBackAttrib );
587 499 mCurrentEditViewPanel.actionEnable( ACTION_SAVE, true );
  @@ -595,8 +507,7 @@
595 507 /**
596 508 * Called on the UI Event Thread
597 509 */
598 - private void selectAttribNew()
599 - {
510 + private void selectAttribNew() {
600 511 mSelectedAttribute = null;
601 512 mCurrentEditViewPanel = null;
602 513 mNewAttribute = true;
  @@ -605,8 +516,7 @@
605 516 }
606 517
607 518 @Override
608 - public void newObjectTypeSelected( ObjectSet pObjectSet )
609 - {
519 + public void newObjectTypeSelected( ObjectSet pObjectSet ) {
610 520 mCurrentEditViewPanel = mEditViewPanelController.showObjectNew( mSubSystemForSaving, mNewObjectSet = pObjectSet );
611 521 mCurrentEditViewPanel.initializeView();
612 522 mCurrentEditViewPanel.actionEnable( ACTION_SAVE, false );
  @@ -614,8 +524,7 @@
614 524 }
615 525
616 526 @Override
617 - public void newAttributeTypeSelected( boolean pVirtual, AttributeSet pAttributeSet )
618 - {
527 + public void newAttributeTypeSelected( boolean pVirtual, AttributeSet pAttributeSet ) {
619 528 mSelectedAttribute = null;
620 529 mCurrentEditViewPanel = mEditViewPanelController.showAttributeNew( mSelectedObject, mNewAttributeVirtual = pVirtual, mNewAttributeSet = pAttributeSet );
621 530 mCurrentEditViewPanel.initializeView();
  @@ -623,14 +532,11 @@
623 532 }
624 533
625 534 @Override
626 - public void changeStateUpdated( Changeable pChangeable )
627 - {
628 - if ( mSelectedObject != null )
629 - {
535 + public void changeStateUpdated( Changeable pChangeable ) {
536 + if ( mSelectedObject != null ) {
630 537 showObjectGraph( mSelectedObject.getName() );
631 538 }
632 - if ( mSystemMetaData.objectListHasChanged() )
633 - {
539 + if ( mSystemMetaData.objectListHasChanged() ) {
634 540 mObjectListUpdater.updateObjectList( mSystemMetaData.getSortedObjectMetaDatas() );
635 541 }
636 542 }
  @@ -638,20 +544,16 @@
638 544 /**
639 545 * Called on the "UI" Event Thread
640 546 */
641 - private boolean showObjectGraph( String pObjectName )
642 - {
643 - if ( mSelectedObject != null )
644 - {
547 + private boolean showObjectGraph( String pObjectName ) {
548 + if ( mSelectedObject != null ) {
645 549 mSelectedObject.remove( this );
646 550 mSelectedObject = null;
647 551 }
648 552 setObjectAndAttributesWithOneDegreeSeperationView( null ); // turn off display
649 - if ( pObjectName != null )
650 - {
553 + if ( pObjectName != null ) {
651 554 mSelectedObject = mSystemMetaData.getObject( pObjectName );
652 555 }
653 - if ( mSelectedObject == null )
654 - {
556 + if ( mSelectedObject == null ) {
655 557 return false;
656 558 }
657 559 mSelectedObject.add( this );
  @@ -661,29 +563,21 @@
661 563 oneDegreeSepView.setParentName( mSelectedObject.getParentName() );
662 564 oneDegreeSepView.setGeneratedRelationsByParentNames( mSelectedObject.getSortedChildNames() );
663 565 List<AttributeMetaData> attributes = mSelectedObject.getSortedAttributes();
664 - for ( AttributeMetaData attribute : attributes )
665 - {
566 + for ( AttributeMetaData attribute : attributes ) {
666 567 String zChanged = attribute.isChanged() ? " * " : " ";
667 568 String zName = zChanged + attribute.getName() + zChanged;
668 - if ( attribute instanceof AttributeMetaDataSimple )
669 - {
569 + if ( attribute instanceof AttributeMetaDataSimple ) {
670 570 oneDegreeSepView.addSimpleAttribute( zName, attribute.isVirtual() );
671 - }
672 - else
673 - {
571 + } else {
674 572 AttributeMetaDataRelated rmd = (AttributeMetaDataRelated) attribute;
675 - if ( rmd.getRelatedTo() == null )
676 - {
573 + if ( rmd.getRelatedTo() == null ) {
677 574 oneDegreeSepView.addRelatedAttributeToSelf( zName, attribute.isVirtual() );
678 - }
679 - else
680 - {
575 + } else {
681 576 oneDegreeSepView.addRelatedAttribute( zName, attribute.isVirtual(), rmd.getRelatedTo() );
682 577 }
683 578 }
684 579 }
685 - if ( mSelectedObject.isEditable() )
686 - {
580 + if ( mSelectedObject.isEditable() ) {
687 581 oneDegreeSepView.addNewAttributeOption();
688 582 }
689 583 setObjectAndAttributesWithOneDegreeSeperationView( oneDegreeSepView );
  @@ -693,8 +587,7 @@
693 587 /**
694 588 * Called on the UI Event Thread
695 589 */
696 - private NameValuesComponent setUpViewSupportable( ViewSupportable pViewSupportable )
697 - {
590 + private NameValuesComponent setUpViewSupportable( ViewSupportable pViewSupportable ) {
698 591 clearStatus();
699 592 NameValuesComponent zValuesComponent = mCurrentEditViewPanel.setUpView( pViewSupportable );
700 593 buttonsToInitialState();
  @@ -704,8 +597,7 @@
704 597 /**
705 598 * Called on the UI Event Thread
706 599 */
707 - private void buttonsToInitialState()
708 - {
600 + private void buttonsToInitialState() {
709 601 mCurrentEditViewPanel.actionEnable( ACTION_SAVE, false );
710 602 mCurrentEditViewPanel.actionEnable( ACTION_REVERT, false );
711 603 mCurrentEditViewPanel.actionEnable( ACTION_DELETE, true );
  @@ -715,91 +607,60 @@
715 607 * Called on the UI Event Thread
716 608 */
717 609 @Override
718 - public void actionRequested( String pAction )
719 - {
610 + public void actionRequested( String pAction ) {
720 611 // System.out.println( "actionRequested: " + pAction );
721 - if ( ACTION_CANCEL.equals( pAction ) )
722 - {
723 - if ( mSelectedObject != null )
724 - {
612 + if ( ACTION_CANCEL.equals( pAction ) ) {
613 + if ( mSelectedObject != null ) {
725 614 selectObjectExisting();
726 - }
727 - else
728 - {
615 + } else {
729 616 clearSelections();
730 617 }
731 618 return;
732 619 }
733 - if ( ACTION_REVERT.equals( pAction ) )
734 - {
735 - if ( mSelectedAttribute != null )
736 - {
620 + if ( ACTION_REVERT.equals( pAction ) ) {
621 + if ( mSelectedAttribute != null ) {
737 622 selectAttribExisting();
738 - }
739 - else if ( mSelectedObject != null )
740 - {
623 + } else if ( mSelectedObject != null ) {
741 624 selectObjectExisting();
742 - }
743 - else
744 - {
625 + } else {
745 626 clearSelections();
746 627 }
747 628 return;
748 629 }
749 - if ( ACTION_DELETE.equals( pAction ) )
750 - {
751 - if ( mSelectedAttribute != null )
752 - {
753 - if ( null == updateStatus( mSelectedAttribute.deleteExisting() ) )
754 - {
630 + if ( ACTION_DELETE.equals( pAction ) ) {
631 + if ( mSelectedAttribute != null ) {
632 + if ( null == updateStatus( mSelectedAttribute.deleteExisting() ) ) {
755 633 selectObjectExisting();
756 634 }
757 - }
758 - else if ( mSelectedObject != null )
759 - {
760 - if ( null == updateStatus( mSelectedObject.deleteExisting() ) )
761 - {
635 + } else if ( mSelectedObject != null ) {
636 + if ( null == updateStatus( mSelectedObject.deleteExisting() ) ) {
762 637 clearSelections();
763 638 }
764 639 }
765 640 return;
766 641 }
767 - if ( ACTION_SAVE.equals( pAction ) )
768 - {
769 - if ( mSelectedAttribute != null )
770 - {
771 - if ( null == updateStatus( mCurrentEditViewPanel.update( mSelectedAttribute ) ) )
772 - {
642 + if ( ACTION_SAVE.equals( pAction ) ) {
643 + if ( mSelectedAttribute != null ) {
644 + if ( null == updateStatus( mCurrentEditViewPanel.update( mSelectedAttribute ) ) ) {
773 645 selectAttribExisting();
774 646 }
775 - }
776 - else if ( mNewAttribute )
777 - {
778 - if ( null == updateStatus( verifyNameEntered() ) )
779 - {
647 + } else if ( mNewAttribute ) {
648 + if ( null == updateStatus( verifyNameEntered() ) ) {
780 649 AttributeMetaData newAttribute = mSelectedObject.createAttributeMetaData( mNewAttributeSet.getType(), mNewAttributeVirtual );
781 - if ( null == updateStatus( mCurrentEditViewPanel.update( newAttribute ) ) )
782 - {
650 + if ( null == updateStatus( mCurrentEditViewPanel.update( newAttribute ) ) ) {
783 651 newAttribute.setNewSaved();
784 652 selectAttribExisting( newAttribute.getName() );
785 653 }
786 654 }
787 - }
788 - else if ( mSelectedObject != null )
789 - {
655 + } else if ( mSelectedObject != null ) {
790 656 ObjectMetaData zObjectMetaData = mSelectedObject;
791 - if ( null == updateStatus( mCurrentEditViewPanel.update( mSelectedObject ) ) )
792 - {
657 + if ( null == updateStatus( mCurrentEditViewPanel.update( mSelectedObject ) ) ) {
793 658 selectObjectRelated( zObjectMetaData.getName() ); // Will force the Object To Be Selected
794 659 }
795 - }
796 - else if ( mNewObject )
797 - {
798 - if ( null == updateStatus( verifyNameEntered() ) )
799 - {
660 + } else if ( mNewObject ) {
661 + if ( null == updateStatus( verifyNameEntered() ) ) {
800 662 ObjectMetaData newObject = mSubSystemForSaving.createObjectMetaData( mNewObjectSet );
801 - if ( null == updateStatus( mCurrentEditViewPanel.update( newObject ) ) )
802 - {
663 + if ( null == updateStatus( mCurrentEditViewPanel.update( newObject ) ) ) {
803 664 newObject.setNewSaved();
804 665 selectObjectRelated( newObject.getName() ); // Will force the Object To Be Selected
805 666 }
  @@ -810,13 +671,10 @@
810 671 System.out.println( "What the ????: '" + pAction + "' actionRequested" );
811 672 }
812 673
813 - private String verifyNameEntered()
814 - {
674 + private String verifyNameEntered() {
815 675 String zName = mCurrentEditViewPanel.getValue( AttribNames.NAME );
816 - if ( zName != null )
817 - {
818 - if ( zName.trim().length() != 0 )
819 - {
676 + if ( zName != null ) {
677 + if ( zName.trim().length() != 0 ) {
820 678 return null;
821 679 }
822 680 }
  @@ -826,13 +684,10 @@
826 684 /**
827 685 * Called on the UI Event Thread
828 686 */
829 - private class OurBoxedTextClickListener implements BoxedTextClickListener
830 - {
687 + private class OurBoxedTextClickListener implements BoxedTextClickListener {
831 688 @Override
832 - public void clickedOn( BoxedText pBoxedText )
833 - {
834 - switch ( pBoxedText.getType() )
835 - {
689 + public void clickedOn( BoxedText pBoxedText ) {
690 + switch ( pBoxedText.getType() ) {
836 691 case ObjectAndAttributesWithOneDegreeSeperationView.TYPE_OBJECT_RELATED:
837 692 selectObjectRelated( pBoxedText.getName() );
838 693 break;
  @@ -855,42 +710,35 @@
855 710 /**
856 711 * Called on the UI Event Thread
857 712 */
858 - private class OurObjectListClickListener implements ObjectListClickListener
859 - {
713 + private class OurObjectListClickListener implements ObjectListClickListener {
860 714 @Override
861 - public boolean requestSaveAllowed()
862 - {
715 + public boolean requestSaveAllowed() {
863 716 return mEditable;
864 717 }
865 718
866 719 @Override
867 - public void requestSave()
868 - {
720 + public void requestSave() {
869 721 updateStatus( "Saving..." );
870 722 save( mSubSystemForSaving.toSubSystemWriter() );
871 723 }
872 724
873 725 @Override
874 - public boolean createNewAllowed()
875 - {
726 + public boolean createNewAllowed() {
876 727 return mEditable;
877 728 }
878 729
879 730 @Override
880 - public void createNewRequested()
881 - {
731 + public void createNewRequested() {
882 732 selectObjectNew();
883 733 }
884 734
885 735 @Override
886 - public void refreshRequested()
887 - {
736 + public void refreshRequested() {
888 737 refresh();
889 738 }
890 739
891 740 @Override
892 - public void selected( ObjectMetaData pObjectMetaData )
893 - {
741 + public void selected( ObjectMetaData pObjectMetaData ) {
894 742 selectObjectFromList( (pObjectMetaData != null) ? pObjectMetaData.getName() : null );
895 743 }
896 744 }