Package uk.ac.starlink.table.gui
Class AbstractTableLoadDialog
java.lang.Object
uk.ac.starlink.table.gui.AbstractTableLoadDialog
- All Implemented Interfaces:
TableLoadDialog
- Direct Known Subclasses:
FileChooserTableLoadDialog
,FilestoreTableLoadDialog
,LocationTableLoadDialog
,SQLTableLoadDialog
Partial implementation of TableLoadDialog interface.
- Since:
- 13 Sept 2010
- Author:
- Mark Taylor
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AbstractTableLoadDialog
(String name, String description) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionstatic IOException
Converts an exception to an IOException, probably by wrapping it in one.void
configure
(StarTableFactory tfact, Action submitAct) Provides some configuration which must be performed before use.Returns a new combo box which can be used to select table formats from the ones known by this dialogue.protected abstract Component
Constructs the query component used by this dialogue.Returns a short description of this dialogue.getIcon()
Returns an icon associated with this dialogue.JMenu[]
getMenus()
Returns an array of menus which may be presented in the window alongside the query component.getName()
Returns the name of this dialogue.Returns the GUI component which allows the user to select how tables are to be loaded.Returns the table format currently selected by any of the format selectors.Returns the action set byTableLoadDialog.configure(uk.ac.starlink.table.StarTableFactory, javax.swing.Action)
.Action[]
Returns an array of actions suitable for presentation as toolbar buttons alongside the query component.boolean
The default implementation returns true.boolean
Indicates whether the query component of this dialogue is currently contained in a visible window.boolean
isReady()
Indicates whether the submit action should be enabled.void
Sets the icon to associate with this dialogue.void
setIconUrl
(URL iconUrl) Sets the icon to associate with this dialogue by specifying its URL.void
Sets the menus for this dialogue.protected void
setToolbarActions
(Action[] acts) Sets the toolbar actions for this dialogue.protected void
submit()
Invokes this dialogue's Submit Action with a non-descript ActionEvent.protected void
Updates the enabledness state of this dialogue's Submit Action according to the current value ofisReady()
.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface uk.ac.starlink.table.gui.TableLoadDialog
createTableLoader
-
Constructor Details
-
AbstractTableLoadDialog
Constructor.- Parameters:
name
- dialogue namedescription
- dialogue description
-
-
Method Details
-
createQueryComponent
Constructs the query component used by this dialogue. Called only once (lazily).- Returns:
- query component
-
getName
Description copied from interface:TableLoadDialog
Returns the name of this dialogue. This may be used as the text of a button (Action.NAME
).- Specified by:
getName
in interfaceTableLoadDialog
- Returns:
- dialogue name
-
getDescription
Description copied from interface:TableLoadDialog
Returns a short description of this dialogue. This may be used as the tooltip text of a button (Action.SHORT_DESCRIPTION
).- Specified by:
getDescription
in interfaceTableLoadDialog
- Returns:
- dialogue description
-
getIcon
Description copied from interface:TableLoadDialog
Returns an 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 interfaceTableLoadDialog
- Returns:
- dialogue icon
-
getQueryComponent
Description copied from interface:TableLoadDialog
Returns the GUI component which allows the user to select how tables are to be loaded.- Specified by:
getQueryComponent
in interfaceTableLoadDialog
- Returns:
- component for user interaction
-
getMenus
Description copied from interface:TableLoadDialog
Returns an array of menus which may be presented in the window alongside the query component.- Specified by:
getMenus
in interfaceTableLoadDialog
- Returns:
- menu array; may be empty
-
setMenus
Sets the menus for this dialogue.- Parameters:
menus
- menu array
-
getToolbarActions
Description copied from interface:TableLoadDialog
Returns an array of actions suitable for presentation as toolbar buttons alongside the query component.- Specified by:
getToolbarActions
in interfaceTableLoadDialog
- Returns:
- toolbar action array; may be empty
-
setToolbarActions
Sets the toolbar actions for this dialogue.- Parameters:
acts
- toolbar actions
-
isAvailable
public boolean isAvailable()The default implementation returns true.- Specified by:
isAvailable
in interfaceTableLoadDialog
- Returns:
- true iff this dialogue may be able to do something useful
-
setIcon
Sets the icon to associate with this dialogue.- Parameters:
icon
- icon
-
setIconUrl
Sets the icon to associate with this dialogue by specifying its URL. If a null URL is given, the icon is set null.- Parameters:
iconUrl
- URL of gif, png or jpeg icon
-
configure
Description copied from interface:TableLoadDialog
Provides some configuration which must be performed before use. This method should be called beforeTableLoadDialog.getQueryComponent()
is called.The
tfact
argument provides a table factory which resembles the one to be used for generating tables. Although this factory should not in general be used or retained, since the one presented later to the TableLoader should be used instead, it can be interrogated for known table formats etc.The
submitAct
argument sets the action which when invoked will causeTableLoadDialog.createTableLoader()
to be called. Its setEnabled method can be called to reflect readiness, and it can be added as a listener to dialogue-specific events which indicate that a selection has been made.- Specified by:
configure
in interfaceTableLoadDialog
- Parameters:
tfact
- representative table factorysubmitAct
- action for load submission
-
createFormatSelector
Returns a new combo box which can be used to select table formats from the ones known by this dialogue. This method may be called multiple times, but the same model is used in each case.- Returns:
- table format combo box
-
getSelectedFormat
Returns the table format currently selected by any of the format selectors.- Returns:
- selected table format
- See Also:
-
getSubmitAction
Description copied from interface:TableLoadDialog
Returns the action set byTableLoadDialog.configure(uk.ac.starlink.table.StarTableFactory, javax.swing.Action)
.- Specified by:
getSubmitAction
in interfaceTableLoadDialog
- Returns:
- action which initiates a table load attempt
-
isComponentShowing
public boolean isComponentShowing()Indicates whether the query component of this dialogue is currently contained in a visible window.- Returns:
- true iff this dialog's query component exists and is showing
-
submit
protected void submit()Invokes this dialogue's Submit Action with a non-descript ActionEvent. -
updateReady
protected void updateReady()Updates the enabledness state of this dialogue's Submit Action according to the current value ofisReady()
. Subclasses should call this method when the return value ofisReady
might have changed. -
isReady
public boolean isReady()Indicates whether the submit action should be enabled. The implementation should return true if the user should be allowed to submit the query, or false if the internal state of this dialogue is known to be incomplete in some way. Evaluation should be fast; the return does not need to provide a guarantee that a submitted query will suceed.The default implementation returns true.
- Returns:
- false iff dialogue state is known to be incomplete
-
asIOException
Converts an exception to an IOException, probably by wrapping it in one. This utility method can be used for wrapping up an exception of some other kind if it needs to be thrown inTableSupplier.getTable
.- Parameters:
th
- base throwable- Returns:
- IOException based on
th
-