uk.ac.starlink.topcat
Class Scheduler

java.lang.Object
  extended by 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 Summary
Scheduler(JComponent parent)
          Constructor.
 
Method Summary
 JComponent getParent()
          Returns the component specified for this scheduler at construction time.
abstract  boolean isActive()
          Indicates whether this object is considered active.
 void schedule(Runnable runnable)
          Schedules a runnable to be performed later on the Event Dispatch Thread, as long as this object is considered active.
 void scheduleError(String title, Throwable error)
          Schedules display of an ErrorDialog error message.
 void scheduleMemoryError(OutOfMemoryError error)
          Schedules display of an OutOfMemoryError.
 void scheduleMessage(String message, String title, int messageType)
          Schedules display of a JOptionPane message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Scheduler

public Scheduler(JComponent parent)
Constructor.

Parameters:
parent - parent component used for parenting popup windows; may be null
Method Detail

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:
JOptionPane

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:
TopcatUtils.memoryError(java.lang.OutOfMemoryError)

getParent

public JComponent getParent()
Returns the component specified for this scheduler at construction time.

Returns:
parent component, may be null


Copyright © 2003-2018 CCLRC: Council for the Central Laboratory of the Research Councils. All Rights Reserved.