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 thefileSystem(), 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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description JWFileChooserActionaction()booleanallowDirectoryCreation()static JWFileChooserConfiguration.Builderbuilder()Creates a builder forJWFileChooserConfiguration.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.List<JWFileChooserFilterType>fileFilters()java.util.Optional<JWFileImageSetType>fileImageSet()The image set used to select images for the file chooser UI.JWFileSizeFormatterTypefileSizeFormatter()java.nio.file.FileSystemfileSystem()java.time.format.DateTimeFormatterfileTimeFormatter()inthashCode()Computes a hash code from attributes:recentFiles,fileSystem,initialDirectory,fileImageSet,cssStylesheet,fileFilters,allowDirectoryCreation,fileTimeFormatter,fileSizeFormatter,action.java.util.Optional<java.nio.file.Path>initialDirectory()java.util.List<java.nio.file.Path>recentFiles()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.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.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.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.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.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.-
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 Detail
-
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
-
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:
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
public java.util.List<JWFileChooserFilterType> fileFilters()
- Specified by:
fileFiltersin interfaceJWFileChooserConfigurationType- Returns:
- The list of file filters
-
allowDirectoryCreation
public boolean allowDirectoryCreation()
- Specified by:
allowDirectoryCreationin interfaceJWFileChooserConfigurationType- Returns:
trueif the UI will allow the creation of directories
-
fileTimeFormatter
public java.time.format.DateTimeFormatter fileTimeFormatter()
- Specified by:
fileTimeFormatterin interfaceJWFileChooserConfigurationType- Returns:
- The date/time formatter used to display file times
-
fileSizeFormatter
public JWFileSizeFormatterType fileSizeFormatter()
- Specified by:
fileSizeFormatterin interfaceJWFileChooserConfigurationType- Returns:
- The formatter used to display file sizes
-
action
public JWFileChooserAction action()
- Specified by:
actionin interfaceJWFileChooserConfigurationType- Returns:
- The action that the user is performing
-
withRecentFiles
public final JWFileChooserConfiguration withRecentFiles(java.nio.file.Path... elements)
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
public final JWFileChooserConfiguration withFileSystem(java.nio.file.FileSystem value)
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
public final JWFileChooserConfiguration withInitialDirectory(java.nio.file.Path value)
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
-
withFileImageSet
public final JWFileChooserConfiguration withFileImageSet(JWFileImageSetType value)
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
public final JWFileChooserConfiguration withCssStylesheet(java.net.URL value)
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
public final JWFileChooserConfiguration withFileFilters(JWFileChooserFilterType... elements)
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
-
withAllowDirectoryCreation
public final JWFileChooserConfiguration withAllowDirectoryCreation(boolean value)
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
-
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
public final JWFileChooserConfiguration withFileSizeFormatter(JWFileSizeFormatterType value)
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
public final JWFileChooserConfiguration withAction(JWFileChooserAction value)
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
-
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,fileImageSet,cssStylesheet,fileFilters,allowDirectoryCreation,fileTimeFormatter,fileSizeFormatter,action.- 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
public static JWFileChooserConfiguration copyOf(JWFileChooserConfigurationType instance)
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
public static JWFileChooserConfiguration.Builder builder()
Creates a builder forJWFileChooserConfiguration.JWFileChooserConfiguration.builder() .addRecentFiles|addAllRecentFiles(java.nio.file.Path) //recentFileselements .setFileSystem(java.nio.file.FileSystem) // requiredfileSystem.setInitialDirectory(java.nio.file.Path) // optionalinitialDirectory.setFileImageSet(com.io7m.jwheatsheaf.api.JWFileImageSetType) // optionalfileImageSet.setCssStylesheet(java.net.URL) // optionalcssStylesheet.addFileFilters|addAllFileFilters(com.io7m.jwheatsheaf.api.JWFileChooserFilterType) //fileFilterselements .setAllowDirectoryCreation(boolean) // optionalallowDirectoryCreation.setFileTimeFormatter(java.time.format.DateTimeFormatter) // optionalfileTimeFormatter.setFileSizeFormatter(com.io7m.jwheatsheaf.api.JWFileSizeFormatterType) // optionalfileSizeFormatter.setAction(com.io7m.jwheatsheaf.api.JWFileChooserAction) // optionalaction.build();- Returns:
- A new JWFileChooserConfiguration builder
-
-