com.sun.electric.tool
Class SwingExamineTask

java.lang.Object
  extended by com.sun.electric.tool.SwingExamineTask
All Implemented Interfaces:
java.lang.Runnable

public abstract class SwingExamineTask
extends java.lang.Object
implements java.lang.Runnable

Allows the GUI thread to attempt to examine the database immediately. If that fails, then the GUI can pass this object to the Job queue via Job.invokeExamineLater() to have it run at a later time in the GUI thread. A standard usage is as follows:


 SwingExamineTask task = new SwingExamineTask() {
     protected boolean doIt() {
         // do something that requires database examine and GUI modification
     }
 }
 // try to run the task immediately, if not possible, run at a later time
 if (!task.runImmediately()) {
     Job.invokeExamineLater(task, null);
 }
 

Note: it is not necessary to acquire an examine lock in doIt(), as the SwingExamineTask ensures that an examine lock already held in all cases.


Constructor Summary
SwingExamineTask()
           
 
Method Summary
protected abstract  boolean doIt(boolean immediate)
          This should contain the code that needs to examine the database while in the GUI thread
 void run()
          This should only be called by the Job class.
 boolean runImmediately()
          This tries to execute doIt() immediately by trying to acquire an examine lock for the database.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SwingExamineTask

public SwingExamineTask()
Method Detail

run

public final void run()
This should only be called by the Job class. It asserts that the Job class has created an active examine Job which guarantees that this will be able to get an examine lock from the GUI thread.

Specified by:
run in interface java.lang.Runnable

runImmediately

public final boolean runImmediately()
This tries to execute doIt() immediately by trying to acquire an examine lock for the database. Returns false if could not get lock.

Returns:
true if lock acquired and doIt() run, false if lock not acquired and nothing done.

doIt

protected abstract boolean doIt(boolean immediate)
This should contain the code that needs to examine the database while in the GUI thread

Parameters:
immediate - true if run immediately using runImmediate(), false if run through callback to run().
Returns:
true if successful, false otherwise