PamController
Class AWTScheduler

java.lang.Object
  extended by PamController.AWTScheduler

public class AWTScheduler
extends java.lang.Object

Class to schedule SwingWorker tasks so that they execute one at a time. SwingWorkers do of course do their work in a different thread to the AWT thread. The point of this scheduler is to ensure that they execute one by one, can themselves update the GUI (for instance with progress bars or text output) but that the GUI itself is locked for user input to avoid problems causes by impatient users.

Author:
Doug Gillespie

Nested Class Summary
private  class AWTScheduler.ScheduledWorkerTask
          USed by InvokeLater to start a SwingWorker task.
private  class AWTScheduler.WorkerPropertyChangeListener
           
 
Field Summary
private  PamController pamController
           
private static AWTScheduler singleInstance
           
private  java.util.List<java.lang.Runnable> taskList
           
 
Constructor Summary
private AWTScheduler()
           
 
Method Summary
static AWTScheduler getInstance()
          Get singleton instance.
 int scheduleTask(java.lang.Runnable swingWorker)
          Schedules a task for execution.
 void startNextTask()
          Start the next task in the list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

singleInstance

private static AWTScheduler singleInstance

pamController

private PamController pamController

taskList

private java.util.List<java.lang.Runnable> taskList
Constructor Detail

AWTScheduler

private AWTScheduler()
Method Detail

getInstance

public static AWTScheduler getInstance()
Get singleton instance.

Returns:
singleton instance of AWTScheduler.

scheduleTask

public int scheduleTask(java.lang.Runnable swingWorker)
Schedules a task for execution. Starts from the AWT thread, but SwingWorker execution is in a different thread.

This function will always return immediately, using invokeLAter to start the task on AWT when the function calling this has completed.

Parameters:
swingWorker - Prepared swing worker to execute
Returns:
number of tasks in the queue in front of this task.

startNextTask

public void startNextTask()
Start the next task in the list.

If it's a SwingWorker, then run it as a scheduled worker task which will handle the disabling and re-enabling of the PAMGUARD GUI.

If it's a plain old runnable, then just send it off to the AWT thread with invoke later and go straight on to setting up the task after it.