Class AbstractExtensionFileFilterFileChooser<F extends ExtensionFileFilter>

    • Field Detail

      • UNHANDLED_DIALOG

        public static final int UNHANDLED_DIALOG
        unhandled type of dialog.
        See Also:
        Constant Field Values
      • m_DialogType

        protected int m_DialogType
        the type of dialog to display.
      • m_CurrentHandler

        protected Object m_CurrentHandler
        the converter that was chosen by the user.
      • m_LastFilter

        protected ExtensionFileFilter m_LastFilter
        the last filter that was used for opening/saving.
      • m_FileMustExist

        protected boolean m_FileMustExist
        whether the file to be opened must exist (only open dialog).
    • Constructor Detail

      • AbstractExtensionFileFilterFileChooser

        protected AbstractExtensionFileFilterFileChooser()
        onstructs a FileChooser pointing to the user's default directory.
      • AbstractExtensionFileFilterFileChooser

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

        protected AbstractExtensionFileFilterFileChooser​(String currentDirectory)
        Constructs a FileChooser using the given path.
        Parameters:
        currentDirectory - the path to start in
    • Method Detail

      • getFiltersInitialized

        protected abstract boolean getFiltersInitialized()
        Returns whether the filters have already been initialized.
        Returns:
        true if the filters have been initialized
      • doInitializeFilters

        protected abstract void doInitializeFilters()
        Performs the actual initialization of the filters.
      • 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
      • getOpenFileFilters

        protected abstract List<F> getOpenFileFilters()
        Returns the file filters for opening files.
        Returns:
        the file filters
      • getSaveFileFilters

        protected abstract List<F> getSaveFileFilters()
        Returns the file filters for writing files.
        Returns:
        the file filters
      • getDefaultFileFilter

        protected F getDefaultFileFilter​(int dialogType)
        Returns the default file filter to use.
        Parameters:
        dialogType - the dialog type: open/save
        Returns:
        the default file filter, null if unable find default one
      • restoreLastFilter

        protected F restoreLastFilter​(int dialogType)
        Attempts to restore the last filter in use.
        Parameters:
        dialogType - the dialog type: open/save
        Returns:
        the filter that was selected, null if none
      • initGUI

        protected void initGUI​(int dialogType)
        initializes the GUI.
        Parameters:
        dialogType - the type of dialog to setup the GUI for
      • 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.
        Specified by:
        showDialog in interface FileChooser
        Overrides:
        showDialog in class BaseFileChooser
        Parameters:
        parent - the parent of this dialog
        approveButtonText - the text for the OK button
        Returns:
        the user's action
        See Also:
        GraphicsEnvironment.isHeadless()
      • updateCurrentHandlerHook

        protected void updateCurrentHandlerHook()
        Sets the current handler according to the current filefilter.

        Default implementation does nothing.
        See Also:
        m_CurrentHandler
      • configureCurrentHandlerHook

        protected void configureCurrentHandlerHook​(int dialogType)
        Configures the current handler.

        Default implementation does nothing.
        Parameters:
        dialogType - the type of dialog to configure for
        See Also:
        m_CurrentHandler
      • setCorrectOpenFileFilter

        public boolean setCorrectOpenFileFilter​(File file)
        Attempts to set the correct file filter for the specified file, using its extension to determine the file filter.
        Parameters:
        file - the file to set the filter for
        Returns:
        true if successfully set filter
      • setCorrectSaveFileFilter

        public boolean setCorrectSaveFileFilter​(File file)
        Attempts to set the correct file filter for the specified file, using its extension to determine the file filter.
        Parameters:
        file - the file to set the filter for
        Returns:
        true if successfully set filter
      • isAllFilter

        public static boolean isAllFilter​(ExtensionFileFilter filter)
        Checks whether the filter uses "*.*".
        Parameters:
        filter - the filter to check
        Returns:
        true if filter has extension .*