Class JWFileChooserConfiguration

  • All Implemented Interfaces:
    JWFileChooserConfigurationType

    public final class JWFileChooserConfiguration
    extends java.lang.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 Detail

      • recentFiles

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

        public java.util.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 java.util.Optional<java.net.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
      • withRecentFiles

        public final JWFileChooserConfiguration withRecentFiles​(java.nio.file.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​(java.lang.Iterable<? extends java.nio.file.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​(java.nio.file.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​(java.nio.file.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​(java.util.Optional<? extends java.nio.file.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
      • 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​(java.util.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​(java.net.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​(java.util.Optional<? extends java.net.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​(java.lang.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
      • 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
      • withFileTimeFormatter

        public final JWFileChooserConfiguration withFileTimeFormatter​(java.time.format.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
      • equals

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

        public int hashCode()
        Computes a hash code from attributes: recentFiles, fileSystem, initialDirectory, fileImageSet, cssStylesheet, fileFilters, allowDirectoryCreation, fileTimeFormatter, fileSizeFormatter, action.
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        hashCode value
      • toString

        public java.lang.String toString()
        Prints the immutable value JWFileChooserConfiguration with attribute values.
        Overrides:
        toString in class java.lang.Object
        Returns:
        A string representation of the value
      • 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) // required fileSystem
            .setInitialDirectory(java.nio.file.Path) // optional initialDirectory
            .setFileImageSet(com.io7m.jwheatsheaf.api.JWFileImageSetType) // optional fileImageSet
            .setCssStylesheet(java.net.URL) // optional cssStylesheet
            .addFileFilters|addAllFileFilters(com.io7m.jwheatsheaf.api.JWFileChooserFilterType) // fileFilters elements
            .setAllowDirectoryCreation(boolean) // optional allowDirectoryCreation
            .setFileTimeFormatter(java.time.format.DateTimeFormatter) // optional fileTimeFormatter
            .setFileSizeFormatter(com.io7m.jwheatsheaf.api.JWFileSizeFormatterType) // optional fileSizeFormatter
            .setAction(com.io7m.jwheatsheaf.api.JWFileChooserAction) // optional action
            .build();
         
        Returns:
        A new JWFileChooserConfiguration builder