Some graphical components exist to make it easier to load or save tables.
They are effectively table-friendly alternatives to using a
JFileChooser
.
StarTableChooser
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 standard JFileChooser
component.
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.FileChooserLoader
(visible by default)
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
uk.ac.starlink.astrogrid.MyspaceTableLoadDialog
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.6.
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 StarTableChooser
can be as simple as:
StarTable table = new StarTableChooser().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 StarTableChooser( new StarTableFactory( true ) ) .showTableDialog( null );
StarTableSaver
is used for saving tables.
As well as allowing the user to browse the filesystem and select a
filename as usual, it also allows selection of the output file format
from the list of those which the StarTableOutput
knows about.