Class Scheduler

java.lang.Object
uk.ac.starlink.topcat.Scheduler

public abstract class Scheduler extends Object
Schedules tasks to run conditionally on on the Event Dispatch Thread. Such tasks are only run if this object's (abstract) isActive method returns true at both scheduling time and run time.
Since:
5 Jun 2014
Author:
Mark Taylor
  • Constructor Details

    • Scheduler

      public Scheduler(JComponent parent)
      Constructor.
      Parameters:
      parent - parent component used for parenting popup windows; may be null
  • Method Details

    • isActive

      public abstract boolean isActive()
      Indicates whether this object is considered active. If not, no jobs will be scheduled, and any scheduled jobs will be ignored when they are run on the EDT.

      The expectation is that this method starts off by returning true, but may eventually transition to returning false. Once that has happened, it will not return true again.

      Returns:
      true iff this object is considered active
    • schedule

      public void schedule(Runnable runnable)
      Schedules a runnable to be performed later on the Event Dispatch Thread, as long as this object is considered active. If isActive returns false either when this method is called, or when the runnable comes to be executed on the EDT, nothing is done.

      This method may be called on any thread.

      Parameters:
      runnable - action to run on the EDT if still active
    • scheduleMessage

      public void scheduleMessage(String message, String title, int messageType)
      Schedules display of a JOptionPane message.

      This method may be called on any thread.

      Parameters:
      message - the Object to display
      title - the title string for the dialog
      messageType - the type of message to be displayed, one of the JOptionPane.*_MESSAGE constants
      See Also:
    • scheduleError

      public void scheduleError(String title, Throwable error)
      Schedules display of an ErrorDialog error message.

      This method may be called on any thread.

      Parameters:
      title - window title
      error - throwable
      See Also:
      • ErrorDialog
    • scheduleMemoryError

      public void scheduleMemoryError(OutOfMemoryError error)
      Schedules display of an OutOfMemoryError.
      Parameters:
      error - throwable
      See Also:
    • getParent

      public JComponent getParent()
      Returns the component specified for this scheduler at construction time.
      Returns:
      parent component, may be null