Class FileChooser

All Implemented Interfaces:
ActionListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, IdvConstants
Direct Known Subclasses:
Level2RadarChooser, PollingFileChooser

public class FileChooser extends IdvChooser
This provides a JFileChooser for choosing data sets from the file system. It can be instantiated from the chooser.xml with the attributes:
 path="initial file system path"
 filters="File filters to use" (Define file filters)
 datasourceid="The data source id (from datasource.xml, force the file to
                                   be passed to the data source)
 
For information on the filters attribute see PatternFileFilter.createFilters(String)
Author:
IDV development team
See Also:
  • Field Details

    • ATTR_PATH

      public static final String ATTR_PATH
      Any initial file system path to start with
      See Also:
    • ATTR_FILECOUNT

      public static final String ATTR_FILECOUNT
      The most recent attribute
      See Also:
    • ATTR_POLLON

      public static final String ATTR_POLLON
      Default polling value
      See Also:
    • ATTR_DSCOMP

      public static final String ATTR_DSCOMP
      Should we show the polling cbx
      See Also:
    • ATTR_SHOWPATTERNFIELD

      public static final String ATTR_SHOWPATTERNFIELD
      Should we show the file pattern field
      See Also:
    • ATTR_FILEPATTERN

      public static final String ATTR_FILEPATTERN
      Default pattern
      See Also:
    • ATTR_FILTERS

      public static final String ATTR_FILTERS
      Any filter filters to use
      See Also:
    • ATTR_DATASOURCEID

      public static final String ATTR_DATASOURCEID
      Pre-defined data source id to use
      See Also:
    • recentFilesCbx

      protected JComboBox recentFilesCbx
      Como box for choosing relative files
    • allowDirectorySelectionCbx

      protected JCheckBox allowDirectorySelectionCbx
      allow directory selection checkbox
    • patternFld

      protected JTextField patternFld
      Holds the file pattern
  • Constructor Details

    • FileChooser

      public FileChooser(IdvChooserManager mgr, Element root)
      Create the FileChooser, passing in the manager and the xml element from choosers.xml
      Parameters:
      mgr - The manager
      root - The xml root
  • Method Details

    • getButtonLabels

      protected String[] getButtonLabels()
      _more_
      Overrides:
      getButtonLabels in class ChooserPanel
      Returns:
      _more_
    • getLoadToolTip

      protected String getLoadToolTip()
      Get the tooltip for the load button
      Overrides:
      getLoadToolTip in class ChooserPanel
      Returns:
      The tooltip for the load button
    • getUpdateToolTip

      protected String getUpdateToolTip()
      Get the tooltip for the update button
      Overrides:
      getUpdateToolTip in class ChooserPanel
      Returns:
      The tooltip for the update button
    • getRecentFilesComponent

      protected JComponent getRecentFilesComponent()
      Get the recent file component
      Returns:
      the component
    • getRecentFilesComponent

      protected JComponent getRecentFilesComponent(int[] values, int value, boolean addPatternField)
      Get the recent files component with the appropriate params
      Parameters:
      values - values
      value - selected value
      addPatternField - the pattern field
      Returns:
      the component
    • getFileCount

      protected int getFileCount()
      Get the count of recent files
      Returns:
      Recent file count
    • checkRecentPatternWidgetsEnable

      protected void checkRecentPatternWidgetsEnable()
      Disable or enable the file pattern widget and label
    • getFilePattern

      protected String getFilePattern()
      Get the file pattern
      Returns:
      the file pattern
    • doMakeContents

      protected JComponent doMakeContents()
      Construct a JFileChooser to put into the IdvChooserManager. Initialize to point to the DEFAULTDIR preference (if defined)
      Overrides:
      doMakeContents in class ChooserPanel
      Returns:
      The gui of this chooser
    • getAllowDirectorySelectionCbx

      protected JCheckBox getAllowDirectorySelectionCbx()
      Get the checkbox for allowing directory selection
      Returns:
      the checkbox
    • getTopComponents

      protected void getTopComponents(List comps)
      Get the top components for the chooser
      Parameters:
      comps - the top component
    • doMakeFileChooser

      protected JFileChooser doMakeFileChooser(String path)
      Make the file chooser
      Parameters:
      path - the initial path
      Returns:
      the file chooser
    • setHaveData

      public void setHaveData(boolean haveData)
      _more_
      Overrides:
      setHaveData in class ChooserPanel
      Parameters:
      haveData - _more_
    • shouldShowRecentComponent

      protected boolean shouldShowRecentComponent()
      Should show the recent (time relative) component
      Returns:
      false - subclasses should override
    • getAccessory

      protected JComponent getAccessory()
      Get the accessory component
      Returns:
      the component
    • selectFiles

      protected final void selectFiles(File[] files, File directory)
      Handle the selection of the set of files
      Parameters:
      files - The files the user chose
      directory - The directory they chose them from
    • getFileChooser

      protected JFileChooser getFileChooser()
      Get the file chooser
      Returns:
      the chooser for this instance
    • doLoadInThread

      public void doLoadInThread()
      Override the base class method to catch the do load
      Overrides:
      doLoadInThread in class ChooserPanel
    • doUpdate

      public void doUpdate()
      Override the base class method to catch the do update
      Overrides:
      doUpdate in class ChooserPanel
    • selectFilesInner

      protected boolean selectFilesInner(File[] files, File directory) throws Exception
      Handle the selection of the set of files.
      Parameters:
      files - The files the user chose
      directory - The directory they chose them from
      Returns:
      True if the file was successful
      Throws:
      Exception - the exception
    • getFileNames

      protected String[] getFileNames(File[] files)
      Convert the given array of File objects to an array of String file names. Only include the files that actually exist.
      Parameters:
      files - Selected files
      Returns:
      Selected files as Strings