Package weka.gui

Class ConverterFileChooser

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class ConverterFileChooser extends WekaFileChooser
A specialized JFileChooser that lists all available file Loaders and Savers. To list only savers that can handle the data that is about to be saved, one can set a Capabilities filter.
Version:
$Revision: 15656 $
Author:
fracpete (fracpete at waikato dot ac dot nz)
See Also:
  • Field Details

    • UNHANDLED_DIALOG

      public static final int UNHANDLED_DIALOG
      unhandled type of dialog.
      See Also:
    • LOADER_DIALOG

      public static final int LOADER_DIALOG
      the loader dialog.
      See Also:
    • SAVER_DIALOG

      public static final int SAVER_DIALOG
      the saver dialog.
      See Also:
  • Constructor Details

    • ConverterFileChooser

      public ConverterFileChooser()
      onstructs a FileChooser pointing to the user's default directory.
    • ConverterFileChooser

      public ConverterFileChooser(File currentDirectory)
      Constructs a FileChooser using the given File as the path.
      Parameters:
      currentDirectory - the path to start in
    • ConverterFileChooser

      public ConverterFileChooser(String currentDirectory)
      Constructs a FileChooser using the given path.
      Parameters:
      currentDirectory - the path to start in
  • Method Details

    • initDefaultFilters

      public static void initDefaultFilters()
      Initialize the default set of filters for loaders and savers
    • setCapabilitiesFilter

      public void setCapabilitiesFilter(Capabilities value)
      sets the capabilities that the savers must have. use null if all should be listed.
      Parameters:
      value - the minimum Capabilities the savers must have
    • getCapabilitiesFilter

      public Capabilities getCapabilitiesFilter()
      returns the capabilities filter for the savers, can be null if all are listed.
      Returns:
      the minimum Capabilities the savers must have
    • setOverwriteWarning

      public void setOverwriteWarning(boolean value)
      Whether a warning is popped up if the file that is to be saved already exists (only save dialog).
      Parameters:
      value - if true a warning will be popup
    • getOverwriteWarning

      public boolean getOverwriteWarning()
      Returns whether a popup appears with a warning that the file already exists (only save dialog).
      Returns:
      true if a warning pops up
    • setFileMustExist

      public void setFileMustExist(boolean value)
      Whether the selected file must exst (only open dialog).
      Parameters:
      value - if true the file must exist
    • getFileMustExist

      public boolean getFileMustExist()
      Returns whether the selected file must exist (only open dialog).
      Returns:
      true if the file must exist
    • setCoreConvertersOnly

      public void setCoreConvertersOnly(boolean value)
      Whether to display only the hardocded core converters. Necessary for RMI/Remote Experiments (dynamic class discovery doesn't work there!).
      Parameters:
      value - if true only the core converters will be displayed
      See Also:
      • m_CoreConvertersOnly
    • getCoreConvertersOnly

      public boolean getCoreConvertersOnly()
      Returns whether only the hardcoded core converters are displayed. Necessary for RMI/REmote Experiments (dynamic class discovery doesn't work there!).
      Returns:
      true if the file must exist
      See Also:
      • m_CoreConvertersOnly
    • showDialog

      public int showDialog(Component parent, String approveButtonText)
      Pops a custom file chooser dialog with a custom approve button. Throws an exception, if the dialog type is UNHANDLED_DIALOG.
      Overrides:
      showDialog in class JFileChooser
      Parameters:
      parent - the parent of this dialog
      approveButtonText - the text for the OK button
      Returns:
      the user's action
    • showOpenDialog

      public int showOpenDialog(Component parent)
      Pops up an "Open File" file chooser dialog.
      Overrides:
      showOpenDialog in class JFileChooser
      Parameters:
      parent - the parent of this file chooser
      Returns:
      the result of the user's action
    • showSaveDialog

      public int showSaveDialog(Component parent)
      Pops up an "Save File" file chooser dialog.
      Overrides:
      showSaveDialog in class JFileChooser
      Parameters:
      parent - the parent of this file chooser
      Returns:
      the result of the user's action
    • getLoader

      public AbstractFileLoader getLoader()
      returns the loader that was chosen by the user, can be null in case the user aborted the dialog or the save dialog was shown.
      Returns:
      the chosen loader, if any
    • getSaver

      public AbstractFileSaver getSaver()
      returns the saver that was chosen by the user, can be null in case the user aborted the dialog or the open dialog was shown.
      Returns:
      the chosen saver, if any
    • main

      public static void main(String[] args) throws Exception
      For testing the file chooser.
      Parameters:
      args - the commandline options - ignored
      Throws:
      Exception - if something goes wrong with loading/saving