# Class TableLoadWorker

java.lang.Object
java.lang.Thread
uk.ac.starlink.table.gui.TableLoadWorker

All Implemented Interfaces:
  `Runnable`

public class TableLoadWorker extends 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

## Nested Class Summary

### Nested classes/interfaces inherited from class Thread

`Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler`

## Field Summary

### Fields inherited from class Thread

`MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY`

## Constructor Summary

Constructors
Constructor
Description
`TableLoadWorker(TableLoader loader, TableLoadClient client)`
Constructs a TableLoadWorker with a default progress bar.
`TableLoadWorker(TableLoader loader, TableLoadClient client, JProgressBar progBar)`
Constructs a TableLoadWorker with a given progress bar.

## Method Summary

Modifier and Type
Method
Description
`void`
`cancel()`
Cancels the current load.
`protected void`
`finish(boolean cancelled)`
Tidies up following execution.
`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.
`JProgressBar`
`getProgressBar()`
Returns the progress bar controlled by this worker.
`void`
`run()`
Performs loading until completed or cancelled.

### Methods inherited from class Thread

`activeCount, checkAccess, clone, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, isVirtual, join, join, join, join, ofPlatform, ofVirtual, onSpinWait, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, sleep, start, startVirtualThread, stop, threadId, toString, yield`

### Methods inherited from class Object

`equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

## Constructor Details

### TableLoadWorker

public TableLoadWorker(TableLoader loader, TableLoadClient client, JProgressBar progBar)
Constructs a TableLoadWorker with a given progress bar.

Parameters:
  `loader` - table loader, supplies tables
  `client` - table load client, consumes tables into a GUI
  `progBar` - 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 tables
  `client` - table load client, consumes tables into a GUI

## Method Details

### 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 Action getCancelAction()
Returns an action which will cancel the current load.

Returns:
  cancel action

### getProgressBar

public 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 interface `Runnable`
Overrides:
  `run` in class `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