Next Previous Up Contents
Next: SQL Database Interaction
Up: GUI Support
Previous: Drag and Drop

4.2 Table Chooser Components

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)
browses local and remote filesystems.
uk.ac.starlink.table.gui.FileChooserLoader
allows selection of files using a standard JFileChooser component.
uk.ac.starlink.table.gui.SQLDialog
allows import of tables formed from SQL queries on a relational database (see Section 3.7).

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
gives you a Treeview-like view of the hierarchical nature of a filespace, for instance looking inside zip/tar archives, or selecting HDUs within FITS files or TABLE elements within VOTable documents.
uk.ac.starlink.vo.RegistryTableLoadDialog
lets you specify a registry query and import the resulting list of known resources as a table.
uk.ac.starlink.vo.ConeSearchDialog
lets you enter a position on the sky and search radius and query one of the listed servers for a catalogue containig sources known in that region.
More may be made available in the future, and you can provide your own by implementing the 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.7. 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.


Next Previous Up Contents
Next: SQL Database Interaction
Up: GUI Support
Previous: Drag and Drop

STIL - Starlink Tables Infrastructure Library
Starlink User Note 252
STIL web page: http://www.starlink.ac.uk/stil/
Author email: m.b.taylor@bristol.ac.uk
Starlink: http://www.starlink.ac.uk/