Package com.io7m.jwheatsheaf.api
Class JWFileChooserConfiguration
java.lang.Object
com.io7m.jwheatsheaf.api.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.-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classJWFileChooserConfiguration.BuilderBuilds instances of typeJWFileChooserConfiguration. -
Method Summary
Modifier and Type Method Description JWFileChooserActionaction()booleanallowDirectoryCreation()static JWFileChooserConfiguration.Builderbuilder()Creates a builder forJWFileChooserConfiguration.booleanconfirmFileSelection()If set totrue, then when the user is using a mode such asJWFileChooserAction.CREATE, a confirmation dialog will be displayed if the user selects a file that already exists.static JWFileChooserConfigurationcopyOf(JWFileChooserConfigurationType instance)Creates an immutable copy of aJWFileChooserConfigurationTypevalue.java.util.Optional<java.net.URL>cssStylesheet()The CSS stylesheet that will be added to the file chooser UI.booleanequals(java.lang.Object another)This instance is equal to all instances ofJWFileChooserConfigurationthat have equal attribute values.java.util.Optional<JWFileChooserFilterType>fileFilterDefault()java.util.List<JWFileChooserFilterType>fileFilters()java.util.Optional<JWFileImageSetType>fileImageSet()The image set used to select images for the file chooser UI.java.util.function.Function<java.nio.file.Path,java.lang.Boolean>fileSelectionMode()Sets a mode that prevents returning a file to the client if that file does not meet criteria returned by this method.JWFileSizeFormatterTypefileSizeFormatter()java.nio.file.FileSystemfileSystem()java.time.format.DateTimeFormatterfileTimeFormatter()inthashCode()Computes a hash code from attributes:recentFiles,fileSystem,initialDirectory,homeDirectory,initialFileName,title,fileImageSet,cssStylesheet,fileFilters,fileFilterDefault,fileSelectionMode,allowDirectoryCreation,showParentDirectory,fileTimeFormatter,fileSizeFormatter,action,confirmFileSelection,stringOverrides.java.util.Optional<java.nio.file.Path>homeDirectory()The directory to which the chooser will navigate when the user clicks the "home" button.java.util.Optional<java.nio.file.Path>initialDirectory()java.util.Optional<java.lang.String>initialFileName()java.util.List<java.nio.file.Path>recentFiles()booleanshowParentDirectory()Determine whether or not to show a link to the parent directory inside the file listing.JWFileChooserStringOverridesTypestringOverrides()java.util.Optional<java.lang.String>title()java.lang.StringtoString()Prints the immutable valueJWFileChooserConfigurationwith attribute values.JWFileChooserConfigurationwithAction(JWFileChooserAction value)Copy the current immutable object by setting a value for theactionattribute.JWFileChooserConfigurationwithAllowDirectoryCreation(boolean value)Copy the current immutable object by setting a value for theallowDirectoryCreationattribute.JWFileChooserConfigurationwithConfirmFileSelection(boolean value)Copy the current immutable object by setting a value for theconfirmFileSelectionattribute.JWFileChooserConfigurationwithCssStylesheet(java.net.URL value)Copy the current immutable object by setting a present value for the optionalcssStylesheetattribute.JWFileChooserConfigurationwithCssStylesheet(java.util.Optional<? extends java.net.URL> optional)Copy the current immutable object by setting an optional value for thecssStylesheetattribute.JWFileChooserConfigurationwithFileFilterDefault(JWFileChooserFilterType value)Copy the current immutable object by setting a present value for the optionalfileFilterDefaultattribute.JWFileChooserConfigurationwithFileFilterDefault(java.util.Optional<? extends JWFileChooserFilterType> optional)Copy the current immutable object by setting an optional value for thefileFilterDefaultattribute.JWFileChooserConfigurationwithFileFilters(JWFileChooserFilterType... elements)Copy the current immutable object with elements that replace the content offileFilters.JWFileChooserConfigurationwithFileFilters(java.lang.Iterable<? extends JWFileChooserFilterType> elements)Copy the current immutable object with elements that replace the content offileFilters.JWFileChooserConfigurationwithFileImageSet(JWFileImageSetType value)Copy the current immutable object by setting a present value for the optionalfileImageSetattribute.JWFileChooserConfigurationwithFileImageSet(java.util.Optional<? extends JWFileImageSetType> optional)Copy the current immutable object by setting an optional value for thefileImageSetattribute.JWFileChooserConfigurationwithFileSelectionMode(java.util.function.Function<java.nio.file.Path,java.lang.Boolean> value)Copy the current immutable object by setting a value for thefileSelectionModeattribute.JWFileChooserConfigurationwithFileSizeFormatter(JWFileSizeFormatterType value)Copy the current immutable object by setting a value for thefileSizeFormatterattribute.JWFileChooserConfigurationwithFileSystem(java.nio.file.FileSystem value)Copy the current immutable object by setting a value for thefileSystemattribute.JWFileChooserConfigurationwithFileTimeFormatter(java.time.format.DateTimeFormatter value)Copy the current immutable object by setting a value for thefileTimeFormatterattribute.JWFileChooserConfigurationwithHomeDirectory(java.nio.file.Path value)Copy the current immutable object by setting a present value for the optionalhomeDirectoryattribute.JWFileChooserConfigurationwithHomeDirectory(java.util.Optional<? extends java.nio.file.Path> optional)Copy the current immutable object by setting an optional value for thehomeDirectoryattribute.JWFileChooserConfigurationwithInitialDirectory(java.nio.file.Path value)Copy the current immutable object by setting a present value for the optionalinitialDirectoryattribute.JWFileChooserConfigurationwithInitialDirectory(java.util.Optional<? extends java.nio.file.Path> optional)Copy the current immutable object by setting an optional value for theinitialDirectoryattribute.JWFileChooserConfigurationwithInitialFileName(java.lang.String value)Copy the current immutable object by setting a present value for the optionalinitialFileNameattribute.JWFileChooserConfigurationwithInitialFileName(java.util.Optional<java.lang.String> optional)Copy the current immutable object by setting an optional value for theinitialFileNameattribute.JWFileChooserConfigurationwithRecentFiles(java.lang.Iterable<? extends java.nio.file.Path> elements)Copy the current immutable object with elements that replace the content ofrecentFiles.JWFileChooserConfigurationwithRecentFiles(java.nio.file.Path... elements)Copy the current immutable object with elements that replace the content ofrecentFiles.JWFileChooserConfigurationwithShowParentDirectory(boolean value)Copy the current immutable object by setting a value for theshowParentDirectoryattribute.JWFileChooserConfigurationwithStringOverrides(JWFileChooserStringOverridesType value)Copy the current immutable object by setting a value for thestringOverridesattribute.JWFileChooserConfigurationwithTitle(java.lang.String value)Copy the current immutable object by setting a present value for the optionaltitleattribute.JWFileChooserConfigurationwithTitle(java.util.Optional<java.lang.String> optional)Copy the current immutable object by setting an optional value for thetitleattribute.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.io7m.jwheatsheaf.api.JWFileChooserConfigurationType
checkPreconditions
-
Method Details
-
recentFiles
public java.util.List<java.nio.file.Path> recentFiles()- Specified by:
recentFilesin interfaceJWFileChooserConfigurationType- Returns:
- The list of recent files to be shown in the file chooser
-
fileSystem
public java.nio.file.FileSystem fileSystem()- Specified by:
fileSystemin interfaceJWFileChooserConfigurationType- Returns:
- The file system traversed by the file chooser
-
initialDirectory
public java.util.Optional<java.nio.file.Path> initialDirectory()- Specified by:
initialDirectoryin interfaceJWFileChooserConfigurationType- Returns:
- The starting directory
-
homeDirectory
public java.util.Optional<java.nio.file.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:
homeDirectoryin interfaceJWFileChooserConfigurationType- Returns:
- The user's home directory
-
initialFileName
public java.util.Optional<java.lang.String> initialFileName()- Specified by:
initialFileNamein interfaceJWFileChooserConfigurationType- Returns:
- The file name initially entered into the selection field
-
title
public java.util.Optional<java.lang.String> title()- Specified by:
titlein interfaceJWFileChooserConfigurationType- Returns:
- A string that will override the generic dialog title
-
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:
fileImageSetin interfaceJWFileChooserConfigurationType- 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:
cssStylesheetin interfaceJWFileChooserConfigurationType- Returns:
- The URL of the CSS stylesheet
-
fileFilters
- Specified by:
fileFiltersin interfaceJWFileChooserConfigurationType- Returns:
- The list of file filters
-
fileFilterDefault
- Specified by:
fileFilterDefaultin interfaceJWFileChooserConfigurationType- Returns:
- The default file filter
-
fileSelectionMode
public java.util.function.Function<java.nio.file.Path,java.lang.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 returnstruewhen the file is considered a regular file.- Specified by:
fileSelectionModein interfaceJWFileChooserConfigurationType- Returns:
- The
Functionthat accepts or rejects selected files
-
allowDirectoryCreation
public boolean allowDirectoryCreation()- Specified by:
allowDirectoryCreationin interfaceJWFileChooserConfigurationType- Returns:
trueif the UI will allow the creation of directories
-
showParentDirectory
public boolean showParentDirectory()Determine whether or not to show a link to the parent directory inside the file listing. This entry is always called "..".- Specified by:
showParentDirectoryin interfaceJWFileChooserConfigurationType- Returns:
trueif the directory listing will contain ".."- Since:
- 3.0.0
-
fileTimeFormatter
public java.time.format.DateTimeFormatter fileTimeFormatter()- Specified by:
fileTimeFormatterin interfaceJWFileChooserConfigurationType- Returns:
- The date/time formatter used to display file times
-
fileSizeFormatter
- Specified by:
fileSizeFormatterin interfaceJWFileChooserConfigurationType- Returns:
- The formatter used to display file sizes
-
action
- Specified by:
actionin interfaceJWFileChooserConfigurationType- Returns:
- The action that the user is performing
-
confirmFileSelection
public boolean confirmFileSelection()If set totrue, then when the user is using a mode such asJWFileChooserAction.CREATE, a confirmation dialog will be displayed if the user selects a file that already exists.- Specified by:
confirmFileSelectionin interfaceJWFileChooserConfigurationType- Returns:
trueif confirmation dialogs should be shown- Since:
- 3.0.0
-
stringOverrides
- Specified by:
stringOverridesin interfaceJWFileChooserConfigurationType- Returns:
- A provider of UI string overrides
- Since:
- 3.0.0
-
withRecentFiles
Copy the current immutable object with elements that replace the content ofrecentFiles.- Parameters:
elements- The elements to set- Returns:
- A modified copy of
thisobject
-
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 ofrecentFiles. A shallow reference equality check is used to prevent copying of the same value by returningthis.- Parameters:
elements- An iterable of recentFiles elements to set- Returns:
- A modified copy of
thisobject
-
withFileSystem
Copy the current immutable object by setting a value for thefileSystemattribute. A shallow reference equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for fileSystem- Returns:
- A modified copy of the
thisobject
-
withInitialDirectory
Copy the current immutable object by setting a present value for the optionalinitialDirectoryattribute.- Parameters:
value- The value for initialDirectory- Returns:
- A modified copy of
thisobject
-
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 theinitialDirectoryattribute. A shallow reference equality check is used on unboxed optional value to prevent copying of the same value by returningthis.- Parameters:
optional- A value for initialDirectory- Returns:
- A modified copy of
thisobject
-
withHomeDirectory
Copy the current immutable object by setting a present value for the optionalhomeDirectoryattribute.- Parameters:
value- The value for homeDirectory- Returns:
- A modified copy of
thisobject
-
withHomeDirectory
public final JWFileChooserConfiguration withHomeDirectory(java.util.Optional<? extends java.nio.file.Path> optional)Copy the current immutable object by setting an optional value for thehomeDirectoryattribute. A shallow reference equality check is used on unboxed optional value to prevent copying of the same value by returningthis.- Parameters:
optional- A value for homeDirectory- Returns:
- A modified copy of
thisobject
-
withInitialFileName
Copy the current immutable object by setting a present value for the optionalinitialFileNameattribute.- Parameters:
value- The value for initialFileName- Returns:
- A modified copy of
thisobject
-
withInitialFileName
public final JWFileChooserConfiguration withInitialFileName(java.util.Optional<java.lang.String> optional)Copy the current immutable object by setting an optional value for theinitialFileNameattribute. An equality check is used on inner nullable value to prevent copying of the same value by returningthis.- Parameters:
optional- A value for initialFileName- Returns:
- A modified copy of
thisobject
-
withTitle
Copy the current immutable object by setting a present value for the optionaltitleattribute.- Parameters:
value- The value for title- Returns:
- A modified copy of
thisobject
-
withTitle
Copy the current immutable object by setting an optional value for thetitleattribute. An equality check is used on inner nullable value to prevent copying of the same value by returningthis.- Parameters:
optional- A value for title- Returns:
- A modified copy of
thisobject
-
withFileImageSet
Copy the current immutable object by setting a present value for the optionalfileImageSetattribute.- Parameters:
value- The value for fileImageSet- Returns:
- A modified copy of
thisobject
-
withFileImageSet
public final JWFileChooserConfiguration withFileImageSet(java.util.Optional<? extends JWFileImageSetType> optional)Copy the current immutable object by setting an optional value for thefileImageSetattribute. A shallow reference equality check is used on unboxed optional value to prevent copying of the same value by returningthis.- Parameters:
optional- A value for fileImageSet- Returns:
- A modified copy of
thisobject
-
withCssStylesheet
Copy the current immutable object by setting a present value for the optionalcssStylesheetattribute.- Parameters:
value- The value for cssStylesheet- Returns:
- A modified copy of
thisobject
-
withCssStylesheet
public final JWFileChooserConfiguration withCssStylesheet(java.util.Optional<? extends java.net.URL> optional)Copy the current immutable object by setting an optional value for thecssStylesheetattribute. A shallow reference equality check is used on unboxed optional value to prevent copying of the same value by returningthis.- Parameters:
optional- A value for cssStylesheet- Returns:
- A modified copy of
thisobject
-
withFileFilters
Copy the current immutable object with elements that replace the content offileFilters.- Parameters:
elements- The elements to set- Returns:
- A modified copy of
thisobject
-
withFileFilters
public final JWFileChooserConfiguration withFileFilters(java.lang.Iterable<? extends JWFileChooserFilterType> elements)Copy the current immutable object with elements that replace the content offileFilters. A shallow reference equality check is used to prevent copying of the same value by returningthis.- Parameters:
elements- An iterable of fileFilters elements to set- Returns:
- A modified copy of
thisobject
-
withFileFilterDefault
Copy the current immutable object by setting a present value for the optionalfileFilterDefaultattribute.- Parameters:
value- The value for fileFilterDefault- Returns:
- A modified copy of
thisobject
-
withFileFilterDefault
public final JWFileChooserConfiguration withFileFilterDefault(java.util.Optional<? extends JWFileChooserFilterType> optional)Copy the current immutable object by setting an optional value for thefileFilterDefaultattribute. A shallow reference equality check is used on unboxed optional value to prevent copying of the same value by returningthis.- Parameters:
optional- A value for fileFilterDefault- Returns:
- A modified copy of
thisobject
-
withFileSelectionMode
public final JWFileChooserConfiguration withFileSelectionMode(java.util.function.Function<java.nio.file.Path,java.lang.Boolean> value)Copy the current immutable object by setting a value for thefileSelectionModeattribute. A shallow reference equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for fileSelectionMode- Returns:
- A modified copy of the
thisobject
-
withAllowDirectoryCreation
Copy the current immutable object by setting a value for theallowDirectoryCreationattribute. A value equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for allowDirectoryCreation- Returns:
- A modified copy of the
thisobject
-
withShowParentDirectory
Copy the current immutable object by setting a value for theshowParentDirectoryattribute. A value equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for showParentDirectory- Returns:
- A modified copy of the
thisobject
-
withFileTimeFormatter
public final JWFileChooserConfiguration withFileTimeFormatter(java.time.format.DateTimeFormatter value)Copy the current immutable object by setting a value for thefileTimeFormatterattribute. A shallow reference equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for fileTimeFormatter- Returns:
- A modified copy of the
thisobject
-
withFileSizeFormatter
Copy the current immutable object by setting a value for thefileSizeFormatterattribute. A shallow reference equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for fileSizeFormatter- Returns:
- A modified copy of the
thisobject
-
withAction
Copy the current immutable object by setting a value for theactionattribute. A value equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for action- Returns:
- A modified copy of the
thisobject
-
withConfirmFileSelection
Copy the current immutable object by setting a value for theconfirmFileSelectionattribute. A value equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for confirmFileSelection- Returns:
- A modified copy of the
thisobject
-
withStringOverrides
public final JWFileChooserConfiguration withStringOverrides(JWFileChooserStringOverridesType value)Copy the current immutable object by setting a value for thestringOverridesattribute. A shallow reference equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for stringOverrides- Returns:
- A modified copy of the
thisobject
-
equals
public boolean equals(java.lang.Object another)This instance is equal to all instances ofJWFileChooserConfigurationthat have equal attribute values.- Overrides:
equalsin classjava.lang.Object- Returns:
trueifthisis equal toanotherinstance
-
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.- Overrides:
hashCodein classjava.lang.Object- Returns:
- hashCode value
-
toString
public java.lang.String toString()Prints the immutable valueJWFileChooserConfigurationwith attribute values.- Overrides:
toStringin classjava.lang.Object- Returns:
- A string representation of the value
-
copyOf
Creates an immutable copy of aJWFileChooserConfigurationTypevalue. 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
Creates a builder forJWFileChooserConfiguration.JWFileChooserConfiguration.builder() .addRecentFiles|addAllRecentFiles(java.nio.file.Path) //recentFileselements .setFileSystem(java.nio.file.FileSystem) // optionalfileSystem.setInitialDirectory(java.nio.file.Path) // optionalinitialDirectory.setHomeDirectory(java.nio.file.Path) // optionalhomeDirectory.setInitialFileName(String) // optionalinitialFileName.setTitle(String) // optionaltitle.setFileImageSet(com.io7m.jwheatsheaf.api.JWFileImageSetType) // optionalfileImageSet.setCssStylesheet(java.net.URL) // optionalcssStylesheet.addFileFilters|addAllFileFilters(com.io7m.jwheatsheaf.api.JWFileChooserFilterType) //fileFilterselements .setFileFilterDefault(com.io7m.jwheatsheaf.api.JWFileChooserFilterType) // optionalfileFilterDefault.setFileSelectionMode(function.Function<java.nio.file.Path, Boolean>) // optionalfileSelectionMode.setAllowDirectoryCreation(boolean) // optionalallowDirectoryCreation.setShowParentDirectory(boolean) // optionalshowParentDirectory.setFileTimeFormatter(java.time.format.DateTimeFormatter) // optionalfileTimeFormatter.setFileSizeFormatter(com.io7m.jwheatsheaf.api.JWFileSizeFormatterType) // optionalfileSizeFormatter.setAction(com.io7m.jwheatsheaf.api.JWFileChooserAction) // optionalaction.setConfirmFileSelection(boolean) // optionalconfirmFileSelection.setStringOverrides(com.io7m.jwheatsheaf.api.JWFileChooserStringOverridesType) // optionalstringOverrides.build();- Returns:
- A new JWFileChooserConfiguration builder
-