Class TableSaveChooser

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public abstract class TableSaveChooser extends JPanel
Dialog which permits a user to save one or more StarTables in a place and format of choice. It should be able to provide suitable dialogs for all the supported table types; in particular it includes a filestore browser and special JDBC connection dialog.

The usual way to use this is to implement getTables() to provide the table which will be saved, and then call showSaveDialog(java.awt.Component).

Author:
Mark Taylor (Starlink)
See Also:
  • Constructor Details

    • TableSaveChooser

      public TableSaveChooser()
      Constructs a saver with a default StarTableOutput and save dialogues.
    • TableSaveChooser

      public TableSaveChooser(StarTableOutput sto, TableSaveDialog[] saveDialogs)
      Constructs a saver with a given StarTableOutput and save dialogues.
      Parameters:
      sto - output marshaller
      saveDialogs - array of save dialogues to use
  • Method Details

    • setTableOutput

      public void setTableOutput(StarTableOutput sto)
      Sets the StarTableOutput object which this saver uses to do the actual writing of the StarTables.
      Parameters:
      sto - the new StarTableOutput to use
    • getTableOutput

      public StarTableOutput getTableOutput()
      Returns the StarTableOutput object which this saver uses to do the actual writing of the StarTables.
      Returns:
      sto the StarTableOutput object
    • getFormatSelector

      public JComboBox<String> getFormatSelector()
      Returns the selector which chooses table output formats. It may be replaced.
      Returns:
      format selector
    • getTables

      public abstract StarTable[] getTables()
      Obtains the tables to write. This must be implemented by concrete subclasses.
      Returns:
      table to write
    • setProgressBar

      public void setProgressBar(JProgressBar progBar)
      Sets the progress bar that will be used by this chooser. Should be called before the component is displayed to the user.
      Parameters:
      progBar - progress bar for displaying save progress
    • getSaveDialogActions

      public Action[] getSaveDialogActions()
      Returns actions which correspond to the save dialogues this saver is using. Each action is the result of an earlier call to createSaveDialogAction(uk.ac.starlink.table.gui.TableSaveDialog).
      Returns:
      array of actions which will trigger a particular save dialogue
    • done

      public void done()
      Called when the table has been written.
    • showSaveDialog

      public void showSaveDialog(Component parent)
      Pops up a modal dialogue which interacts with the user to save the tables returned by getTables().
      Parameters:
      parent - parent component
    • setEnabled

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

      public String getSelectedFormat()
      Returns the currently selected format string.
      Returns:
      format label
    • setSelectedFormat

      public void setSelectedFormat(String format)
      Sets the currently selected format string.
      Parameters:
      format - format label
    • createDialog

      public JDialog createDialog(Component parent)
      Creates a dialogue which can be used for user interaction.
      Parameters:
      parent - parent component
    • createSaveDialogAction

      public final Action createSaveDialogAction(TableSaveDialog tsd)
      Returns an action which will result in the given save dialogue being posted to allow the user to save this chooser's current table. This method is invoked in the constructor, hence is declared final.
      Parameters:
      tsd - save dialogue
      Returns:
      action to post tsd
    • makeFormatBoxModel

      public static ComboBoxModel<String> makeFormatBoxModel(StarTableOutput sto, boolean multi)
      Constructs a ComboBoxModel containing an entry for each of the known output formats.
      Parameters:
      sto - output marshaller
      multi - true if multiple tables might be used, false if only a single table will be written
      Returns:
      format combo box model
    • getExtraWriterNames

      public static String[] getExtraWriterNames(boolean multi)
      Returns a selection of output handler specifications that can be offered to the user alongside the default-configuration ones.
      Parameters:
      multi - true if multiple tables might be used, false if only a single table will be written
      Returns:
      example/useful writer specifications including config options
    • main

      public static void main(String[] args)
      Testing purposes only.