A Spring service that provides a reusable and type-safe file chooser utility for selecting different kinds of files (e.g., images, audio).
More...
|
| Optional< File > | chooseFile (@Nullable Stage ownerStage, FileType type) |
| | Opens a FileChooser dialog for the specified file type.
|
| |
|
| static final Logger | LOG = LoggerFactory.getLogger(FileChooserService.class) |
| |
A Spring service that provides a reusable and type-safe file chooser utility for selecting different kinds of files (e.g., images, audio).
The service handles:
-
Configuring extension filters based on file type
-
Setting an initial directory (user home by default)
-
Gracefully handling errors and returning Optional.empty() if cancelled or failed
◆ chooseFile()
| Optional< File > fr.softsf.sudokufx.service.ui.FileChooserService.chooseFile |
( |
@Nullable Stage | ownerStage, |
|
|
FileType | type ) |
Opens a FileChooser dialog for the specified file type.
If the user selects a valid file, it is returned wrapped in an Optional. If the user cancels or an error occurs, Optional#empty() is returned.
- Parameters
-
| ownerStage | the parent Stage for the dialog; can be null, in which case the method returns Optional.empty() |
| type | the type of file to choose (IMAGE or AUDIO); must not be null |
- Returns
- an
Optional containing the selected file, or empty if cancelled or failed
- Exceptions
-
| NullPointerException | if type is null |
◆ getFilter()
| FileChooser.ExtensionFilter fr.softsf.sudokufx.service.ui.FileChooserService.getFilter |
( |
FileType | type | ) |
|
|
private |
Returns the appropriate FileChooser.ExtensionFilter for the given file type.
- Parameters
-
| type | the file type (IMAGE or AUDIO); must not be null |
- Returns
- a FileChooser.ExtensionFilter restricting files to the allowed extensions
- Exceptions
-
| NullPointerException | if type is null |
◆ LOG
| final Logger fr.softsf.sudokufx.service.ui.FileChooserService.LOG =
LoggerFactory.getLogger(FileChooserService.class) |
|
staticprivate |
The documentation for this class was generated from the following file: