Package uk.ac.starlink.topcat
Class Scheduler
- java.lang.Object
-
- uk.ac.starlink.topcat.Scheduler
-
public abstract class Scheduler extends java.lang.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
Constructors Constructor Description Scheduler(javax.swing.JComponent parent)
Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description javax.swing.JComponent
getParent()
Returns the component specified for this scheduler at construction time.abstract boolean
isActive()
Indicates whether this object is considered active.void
schedule(java.lang.Runnable runnable)
Schedules a runnable to be performed later on the Event Dispatch Thread, as long as this object is considered active.void
scheduleError(java.lang.String title, java.lang.Throwable error)
Schedules display of an ErrorDialog error message.void
scheduleMemoryError(java.lang.OutOfMemoryError error)
Schedules display of an OutOfMemoryError.void
scheduleMessage(java.lang.String message, java.lang.String title, int messageType)
Schedules display of a JOptionPane message.
-
-
-
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(java.lang.Runnable runnable)
Schedules a runnable to be performed later on the Event Dispatch Thread, as long as this object is considered active. IfisActive
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(java.lang.String message, java.lang.String title, int messageType)
Schedules display of a JOptionPane message.This method may be called on any thread.
- Parameters:
message
- the Object to displaytitle
- the title string for the dialogmessageType
- the type of message to be displayed, one of the JOptionPane.*_MESSAGE constants- See Also:
JOptionPane
-
scheduleError
public void scheduleError(java.lang.String title, java.lang.Throwable error)
Schedules display of an ErrorDialog error message.This method may be called on any thread.
- Parameters:
title
- window titleerror
- throwable- See Also:
ErrorDialog
-
scheduleMemoryError
public void scheduleMemoryError(java.lang.OutOfMemoryError error)
Schedules display of an OutOfMemoryError.- Parameters:
error
- throwable- See Also:
TopcatUtils.memoryError(java.lang.OutOfMemoryError)
-
getParent
public javax.swing.JComponent getParent()
Returns the component specified for this scheduler at construction time.- Returns:
- parent component, may be null
-
-