Package PamController
Class AWTScheduler
java.lang.Object
PamController.AWTScheduler
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
-
Method Summary
Modifier and TypeMethodDescriptionstatic AWTScheduler
Get singleton instance.int
scheduleTask
(Runnable swingWorker) Schedules a task for execution.void
Start the next task in the list.
-
Method Details
-
getInstance
Get singleton instance.- Returns:
- singleton instance of AWTScheduler.
-
scheduleTask
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.
-