uk.ac.starlink.table.gui
Class TableLoadChooser

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--uk.ac.starlink.table.gui.TableLoadChooser
All Implemented Interfaces:
Accessible, ImageObserver, MenuContainer, Serializable

public class TableLoadChooser
extends JPanel

Window which permits the user to select an existing StarTable from file browsers or other external sources. The most straightforward way to use this is to invoke the showTableDialog(java.awt.Component) method.

As well as a text field in which the user may type the location of a table, a number of buttons are offered which pop up additional dialogues, for instance a normal file browser and a dialogue for posing an SQL query. This list is extensible at run time; if you wish to provide an additional table acquisition dialogue, then you must provide an implementation of the TableLoadDialog interface. This can be made known to the chooser either by passing a list of additional dialogues to the constructor, or by specifying the class names as the value of the system property with the name LOAD_DIALOGS_PROPERTY (multiple classnames may be separated by colons). In the latter case the implementing class(es) must have a no-arg constructor.

By default, if the required classes are present, only the FileChooserLoader handler is installed. As well as ones you might implement yourself, a number of other useful TableLoadDialog implementations are available in the Starlink java set, including:

these can be installed if desired as explained above.

If you want to make more customised use of this component than is offered by showTableDialog it is possible, but these javadocs don't go out of their way to explain how. Take a look at the implementation of showTableDialog.

Since:
26 Nov 2004
See Also:
Serialized Form

Field Summary
static String LOAD_DIALOGS_PROPERTY
          Name of the system property which can be used to specify the class names of additional TableLoadDialog implementations.
static String[] STANDARD_DIALOG_CLASSES
          List of classnames for TableLoadDialog implementations used by default.
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
TableLoadChooser()
          Constructs a new chooser window with default characteristics.
TableLoadChooser(StarTableFactory factory)
          Constructs a new chooser window with a specified table factory.
TableLoadChooser(StarTableFactory factory, TableLoadDialog[] dialogs, String[] extraDialogNames)
          Constructs a new chooser window with a specified table factory and specification of what load dialogues to use.
 
Method Summary
 void configureFromSaver(TableSaveChooser saver)
          Sets the configuration of this loader to match that of a saver widget.
 JDialog createDialog(Component parent, JProgressBar progBar)
          Constructs a modal dialogue containing this window which can be presented to the user.
 String getFormatName()
          Returns the format selected with which to interpret the table.
 TableLoadDialog[] getKnownDialogs()
          Returns an array of all dialogues known by this chooser.
 StarTableFactory getStarTableFactory()
          Returns the factory object which this chooser uses to resolve files into StarTables.
 Action getSubmitAction()
          Returns the action used when the location text is submitted.
 StarTable getTable(Component parent)
          Deprecated. use showTableDialog instead
 TableConsumer getTableConsumer()
          Returns the object which does something with tables that the user selects to load.
 TransferHandler getTableImportTransferHandler()
          Returns a transfer handler which will accept a table dropped on it as a selected one.
 Action makeAction(TableLoadDialog tld)
          Constructs and returns a new action suitable for invoking a TableLoadDialog within this chooser.
static TableLoadDialog[] makeDefaultLoadDialogs()
          Returns a default list of sub-dialogs which can be invoked to load a table.
static ComboBoxModel makeFormatBoxModel(StarTableFactory factory)
          Creates and returns a ComboBoxModel suitable for use in a JComboBox which the user can use to choose the format of tables to be loaded.
 JMenu makeKnownDialogsMenu(String menuName)
          Creates a menu containing actions for popping up modal dialogues corresponding to all the known load dialogue classes (as reported by getKnownDialogs().
 void setEnabled(boolean isEnabled)
           
 void setStarTableFactory(StarTableFactory factory)
          Sets the factory object which this chooser uses to resove files into StarTables.
 void setTableConsumer(TableConsumer eater)
          Sets the object which does something with tables that the user selects to load.
 StarTable showTableDialog(Component parent)
          Pops up a modal dialogue which invites the user to select a table.
 void submitLocation(String location)
          Attempts to make and select a table from a location string.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

STANDARD_DIALOG_CLASSES

public static String[] STANDARD_DIALOG_CLASSES
List of classnames for TableLoadDialog implementations used by default.


LOAD_DIALOGS_PROPERTY

public static final String LOAD_DIALOGS_PROPERTY
Name of the system property which can be used to specify the class names of additional TableLoadDialog implementations. Each must have a no-arg constructor. Multiple classnames should be separated by colons.

See Also:
Constant Field Values
Constructor Detail

TableLoadChooser

public TableLoadChooser()
Constructs a new chooser window with default characteristics. A new default table factory and a default set of load dialogue options, as supplied by makeDefaultLoadDialogs(), are used.


TableLoadChooser

public TableLoadChooser(StarTableFactory factory)
Constructs a new chooser window with a specified table factory. A default set of load dialogue options, as supplied by makeDefaultLoadDialogs(), is used.

Parameters:
factory - factory to use for creating tables

TableLoadChooser

public TableLoadChooser(StarTableFactory factory,
                        TableLoadDialog[] dialogs,
                        String[] extraDialogNames)
Constructs a new chooser window with a specified table factory and specification of what load dialogues to use. The dialogs argument specifies the main list of actual subdialogues which can be used for loading tables. The extraDialogNames argument gives an additional list of dialogue class names which will be instantiated if possible, and perhaps presented in a menu or something. It may or may not contain some of the same names as the classes in dialogs (any duplicates will be weeded out).

Parameters:
factory - table factory
dialogs - main list of load dialogues
extraDialogNames - names of additional classes which implement TableLoadDialog
Method Detail

showTableDialog

public StarTable showTableDialog(Component parent)
Pops up a modal dialogue which invites the user to select a table. If the user selects a valid StarTable it is returned, if he declines, then null will be returned. The user will be informed of any errors and asked to reconsider (so this method should not normally be invoked in a loop).

Parameters:
parent - the parent component, used for window positioning etc
Returns:
a selected table, or null

getTable

public StarTable getTable(Component parent)
Deprecated. use showTableDialog instead

Synonym for showTableDialog(java.awt.Component).


setTableConsumer

public void setTableConsumer(TableConsumer eater)
Sets the object which does something with tables that the user selects to load.

Parameters:
eater - table consumer

getTableConsumer

public TableConsumer getTableConsumer()
Returns the object which does something with tables that the user selects to load.

Returns:
table consumer

getStarTableFactory

public StarTableFactory getStarTableFactory()
Returns the factory object which this chooser uses to resolve files into StarTables.

Returns:
the factory

setStarTableFactory

public void setStarTableFactory(StarTableFactory factory)
Sets the factory object which this chooser uses to resove files into StarTables.


configureFromSaver

public void configureFromSaver(TableSaveChooser saver)
Sets the configuration of this loader to match that of a saver widget. This will typically involve things like making sure they are viewing the same directory.

Parameters:
saver - saver

getFormatName

public String getFormatName()
Returns the format selected with which to interpret the table.

Returns:
the selected format name (or null)

getKnownDialogs

public TableLoadDialog[] getKnownDialogs()
Returns an array of all dialogues known by this chooser. This may be larger than the usually presented list, and may incur some additional cost (for instance classloading) when it is called. It is designed for presenting a more exhaustive list in a menu, for instance.

Returns:
list of actions corresponding to all known subdialogues

makeKnownDialogsMenu

public JMenu makeKnownDialogsMenu(String menuName)
Creates a menu containing actions for popping up modal dialogues corresponding to all the known load dialogue classes (as reported by getKnownDialogs(). Some of these may be inactive if the requisite classes are not present etc.

Parameters:
menuName - name of the menu. A default will be used if null is supplied

setEnabled

public void setEnabled(boolean isEnabled)
Overrides:
setEnabled in class JComponent

createDialog

public JDialog createDialog(Component parent,
                            JProgressBar progBar)
Constructs a modal dialogue containing this window which can be presented to the user.

Parameters:
parent - parent window
progBar - progress bar used to indicate load progress

makeAction

public Action makeAction(TableLoadDialog tld)
Constructs and returns a new action suitable for invoking a TableLoadDialog within this chooser. This is called when constructing the buttons for display.

Parameters:
tld - loader dialogue supplier
Returns:
action which calls the showLoadDialog method of tld

getTableImportTransferHandler

public TransferHandler getTableImportTransferHandler()
Returns a transfer handler which will accept a table dropped on it as a selected one. This handler is installed by default on this window.


submitLocation

public void submitLocation(String location)
Attempts to make and select a table from a location string.

Parameters:
location -

getSubmitAction

public Action getSubmitAction()
Returns the action used when the location text is submitted.

Returns:
action

makeDefaultLoadDialogs

public static TableLoadDialog[] makeDefaultLoadDialogs()
Returns a default list of sub-dialogs which can be invoked to load a table. This consists of those named in the STANDARD_DIALOG_CLASSES variable as well as any named by the contents of the LOAD_DIALOGS_PROPERTY property (as long as the requisite classes can be loaded and instantiated).

Returns:
an array of TableLoadDialog objects

makeFormatBoxModel

public static ComboBoxModel makeFormatBoxModel(StarTableFactory factory)
Creates and returns a ComboBoxModel suitable for use in a JComboBox which the user can use to choose the format of tables to be loaded. Each element of the returned model is a String.

Returns:
ComboBoxModel with entries for each of the known formats, as well as an AUTO option

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