Class FileBrowser

    • Constructor Detail

      • FileBrowser

        public FileBrowser()
        Creates a new FileBrowser with the root directory set to the "user.home" value.

        Note that this version sets the mode to "open".

      • FileBrowser

        public FileBrowser​(java.lang.String rootDirectoryName)
        Creates a new FileBrowser

        Note that this version of the constructor must be used when a custom root directory has to be set.

        Parameters:
        rootDirectoryName - The root directory full name.
      • FileBrowser

        public FileBrowser​(java.io.File initialRootDirectory)
        Creates a new FileBrowser

        Note that this version of the constructor must be used when a custom root directory has to be set.

        Parameters:
        initialRootDirectory - The initial root directory.
    • Method Detail

      • getRootDirectory

        public java.io.File getRootDirectory()
        Returns:
        The current root directory.
      • setRootDirectory

        public void setRootDirectory​(java.io.File rootDir)
        Sets the root directory. Clears any existing file selection.
        Parameters:
        rootDir - The new root directory to browse in.
        Throws:
        java.lang.IllegalArgumentException - if the argument is null or is not a directory.
      • addSelectedFile

        public boolean addSelectedFile​(java.io.File file)
        Adds a file to the file selection.
        Parameters:
        file - The new file to add to the selection.
        Returns:
        true if the file was added; false if it was already selected.
        Throws:
        java.lang.IllegalArgumentException - if the file argument is null or if the file is not in the current root directory.
      • removeSelectedFile

        public boolean removeSelectedFile​(java.io.File file)
        Removes a file from the file selection.
        Parameters:
        file - The previously selected file to be removed from the selection.
        Returns:
        true if the file was removed; false if it was not already selected.
        Throws:
        java.lang.IllegalArgumentException - if the file argument is null.
      • getSelectedFile

        public java.io.File getSelectedFile()
        When in single-select mode, returns the currently selected file.
        Returns:
        The currently selected file.
      • setSelectedFile

        public void setSelectedFile​(java.io.File file)
        Sets the selection to a single file.
        Parameters:
        file - The only file to select, or null to select nothing.
      • getSelectedFiles

        public ImmutableList<java.io.File> getSelectedFiles()
        Returns the currently selected files.
        Returns:
        An immutable list containing the currently selected files. Note that the returned list is a wrapper around the actual selection, not a copy. Any changes made to the selection state will be reflected in the list, but events will not be fired.
      • setSelectedFiles

        public Sequence<java.io.File> setSelectedFiles​(Sequence<java.io.File> files)
        Sets the selected files.
        Parameters:
        files - The files to select.
        Returns:
        The files that were selected, with duplicates eliminated.
        Throws:
        java.lang.IllegalArgumentException - if the selected files sequence is null or if the sequence is longer than one file and multi-select is not enabled, or if any entry is the sequence is null or whose parent is not the current root directory.
      • clearSelection

        public void clearSelection()
        Clears the selection.
      • isFileSelected

        public boolean isFileSelected​(java.io.File file)
        Parameters:
        file - The file to test.
        Returns:
        Whether or not the given file is selected.
      • isMultiSelect

        public boolean isMultiSelect()
        Returns:
        The file browser's multi-select state.
      • setMultiSelect

        public void setMultiSelect​(boolean selectState)
        Sets the file browser's multi-select state.
        Parameters:
        selectState - true if multi-select is enabled; false, otherwise.
      • getDisabledFileFilter

        public Filter<java.io.File> getDisabledFileFilter()
        Returns the current file filter.
        Returns:
        The current file filter, or null if no filter is set.
      • setDisabledFileFilter

        public void setDisabledFileFilter​(Filter<java.io.File> disabledFilter)
        Sets the file filter.
        Parameters:
        disabledFilter - The file filter to use, or null for no filter.
      • getFileAt

        public java.io.File getFileAt​(int x,
                                      int y)
        Call the skin and return the file at the given position.
        Parameters:
        x - The mouse X-position.
        y - The mouse Y-position.
        Returns:
        The file displayed at those coordinates.