ViewModel managing player menu UI state and localized accessibility texts. More...
Public Member Functions | |
| MenuPlayerViewModel (PlayerStateHolder playerStateHolder, PlayerService playerService) | |
| Initializes the MenuPlayerViewModel with necessary infrastructure and reactive bindings. | |
| void | cancelNewPlayer () |
| Clears the text field and stops editing when focus is lost. | |
| StringBinding | cellButtonAccessibleTextProperty () |
| Returns the reactive binding for the cell button accessible text property. | |
| StringBinding | cellConfirmationMessageProperty () |
| Returns the reactive binding for the cell confirmation message property. | |
| StringBinding | cellConfirmationTitleProperty () |
| Returns the reactive binding for the cell button accessible text property. | |
| void | deletePlayer (PlayerDto playerDto) |
| Deletes the specified player from the system and refreshes the UI state. | |
| StringBinding | editAccessibleTextProperty () |
| Returns the reactive binding for the edit accessible text property. | |
| ReadOnlyBooleanProperty | editingProperty () |
| Returns the read-only boolean property indicating if the player name is currently being edited. | |
| StringBinding | editRoleDescriptionProperty () |
| Returns the reactive binding for the edit role description property. | |
| StringBinding | editTooltipProperty () |
| Returns the reactive binding for the edit tooltip property. | |
| TextFormatter.Change | filterPlayerNameInput (TextFormatter.Change change) |
| Filters input changes to enforce character and length constraints. | |
| ObservableList< PlayerDto > | getPlayers () |
| Returns the observable list of players. | |
| StringBinding | maxiPlayerRoleDescriptionProperty () |
| Returns the reactive binding for the maxi player role description property. | |
| StringBinding | maxiPlayerTooltipProperty () |
| Returns the reactive binding for the maxi player tooltip property. | |
| StringBinding | newAccessibleTextProperty () |
| Returns the reactive binding for the new player accessible text property. | |
| StringBinding | newRoleDescriptionProperty () |
| Returns the reactive binding for the new player role description property. | |
| StringBinding | newTextProperty () |
| Returns the reactive binding for the new player text property. | |
| StringBinding | newTooltipProperty () |
| Returns the reactive binding for the new player tooltip property. | |
| StringBinding | playerAccessibleTextProperty () |
| Returns the reactive binding for the player accessible text property. | |
| Property< String > | playerNameInputProperty () |
| Returns the property for the new player name input. | |
| ReadOnlyObjectProperty< PlayerNameStatus > | playerNameStatusProperty () |
| Returns the read-only object property for the player name status. | |
| StringBinding | playerRoleDescriptionProperty () |
| Returns the reactive binding for the player role description property. | |
| ReadOnlyBooleanProperty | playerSwitchedSignalProperty () |
| Returns the read-only boolean property for the player switched signal. | |
| StringBinding | playerTooltipProperty () |
| Returns the reactive binding for the player tooltip property. | |
| void | prepareCreatePlayerNameField () |
| Prepares the name text field for a new player. | |
| void | prepareUpdatePlayerNameField () |
| Prepares the name text field for current player. | |
| StringBinding | reduceAccessibleTextProperty () |
| Returns the reactive binding for the reduce button accessible text property. | |
| StringBinding | reduceTextProperty () |
| Returns the reactive binding for the reduce button tooltip property. | |
| StringBinding | reduceTooltipProperty () |
| Returns the reactive binding for the reduce button tooltip property. | |
| void | savePlayer () |
| Validates and saves the player name into the state holder only on Enter key. | |
| ObjectProperty< PlayerDto > | selectedPlayerProperty () |
| Returns the property for the currently selected player. | |
| 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 | initPlayerNameField (PlayerSaveMode mode, String initialValue) |
| Centralizes UI initialization for player name input. | |
| 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 ObjectProperty< PlayerSaveMode > | currentSaveMode |
| 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< PlayerNameStatus > | playerNameStatus |
| 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 Logger | LOG = LoggerFactory.getLogger(MenuPlayerViewModel.class) |
| 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 |
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.
| fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.MenuPlayerViewModel | ( | PlayerStateHolder | playerStateHolder, |
| PlayerService | playerService ) |
Initializes the MenuPlayerViewModel with necessary infrastructure and reactive bindings.
Configures i18n-aware StringBindings for UI labels, tooltips, and accessibility roles. Sets up listeners for player selection and locale changes to maintain UI synchronization.
| playerStateHolder | holder for persistent player state |
| playerService | service for player management operations |
| void fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.cancelNewPlayer | ( | ) |
Clears the text field and stops editing when focus is lost.
| StringBinding fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.cellButtonAccessibleTextProperty | ( | ) |
Returns the reactive binding for the cell button accessible text property.
| StringBinding fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.cellConfirmationMessageProperty | ( | ) |
Returns the reactive binding for the cell confirmation message property.
| StringBinding fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.cellConfirmationTitleProperty | ( | ) |
Returns the reactive binding for the cell button accessible text property.
|
private |
Creates a localized binding by concatenating two keys.
Updates when locale changes.
|
private |
Creates a localized binding combining a formatted message and suffix.
Updates when locale or selected player changes.
|
private |
Creates a formatted localized binding with player name argument.
Updates when locale or selected player changes.
|
private |
Creates a simple localized binding for a given key.
Updates when locale changes.
| void fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.deletePlayer | ( | PlayerDto | playerDto | ) |
Deletes the specified player from the system and refreshes the UI state.
| playerDto | the player to delete; must not be null |
| IllegalArgumentException | if playerDto is null |
| StringBinding fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.editAccessibleTextProperty | ( | ) |
Returns the reactive binding for the edit accessible text property.
| ReadOnlyBooleanProperty fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.editingProperty | ( | ) |
Returns the read-only boolean property indicating if the player name is currently being edited.
| StringBinding fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.editRoleDescriptionProperty | ( | ) |
Returns the reactive binding for the edit role description property.
| StringBinding fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.editTooltipProperty | ( | ) |
Returns the reactive binding for the edit tooltip property.
| TextFormatter.Change fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.filterPlayerNameInput | ( | TextFormatter.Change | change | ) |
Filters input changes to enforce character and length constraints.
| change | the JavaFX text formatter change context |
| ObservableList< PlayerDto > fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.getPlayers | ( | ) |
Returns the observable list of players.
|
private |
Centralizes UI initialization for player name input.
|
private |
Loads players into the observable list.
| StringBinding fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.maxiPlayerRoleDescriptionProperty | ( | ) |
Returns the reactive binding for the maxi player role description property.
| StringBinding fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.maxiPlayerTooltipProperty | ( | ) |
Returns the reactive binding for the maxi player tooltip property.
| StringBinding fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.newAccessibleTextProperty | ( | ) |
Returns the reactive binding for the new player accessible text property.
| StringBinding fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.newRoleDescriptionProperty | ( | ) |
Returns the reactive binding for the new player role description property.
| StringBinding fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.newTextProperty | ( | ) |
Returns the reactive binding for the new player text property.
| StringBinding fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.newTooltipProperty | ( | ) |
Returns the reactive binding for the new player tooltip property.
| StringBinding fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.playerAccessibleTextProperty | ( | ) |
Returns the reactive binding for the player accessible text property.
|
private |
Returns the name of the currently selected player.
| Property< String > fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.playerNameInputProperty | ( | ) |
Returns the property for the new player name input.
| ReadOnlyObjectProperty< PlayerNameStatus > fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.playerNameStatusProperty | ( | ) |
Returns the read-only object property for the player name status.
| StringBinding fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.playerRoleDescriptionProperty | ( | ) |
Returns the reactive binding for the player role description property.
| ReadOnlyBooleanProperty fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.playerSwitchedSignalProperty | ( | ) |
Returns the read-only boolean property for the player switched signal.
| StringBinding fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.playerTooltipProperty | ( | ) |
Returns the reactive binding for the player tooltip property.
| void fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.prepareCreatePlayerNameField | ( | ) |
Prepares the name text field for a new player.
| void fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.prepareUpdatePlayerNameField | ( | ) |
Prepares the name text field for current player.
| StringBinding fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.reduceAccessibleTextProperty | ( | ) |
Returns the reactive binding for the reduce button accessible text property.
| StringBinding fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.reduceTextProperty | ( | ) |
Returns the reactive binding for the reduce button tooltip property.
| StringBinding fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.reduceTooltipProperty | ( | ) |
Returns the reactive binding for the reduce button tooltip property.
|
private |
Refreshes the UI state by synchronizing the current player, toggling the switched signal, and reloading the player list.
|
private |
Executes the provided action within a guarded block to prevent reentrant updates and state corruption.
| action | the action to execute |
| void fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.savePlayer | ( | ) |
Validates and saves the player name into the state holder only on Enter key.
Depending on the current PlayerSaveMode, this method either creates a new player or updates the name of the existing current player.
| ObjectProperty< PlayerDto > fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.selectedPlayerProperty | ( | ) |
Returns the property for the currently selected player.
|
private |
Sets the selected player to the one marked as selected or first in the list.
| void fr.softsf.sudokufx.viewmodel.MenuPlayerViewModel.validatePlayerName | ( | String | currentText | ) |
Validates the input player name against formatting and availability constraints.
Updates the status property to:
PlayerNameStatus#EMPTY: if text is null or blank. PlayerNameStatus#INVALID: if length exceeds 50 or pattern mismatches. PlayerNameStatus#UNAVAILABLE: if name matches current player, the anonymous token "—", or an existing player. PlayerNameStatus#VALID: if all checks pass. | currentText | the raw text input from the view |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
staticprivate |
|
staticprivate |
|
private |
|
private |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
static |
|
staticprivate |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |