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

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class java.lang.Thread

      `java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler`

  - ### Field Summary

    - ### Fields inherited from class java.lang.Thread

      `MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY`

  - ### Constructor Summary

    Constructors
    Constructor and 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 and 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, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield`

    - ### Methods inherited from class java.lang.Object

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

- - ### 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 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 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 interface `java.lang.Runnable`
      Overrides:
        `run` in class `java.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