|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--uk.ac.starlink.table.gui.LoadWorker
Handles asynchronous table loading.
In conjunction with a TableConsumer
, this can be used to
ensure that a table is loaded out of the event dispatch thread,
so that the GUI remains responsive during what might potentially
be a slow load process.
To use it, implement the abstract attemptLoad()
method
to load a table, and then call invoke()
from the event
dispatch thread. This will cause a table to be loaded asynchronously
and the TableConsumer to be notified accordingly.
It will often be convenient to extend and use this via an anonymous class. For example:
final String location = getFileName(); new LoadWorker( tableEater, location ) { protected StarTable attemptLoad() throws IOException { return new StarTableFactory().makeStarTable( location ); } }.invoke();
Constructor Summary | |
LoadWorker(TableConsumer eater,
String id)
Constructor for a loader which will attempt to feed a loaded table to a given consumer. |
Method Summary | |
protected abstract StarTable |
attemptLoad()
Performs a table load. |
void |
invoke()
Causes the attemptLoad() method to be called from a new
thread, and notifies the table consumer accordingly. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public LoadWorker(TableConsumer eater, String id)
eater
- table consumer which will be notified about the
table load processid
- string identifier for the table such as its filename.
This may be used in messages to the userMethod Detail |
protected abstract StarTable attemptLoad() throws IOException
IOException
- if something goes wrongpublic void invoke()
attemptLoad()
method to be called from a new
thread, and notifies the table consumer accordingly.
This method may only be invoked once for each instance of this class.
It should be invoked from the event dispatch thread (and will execute
quickly).
|
Copyright © 2004 CLRC: Central Laboratory of the Research Councils. All rights reserved. | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |