|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectuk.ac.starlink.table.gui.AbstractTableLoadDialog
Skeleton implementation of a TableLoadDialog
.
Concrete subclasses should implement the abstract methods
submitLoad(javax.swing.JDialog, uk.ac.starlink.table.StarTableFactory, java.lang.String, uk.ac.starlink.table.gui.TableConsumer)
and cancelLoad()
.
Subclasses are encouraged to override the
JComponent.setEnabled(boolean)
method to en/disable
child components which ought not to be active while a load is actually
taking place. The overriding implementation ought to call
super.setEnabled.
Constructor Summary | |
AbstractTableLoadDialog(String name,
String description)
Constructor. |
Method Summary | |
static IOException |
asIOException(Throwable th)
Converts an exception to an IOException, probably by wrapping it in one. |
protected abstract void |
cancelLoad()
Should interrupt any current load action, so that any pending load which is not complete should avoid passing tables to the consumer in the future, and preferably any work in progress should be stopped. |
protected JDialog |
createDialog(Component parent)
Constructs a dialogue based on the component returned by createQueryPanel() ; that component forms
the main part of the dialogue window, with an OK and Cancel button
shown as well. |
protected abstract Component |
createQueryPanel()
Returns the component which contains all the implementation-specific GUI components, including query controls etc. |
protected Action |
getCancelAction()
Returns the action associated with hitting the Cancel dialogue button. |
String |
getDescription()
Description of this dialogue. |
Icon |
getIcon()
Icon associated with this dialogue. |
String |
getName()
Name of this dialogue. |
protected Action |
getOkAction()
Returns the action associated with hitting the OK dialogue button. |
protected JProgressBar |
getProgessBar()
Returns the progress bar at the bottom of the dialogue window. |
Component |
getQueryPanel()
Returns the lazily-constructed query panel. |
protected boolean |
isActive(JDialog dialog)
Indicates whether the given dialogue is currently being displayed to the user containing this component. |
protected void |
setBusy(boolean busy)
Gives visible indication (including disabling components) that this component is active or not. |
protected void |
setFormatModel(ComboBoxModel formatModel)
Installs a table format selector intot this dialogue. |
void |
setIcon(Icon icon)
Sets the icon to associate with this dialogue. |
void |
setIconUrl(URL iconUrl)
Sets the icon to associate with this dialogue by specifying its URL. |
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. |
protected abstract void |
submitLoad(JDialog dialog,
StarTableFactory tfact,
String format,
TableConsumer consumer)
Should feed a table or tables to the given consuemer based on the current state of this component. |
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 |
isAvailable |
Constructor Detail |
public AbstractTableLoadDialog(String name, String description)
name
- dialogue name (typically used as text of a button)description
- dialogue description (typically used as
tooltip text)Method Detail |
public String getName()
TableLoadDialog
Action.NAME
)
which invokes showLoadDialog.
getName
in interface TableLoadDialog
public String getDescription()
TableLoadDialog
Action.SHORT_DESCRIPTION
)
which invokes showLoadDialog
getDescription
in interface TableLoadDialog
public Icon getIcon()
TableLoadDialog
getIcon
in interface TableLoadDialog
public void setIcon(Icon icon)
public void setIconUrl(URL iconUrl)
iconUrl
- URL of gif, png or jpeg iconprotected abstract void submitLoad(JDialog dialog, StarTableFactory tfact, String format, TableConsumer consumer) throws Exception
dialog
- dialogue currently containing this componenttfact
- table factory to use for generating tablesformat
- selected table format;
it may or may not be appropriate to ignore this hintconsumer
- destination for loaded table or tables
Exception
protected abstract void cancelLoad()
protected abstract Component createQueryPanel()
public Component getQueryPanel()
public boolean showLoadDialog(Component parent, StarTableFactory factory, ComboBoxModel formatModel, TableConsumer consumer)
TableLoadDialog
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)
.
showLoadDialog
in interface TableLoadDialog
parent
- parent windowfactory
- factory which may be used for table creationformatModel
- comboBoxModelconsumer
- object which can do something with the loaded table
protected JDialog createDialog(Component parent)
createQueryPanel()
; that component forms
the main part of the dialogue window, with an OK and Cancel button
shown as well. This method may be overridden by subclasses to
customise the dialogue's appearance.
parent
- component
protected void setFormatModel(ComboBoxModel formatModel)
JComboBox
).
The default implementation does nothing (suitable for classes which can't make sense of varying table formats).
formatModel
- selector model to installprotected Action getOkAction()
protected Action getCancelAction()
protected JProgressBar getProgessBar()
protected void setBusy(boolean busy)
busy
- whether we're busyprotected boolean isActive(JDialog dialog)
dialog
- dialog window to test
dialog
is being displayedpublic static IOException asIOException(Throwable th)
TableSupplier.getTable
.
th
- base throwable
th
|
Copyright © 2004 CLRC: Central Laboratory of the Research Councils. All rights reserved. | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |