Package uk.ac.starlink.table.gui
Class TableLoadWorker
- java.lang.Object
-
- java.lang.Thread
-
- uk.ac.starlink.table.gui.TableLoadWorker
-
- All Implemented Interfaces:
java.lang.Runnable
public class TableLoadWorker extends java.lang.Thread
Thread which passes data from a TableLoader to a TableLoadClient. As well as ensuring that everything happens on sensible threads, and updating a progress bar appropriately, it provides the facility to cancel the load in progress.- Since:
- 13 Sept 2010
- Author:
- Mark Taylor
-
-
Constructor Summary
Constructors Constructor Description TableLoadWorker(TableLoader loader, TableLoadClient client)
Constructs a TableLoadWorker with a default progress bar.TableLoadWorker(TableLoader loader, TableLoadClient client, javax.swing.JProgressBar progBar)
Constructs a TableLoadWorker with a given progress bar.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cancel()
Cancels the current load.protected void
finish(boolean cancelled)
Tidies up following execution.javax.swing.Action
getCancelAction()
Returns an action which will cancel the current load.TableLoadClient
getLoadClient()
Returns the table load client used by this worker.TableLoader
getLoader()
Returns the table loader used by this worker.javax.swing.JProgressBar
getProgressBar()
Returns the progress bar controlled by this worker.void
run()
Performs loading until completed or cancelled.-
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
-
-
-
Constructor Detail
-
TableLoadWorker
public TableLoadWorker(TableLoader loader, TableLoadClient client, javax.swing.JProgressBar progBar)
Constructs a TableLoadWorker with a given progress bar.- Parameters:
loader
- table loader, supplies tablesclient
- table load client, consumes tables into a GUIprogBar
- progress bar to keep track of loading
-
TableLoadWorker
public TableLoadWorker(TableLoader loader, TableLoadClient client)
Constructs a TableLoadWorker with a default progress bar.- Parameters:
loader
- table loader, supplies tablesclient
- table load client, consumes tables into a GUI
-
-
Method Detail
-
getLoader
public TableLoader getLoader()
Returns the table loader used by this worker.- Returns:
- table loader
-
getLoadClient
public TableLoadClient getLoadClient()
Returns the table load client used by this worker.- Returns:
- load client
-
getCancelAction
public javax.swing.Action getCancelAction()
Returns an action which will cancel the current load.- Returns:
- cancel action
-
getProgressBar
public javax.swing.JProgressBar getProgressBar()
Returns the progress bar controlled by this worker.- Returns:
- progress bar
-
run
public void run()
Performs loading until completed or cancelled.- Specified by:
run
in interfacejava.lang.Runnable
- Overrides:
run
in classjava.lang.Thread
-
cancel
public void cancel()
Cancels the current load. It is not an error to call this multiple times. It must be called on the Event Dispatch Thread.
-
finish
protected void finish(boolean cancelled)
Tidies up following execution. Must be called exactly once. It must be called on the Event Dispatch Thread.- Parameters:
cancelled
- true iff cancel has been called
-
-