uk.ac.starlink.table.gui
Class FilestoreTableLoadDialog

java.lang.Object
  extended byuk.ac.starlink.table.gui.AbstractTableLoadDialog
      extended byuk.ac.starlink.table.gui.MultiTableLoadDialog
          extended byuk.ac.starlink.table.gui.FilestoreTableLoadDialog
All Implemented Interfaces:
TableLoadDialog

public class FilestoreTableLoadDialog
extends MultiTableLoadDialog

Table load dialogue based on a FilestoreChooser.

Since:
18 Feb 2005

Nested Class Summary
 
Nested classes inherited from class uk.ac.starlink.table.gui.MultiTableLoadDialog
MultiTableLoadDialog.TablesSupplier
 
Constructor Summary
FilestoreTableLoadDialog()
           
 
Method Summary
protected  Component createQueryPanel()
          Returns the component which contains all the implementation-specific GUI components, including query controls etc.
 FilestoreChooser getChooser()
           
protected  MultiTableLoadDialog.TablesSupplier getTablesSupplier()
          Concrete subclasses should implement this method to supply a TablesSupplier object which can attempt to load some tables based on the current state (as filled in by the user) of this component.
 boolean isAvailable()
          Indicates whether this dialog can be invoked.
 void setEnabled(boolean enabled)
           
protected  void setFormatModel(ComboBoxModel formatModel)
          Installs a table format selector intot this dialogue.
 boolean showLoadDialog(Component parent, StarTableFactory factory, ComboBoxModel formatModel, TableConsumer consumer)
          Presents the user with a dialogue which may be used to specify a table to load.
 
Methods inherited from class uk.ac.starlink.table.gui.MultiTableLoadDialog
cancelLoad, submitLoad
 
Methods inherited from class uk.ac.starlink.table.gui.AbstractTableLoadDialog
asIOException, createDialog, getCancelAction, getDescription, getIcon, getName, getOkAction, getProgessBar, getQueryPanel, isActive, setBusy, setIcon, setIconUrl
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FilestoreTableLoadDialog

public FilestoreTableLoadDialog()
Method Detail

createQueryPanel

protected Component createQueryPanel()
Description copied from class: AbstractTableLoadDialog
Returns the component which contains all the implementation-specific GUI components, including query controls etc. Only called once.

Specified by:
createQueryPanel in class AbstractTableLoadDialog
Returns:
returns the component containing query controls

setFormatModel

protected void setFormatModel(ComboBoxModel formatModel)
Description copied from class: AbstractTableLoadDialog
Installs a table format selector intot this dialogue. If it makes sense for a concrete dialogue implementation to display format selection, it should override this method in such a way as to present the format model to the user for selection (presumably by setting it as the model of a visible JComboBox).

The default implementation does nothing (suitable for classes which can't make sense of varying table formats).

Overrides:
setFormatModel in class AbstractTableLoadDialog
Parameters:
formatModel - selector model to install

getTablesSupplier

protected MultiTableLoadDialog.TablesSupplier getTablesSupplier()
Description copied from class: MultiTableLoadDialog
Concrete subclasses should implement this method to supply a TablesSupplier object which can attempt to load some tables based on the current state (as filled in by the user) of this component. If the state is not suitable for an attempt at loading a table (e.g. some components are filled in in an obviously wrong way) then a runtime exception such as IllegalStateException or IllegalArgumentException, with a human-readable message, should be thrown.

Specified by:
getTablesSupplier in class MultiTableLoadDialog
Returns:
table array supplier corresponding to current state of this component

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.

Returns:
true iff this dialog can be used

getChooser

public FilestoreChooser getChooser()

setEnabled

public void setEnabled(boolean enabled)

showLoadDialog

public boolean showLoadDialog(Component parent,
                              StarTableFactory factory,
                              ComboBoxModel formatModel,
                              TableConsumer consumer)
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
Overrides:
showLoadDialog in class AbstractTableLoadDialog

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