Class JWFileChooserConfiguration

java.lang.Object
com.io7m.jwheatsheaf.api.JWFileChooserConfiguration
All Implemented Interfaces:
JWFileChooserConfigurationType

public final class JWFileChooserConfiguration extends Object implements JWFileChooserConfigurationType
The configuration information used to instantiate file choosers. File choosers have a wide range of configurable properties. The only mandatory configuration parameter is the fileSystem(), because this defines the initial filesystem used for file selection.
  • Method Details

    • recentFiles

      public List<Path> recentFiles()
      Specified by:
      recentFiles in interface JWFileChooserConfigurationType
      Returns:
      The list of recent files to be shown in the file chooser
    • fileSystem

      public FileSystem fileSystem()
      Specified by:
      fileSystem in interface JWFileChooserConfigurationType
      Returns:
      The file system traversed by the file chooser
    • initialDirectory

      public Optional<Path> initialDirectory()
      Specified by:
      initialDirectory in interface JWFileChooserConfigurationType
      Returns:
      The starting directory
    • homeDirectory

      public Optional<Path> homeDirectory()
      The directory to which the chooser will navigate when the user clicks the "home" button. If no path is specified, the button is not shown.
      Specified by:
      homeDirectory in interface JWFileChooserConfigurationType
      Returns:
      The user's home directory
    • initialFileName

      public Optional<String> initialFileName()
      Specified by:
      initialFileName in interface JWFileChooserConfigurationType
      Returns:
      The file name initially entered into the selection field
    • title

      public Optional<String> title()
      Specified by:
      title in interface JWFileChooserConfigurationType
      Returns:
      A string that will override the generic dialog title
    • fileImageSet

      public Optional<JWFileImageSetType> fileImageSet()
      The image set used to select images for the file chooser UI. If no set is specified here, a default set of images and icons will be used.
      Specified by:
      fileImageSet in interface JWFileChooserConfigurationType
      Returns:
      An image set
    • cssStylesheet

      public Optional<URL> cssStylesheet()
      The CSS stylesheet that will be added to the file chooser UI.
      Specified by:
      cssStylesheet in interface JWFileChooserConfigurationType
      Returns:
      The URL of the CSS stylesheet
    • fileFilters

      public List<JWFileChooserFilterType> fileFilters()
      Specified by:
      fileFilters in interface JWFileChooserConfigurationType
      Returns:
      The list of file filters
    • fileFilterDefault

      public Optional<JWFileChooserFilterType> fileFilterDefault()
      Specified by:
      fileFilterDefault in interface JWFileChooserConfigurationType
      Returns:
      The default file filter
    • fileSelectionMode

      public Function<Path,Boolean> fileSelectionMode()
      Sets a mode that prevents returning a file to the client if that file does not meet criteria returned by this method. For example, this may be used to prevent selecting directories by implementing a function that returns true when the file is considered a regular file.
      Specified by:
      fileSelectionMode in interface JWFileChooserConfigurationType
      Returns:
      The Function that accepts or rejects selected files
    • allowDirectoryCreation

      public boolean allowDirectoryCreation()
      Specified by:
      allowDirectoryCreation in interface JWFileChooserConfigurationType
      Returns:
      true if the UI will allow the creation of directories
    • showParentDirectory

      public boolean showParentDirectory()
      Determine whether to show a link to the parent directory inside the file listing. This entry is always called "..".
      Specified by:
      showParentDirectory in interface JWFileChooserConfigurationType
      Returns:
      true if the directory listing will contain ".."
      Since:
      3.0.0
    • fileTimeFormatter

      public DateTimeFormatter fileTimeFormatter()
      Specified by:
      fileTimeFormatter in interface JWFileChooserConfigurationType
      Returns:
      The date/time formatter used to display file times
    • fileSizeFormatter

      public JWFileSizeFormatterType fileSizeFormatter()
      Specified by:
      fileSizeFormatter in interface JWFileChooserConfigurationType
      Returns:
      The formatter used to display file sizes
    • action

      public JWFileChooserAction action()
      Specified by:
      action in interface JWFileChooserConfigurationType
      Returns:
      The action that the user is performing
    • confirmFileSelection

      public boolean confirmFileSelection()
      If set to true, then when the user is using a mode such as JWFileChooserAction.CREATE, a confirmation dialog will be displayed if the user selects a file that already exists.
      Specified by:
      confirmFileSelection in interface JWFileChooserConfigurationType
      Returns:
      true if confirmation dialogs should be shown
      Since:
      3.0.0
    • stringOverrides

      public JWFileChooserStringOverridesType stringOverrides()
      Specified by:
      stringOverrides in interface JWFileChooserConfigurationType
      Returns:
      A provider of UI string overrides
      Since:
      3.0.0
    • modality

      public javafx.stage.Modality modality()
      Specified by:
      modality in interface JWFileChooserConfigurationType
      Returns:
      The modality that will be used for file choosers
      Since:
      4.0.0
    • withRecentFiles

      public final JWFileChooserConfiguration withRecentFiles(Path... elements)
      Copy the current immutable object with elements that replace the content of recentFiles.
      Parameters:
      elements - The elements to set
      Returns:
      A modified copy of this object
    • withRecentFiles

      public final JWFileChooserConfiguration withRecentFiles(Iterable<? extends Path> elements)
      Copy the current immutable object with elements that replace the content of recentFiles. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      elements - An iterable of recentFiles elements to set
      Returns:
      A modified copy of this object
    • withFileSystem

      public final JWFileChooserConfiguration withFileSystem(FileSystem value)
      Copy the current immutable object by setting a value for the fileSystem attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for fileSystem
      Returns:
      A modified copy of the this object
    • withInitialDirectory

      public final JWFileChooserConfiguration withInitialDirectory(Path value)
      Copy the current immutable object by setting a present value for the optional initialDirectory attribute.
      Parameters:
      value - The value for initialDirectory
      Returns:
      A modified copy of this object
    • withInitialDirectory

      public final JWFileChooserConfiguration withInitialDirectory(Optional<? extends Path> optional)
      Copy the current immutable object by setting an optional value for the initialDirectory attribute. A shallow reference equality check is used on unboxed optional value to prevent copying of the same value by returning this.
      Parameters:
      optional - A value for initialDirectory
      Returns:
      A modified copy of this object
    • withHomeDirectory

      public final JWFileChooserConfiguration withHomeDirectory(Path value)
      Copy the current immutable object by setting a present value for the optional homeDirectory attribute.
      Parameters:
      value - The value for homeDirectory
      Returns:
      A modified copy of this object
    • withHomeDirectory

      public final JWFileChooserConfiguration withHomeDirectory(Optional<? extends Path> optional)
      Copy the current immutable object by setting an optional value for the homeDirectory attribute. A shallow reference equality check is used on unboxed optional value to prevent copying of the same value by returning this.
      Parameters:
      optional - A value for homeDirectory
      Returns:
      A modified copy of this object
    • withInitialFileName

      public final JWFileChooserConfiguration withInitialFileName(String value)
      Copy the current immutable object by setting a present value for the optional initialFileName attribute.
      Parameters:
      value - The value for initialFileName
      Returns:
      A modified copy of this object
    • withInitialFileName

      public final JWFileChooserConfiguration withInitialFileName(Optional<String> optional)
      Copy the current immutable object by setting an optional value for the initialFileName attribute. An equality check is used on inner nullable value to prevent copying of the same value by returning this.
      Parameters:
      optional - A value for initialFileName
      Returns:
      A modified copy of this object
    • withTitle

      public final JWFileChooserConfiguration withTitle(String value)
      Copy the current immutable object by setting a present value for the optional title attribute.
      Parameters:
      value - The value for title
      Returns:
      A modified copy of this object
    • withTitle

      public final JWFileChooserConfiguration withTitle(Optional<String> optional)
      Copy the current immutable object by setting an optional value for the title attribute. An equality check is used on inner nullable value to prevent copying of the same value by returning this.
      Parameters:
      optional - A value for title
      Returns:
      A modified copy of this object
    • withFileImageSet

      public final JWFileChooserConfiguration withFileImageSet(JWFileImageSetType value)
      Copy the current immutable object by setting a present value for the optional fileImageSet attribute.
      Parameters:
      value - The value for fileImageSet
      Returns:
      A modified copy of this object
    • withFileImageSet

      public final JWFileChooserConfiguration withFileImageSet(Optional<? extends JWFileImageSetType> optional)
      Copy the current immutable object by setting an optional value for the fileImageSet attribute. A shallow reference equality check is used on unboxed optional value to prevent copying of the same value by returning this.
      Parameters:
      optional - A value for fileImageSet
      Returns:
      A modified copy of this object
    • withCssStylesheet

      public final JWFileChooserConfiguration withCssStylesheet(URL value)
      Copy the current immutable object by setting a present value for the optional cssStylesheet attribute.
      Parameters:
      value - The value for cssStylesheet
      Returns:
      A modified copy of this object
    • withCssStylesheet

      public final JWFileChooserConfiguration withCssStylesheet(Optional<? extends URL> optional)
      Copy the current immutable object by setting an optional value for the cssStylesheet attribute. A shallow reference equality check is used on unboxed optional value to prevent copying of the same value by returning this.
      Parameters:
      optional - A value for cssStylesheet
      Returns:
      A modified copy of this object
    • withFileFilters

      public final JWFileChooserConfiguration withFileFilters(JWFileChooserFilterType... elements)
      Copy the current immutable object with elements that replace the content of fileFilters.
      Parameters:
      elements - The elements to set
      Returns:
      A modified copy of this object
    • withFileFilters

      public final JWFileChooserConfiguration withFileFilters(Iterable<? extends JWFileChooserFilterType> elements)
      Copy the current immutable object with elements that replace the content of fileFilters. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      elements - An iterable of fileFilters elements to set
      Returns:
      A modified copy of this object
    • withFileFilterDefault

      public final JWFileChooserConfiguration withFileFilterDefault(JWFileChooserFilterType value)
      Copy the current immutable object by setting a present value for the optional fileFilterDefault attribute.
      Parameters:
      value - The value for fileFilterDefault
      Returns:
      A modified copy of this object
    • withFileFilterDefault

      public final JWFileChooserConfiguration withFileFilterDefault(Optional<? extends JWFileChooserFilterType> optional)
      Copy the current immutable object by setting an optional value for the fileFilterDefault attribute. A shallow reference equality check is used on unboxed optional value to prevent copying of the same value by returning this.
      Parameters:
      optional - A value for fileFilterDefault
      Returns:
      A modified copy of this object
    • withFileSelectionMode

      public final JWFileChooserConfiguration withFileSelectionMode(Function<Path,Boolean> value)
      Copy the current immutable object by setting a value for the fileSelectionMode attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for fileSelectionMode
      Returns:
      A modified copy of the this object
    • withAllowDirectoryCreation

      public final JWFileChooserConfiguration withAllowDirectoryCreation(boolean value)
      Copy the current immutable object by setting a value for the allowDirectoryCreation attribute. A value equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for allowDirectoryCreation
      Returns:
      A modified copy of the this object
    • withShowParentDirectory

      public final JWFileChooserConfiguration withShowParentDirectory(boolean value)
      Copy the current immutable object by setting a value for the showParentDirectory attribute. A value equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for showParentDirectory
      Returns:
      A modified copy of the this object
    • withFileTimeFormatter

      public final JWFileChooserConfiguration withFileTimeFormatter(DateTimeFormatter value)
      Copy the current immutable object by setting a value for the fileTimeFormatter attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for fileTimeFormatter
      Returns:
      A modified copy of the this object
    • withFileSizeFormatter

      public final JWFileChooserConfiguration withFileSizeFormatter(JWFileSizeFormatterType value)
      Copy the current immutable object by setting a value for the fileSizeFormatter attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for fileSizeFormatter
      Returns:
      A modified copy of the this object
    • withAction

      public final JWFileChooserConfiguration withAction(JWFileChooserAction value)
      Copy the current immutable object by setting a value for the action attribute. A value equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for action
      Returns:
      A modified copy of the this object
    • withConfirmFileSelection

      public final JWFileChooserConfiguration withConfirmFileSelection(boolean value)
      Copy the current immutable object by setting a value for the confirmFileSelection attribute. A value equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for confirmFileSelection
      Returns:
      A modified copy of the this object
    • withStringOverrides

      public final JWFileChooserConfiguration withStringOverrides(JWFileChooserStringOverridesType value)
      Copy the current immutable object by setting a value for the stringOverrides attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for stringOverrides
      Returns:
      A modified copy of the this object
    • withModality

      public final JWFileChooserConfiguration withModality(javafx.stage.Modality value)
      Copy the current immutable object by setting a value for the modality attribute. A value equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for modality
      Returns:
      A modified copy of the this object
    • equals

      public boolean equals(Object another)
      This instance is equal to all instances of JWFileChooserConfiguration that have equal attribute values.
      Overrides:
      equals in class Object
      Returns:
      true if this is equal to another instance
    • hashCode

      public int hashCode()
      Computes a hash code from attributes: recentFiles, fileSystem, initialDirectory, homeDirectory, initialFileName, title, fileImageSet, cssStylesheet, fileFilters, fileFilterDefault, fileSelectionMode, allowDirectoryCreation, showParentDirectory, fileTimeFormatter, fileSizeFormatter, action, confirmFileSelection, stringOverrides, modality.
      Overrides:
      hashCode in class Object
      Returns:
      hashCode value
    • toString

      public String toString()
      Prints the immutable value JWFileChooserConfiguration with attribute values.
      Overrides:
      toString in class Object
      Returns:
      A string representation of the value
    • copyOf

      Creates an immutable copy of a JWFileChooserConfigurationType value. Uses accessors to get values to initialize the new immutable instance. If an instance is already immutable, it is returned as is.
      Parameters:
      instance - The instance to copy
      Returns:
      A copied immutable JWFileChooserConfiguration instance
    • builder

      public static JWFileChooserConfiguration.Builder builder()
      Creates a builder for JWFileChooserConfiguration.
       JWFileChooserConfiguration.builder()
          .addRecentFiles|addAllRecentFiles(java.nio.file.Path) // recentFiles elements
          .setFileSystem(java.nio.file.FileSystem) // optional fileSystem
          .setInitialDirectory(java.nio.file.Path) // optional initialDirectory
          .setHomeDirectory(java.nio.file.Path) // optional homeDirectory
          .setInitialFileName(String) // optional initialFileName
          .setTitle(String) // optional title
          .setFileImageSet(com.io7m.jwheatsheaf.api.JWFileImageSetType) // optional fileImageSet
          .setCssStylesheet(java.net.URL) // optional cssStylesheet
          .addFileFilters|addAllFileFilters(com.io7m.jwheatsheaf.api.JWFileChooserFilterType) // fileFilters elements
          .setFileFilterDefault(com.io7m.jwheatsheaf.api.JWFileChooserFilterType) // optional fileFilterDefault
          .setFileSelectionMode(function.Function&lt;java.nio.file.Path, Boolean&gt;) // optional fileSelectionMode
          .setAllowDirectoryCreation(boolean) // optional allowDirectoryCreation
          .setShowParentDirectory(boolean) // optional showParentDirectory
          .setFileTimeFormatter(java.time.format.DateTimeFormatter) // optional fileTimeFormatter
          .setFileSizeFormatter(com.io7m.jwheatsheaf.api.JWFileSizeFormatterType) // optional fileSizeFormatter
          .setAction(com.io7m.jwheatsheaf.api.JWFileChooserAction) // optional action
          .setConfirmFileSelection(boolean) // optional confirmFileSelection
          .setStringOverrides(com.io7m.jwheatsheaf.api.JWFileChooserStringOverridesType) // optional stringOverrides
          .setModality(javafx.stage.Modality) // optional modality
          .build();
       
      Returns:
      A new JWFileChooserConfiguration builder