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 class
JWFileChooserConfiguration.Builder
Builds instances of typeJWFileChooserConfiguration
. -
Method Summary
Modifier and Type Method Description JWFileChooserAction
action()
boolean
allowDirectoryCreation()
static JWFileChooserConfiguration.Builder
builder()
Creates a builder forJWFileChooserConfiguration
.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.static JWFileChooserConfiguration
copyOf(JWFileChooserConfigurationType instance)
Creates an immutable copy of aJWFileChooserConfigurationType
value.java.util.Optional<java.net.URL>
cssStylesheet()
The CSS stylesheet that will be added to the file chooser UI.boolean
equals(java.lang.Object another)
This instance is equal to all instances ofJWFileChooserConfiguration
that 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.JWFileSizeFormatterType
fileSizeFormatter()
java.nio.file.FileSystem
fileSystem()
java.time.format.DateTimeFormatter
fileTimeFormatter()
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
.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()
boolean
showParentDirectory()
Determine whether or not to show a link to the parent directory inside the file listing.JWFileChooserStringOverridesType
stringOverrides()
java.util.Optional<java.lang.String>
title()
java.lang.String
toString()
Prints the immutable valueJWFileChooserConfiguration
with attribute values.JWFileChooserConfiguration
withAction(JWFileChooserAction value)
Copy the current immutable object by setting a value for theaction
attribute.JWFileChooserConfiguration
withAllowDirectoryCreation(boolean value)
Copy the current immutable object by setting a value for theallowDirectoryCreation
attribute.JWFileChooserConfiguration
withConfirmFileSelection(boolean value)
Copy the current immutable object by setting a value for theconfirmFileSelection
attribute.JWFileChooserConfiguration
withCssStylesheet(java.net.URL value)
Copy the current immutable object by setting a present value for the optionalcssStylesheet
attribute.JWFileChooserConfiguration
withCssStylesheet(java.util.Optional<? extends java.net.URL> optional)
Copy the current immutable object by setting an optional value for thecssStylesheet
attribute.JWFileChooserConfiguration
withFileFilterDefault(JWFileChooserFilterType value)
Copy the current immutable object by setting a present value for the optionalfileFilterDefault
attribute.JWFileChooserConfiguration
withFileFilterDefault(java.util.Optional<? extends JWFileChooserFilterType> optional)
Copy the current immutable object by setting an optional value for thefileFilterDefault
attribute.JWFileChooserConfiguration
withFileFilters(JWFileChooserFilterType... elements)
Copy the current immutable object with elements that replace the content offileFilters
.JWFileChooserConfiguration
withFileFilters(java.lang.Iterable<? extends JWFileChooserFilterType> elements)
Copy the current immutable object with elements that replace the content offileFilters
.JWFileChooserConfiguration
withFileImageSet(JWFileImageSetType value)
Copy the current immutable object by setting a present value for the optionalfileImageSet
attribute.JWFileChooserConfiguration
withFileImageSet(java.util.Optional<? extends JWFileImageSetType> optional)
Copy the current immutable object by setting an optional value for thefileImageSet
attribute.JWFileChooserConfiguration
withFileSelectionMode(java.util.function.Function<java.nio.file.Path,java.lang.Boolean> value)
Copy the current immutable object by setting a value for thefileSelectionMode
attribute.JWFileChooserConfiguration
withFileSizeFormatter(JWFileSizeFormatterType value)
Copy the current immutable object by setting a value for thefileSizeFormatter
attribute.JWFileChooserConfiguration
withFileSystem(java.nio.file.FileSystem value)
Copy the current immutable object by setting a value for thefileSystem
attribute.JWFileChooserConfiguration
withFileTimeFormatter(java.time.format.DateTimeFormatter value)
Copy the current immutable object by setting a value for thefileTimeFormatter
attribute.JWFileChooserConfiguration
withHomeDirectory(java.nio.file.Path value)
Copy the current immutable object by setting a present value for the optionalhomeDirectory
attribute.JWFileChooserConfiguration
withHomeDirectory(java.util.Optional<? extends java.nio.file.Path> optional)
Copy the current immutable object by setting an optional value for thehomeDirectory
attribute.JWFileChooserConfiguration
withInitialDirectory(java.nio.file.Path value)
Copy the current immutable object by setting a present value for the optionalinitialDirectory
attribute.JWFileChooserConfiguration
withInitialDirectory(java.util.Optional<? extends java.nio.file.Path> optional)
Copy the current immutable object by setting an optional value for theinitialDirectory
attribute.JWFileChooserConfiguration
withInitialFileName(java.lang.String value)
Copy the current immutable object by setting a present value for the optionalinitialFileName
attribute.JWFileChooserConfiguration
withInitialFileName(java.util.Optional<java.lang.String> optional)
Copy the current immutable object by setting an optional value for theinitialFileName
attribute.JWFileChooserConfiguration
withRecentFiles(java.lang.Iterable<? extends java.nio.file.Path> elements)
Copy the current immutable object with elements that replace the content ofrecentFiles
.JWFileChooserConfiguration
withRecentFiles(java.nio.file.Path... elements)
Copy the current immutable object with elements that replace the content ofrecentFiles
.JWFileChooserConfiguration
withShowParentDirectory(boolean value)
Copy the current immutable object by setting a value for theshowParentDirectory
attribute.JWFileChooserConfiguration
withStringOverrides(JWFileChooserStringOverridesType value)
Copy the current immutable object by setting a value for thestringOverrides
attribute.JWFileChooserConfiguration
withTitle(java.lang.String value)
Copy the current immutable object by setting a present value for the optionaltitle
attribute.JWFileChooserConfiguration
withTitle(java.util.Optional<java.lang.String> optional)
Copy the current immutable object by setting an optional value for thetitle
attribute.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.io7m.jwheatsheaf.api.JWFileChooserConfigurationType
checkPreconditions
-
Method Details
-
recentFiles
public java.util.List<java.nio.file.Path> recentFiles()- Specified by:
recentFiles
in interfaceJWFileChooserConfigurationType
- Returns:
- The list of recent files to be shown in the file chooser
-
fileSystem
public java.nio.file.FileSystem fileSystem()- Specified by:
fileSystem
in interfaceJWFileChooserConfigurationType
- Returns:
- The file system traversed by the file chooser
-
initialDirectory
public java.util.Optional<java.nio.file.Path> initialDirectory()- Specified by:
initialDirectory
in 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:
homeDirectory
in interfaceJWFileChooserConfigurationType
- Returns:
- The user's home directory
-
initialFileName
public java.util.Optional<java.lang.String> initialFileName()- Specified by:
initialFileName
in interfaceJWFileChooserConfigurationType
- Returns:
- The file name initially entered into the selection field
-
title
public java.util.Optional<java.lang.String> title()- Specified by:
title
in 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:
fileImageSet
in 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:
cssStylesheet
in interfaceJWFileChooserConfigurationType
- Returns:
- The URL of the CSS stylesheet
-
fileFilters
- Specified by:
fileFilters
in interfaceJWFileChooserConfigurationType
- Returns:
- The list of file filters
-
fileFilterDefault
- Specified by:
fileFilterDefault
in 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 returnstrue
when the file is considered a regular file.- Specified by:
fileSelectionMode
in interfaceJWFileChooserConfigurationType
- Returns:
- The
Function
that accepts or rejects selected files
-
allowDirectoryCreation
public boolean allowDirectoryCreation()- Specified by:
allowDirectoryCreation
in interfaceJWFileChooserConfigurationType
- Returns:
true
if 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:
showParentDirectory
in interfaceJWFileChooserConfigurationType
- Returns:
true
if the directory listing will contain ".."- Since:
- 3.0.0
-
fileTimeFormatter
public java.time.format.DateTimeFormatter fileTimeFormatter()- Specified by:
fileTimeFormatter
in interfaceJWFileChooserConfigurationType
- Returns:
- The date/time formatter used to display file times
-
fileSizeFormatter
- Specified by:
fileSizeFormatter
in interfaceJWFileChooserConfigurationType
- Returns:
- The formatter used to display file sizes
-
action
- Specified by:
action
in 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:
confirmFileSelection
in interfaceJWFileChooserConfigurationType
- Returns:
true
if confirmation dialogs should be shown- Since:
- 3.0.0
-
stringOverrides
- Specified by:
stringOverrides
in 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
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 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
this
object
-
withFileSystem
Copy the current immutable object by setting a value for thefileSystem
attribute. 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
this
object
-
withInitialDirectory
Copy the current immutable object by setting a present value for the optionalinitialDirectory
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 theinitialDirectory
attribute. 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
this
object
-
withHomeDirectory
Copy the current immutable object by setting a present value for the optionalhomeDirectory
attribute.- Parameters:
value
- The value for homeDirectory- Returns:
- A modified copy of
this
object
-
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 thehomeDirectory
attribute. 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
this
object
-
withInitialFileName
Copy the current immutable object by setting a present value for the optionalinitialFileName
attribute.- Parameters:
value
- The value for initialFileName- Returns:
- A modified copy of
this
object
-
withInitialFileName
public final JWFileChooserConfiguration withInitialFileName(java.util.Optional<java.lang.String> optional)Copy the current immutable object by setting an optional value for theinitialFileName
attribute. 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
this
object
-
withTitle
Copy the current immutable object by setting a present value for the optionaltitle
attribute.- Parameters:
value
- The value for title- Returns:
- A modified copy of
this
object
-
withTitle
Copy the current immutable object by setting an optional value for thetitle
attribute. 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
this
object
-
withFileImageSet
Copy the current immutable object by setting a present value for the optionalfileImageSet
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 thefileImageSet
attribute. 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
this
object
-
withCssStylesheet
Copy the current immutable object by setting a present value for the optionalcssStylesheet
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 thecssStylesheet
attribute. 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
this
object
-
withFileFilters
Copy the current immutable object with elements that replace the content offileFilters
.- Parameters:
elements
- The elements to set- 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 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
this
object
-
withFileFilterDefault
Copy the current immutable object by setting a present value for the optionalfileFilterDefault
attribute.- Parameters:
value
- The value for fileFilterDefault- Returns:
- A modified copy of
this
object
-
withFileFilterDefault
public final JWFileChooserConfiguration withFileFilterDefault(java.util.Optional<? extends JWFileChooserFilterType> optional)Copy the current immutable object by setting an optional value for thefileFilterDefault
attribute. 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
this
object
-
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 thefileSelectionMode
attribute. 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
this
object
-
withAllowDirectoryCreation
Copy the current immutable object by setting a value for theallowDirectoryCreation
attribute. 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
this
object
-
withShowParentDirectory
Copy the current immutable object by setting a value for theshowParentDirectory
attribute. 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
this
object
-
withFileTimeFormatter
public final JWFileChooserConfiguration withFileTimeFormatter(java.time.format.DateTimeFormatter value)Copy the current immutable object by setting a value for thefileTimeFormatter
attribute. 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
this
object
-
withFileSizeFormatter
Copy the current immutable object by setting a value for thefileSizeFormatter
attribute. 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
this
object
-
withAction
Copy the current immutable object by setting a value for theaction
attribute. 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
this
object
-
withConfirmFileSelection
Copy the current immutable object by setting a value for theconfirmFileSelection
attribute. 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
this
object
-
withStringOverrides
public final JWFileChooserConfiguration withStringOverrides(JWFileChooserStringOverridesType value)Copy the current immutable object by setting a value for thestringOverrides
attribute. 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
this
object
-
equals
public boolean equals(java.lang.Object another)This instance is equal to all instances ofJWFileChooserConfiguration
that have equal attribute values.- Overrides:
equals
in classjava.lang.Object
- Returns:
true
ifthis
is equal toanother
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
.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- hashCode value
-
toString
public java.lang.String toString()Prints the immutable valueJWFileChooserConfiguration
with attribute values.- Overrides:
toString
in classjava.lang.Object
- Returns:
- A string representation of the value
-
copyOf
Creates an immutable copy of aJWFileChooserConfigurationType
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
Creates a builder forJWFileChooserConfiguration
.JWFileChooserConfiguration.builder() .addRecentFiles|addAllRecentFiles(java.nio.file.Path) //
recentFiles
elements .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) //fileFilters
elements .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
-