Package uk.ac.starlink.table.gui
Class SaveWorker
- java.lang.Object
-
- uk.ac.starlink.table.gui.SaveWorker
-
public abstract class SaveWorker extends java.lang.Object
Handles asynchronous table saving. To save a table, create an instance of this class with a suitable implementation of theattemptSave(uk.ac.starlink.table.StarTable[])
method and callinvoke()
on it from the event dispatch thread. A progress bar will advise the user on how the save is going, and if the save fails a popup will advise of the error. When the save has completed one way or another, thedone(boolean)
method will be called.- Since:
- 24 Feb 2005
- Author:
- Mark Taylor (Starlink)
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
SaveWorker(java.awt.Component parent, StarTable[] tables, java.lang.String location)
Constructs a save worker which will use its own popup widow for progress display.protected
SaveWorker(javax.swing.JProgressBar progBar, StarTable[] tables, java.lang.String location)
Constructs a save worker which will use a given progress bar for progress display.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract void
attemptSave(StarTable[] tables)
This method should do the work of saving the given tables.void
cancel()
Interrupts any save which is in progress.protected abstract void
done(boolean success)
Called from the event dispatch thread when the save has completed.void
invoke()
Begins the save.
-
-
-
Constructor Detail
-
SaveWorker
protected SaveWorker(java.awt.Component parent, StarTable[] tables, java.lang.String location)
Constructs a save worker which will use its own popup widow for progress display.- Parameters:
parent
- parent component used for progress bar popuptables
- tables to be savedlocation
- string identifying the save destination - used for display purposes only
-
SaveWorker
protected SaveWorker(javax.swing.JProgressBar progBar, StarTable[] tables, java.lang.String location)
Constructs a save worker which will use a given progress bar for progress display.- Parameters:
progBar
- progress bar which will be updated to display progresstables
- tables to be savedlocation
- string identifying the save destination - used for display purposes only
-
-
Method Detail
-
attemptSave
protected abstract void attemptSave(StarTable[] tables) throws java.io.IOException
This method should do the work of saving the given tables. It will not be called on the event dispatch thread, so may take some time to execute.- Parameters:
tables
- tables to save- Throws:
java.io.IOException
- if the table cannot be saved
-
done
protected abstract void done(boolean success)
Called from the event dispatch thread when the save has completed. The success argument indicates whether the table was saved successfully or not. If it was not, the user will already have been informed of this.The default implementation does nothing, but subclasses may override it to react in some way to the save's completion.
- Parameters:
success
- save status
-
cancel
public void cancel()
Interrupts any save which is in progress. Call from the event dispatch thread.
-
invoke
public void invoke()
Begins the save. Should be invoked from the event dispatch thread.
-
-