Coordinator is a Spring-managed component handling navigation and UI logic in a JavaFX application (MVVM-C pattern).
More...
|
| void | updatePlayerLanguage (String iso) |
| | Updates the current player's language and refreshes the player state.
|
| |
|
| static final Logger | LOG = LoggerFactory.getLogger(Coordinator.class) |
| |
Coordinator is a Spring-managed component handling navigation and UI logic in a JavaFX application (MVVM-C pattern).
Key responsibilities:
-
Load FXML views and set them as the scene root with Spring-managed controllers.
-
Switch scenes and manage dynamic font resizing.
-
Manage player's language and provide host system integrations (URLs, local files).
◆ Coordinator()
| fr.softsf.sudokufx.navigation.Coordinator.Coordinator |
( |
FXMLLoader | fxmlLoader | ) |
|
Creates a Coordinator with the given non-null FXMLLoader.
- Parameters
-
| fxmlLoader | shared FXML loader |
- Exceptions
-
| IllegalArgumentException | if null |
◆ exitPlatform()
| void fr.softsf.sudokufx.navigation.Coordinator.exitPlatform |
( |
| ) |
|
|
package |
Package-private method to exit the JavaFX platform.
Overridable in tests to avoid actual exit and allow exception handling verification.
◆ getCurrentPlayerLanguageIso()
| String fr.softsf.sudokufx.navigation.Coordinator.getCurrentPlayerLanguageIso |
( |
| ) |
|
Returns the ISO code of the current player's language.
Use this value to initialize the application's locale at startup.
- Returns
- the current player's language ISO code, e.g., "FR" or "EN"
◆ getDefaultScene()
| Scene fr.softsf.sudokufx.navigation.Coordinator.getDefaultScene |
( |
| ) |
|
Returns the JavaFX default scene managed by this coordinator.
- Returns
- the current default scene
◆ openGitHubRepositoryReleaseUrl()
| void fr.softsf.sudokufx.navigation.Coordinator.openGitHubRepositoryReleaseUrl |
( |
| ) |
|
Opens the GitHub repository releases page in the user's default web browser.
◆ openLocalFile()
| void fr.softsf.sudokufx.navigation.Coordinator.openLocalFile |
( |
File | file | ) |
|
Opens the given local file in the user's default web browser.
◆ openMyWebsiteUrl()
| void fr.softsf.sudokufx.navigation.Coordinator.openMyWebsiteUrl |
( |
| ) |
|
Opens my website's page in the user's default web browser.
◆ setDefaultScene()
| void fr.softsf.sudokufx.navigation.Coordinator.setDefaultScene |
( |
Scene | scene | ) |
|
Sets the default JavaFX scene.
- Parameters
-
- Exceptions
-
| IllegalArgumentException | if null |
◆ setDynamicFontSize()
| void fr.softsf.sudokufx.navigation.Coordinator.setDynamicFontSize |
( |
DynamicFontSize | dynamicFontSize | ) |
|
Sets the dynamic font resizing utility.
- Parameters
-
| dynamicFontSize | non-null font size updater |
- Exceptions
-
| IllegalArgumentException | if null |
◆ setHostServices()
| void fr.softsf.sudokufx.navigation.Coordinator.setHostServices |
( |
HostServices | hostServices | ) |
|
Injects the non-null HostServices instance provided by the JavaFX application.
- Parameters
-
| hostServices | the non-null HostServices instance |
- Exceptions
-
| IllegalArgumentException | if hostServices is null |
◆ setPlayerLanguageService()
◆ setPlayerService()
| void fr.softsf.sudokufx.navigation.Coordinator.setPlayerService |
( |
PlayerService | playerService | ) |
|
|
package |
◆ setPlayerStateHolder()
| void fr.softsf.sudokufx.navigation.Coordinator.setPlayerStateHolder |
( |
PlayerStateHolder | holder | ) |
|
|
package |
◆ setRootByFXMLName()
| public< T > T fr.softsf.sudokufx.navigation.Coordinator.setRootByFXMLName |
( |
final String | fxml | ) |
|
|
package |
Loads the specified FXML file, sets it as the root of the current JavaFX scene, and returns its controller.
This method uses FXMLLoader together with Spring's ApplicationContext to instantiate the controller and inject Spring-managed beans if the context is available.
Important: If the Spring application context is not yet initialized, or if a bean failed to initialize, the applicationContext field will be null. In that case, the controller is instantiated by FXMLLoader alone, without Spring injection. This prevents a NullPointerException when calling
applicationContext.getBean(...).
If dynamicFontSize is set, font sizes are updated after loading.
Any exception during loading (e.g., FXML not found, controller instantiation failure) is logged. The application is terminated via Platform#exit() in case of critical errors.
- Parameters
-
| <T> | the controller type |
| fxml | the FXML filename; must not be null or blank |
- Returns
- the controller instance, or
null if loading fails or Spring context is unavailable
- Exceptions
-
| IllegalArgumentException | if fxml is null or blank |
◆ setToasterService()
| void fr.softsf.sudokufx.navigation.Coordinator.setToasterService |
( |
ToasterService | toasterService | ) |
|
|
package |
◆ toggleLanguage()
| void fr.softsf.sudokufx.navigation.Coordinator.toggleLanguage |
( |
| ) |
|
Toggles the application's language between French ("FR") and English ("EN").
Updates the current player's language, refreshes the player state, and switches the translation bundle. Exceptions from updating the player are caught, logged, and displayed as a toast notification via the ToasterService.
This method no longer requires an explicit ToasterVBox parameter since error handling is delegated to the injected ToasterService.
- See also
- ToasterService.showError(String, String)
◆ updatePlayerLanguage()
| void fr.softsf.sudokufx.navigation.Coordinator.updatePlayerLanguage |
( |
String | iso | ) |
|
|
private |
Updates the current player's language and refreshes the player state.
Called internally by toggleLanguage(). May throw exceptions if the language does not exist or the player update fails.
- Parameters
-
| iso | the ISO code of the target language ("FR" or "EN") |
- Exceptions
-
| IllegalArgumentException | if iso is null or blank |
| RuntimeException | if updating the player fails |
◆ applicationContext
| ApplicationContext fr.softsf.sudokufx.navigation.Coordinator.applicationContext |
|
private |
◆ defaultScene
| Scene fr.softsf.sudokufx.navigation.Coordinator.defaultScene |
|
private |
The main JavaFX scene managed by this coordinator.
◆ dynamicFontSize
Utility for responsive font resizing based on scene dimensions.
◆ fxmlLoader
| final FXMLLoader fr.softsf.sudokufx.navigation.Coordinator.fxmlLoader |
|
private |
Shared FXMLLoader for FXML view loading and controller injection.
◆ hostServices
| HostServices fr.softsf.sudokufx.navigation.Coordinator.hostServices |
|
private |
Provides access to system-level features like opening URLs in a browser.
◆ LOG
| final Logger fr.softsf.sudokufx.navigation.Coordinator.LOG = LoggerFactory.getLogger(Coordinator.class) |
|
staticprivate |
◆ playerLanguageService
◆ playerService
| PlayerService fr.softsf.sudokufx.navigation.Coordinator.playerService |
|
private |
◆ playerStateHolder
◆ toasterService
| ToasterService fr.softsf.sudokufx.navigation.Coordinator.toasterService |
|
private |
The documentation for this class was generated from the following file: