SudokuFX
Loading...
Searching...
No Matches
fr.softsf.sudokufx.navigation.Coordinator Class Reference

Coordinator is a Spring-managed component handling navigation and UI logic in a JavaFX application (MVVM-C pattern). More...

+ Collaboration diagram for fr.softsf.sudokufx.navigation.Coordinator:

Public Member Functions

 Coordinator (FXMLLoader fxmlLoader)
 Creates a Coordinator with the given non-null FXMLLoader.
 
String getCurrentPlayerLanguageIso ()
 Returns the ISO code of the current player's language.
 
Scene getDefaultScene ()
 Returns the JavaFX default scene managed by this coordinator.
 
void openGitHubRepositoryReleaseUrl ()
 Opens the GitHub repository releases page in the user's default web browser.
 
void openLocalFile (File file)
 Opens the given local file in the user's default web browser.
 
void openMyWebsiteUrl ()
 Opens my website's page in the user's default web browser.
 
void setDefaultScene (Scene scene)
 Sets the default JavaFX scene.
 
void setDynamicFontSize (DynamicFontSize dynamicFontSize)
 Sets the dynamic font resizing utility.
 
void setHostServices (HostServices hostServices)
 Injects the non-null HostServices instance provided by the JavaFX application.
 
void toggleLanguage ()
 Toggles the application's language between French ("FR") and English ("EN").
 

Package Functions

void exitPlatform ()
 Package-private method to exit the JavaFX platform.
 
void setPlayerLanguageService (PlayerLanguageService service)
 For testing only: injects a PlayerLanguageService.
 
void setPlayerService (PlayerService playerService)
 For testing only: injects a PlayerService.
 
void setPlayerStateHolder (PlayerStateHolder holder)
 For testing only: injects a PlayerStateHolder.
 
public< T > T setRootByFXMLName (final String fxml)
 Loads the specified FXML file, sets it as the root of the current JavaFX scene, and returns its controller.
 
void setToasterService (ToasterService toasterService)
 For testing only: injects a ToasterService.
 

Private Member Functions

void updatePlayerLanguage (String iso)
 Updates the current player's language and refreshes the player state.
 

Private Attributes

ApplicationContext applicationContext
 
Scene defaultScene
 The main JavaFX scene managed by this coordinator.
 
DynamicFontSize dynamicFontSize
 Utility for responsive font resizing based on scene dimensions.
 
final FXMLLoader fxmlLoader
 Shared FXMLLoader for FXML view loading and controller injection.
 
HostServices hostServices
 Provides access to system-level features like opening URLs in a browser.
 
PlayerLanguageService playerLanguageService
 
PlayerService playerService
 
PlayerStateHolder playerStateHolder
 
ToasterService toasterService
 

Static Private Attributes

static final Logger LOG = LoggerFactory.getLogger(Coordinator.class)
 

Detailed Description

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).

Constructor & Destructor Documentation

◆ Coordinator()

fr.softsf.sudokufx.navigation.Coordinator.Coordinator ( FXMLLoader fxmlLoader)

Creates a Coordinator with the given non-null FXMLLoader.

Parameters
fxmlLoadershared FXML loader
Exceptions
IllegalArgumentExceptionif null

Member Function Documentation

◆ 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
scenenon-null scene
Exceptions
IllegalArgumentExceptionif null

◆ setDynamicFontSize()

void fr.softsf.sudokufx.navigation.Coordinator.setDynamicFontSize ( DynamicFontSize dynamicFontSize)

Sets the dynamic font resizing utility.

Parameters
dynamicFontSizenon-null font size updater
Exceptions
IllegalArgumentExceptionif null

◆ setHostServices()

void fr.softsf.sudokufx.navigation.Coordinator.setHostServices ( HostServices hostServices)

Injects the non-null HostServices instance provided by the JavaFX application.

Parameters
hostServicesthe non-null HostServices instance
Exceptions
IllegalArgumentExceptionif hostServices is null

◆ setPlayerLanguageService()

void fr.softsf.sudokufx.navigation.Coordinator.setPlayerLanguageService ( PlayerLanguageService service)
package

For testing only: injects a PlayerLanguageService.

◆ setPlayerService()

void fr.softsf.sudokufx.navigation.Coordinator.setPlayerService ( PlayerService playerService)
package

For testing only: injects a PlayerService.

◆ setPlayerStateHolder()

void fr.softsf.sudokufx.navigation.Coordinator.setPlayerStateHolder ( PlayerStateHolder holder)
package

For testing only: injects a PlayerStateHolder.

◆ 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
fxmlthe FXML filename; must not be null or blank
Returns
the controller instance, or null if loading fails or Spring context is unavailable
Exceptions
IllegalArgumentExceptionif fxml is null or blank
+ Here is the call graph for this function:

◆ setToasterService()

void fr.softsf.sudokufx.navigation.Coordinator.setToasterService ( ToasterService toasterService)
package

For testing only: injects a ToasterService.

◆ 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)
+ Here is the call graph for this function:

◆ 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
isothe ISO code of the target language ("FR" or "EN")
Exceptions
IllegalArgumentExceptionif iso is null or blank
RuntimeExceptionif updating the player fails

Member Data Documentation

◆ 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

DynamicFontSize fr.softsf.sudokufx.navigation.Coordinator.dynamicFontSize
private

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

PlayerLanguageService fr.softsf.sudokufx.navigation.Coordinator.playerLanguageService
private

◆ playerService

PlayerService fr.softsf.sudokufx.navigation.Coordinator.playerService
private

◆ playerStateHolder

PlayerStateHolder fr.softsf.sudokufx.navigation.Coordinator.playerStateHolder
private

◆ toasterService

ToasterService fr.softsf.sudokufx.navigation.Coordinator.toasterService
private

The documentation for this class was generated from the following file: