uk.ac.starlink.table.gui
Class SQLReadDialog

java.lang.Object
  extended byuk.ac.starlink.table.gui.SQLReadDialog
All Implemented Interfaces:
TableLoadDialog

public class SQLReadDialog
extends Object
implements TableLoadDialog

A table load dialogue which interrogates the user about an SQL query on a JDBC database.

Since:
1 Dec 2004

Constructor Summary
SQLReadDialog()
          Constructs a new SQLReadDialog.
 
Method Summary
 String getDescription()
          Description of this dialogue.
 Icon getIcon()
          Icon associated with this dialogue.
 String getName()
          Name of this dialogue.
 boolean isAvailable()
          Indicates whether this dialog can be invoked.
 boolean showLoadDialog(Component parent, StarTableFactory factory, ComboBoxModel formatModel, TableConsumer eater)
          Presents the user with a dialogue which may be used to specify a table to load.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SQLReadDialog

public SQLReadDialog()
Constructs a new SQLReadDialog.

Method Detail

getName

public String getName()
Description copied from interface: TableLoadDialog
Name of this dialogue. This will typically be used as the text of a button (Action.NAME) which invokes showLoadDialog.

Specified by:
getName in interface TableLoadDialog
Returns:
name

getDescription

public String getDescription()
Description copied from interface: TableLoadDialog
Description of this dialogue. This will typically be used as the tooltip text of a button (Action.SHORT_DESCRIPTION) which invokes showLoadDialog

Specified by:
getDescription in interface TableLoadDialog
Returns:
short description

getIcon

public Icon getIcon()
Description copied from interface: TableLoadDialog
Icon associated with this dialogue. A size of 24x24 pixels is preferred. Null may be returned if no icon is available.

Specified by:
getIcon in interface TableLoadDialog
Returns:
icon

isAvailable

public boolean isAvailable()
Description copied from interface: TableLoadDialog
Indicates whether this dialog can be invoked. This allows the implementation to check that it has enough resources (e.g. required classes) for it to be worth trying it. This method should be invoked before the first invocation of TableLoadDialog.showLoadDialog(java.awt.Component, uk.ac.starlink.table.StarTableFactory, javax.swing.ComboBoxModel, uk.ac.starlink.table.gui.TableConsumer), but is not guaranteed to be invoked again.

Specified by:
isAvailable in interface TableLoadDialog
Returns:
true iff this dialog can be used

showLoadDialog

public boolean showLoadDialog(Component parent,
                              StarTableFactory factory,
                              ComboBoxModel formatModel,
                              TableConsumer eater)
Description copied from interface: TableLoadDialog
Presents the user with a dialogue which may be used to specify a table to load. This method should return true if an attempt will be made to load a table, and false if it will not (for instance if the user hit a Cancel button).

In the event that true is returned, the implementation of this method should ensure that notification of the table load attempt should be made to the consumer argument using the defined TableConsumer methods. The purpose of doing it like this (rather than just returning a StarTable from this method) is so that the table loading, which may be time-consuming, can be done in a thread other than the event dispatch thread on which this method will have been called. The LoadWorker class is provided to assist with this; the usual idiom for performing the load from the event dispatch thread within the implementation of this method looks like this:

     new LoadWorker( tableConsumer, tableId ) {
         protected StarTable attemptLoad() throws IOException {
             return tableFactory.makeStarTable( ... );
         }
     }.invoke();
 

Error conditions during the course of the user interaction by this method should in general be dealt with by informing the user (e.g. with a popup) and permitting another attempt. Some sort of cancel button should be provided which should trigger return with a false result.

The formatModel argument may be used to determine or set the format to be used for interpreting tables. Its entries are Strings, and in general the selected one should be passed as the handler argument to one of factory's makeStarTable methods. The dialogue may wish to allow the user to modify the selection by presenting a JComboBox based on this model. A suitable model can be obtained using TableLoadChooser.makeFormatBoxModel(uk.ac.starlink.table.StarTableFactory).

Specified by:
showLoadDialog in interface TableLoadDialog
Parameters:
parent - parent window
factory - factory which may be used for table creation
formatModel - comboBoxModel
eater - object which can do something with the loaded table
Returns:
true if an attempt will be made to load a table

Copyright © 2004 CLRC: Central Laboratory of the Research Councils. All rights reserved.