Class AbstractTableLoadDialog

java.lang.Object
uk.ac.starlink.table.gui.AbstractTableLoadDialog
All Implemented Interfaces:
TableLoadDialog
Direct Known Subclasses:
FileChooserTableLoadDialog, FilestoreTableLoadDialog, LocationTableLoadDialog, SQLTableLoadDialog

public abstract class AbstractTableLoadDialog extends Object implements TableLoadDialog
Partial implementation of TableLoadDialog interface.
Since:
13 Sept 2010
Author:
Mark Taylor
  • Constructor Details

    • AbstractTableLoadDialog

      protected AbstractTableLoadDialog(String name, String description)
      Constructor.
      Parameters:
      name - dialogue name
      description - dialogue description
  • Method Details

    • createQueryComponent

      protected abstract Component createQueryComponent()
      Constructs the query component used by this dialogue. Called only once (lazily).
      Returns:
      query component
    • getName

      public String 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 interface TableLoadDialog
      Returns:
      dialogue name
    • getDescription

      public String 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 interface TableLoadDialog
      Returns:
      dialogue description
    • getIcon

      public Icon 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 interface TableLoadDialog
      Returns:
      dialogue icon
    • getQueryComponent

      public Component 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 interface TableLoadDialog
      Returns:
      component for user interaction
    • getMenus

      public JMenu[] 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 interface TableLoadDialog
      Returns:
      menu array; may be empty
    • setMenus

      public void setMenus(JMenu[] menus)
      Sets the menus for this dialogue.
      Parameters:
      menus - menu array
    • getToolbarActions

      public Action[] 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 interface TableLoadDialog
      Returns:
      toolbar action array; may be empty
    • setToolbarActions

      protected void setToolbarActions(Action[] acts)
      Sets the toolbar actions for this dialogue.
      Parameters:
      acts - toolbar actions
    • addToolbarAction

      protected void addToolbarAction(Action act)
      Adds an action to the toolbar for this dialogue. Utility function.
      Parameters:
      act - action to add
    • isAvailable

      public boolean isAvailable()
      The default implementation returns true.
      Specified by:
      isAvailable in interface TableLoadDialog
      Returns:
      true iff this dialogue may be able to do something useful
    • setIcon

      public void setIcon(Icon icon)
      Sets the icon to associate with this dialogue.
      Parameters:
      icon - icon
    • setIconUrl

      public void setIconUrl(URL iconUrl)
      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

      public void configure(StarTableFactory tfact, Action submitAct)
      Description copied from interface: TableLoadDialog
      Provides some configuration which must be performed before use. This method should be called before TableLoadDialog.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 cause TableLoadDialog.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 interface TableLoadDialog
      Parameters:
      tfact - representative table factory
      submitAct - action for load submission
    • createFormatSelector

      public JComboBox<String> 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

      public String getSelectedFormat()
      Returns the table format currently selected by any of the format selectors.
      Returns:
      selected table format
      See Also:
    • getSubmitAction

      public Action getSubmitAction()
      Description copied from interface: TableLoadDialog
      Specified by:
      getSubmitAction in interface TableLoadDialog
      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 of isReady(). Subclasses should call this method when the return value of isReady 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

      public static IOException asIOException(Throwable th)
      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 in TableSupplier.getTable.
      Parameters:
      th - base throwable
      Returns:
      IOException based on th