Package com.io7m.jwheatsheaf.api
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.-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
Builds instances of typeJWFileChooserConfiguration
. -
Method Summary
Modifier and TypeMethodDescriptionaction()
boolean
builder()
Creates a builder forJWFileChooserConfiguration
.boolean
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.The CSS stylesheet that will be added to the file chooser UI.boolean
This instance is equal to all instances ofJWFileChooserConfiguration
that have equal attribute values.The image set used to select images for the file chooser UI.Sets a mode that prevents returning a file to the client if that file does not meet criteria returned by this method.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
.The directory to which the chooser will navigate when the user clicks the "home" button.javafx.stage.Modality
modality()
boolean
Determine whether to show a link to the parent directory inside the file listing.title()
toString()
Prints the immutable valueJWFileChooserConfiguration
with attribute values.withAction
(JWFileChooserAction value) Copy the current immutable object by setting a value for theaction
attribute.withAllowDirectoryCreation
(boolean value) Copy the current immutable object by setting a value for theallowDirectoryCreation
attribute.withConfirmFileSelection
(boolean value) Copy the current immutable object by setting a value for theconfirmFileSelection
attribute.withCssStylesheet
(URL value) Copy the current immutable object by setting a present value for the optionalcssStylesheet
attribute.withCssStylesheet
(Optional<? extends URL> optional) Copy the current immutable object by setting an optional value for thecssStylesheet
attribute.Copy the current immutable object by setting a present value for the optionalfileFilterDefault
attribute.withFileFilterDefault
(Optional<? extends JWFileChooserFilterType> optional) Copy the current immutable object by setting an optional value for thefileFilterDefault
attribute.withFileFilters
(JWFileChooserFilterType... elements) Copy the current immutable object with elements that replace the content offileFilters
.withFileFilters
(Iterable<? extends JWFileChooserFilterType> elements) Copy the current immutable object with elements that replace the content offileFilters
.Copy the current immutable object by setting a present value for the optionalfileImageSet
attribute.withFileImageSet
(Optional<? extends JWFileImageSetType> optional) Copy the current immutable object by setting an optional value for thefileImageSet
attribute.withFileSelectionMode
(Function<Path, Boolean> value) Copy the current immutable object by setting a value for thefileSelectionMode
attribute.Copy the current immutable object by setting a value for thefileSizeFormatter
attribute.withFileSystem
(FileSystem value) Copy the current immutable object by setting a value for thefileSystem
attribute.Copy the current immutable object by setting a value for thefileTimeFormatter
attribute.withHomeDirectory
(Path value) Copy the current immutable object by setting a present value for the optionalhomeDirectory
attribute.withHomeDirectory
(Optional<? extends Path> optional) Copy the current immutable object by setting an optional value for thehomeDirectory
attribute.withInitialDirectory
(Path value) Copy the current immutable object by setting a present value for the optionalinitialDirectory
attribute.withInitialDirectory
(Optional<? extends Path> optional) Copy the current immutable object by setting an optional value for theinitialDirectory
attribute.withInitialFileName
(String value) Copy the current immutable object by setting a present value for the optionalinitialFileName
attribute.withInitialFileName
(Optional<String> optional) Copy the current immutable object by setting an optional value for theinitialFileName
attribute.withModality
(javafx.stage.Modality value) Copy the current immutable object by setting a value for themodality
attribute.withRecentFiles
(Iterable<? extends Path> elements) Copy the current immutable object with elements that replace the content ofrecentFiles
.withRecentFiles
(Path... elements) Copy the current immutable object with elements that replace the content ofrecentFiles
.withShowParentDirectory
(boolean value) Copy the current immutable object by setting a value for theshowParentDirectory
attribute.Copy the current immutable object by setting a value for thestringOverrides
attribute.Copy the current immutable object by setting a present value for the optionaltitle
attribute.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
- Specified by:
recentFiles
in interfaceJWFileChooserConfigurationType
- Returns:
- The list of recent files to be shown in the file chooser
-
fileSystem
- Specified by:
fileSystem
in interfaceJWFileChooserConfigurationType
- Returns:
- The file system traversed by the file chooser
-
initialDirectory
- Specified by:
initialDirectory
in interfaceJWFileChooserConfigurationType
- Returns:
- The starting directory
-
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
- Specified by:
initialFileName
in interfaceJWFileChooserConfigurationType
- Returns:
- The file name initially entered into the selection field
-
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
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
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 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
- 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
-
modality
public javafx.stage.Modality modality()- Specified by:
modality
in interfaceJWFileChooserConfigurationType
- Returns:
- The modality that will be used for file choosers
- Since:
- 4.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
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
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
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
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(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
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(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(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
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
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
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
-
withModality
Copy the current immutable object by setting a value for themodality
attribute. A value equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for modality- Returns:
- A modified copy of the
this
object
-
equals
This instance is equal to all instances ofJWFileChooserConfiguration
that have equal attribute values. -
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
. -
toString
Prints the immutable valueJWFileChooserConfiguration
with attribute values. -
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
.setModality(javafx.stage.Modality) // optionalmodality
.build();- Returns:
- A new JWFileChooserConfiguration builder
-