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.

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)
allows selection of files using a normal file chooser component.
uk.ac.starlink.table.gui.SQLDialog
allows import of tables formed from SQL queries on a relational database (see Section 3.6).

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.
uk.ac.starlink.astrogrid.MyspaceTableLoadDialog
browses MySpace for table files.
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.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.


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/