Class FileChooserPanel

    • Field Detail

      • m_FileChooser

        protected BaseFileChooser m_FileChooser
        the JFileChooser for selecting a file.
      • m_UseSaveDialog

        protected boolean m_UseSaveDialog
        whether to use the open or save dialog.
      • m_FileChooserTitle

        protected String m_FileChooserTitle
        the title to use for the filechooser.
      • m_FileChooserTitleDefault

        protected String m_FileChooserTitleDefault
        the default filechooser title.
      • m_UseAbsolutePath

        protected boolean m_UseAbsolutePath
        whether to use absolute path rather than placeholders.
    • Constructor Detail

      • FileChooserPanel

        public FileChooserPanel()
        Initializes the panel with no file.
      • FileChooserPanel

        public FileChooserPanel​(String path)
        Initializes the panel with the given filename/directory.
        Parameters:
        path - the filename/directory to use
      • FileChooserPanel

        public FileChooserPanel​(File path)
        Initializes the panel with the given filename/directory.
        Parameters:
        path - the filename/directory to use
    • Method Detail

      • setFileChooserTitle

        public void setFileChooserTitle​(String value)
        Sets the title for the filechooser.
        Parameters:
        value - the title, null or empty string for default
      • getFileChooserTitle

        public String getFileChooserTitle()
        Returns the tile for the filechooser.
        Returns:
        the title, empty string for default
      • doChoose

        protected File doChoose()
        Performs the actual choosing of an object.
        Specified by:
        doChoose in class AbstractChooserPanel<File>
        Returns:
        the chosen object or null if none chosen
      • toString

        protected String toString​(File value)
        Converts the value into its string representation.
        Specified by:
        toString in class AbstractChooserPanel<File>
        Parameters:
        value - the value to convert
        Returns:
        the generated string
      • fromString

        protected File fromString​(String value)
        Converts the string representation into its object representation.
        Specified by:
        fromString in class AbstractChooserPanel<File>
        Parameters:
        value - the string value to convert
        Returns:
        the generated object
      • isValid

        protected boolean isValid​(String value)
        Checks whether the string value is valid and can be parsed.
        Overrides:
        isValid in class AbstractChooserPanel<File>
        Parameters:
        value - the value to check
        Returns:
        true if valid
      • setUseAbsolutePath

        public void setUseAbsolutePath​(boolean value)
        Sets whether to use absolute paths.
        Specified by:
        setUseAbsolutePath in interface AbsolutePathSupporter
        Parameters:
        value - if true if absolute paths
      • getUseAbsolutePath

        public boolean getUseAbsolutePath()
        Returns whether to use absolute paths.
        Specified by:
        getUseAbsolutePath in interface AbsolutePathSupporter
        Returns:
        true if absolute paths
      • setFileSelectionMode

        public void setFileSelectionMode​(int value)
        Sets the selection mode, whether only files or directories, or both can be selected. FILES_ONLY is the default.
        Parameters:
        value - the mode
      • addChoosableFileFilter

        public void addChoosableFileFilter​(FileFilter value)
        Adds the given file filter to the filechooser.
        Parameters:
        value - the file filter to add
      • removeChoosableFileFilter

        public void removeChoosableFileFilter​(FileFilter value)
        Removes the specified file filter from the filechooser.
        Parameters:
        value - the file filter to remove
      • removeChoosableFileFilters

        public void removeChoosableFileFilters()
        Removes all file filters from the filechooser.
      • getChoosableFileFilters

        public FileFilter[] getChoosableFileFilters()
        Returns all choosable file filters.
        Returns:
        the current file filters
      • setAcceptAllFileFilterUsed

        public void setAcceptAllFileFilterUsed​(boolean value)
        Sets whether the "accept all files" filter is used.
        Parameters:
        value - if true then the filter will be used
      • isAcceptAllFileFilterUsed

        public boolean isAcceptAllFileFilterUsed()
        Returns whether the "accept all files" filter is used.
        Returns:
        true if the filter is used
      • setFileFilter

        public void setFileFilter​(FileFilter value)
        Sets the active file filter.
        Parameters:
        value - the file filter to select
      • getFileFilter

        public FileFilter getFileFilter()
        Returns the active file filter.
        Returns:
        the current file filter
      • setPromptOverwriteFile

        public void setPromptOverwriteFile​(boolean value)
        Sets whether the user gets prompted by the save dialog if the selected file already exists.
        Parameters:
        value - if true, then the user will get prompted if file already exists
      • getPromptOverwriteFile

        public boolean getPromptOverwriteFile()
        Returns whether the user gets prompted by the save dialog if the selected file already exists.
        Returns:
        true if the user will get prompted
      • setAutoAppendExtension

        public void setAutoAppendExtension​(boolean value)
        Sets whether to automatically append the currently selected file extension or the default one (if All-Filter is used).
        Parameters:
        value - if true, then the file extension will be added automatically
      • getAutoAppendExtension

        public boolean getAutoAppendExtension()
        Returns whether to automatically append the currently selected file extension or the default one (if All-Filter is used).
        Returns:
        true if the file extension will be added automatically
      • setDefaultExtension

        public void setDefaultExtension​(String value)
        Sets the default extension. Is used if m_AutoAppendExtension is true and the All-Filter is selected.
        Parameters:
        value - the extension (without dot), use null to unset
      • getDefaultExtension

        public String getDefaultExtension()
        Returns the default extension. Is used if m_AutoAppendExtension is true and the All-Filter is selected.
        Returns:
        the extension, can be null
      • setCurrentDirectory

        public void setCurrentDirectory​(File value)
        Sets the current directory to use for the file chooser.
        Parameters:
        value - the current directory
      • getCurrentDirectory

        public File getCurrentDirectory()
        Returns the current directory in use by the file chooser.
        Returns:
        the current directory
      • setCurrent

        public boolean setCurrent​(File value)
        Sets the current value.
        Overrides:
        setCurrent in class AbstractChooserPanel<File>
        Parameters:
        value - the value to use, can be null
        Returns:
        true if successfully set
      • setUseSaveDialog

        public void setUseSaveDialog​(boolean value)
        Sets whether to use the save or open dialog.
        Parameters:
        value - if true the save dialog is used
      • getUseSaveDialog

        public boolean getUseSaveDialog()
        Returns whether the save or open dialog is used.
        Returns:
        true if the save dialog is used