SudokuFX
Loading...
Searching...
No Matches
fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel Class Reference

ViewModel managing player menu UI state and localized accessibility texts. More...

Collaboration diagram for fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel:

Public Member Functions

 MenuPlayerViewModel (PlayerStateHolder playerStateHolder, PlayerService playerService)
void cancelNewPlayer ()
 Clears the text field and stops editing when focus is lost.
StringBinding cellButtonAccessibleTextProperty ()
StringBinding cellConfirmationMessageProperty ()
StringBinding cellConfirmationTitleProperty ()
void createNewPlayerByName ()
 Validates and sets the player name into the state holder ONLY on Enter key.
void deletePlayer (PlayerDto playerDto)
 Deletes the specified player from the system and refreshes the UI state.
StringBinding editAccessibleTextProperty ()
ReadOnlyBooleanProperty editingProperty ()
StringBinding editRoleDescriptionProperty ()
StringBinding editTooltipProperty ()
TextFormatter.Change filterPlayerNameInput (TextFormatter.Change change)
 Filters input changes to enforce character and length constraints.
ObservableList< PlayerDto > getPlayers ()
StringBinding maxiPlayerRoleDescriptionProperty ()
StringBinding maxiPlayerTooltipProperty ()
StringBinding newAccessibleTextProperty ()
StringBinding newRoleDescriptionProperty ()
StringBinding newTextProperty ()
StringBinding newTooltipProperty ()
StringBinding playerAccessibleTextProperty ()
Property< String > playerNameInputProperty ()
 Returns the property for the new player name input.
ReadOnlyObjectProperty< PlayerNameStatusplayerNameStatusProperty ()
StringBinding playerRoleDescriptionProperty ()
ReadOnlyBooleanProperty playerSwitchedSignalProperty ()
StringBinding playerTooltipProperty ()
void prepareNewPlayer ()
 Prepares the text field for a new player.
StringBinding reduceAccessibleTextProperty ()
StringBinding reduceTextProperty ()
StringBinding reduceTooltipProperty ()
ObjectProperty< PlayerDto > selectedPlayerProperty ()
void validatePlayerName (String currentText)
 Validates the input player name against formatting and availability constraints.

Static Public Attributes

static final String MENU_PLAYER_BUTTON_NEW_PLAYER_TEXT

Private Member Functions

StringBinding createAppendedStringBinding ()
 Creates a localized binding by concatenating two keys.
StringBinding createFormattedAndConcatenatedBinding (String key, String suffixKey)
 Creates a localized binding combining a formatted message and suffix.
StringBinding createFormattedBinding (String key, Supplier< String > argSupplier)
 Creates a formatted localized binding with player name argument.
StringBinding createStringBinding (String key)
 Creates a simple localized binding for a given key.
void loadPlayers ()
 Loads players into the observable list.
String playerName ()
 Returns the name of the currently selected player.
void refreshUI ()
 Refreshes the UI state by synchronizing the current player, toggling the switched signal, and reloading the player list.
void runGuarded (Runnable action)
 Executes the provided action within a guarded block to prevent reentrant updates and state corruption.
void setSelectedPlayer ()
 Sets the selected player to the one marked as selected or first in the list.

Private Attributes

final StringBinding cellButtonAccessibleText
final StringBinding cellConfirmationMessage
final StringBinding cellConfirmationTitle
final StringBinding editAccessibleText
final ReadOnlyBooleanWrapper editing = new ReadOnlyBooleanWrapper(false)
final StringBinding editRoleDescription
final StringBinding editTooltip
boolean isLockedWhileUpdating = false
final StringBinding maxiPlayerRoleDescription
final StringBinding maxiPlayerTooltip
final StringBinding newAccessibleText
final StringBinding newRoleDescription
final StringBinding newText
final StringBinding newTooltip
final StringBinding playerAccessibleText
final StringProperty playerNameInput
final ReadOnlyObjectWrapper< PlayerNameStatusplayerNameStatus
final StringBinding playerRoleDescription
final ObservableList< PlayerDto > players = FXCollections.observableArrayList()
final PlayerService playerService
final PlayerStateHolder playerStateHolder
final ReadOnlyBooleanWrapper playerSwitchedSignal = new ReadOnlyBooleanWrapper(false)
final StringBinding playerTooltip
final StringBinding reduceAccessibleText
final StringBinding reduceText
final StringBinding reduceTooltip

Static Private Attributes

static final int MAX_NAME_LENGTH = 50
static final String MENU_ACCESSIBILITY_ROLE_DESCRIPTION_CLOSED
static final String MENU_ACCESSIBILITY_ROLE_DESCRIPTION_OPENED
static final String MENU_ACCESSIBILITY_ROLE_DESCRIPTION_SUBMENU_OPTION
static final String MENU_PLAYER_BUTTON_PLAYER_ACCESSIBILITY

Detailed Description

ViewModel managing player menu UI state and localized accessibility texts.

Provides observable players list and reactive StringBindings for UI labels, tooltips, and roles, updated on locale or selection changes.

Assumes selected player has a valid non-blank name as enforced upstream.

Constructor & Destructor Documentation

◆ MenuPlayerViewModel()

fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.MenuPlayerViewModel ( PlayerStateHolder playerStateHolder,
PlayerService playerService )
Here is the call graph for this function:

Member Function Documentation

◆ cancelNewPlayer()

void fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.cancelNewPlayer ( )

Clears the text field and stops editing when focus is lost.

◆ cellButtonAccessibleTextProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.cellButtonAccessibleTextProperty ( )
Here is the call graph for this function:

◆ cellConfirmationMessageProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.cellConfirmationMessageProperty ( )
Here is the call graph for this function:

◆ cellConfirmationTitleProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.cellConfirmationTitleProperty ( )
Here is the call graph for this function:

◆ createAppendedStringBinding()

StringBinding fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.createAppendedStringBinding ( )
private

Creates a localized binding by concatenating two keys.

Updates when locale changes.

◆ createFormattedAndConcatenatedBinding()

StringBinding fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.createFormattedAndConcatenatedBinding ( String key,
String suffixKey )
private

Creates a localized binding combining a formatted message and suffix.

Updates when locale or selected player changes.

Here is the call graph for this function:

◆ createFormattedBinding()

StringBinding fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.createFormattedBinding ( String key,
Supplier< String > argSupplier )
private

Creates a formatted localized binding with player name argument.

Updates when locale or selected player changes.

◆ createNewPlayerByName()

void fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.createNewPlayerByName ( )

Validates and sets the player name into the state holder ONLY on Enter key.

Here is the call graph for this function:

◆ createStringBinding()

StringBinding fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.createStringBinding ( String key)
private

Creates a simple localized binding for a given key.

Updates when locale changes.

◆ deletePlayer()

void fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.deletePlayer ( PlayerDto playerDto)

Deletes the specified player from the system and refreshes the UI state.

Parameters
playerDtothe player to delete; must not be null
Exceptions
IllegalArgumentExceptionif playerDto is null
Here is the call graph for this function:

◆ editAccessibleTextProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.editAccessibleTextProperty ( )
Here is the call graph for this function:

◆ editingProperty()

ReadOnlyBooleanProperty fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.editingProperty ( )

◆ editRoleDescriptionProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.editRoleDescriptionProperty ( )
Here is the call graph for this function:

◆ editTooltipProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.editTooltipProperty ( )
Here is the call graph for this function:

◆ filterPlayerNameInput()

TextFormatter.Change fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.filterPlayerNameInput ( TextFormatter.Change change)

Filters input changes to enforce character and length constraints.

Parameters
changethe JavaFX text formatter change context
Returns
the permitted change, or null to reject the input alteration

◆ getPlayers()

ObservableList< PlayerDto > fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.getPlayers ( )
Here is the call graph for this function:

◆ loadPlayers()

void fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.loadPlayers ( )
private

Loads players into the observable list.

◆ maxiPlayerRoleDescriptionProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.maxiPlayerRoleDescriptionProperty ( )
Here is the call graph for this function:

◆ maxiPlayerTooltipProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.maxiPlayerTooltipProperty ( )
Here is the call graph for this function:

◆ newAccessibleTextProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.newAccessibleTextProperty ( )
Here is the call graph for this function:

◆ newRoleDescriptionProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.newRoleDescriptionProperty ( )
Here is the call graph for this function:

◆ newTextProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.newTextProperty ( )
Here is the call graph for this function:

◆ newTooltipProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.newTooltipProperty ( )
Here is the call graph for this function:

◆ playerAccessibleTextProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.playerAccessibleTextProperty ( )
Here is the call graph for this function:

◆ playerName()

String fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.playerName ( )
private

Returns the name of the currently selected player.

Returns
the player name, guaranteed to be non-null and not blank

◆ playerNameInputProperty()

Property< String > fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.playerNameInputProperty ( )

Returns the property for the new player name input.

Returns
the Property managing the new player name
Here is the call graph for this function:

◆ playerNameStatusProperty()

ReadOnlyObjectProperty< PlayerNameStatus > fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.playerNameStatusProperty ( )

◆ playerRoleDescriptionProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.playerRoleDescriptionProperty ( )
Here is the call graph for this function:

◆ playerSwitchedSignalProperty()

ReadOnlyBooleanProperty fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.playerSwitchedSignalProperty ( )

◆ playerTooltipProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.playerTooltipProperty ( )
Here is the call graph for this function:

◆ prepareNewPlayer()

void fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.prepareNewPlayer ( )

Prepares the text field for a new player.

◆ reduceAccessibleTextProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.reduceAccessibleTextProperty ( )
Here is the call graph for this function:

◆ reduceTextProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.reduceTextProperty ( )
Here is the call graph for this function:

◆ reduceTooltipProperty()

StringBinding fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.reduceTooltipProperty ( )
Here is the call graph for this function:

◆ refreshUI()

void fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.refreshUI ( )
private

Refreshes the UI state by synchronizing the current player, toggling the switched signal, and reloading the player list.

Here is the call graph for this function:

◆ runGuarded()

void fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.runGuarded ( Runnable action)
private

Executes the provided action within a guarded block to prevent reentrant updates and state corruption.

Parameters
actionthe action to execute

◆ selectedPlayerProperty()

ObjectProperty< PlayerDto > fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.selectedPlayerProperty ( )

◆ setSelectedPlayer()

void fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.setSelectedPlayer ( )
private

Sets the selected player to the one marked as selected or first in the list.

◆ validatePlayerName()

void fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.validatePlayerName ( String currentText)

Validates the input player name against formatting and availability constraints.

Updates the status property to:

Parameters
currentTextthe raw text input from the view

Member Data Documentation

◆ cellButtonAccessibleText

final StringBinding fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.cellButtonAccessibleText
private

◆ cellConfirmationMessage

final StringBinding fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.cellConfirmationMessage
private

◆ cellConfirmationTitle

final StringBinding fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.cellConfirmationTitle
private

◆ editAccessibleText

final StringBinding fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.editAccessibleText
private

◆ editing

final ReadOnlyBooleanWrapper fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.editing = new ReadOnlyBooleanWrapper(false)
private

◆ editRoleDescription

final StringBinding fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.editRoleDescription
private

◆ editTooltip

final StringBinding fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.editTooltip
private

◆ isLockedWhileUpdating

boolean fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.isLockedWhileUpdating = false
private

◆ MAX_NAME_LENGTH

final int fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.MAX_NAME_LENGTH = 50
staticprivate

◆ maxiPlayerRoleDescription

final StringBinding fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.maxiPlayerRoleDescription
private

◆ maxiPlayerTooltip

final StringBinding fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.maxiPlayerTooltip
private

◆ MENU_ACCESSIBILITY_ROLE_DESCRIPTION_CLOSED

final String fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.MENU_ACCESSIBILITY_ROLE_DESCRIPTION_CLOSED
staticprivate
Initial value:
=
"menu.accessibility.role.description.closed"

◆ MENU_ACCESSIBILITY_ROLE_DESCRIPTION_OPENED

final String fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.MENU_ACCESSIBILITY_ROLE_DESCRIPTION_OPENED
staticprivate
Initial value:
=
"menu.accessibility.role.description.opened"

◆ MENU_ACCESSIBILITY_ROLE_DESCRIPTION_SUBMENU_OPTION

final String fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.MENU_ACCESSIBILITY_ROLE_DESCRIPTION_SUBMENU_OPTION
staticprivate
Initial value:
=
"menu.accessibility.role.description.submenu.option"

◆ MENU_PLAYER_BUTTON_NEW_PLAYER_TEXT

final String fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.MENU_PLAYER_BUTTON_NEW_PLAYER_TEXT
static
Initial value:
=
"menu.player.button.new.player.text"

◆ MENU_PLAYER_BUTTON_PLAYER_ACCESSIBILITY

final String fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.MENU_PLAYER_BUTTON_PLAYER_ACCESSIBILITY
staticprivate
Initial value:
=
"menu.player.button.player.accessibility"

◆ newAccessibleText

final StringBinding fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.newAccessibleText
private

◆ newRoleDescription

final StringBinding fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.newRoleDescription
private

◆ newText

final StringBinding fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.newText
private

◆ newTooltip

final StringBinding fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.newTooltip
private

◆ playerAccessibleText

final StringBinding fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.playerAccessibleText
private

◆ playerNameInput

final StringProperty fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.playerNameInput
private
Initial value:
=
new SimpleStringProperty(I18n.INSTANCE.getValue(MENU_PLAYER_BUTTON_NEW_PLAYER_TEXT))
static final String MENU_PLAYER_BUTTON_NEW_PLAYER_TEXT
Definition MenuPlayerViewModel.java:57
Internationalization (i18n) support.
Definition I18n.java:23
INSTANCE
Definition I18n.java:24

◆ playerNameStatus

final ReadOnlyObjectWrapper<PlayerNameStatus> fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.playerNameStatus
private
Initial value:
=
new ReadOnlyObjectWrapper<>(PlayerNameStatus.EMPTY)
Utility enum representing the validation status of a player name.
Definition PlayerNameStatus.java:9
EMPTY
The player name is empty or consists only of whitespace.
Definition PlayerNameStatus.java:11

◆ playerRoleDescription

final StringBinding fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.playerRoleDescription
private

◆ players

final ObservableList<PlayerDto> fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.players = FXCollections.observableArrayList()
private

◆ playerService

final PlayerService fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.playerService
private

◆ playerStateHolder

final PlayerStateHolder fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.playerStateHolder
private

◆ playerSwitchedSignal

final ReadOnlyBooleanWrapper fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.playerSwitchedSignal = new ReadOnlyBooleanWrapper(false)
private

◆ playerTooltip

final StringBinding fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.playerTooltip
private

◆ reduceAccessibleText

final StringBinding fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.reduceAccessibleText
private

◆ reduceText

final StringBinding fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.reduceText
private

◆ reduceTooltip

final StringBinding fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.reduceTooltip
private

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