d
Class g.ObjectStateDisplay

java.lang.Object
  extended by d.g.ObjectStateDisplay
All Implemented Interfaces:
Runnable
Enclosing class:
g

private static final class g.ObjectStateDisplay
extends Object
implements Runnable

...

Like typical Java GUI code, this class is not multithread safe: it expects to only be called by EventQueue's dispatch thread. This threading limitation is checked in every public method. +++ actually, the above statement is false: --the constructor, which can be called by any thread, seems to rely on the fact that its params get turned into final fields for their thread safety --then this class relies on synchronozed for the run/waitOnUser interaction to safely work Need to rethink this totally...


Field Summary
private  JButton closeButton
           
private  JButton continueButton
           
private  JFrame frame
           
private  long instanceId
          Records this instance's Id.
private static AtomicLong instanceIdNext
          The next ObjectStateDisplay instance's instanceId field.
private  String label
           
private static int latestX
          Every time any ObjectStateDisplay instance is moved, this field stores its latest x position.
private static int latestY
          Every time any ObjectStateDisplay instance is moved, this field stores its latest y position.
private  ObjectState objectState
           
private  boolean pauseExecution
           
private static long serialVersionUID
           
private  boolean shouldWait
           
private static int tabSize
          Specifies how many spaces a tab char will expand to when display Strings.
private  Object waitObject
          Condition predicate for this instance's condition queue (i.e. the wait/notifyAll calls below; see "Java Concurrency in Practice" by Goetz et al p. 296ff, especially p. 299).
 
Constructor Summary
private g.ObjectStateDisplay(String label, Object obj, boolean pauseExecution)
           
 
Method Summary
private  JComponent buildButtons()
           
private  JComponent buildFieldsDisplay()
           
private  JComponent buildGui()
           
private  void handleWindowClose()
          This method calls onContinueExecution(), and then calls dispose().
private  String makeTitle()
           
private  void onContinueExecution()
          This method always disables continueButton and sets its label to indicate that execution has proceeded.
 void run()
          ...
private  void waitOnUser()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

tabSize

private static final int tabSize
Specifies how many spaces a tab char will expand to when display Strings.

See Also:
Constant Field Values

instanceIdNext

private static final AtomicLong instanceIdNext
The next ObjectStateDisplay instance's instanceId field.

Contract: is initialized to 0, and if this field has that value, it means that no instances have been created.


latestX

private static int latestX
Every time any ObjectStateDisplay instance is moved, this field stores its latest x position.


latestY

private static int latestY
Every time any ObjectStateDisplay instance is moved, this field stores its latest y position.


instanceId

private final long instanceId
Records this instance's Id.


label

private final String label

objectState

private final ObjectState objectState

pauseExecution

private final boolean pauseExecution

shouldWait

private boolean shouldWait

waitObject

private final Object waitObject
Condition predicate for this instance's condition queue (i.e. the wait/notifyAll calls below; see "Java Concurrency in Practice" by Goetz et al p. 296ff, especially p. 299).


frame

private JFrame frame

continueButton

private JButton continueButton

closeButton

private JButton closeButton
Constructor Detail

g.ObjectStateDisplay

private g.ObjectStateDisplay(String label,
                             Object obj,
                             boolean pauseExecution)
                      throws IllegalStateException
Throws:
IllegalStateException
Method Detail

run

public void run()
         throws IllegalStateException
...

Specified by:
run in interface Runnable
Throws:
IllegalStateException - if calling thread is not EventQueue's dispatch thread

makeTitle

private String makeTitle()

buildGui

private JComponent buildGui()

buildFieldsDisplay

private JComponent buildFieldsDisplay()

buildButtons

private JComponent buildButtons()

handleWindowClose

private void handleWindowClose()
This method calls onContinueExecution(), and then calls dispose().


onContinueExecution

private void onContinueExecution()
This method always disables continueButton and sets its label to indicate that execution has proceeded. Then it makes the close button be the default button. Finally, if waitObject is not null, it calls waitObject.notifyAll() and then dereferences waitObject (assigns it to null) so that the notification code never executes twice. This method is multithread safe.


waitOnUser

private void waitOnUser()
                 throws IllegalStateException,
                        InterruptedException
Throws:
IllegalStateException
InterruptedException