Package com.dua3.utility.fx.controls
Class FileInputBuilder
java.lang.Object
com.dua3.utility.fx.controls.FileInputBuilder
Builder for creating instances of
FileInput
with customizable options.
The builder provides methods to configure the file dialog mode, initial path,
extension filters, validation, and disabled state.-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Builds aFileInput
object using the properties specified in theFileInputBuilder
.Sets the 'disabled' property for the FileInput control.existingOnly
(boolean flag) Sets the flag indicating whether only existing files or directories should be selectable.filter
(javafx.stage.FileChooser.ExtensionFilter... filter) Adds the specified file extension filters to the FileChooser.initialPath
(@Nullable Path initialPath) Sets the initial path for the file input.initialPath
(Supplier<Path> initialPath) Sets the initial path for the FileInputBuilder using the providedSupplier<Path>
.Sets the validation function for the file input.
-
Method Details
-
disabled
Sets the 'disabled' property for the FileInput control.- Parameters:
disabled
- an ObservableValue object representing the disabled state of the FileInput control- Returns:
- the current instance of FileInputBuilder with the 'disabled' property set
-
validate
Sets the validation function for the file input.- Parameters:
validate
- a function that takes a Path and returns an Optional containing an error message if validation fails, or an empty Optional if validation succeeds- Returns:
- the updated FileInputBuilder instance
-
initialPath
Sets the initial path for the file input.- Parameters:
initialPath
- the initial path to set, which may be null- Returns:
- an instance of FileInputBuilder with the specified initial path
-
initialPath
Sets the initial path for the FileInputBuilder using the providedSupplier<Path>
.- Parameters:
initialPath
- a Supplier that provides the initial Path- Returns:
- the FileInputBuilder instance with the updated initial path
-
filter
Adds the specified file extension filters to the FileChooser.- Parameters:
filter
- One or more FileChooser.ExtensionFilter objects representing the file extension filters to be added.- Returns:
- The current instance of FileInputBuilder, allowing for method chaining.
-
existingOnly
Sets the flag indicating whether only existing files or directories should be selectable.- Parameters:
flag
- a boolean flag; if true, only existing files or directories can be selected, otherwise new ones can also be selected- Returns:
- the current instance of FileInputBuilder for method chaining
-
build
Builds aFileInput
object using the properties specified in theFileInputBuilder
.- Returns:
- a constructed
FileInput
control based on the current configuration.
-