Some graphical components exist to make it easier to load or save tables.
They are effectively table-friendly alternatives to using a
JFileChooser
.
TableLoadChooser
is for use when you want the user to select an existing table to load.
Depending on how it's set up, it may offer the user a range of
ways of selecting a table. In the simplest instance the user can
type a filename into a text field, but there are also
sub-dialogues which offer alternative ways to get a table.
By default the only one visible is a button allowing you to choose
a table using a FilestoreChooser
component; this allows browsing of files on local disk or on
remote filesystems such as MySpace or SRB
(the classes required to access these remote filesystems are not
included in the standard STIL distribution, but are part of the
full Starlink java set -
see the ConnectorManager
class).
However, others are supplied, and you can write your own.
Any implementation of the
TableLoadDialog
interface can be presented as a way of loading tables.
The following classes are available within STIL itself to provide
different ways of importing tables:
uk.ac.starlink.table.gui.FilestoreTableLoadDialog
(visible by default)
uk.ac.starlink.table.gui.FileChooserLoader
uk.ac.starlink.table.gui.SQLDialog
The following load dialogue classes are available elsewhere within the Starlink Java software set, but not contained in the standard STIL distribution. Download the full Starjava set for these, or contact the author (or you can find them in a full TOPCAT distribution):
uk.ac.starlink.datanode.tree.TreeTableLoadDialog
uk.ac.starlink.vo.RegistryTableLoadDialog
uk.ac.starlink.vo.ConeSearchDialog
TableLoadDialog
interface
(you may find the skeleton
BasicTableLoadDialog
useful).
Any of these sub-dialogues can be added by modifying the list of
TableLoadDialog
objects
maintained by the chooser, either by using chooser methods
or by setting the system property startable.load.dialogs
as described in Appendix A.8.
For instance you could add a dialogue which would get the user to
interact with a web service to obtain a table result.
Using a TableLoadChooser
can be as simple as:
StarTable table = new TableLoadChooser().showTableDialog( null );which pops up a modal dialogue and only returns when the user has obtained a table or decided that he doesn't want to. If you want to make sure that the table returned will have random access, you should ensure that the chooser's factory has its
requireRandom
flag
set true, for instance like this:
StarTable table = new TableLoadChooser( new StarTableFactory( true ) ) .showTableDialog( null );
TableSaveChooser
is used for saving tables.
As well as allowing the user to select the table's destination,
it also allows selection of the output file format
from the list of those which the StarTableOutput
knows about.
Like the load dialogue, it provides special subdialogues for
writing to SQL and browsing local and remote filesystems.