From 1a4e05b02fa1873396849de3ef4ff391d533fb09 Mon Sep 17 00:00:00 2001 From: delvh Date: Fri, 9 Oct 2020 11:09:59 +0200 Subject: [PATCH 1/4] Add enhanced keyboard shortcut mechanism --- .../data/shortcuts/EnvoyShortcutConfig.java | 42 +++++++ .../data/shortcuts/GlobalKeyShortcuts.java | 118 ++++++++++++++++++ .../data/shortcuts/KeyboardMapping.java | 25 ++++ .../client/data/shortcuts/package-info.java | 7 ++ .../java/envoy/client/ui/SceneContext.java | 29 ++--- .../main/java/envoy/client/ui/Startup.java | 4 + .../client/ui/controller/SettingsScene.java | 13 +- 7 files changed, 217 insertions(+), 21 deletions(-) create mode 100644 client/src/main/java/envoy/client/data/shortcuts/EnvoyShortcutConfig.java create mode 100644 client/src/main/java/envoy/client/data/shortcuts/GlobalKeyShortcuts.java create mode 100644 client/src/main/java/envoy/client/data/shortcuts/KeyboardMapping.java create mode 100644 client/src/main/java/envoy/client/data/shortcuts/package-info.java diff --git a/client/src/main/java/envoy/client/data/shortcuts/EnvoyShortcutConfig.java b/client/src/main/java/envoy/client/data/shortcuts/EnvoyShortcutConfig.java new file mode 100644 index 0000000..d829597 --- /dev/null +++ b/client/src/main/java/envoy/client/data/shortcuts/EnvoyShortcutConfig.java @@ -0,0 +1,42 @@ +package envoy.client.data.shortcuts; + +import javafx.scene.input.*; + +import envoy.client.data.Context; +import envoy.client.helper.ShutdownHelper; +import envoy.client.ui.SceneContext.SceneInfo; + +/** + * Envoy-specific implementation of the keyboard-shortcut interaction offered by + * {@link GlobalKeyShortcuts}. + * + * @author Leon Hofmeister + * @since Envoy Client v0.3-beta + */ +public class EnvoyShortcutConfig { + + private EnvoyShortcutConfig() {} + + /** + * Supplies the default shortcuts for {@link GlobalKeyShortcuts}. + * + * @since Envoy Client v0.3-beta + */ + public static void initializeEnvoyShortcuts() { + final var instance = GlobalKeyShortcuts.getInstance(); + + // Add the option to exit Linux-like with "Control" + "Q" or "Alt" + "F4" + instance.add(new KeyCodeCombination(KeyCode.Q, KeyCombination.CONTROL_DOWN), ShutdownHelper::exit); + + // Add the option to logout using "Control"+"Shift"+"L" if not in login scene + instance.addForNotExcluded(new KeyCodeCombination(KeyCode.L, KeyCombination.CONTROL_DOWN, KeyCombination.SHIFT_DOWN), + ShutdownHelper::logout, + SceneInfo.LOGIN_SCENE); + + // Add option to open settings scene with "Control"+"S", if not in login scene + instance.addForNotExcluded(new KeyCodeCombination(KeyCode.S, KeyCombination.CONTROL_DOWN), + () -> Context.getInstance().getSceneContext().load(SceneInfo.SETTINGS_SCENE), + SceneInfo.SETTINGS_SCENE, + SceneInfo.LOGIN_SCENE); + } +} diff --git a/client/src/main/java/envoy/client/data/shortcuts/GlobalKeyShortcuts.java b/client/src/main/java/envoy/client/data/shortcuts/GlobalKeyShortcuts.java new file mode 100644 index 0000000..b1f2e0b --- /dev/null +++ b/client/src/main/java/envoy/client/data/shortcuts/GlobalKeyShortcuts.java @@ -0,0 +1,118 @@ +package envoy.client.data.shortcuts; + +import java.util.*; +import java.util.Map.Entry; + +import javafx.scene.input.KeyCombination; + +import envoy.client.ui.SceneContext.SceneInfo; + +/** + * Contains all KeyBoardshotcuts used throughout the application. + * + * @author Leon Hofmeister + * @since Envoy Client v0.3-beta + */ +public final class GlobalKeyShortcuts { + + /** + * Helper class for the Entry interface. + * + * @author Leon Hofmeister + * @since Envoy Client v0.3-beta + */ + public final class KeyCombinationAction implements Entry { + + private final KeyCombination keys; + private final Runnable action; + + /** + * Creates a new {@code KeyCombinationAction}. + * + * @param keys the keys to press to perform the given action + * @param action the action to perform + * @since Envoy Client v0.3-beta + */ + public KeyCombinationAction(KeyCombination keys, Runnable action) { + if (keys == null || action == null) throw new NullPointerException("Cannot create key combination action"); + this.keys = keys; + this.action = action; + } + + @Override + public KeyCombination getKey() { return keys; } + + @Override + public Runnable getValue() { return action; } + + @Override + public Runnable setValue(Runnable none) { + throw new UnsupportedOperationException("Reassignment of keyboard shortcut actions is not supported"); + } + + } + + private final EnumMap> shortcuts = new EnumMap<>(SceneInfo.class); + + private static GlobalKeyShortcuts instance = new GlobalKeyShortcuts(); + + private GlobalKeyShortcuts() { + for (final var sceneInfo : SceneInfo.values()) + shortcuts.put(sceneInfo, new HashSet()); + } + + /** + * @return the instance of global keyboard shortcuts. + * @since Envoy Client v0.3-beta + */ + public static GlobalKeyShortcuts getInstance() { return instance; } + + /** + * Adds the given keyboard shortcut and its action to all scenes. + * + * @param keys the keys to press to perform the given action + * @param action the action to perform + * @since Envoy Client v0.3-beta + */ + public void add(KeyCombination keys, Runnable action) { + final var keyCombinationAction = new KeyCombinationAction(keys, action); + shortcuts.values().forEach(collection -> collection.add(keyCombinationAction)); + } + + /** + * Adds the given keyboard shortcut and its action to all scenes that are not + * part of exclude. + * + * @param keys the keys to press to perform the given action + * @param action the action to perform + * @param exclude the scenes that should be excluded from receiving this + * keyboard shortcut + * @since Envoy Client v0.3-beta + */ + public void addForNotExcluded(KeyCombination keys, Runnable action, SceneInfo... exclude) { + + // Computing the remaining sceneInfos + final var include = new SceneInfo[SceneInfo.values().length - exclude.length]; + int index = 0; + outer: + for (final var sceneInfo : SceneInfo.values()) { + for (final var excluded : exclude) + if (sceneInfo.equals(excluded)) continue outer; + include[index++] = sceneInfo; + } + + // Adding the action to the remaining sceneInfos + final var keyCombinationAction = new KeyCombinationAction(keys, action); + for (final var sceneInfo : include) + shortcuts.get(sceneInfo).add(keyCombinationAction); + } + + /** + * Returns all stored keyboard shortcuts for the given scene constant + * + * @param sceneInfo the currently loading scene + * @return all stored keyboard shortcuts for this scene + * @since Envoy Client v0.3-beta + */ + public Collection getKeyboardShortcuts(SceneInfo sceneInfo) { return shortcuts.get(sceneInfo); } +} diff --git a/client/src/main/java/envoy/client/data/shortcuts/KeyboardMapping.java b/client/src/main/java/envoy/client/data/shortcuts/KeyboardMapping.java new file mode 100644 index 0000000..f98c055 --- /dev/null +++ b/client/src/main/java/envoy/client/data/shortcuts/KeyboardMapping.java @@ -0,0 +1,25 @@ +package envoy.client.data.shortcuts; + +import java.util.Map; + +import javafx.scene.input.KeyCombination; + +import envoy.client.ui.SceneContext; + +/** + * Provides methods to set the keyboard shortcuts for a specific scene. + * Should only be implemented by Controllers of Scenes so that these methods can + * automatically be called inside {@link SceneContext} as soon + * as the underlying fxml file has been loaded. + * + * @author Leon Hofmeister + * @since Envoy Client v0.3-beta + */ +public interface KeyboardMapping { + + /** + * @return all keyboard shortcuts of a scene + * @since Envoy Client v0.3-beta + */ + Map getKeyboardShortcuts(); +} diff --git a/client/src/main/java/envoy/client/data/shortcuts/package-info.java b/client/src/main/java/envoy/client/data/shortcuts/package-info.java new file mode 100644 index 0000000..0e8591c --- /dev/null +++ b/client/src/main/java/envoy/client/data/shortcuts/package-info.java @@ -0,0 +1,7 @@ +/** + * Contains the necessary classes to enable using keyboard shortcuts in Envoy. + * + * @author Leon Hofmeister + * @since Envoy Client v0.3-beta + */ +package envoy.client.data.shortcuts; diff --git a/client/src/main/java/envoy/client/ui/SceneContext.java b/client/src/main/java/envoy/client/ui/SceneContext.java index e458407..eb790c4 100644 --- a/client/src/main/java/envoy/client/ui/SceneContext.java +++ b/client/src/main/java/envoy/client/ui/SceneContext.java @@ -7,12 +7,11 @@ import java.util.logging.Level; import javafx.application.Platform; import javafx.fxml.FXMLLoader; import javafx.scene.*; -import javafx.scene.input.*; import javafx.stage.Stage; import envoy.client.data.Settings; +import envoy.client.data.shortcuts.*; import envoy.client.event.*; -import envoy.client.helper.ShutdownHelper; import envoy.util.EnvoyLog; import dev.kske.eventbus.*; @@ -100,12 +99,18 @@ public final class SceneContext implements EventListener { try { final var rootNode = (Parent) loader.load(getClass().getResourceAsStream(sceneInfo.path)); final var scene = new Scene(rootNode); - controllerStack.push(loader.getController()); + final var controller = loader.getController(); + controllerStack.push(controller); sceneStack.push(scene); stage.setScene(scene); - supplyKeyboardShortcuts(sceneInfo, scene); + // Supply the global custom keyboard shortcuts for that scene + for (final var shortcut : GlobalKeyShortcuts.getInstance().getKeyboardShortcuts(sceneInfo)) + scene.getAccelerators().put(shortcut.getKey(), shortcut.getValue()); + + // Supply the scene specific keyboard shortcuts + if (controller instanceof KeyboardMapping) scene.getAccelerators().putAll(((KeyboardMapping) controller).getKeyboardShortcuts()); // The LoginScene is the only scene not intended to be resized // As strange as it seems, this is needed as otherwise the LoginScene won't be @@ -120,22 +125,6 @@ public final class SceneContext implements EventListener { } } - private void supplyKeyboardShortcuts(SceneInfo sceneInfo, final Scene scene) { - final var accelerators = scene.getAccelerators(); - - // Add the option to exit Linux-like with "Control" + "Q" or "Alt" + "F4" - accelerators.put(new KeyCodeCombination(KeyCode.Q, KeyCombination.CONTROL_DOWN), ShutdownHelper::exit); - - // Add the option to logout using "Control"+"Shift"+"L" if not in login scene - if (sceneInfo != SceneInfo.LOGIN_SCENE) - accelerators.put(new KeyCodeCombination(KeyCode.L, KeyCombination.CONTROL_DOWN, KeyCombination.SHIFT_DOWN), ShutdownHelper::logout); - - // Add the option to open the settings scene with "Control"+"S", if being in - // chat scene - if (sceneInfo == SceneInfo.CHAT_SCENE) - accelerators.put(new KeyCodeCombination(KeyCode.S, KeyCombination.CONTROL_DOWN), () -> load(SceneInfo.SETTINGS_SCENE)); - } - /** * Removes the current scene and displays the previous one. * diff --git a/client/src/main/java/envoy/client/ui/Startup.java b/client/src/main/java/envoy/client/ui/Startup.java index 811ba61..a269397 100644 --- a/client/src/main/java/envoy/client/ui/Startup.java +++ b/client/src/main/java/envoy/client/ui/Startup.java @@ -11,6 +11,7 @@ import javafx.scene.control.Alert.AlertType; import javafx.stage.Stage; import envoy.client.data.*; +import envoy.client.data.shortcuts.EnvoyShortcutConfig; import envoy.client.helper.ShutdownHelper; import envoy.client.net.Client; import envoy.client.ui.SceneContext.SceneInfo; @@ -84,6 +85,9 @@ public final class Startup extends Application { stage.setTitle("Envoy"); stage.getIcons().add(IconUtil.loadIcon("envoy_logo")); + // Configure global shortcuts used + EnvoyShortcutConfig.initializeEnvoyShortcuts(); + // Create scene context final var sceneContext = new SceneContext(stage); context.setSceneContext(sceneContext); diff --git a/client/src/main/java/envoy/client/ui/controller/SettingsScene.java b/client/src/main/java/envoy/client/ui/controller/SettingsScene.java index f69475a..13f97e4 100644 --- a/client/src/main/java/envoy/client/ui/controller/SettingsScene.java +++ b/client/src/main/java/envoy/client/ui/controller/SettingsScene.java @@ -1,9 +1,13 @@ package envoy.client.ui.controller; +import java.util.*; + import javafx.fxml.FXML; import javafx.scene.control.*; +import javafx.scene.input.*; import envoy.client.data.Context; +import envoy.client.data.shortcuts.KeyboardMapping; import envoy.client.ui.listcell.ListCellFactory; import envoy.client.ui.settings.*; @@ -13,7 +17,7 @@ import envoy.client.ui.settings.*; * @author Kai S. K. Engelbart * @since Envoy Client v0.1-beta */ -public final class SettingsScene { +public final class SettingsScene implements KeyboardMapping { @FXML private ListView settingsList; @@ -38,4 +42,11 @@ public final class SettingsScene { @FXML private void backButtonClicked() { Context.getInstance().getSceneContext().pop(); } + + @Override + public Map getKeyboardShortcuts() { + final var map = new HashMap(); + map.put(new KeyCodeCombination(KeyCode.B, KeyCombination.CONTROL_DOWN), this::backButtonClicked); + return map; + } } -- 2.45.2 From a6bcc68cb48cc67469e9bcbd74b4d1a93a80f1f5 Mon Sep 17 00:00:00 2001 From: delvh Date: Sat, 10 Oct 2020 14:27:17 +0200 Subject: [PATCH 2/4] Fix merge error --- .../java/envoy/client/data/shortcuts/EnvoyShortcutConfig.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/src/main/java/envoy/client/data/shortcuts/EnvoyShortcutConfig.java b/client/src/main/java/envoy/client/data/shortcuts/EnvoyShortcutConfig.java index d829597..fe5db8f 100644 --- a/client/src/main/java/envoy/client/data/shortcuts/EnvoyShortcutConfig.java +++ b/client/src/main/java/envoy/client/data/shortcuts/EnvoyShortcutConfig.java @@ -5,6 +5,7 @@ import javafx.scene.input.*; import envoy.client.data.Context; import envoy.client.helper.ShutdownHelper; import envoy.client.ui.SceneContext.SceneInfo; +import envoy.client.util.UserUtil; /** * Envoy-specific implementation of the keyboard-shortcut interaction offered by @@ -30,7 +31,7 @@ public class EnvoyShortcutConfig { // Add the option to logout using "Control"+"Shift"+"L" if not in login scene instance.addForNotExcluded(new KeyCodeCombination(KeyCode.L, KeyCombination.CONTROL_DOWN, KeyCombination.SHIFT_DOWN), - ShutdownHelper::logout, + UserUtil::logout, SceneInfo.LOGIN_SCENE); // Add option to open settings scene with "Control"+"S", if not in login scene -- 2.45.2 From fbdcbf45006d9de12c7dbf39158bbe0a6339f6cb Mon Sep 17 00:00:00 2001 From: delvh Date: Sat, 10 Oct 2020 17:21:39 +0200 Subject: [PATCH 3/4] Fix bug disabling registration --- client/src/main/java/envoy/client/ui/Startup.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/main/java/envoy/client/ui/Startup.java b/client/src/main/java/envoy/client/ui/Startup.java index c512855..391baa7 100644 --- a/client/src/main/java/envoy/client/ui/Startup.java +++ b/client/src/main/java/envoy/client/ui/Startup.java @@ -117,7 +117,7 @@ public final class Startup extends Application { cacheMap.put(GroupMessage.class, new Cache()); cacheMap.put(MessageStatusChange.class, new Cache()); cacheMap.put(GroupMessageStatusChange.class, new Cache()); - final var originalStatus = localDB.getUser().getStatus(); + final var originalStatus = localDB.getUser() == null ? UserStatus.ONLINE : localDB.getUser().getStatus(); try { client.performHandshake(credentials, cacheMap); if (client.isOnline()) { -- 2.45.2 From 7477f9dbd9c331574b1baaf9660c449dbf54448a Mon Sep 17 00:00:00 2001 From: delvh Date: Mon, 12 Oct 2020 09:50:00 +0200 Subject: [PATCH 4/4] Apply suggestions by @kske --- .../data/shortcuts/EnvoyShortcutConfig.java | 3 +- .../data/shortcuts/GlobalKeyShortcuts.java | 56 +++---------------- .../data/shortcuts/KeyboardMapping.java | 4 +- .../java/envoy/client/ui/SceneContext.java | 3 +- .../main/java/envoy/client/ui/Startup.java | 2 +- .../client/ui/controller/SettingsScene.java | 6 +- 6 files changed, 15 insertions(+), 59 deletions(-) diff --git a/client/src/main/java/envoy/client/data/shortcuts/EnvoyShortcutConfig.java b/client/src/main/java/envoy/client/data/shortcuts/EnvoyShortcutConfig.java index fe5db8f..14a110c 100644 --- a/client/src/main/java/envoy/client/data/shortcuts/EnvoyShortcutConfig.java +++ b/client/src/main/java/envoy/client/data/shortcuts/EnvoyShortcutConfig.java @@ -26,7 +26,8 @@ public class EnvoyShortcutConfig { public static void initializeEnvoyShortcuts() { final var instance = GlobalKeyShortcuts.getInstance(); - // Add the option to exit Linux-like with "Control" + "Q" or "Alt" + "F4" + // Add the option to exit with "Control" + "Q" or "Alt" + "F4" as offered by + // some desktop environments instance.add(new KeyCodeCombination(KeyCode.Q, KeyCombination.CONTROL_DOWN), ShutdownHelper::exit); // Add the option to logout using "Control"+"Shift"+"L" if not in login scene diff --git a/client/src/main/java/envoy/client/data/shortcuts/GlobalKeyShortcuts.java b/client/src/main/java/envoy/client/data/shortcuts/GlobalKeyShortcuts.java index b1f2e0b..c3643ee 100644 --- a/client/src/main/java/envoy/client/data/shortcuts/GlobalKeyShortcuts.java +++ b/client/src/main/java/envoy/client/data/shortcuts/GlobalKeyShortcuts.java @@ -1,64 +1,26 @@ package envoy.client.data.shortcuts; import java.util.*; -import java.util.Map.Entry; import javafx.scene.input.KeyCombination; import envoy.client.ui.SceneContext.SceneInfo; /** - * Contains all KeyBoardshotcuts used throughout the application. + * Contains all keyboard shortcuts used throughout the application. * * @author Leon Hofmeister * @since Envoy Client v0.3-beta */ public final class GlobalKeyShortcuts { - /** - * Helper class for the Entry interface. - * - * @author Leon Hofmeister - * @since Envoy Client v0.3-beta - */ - public final class KeyCombinationAction implements Entry { - - private final KeyCombination keys; - private final Runnable action; - - /** - * Creates a new {@code KeyCombinationAction}. - * - * @param keys the keys to press to perform the given action - * @param action the action to perform - * @since Envoy Client v0.3-beta - */ - public KeyCombinationAction(KeyCombination keys, Runnable action) { - if (keys == null || action == null) throw new NullPointerException("Cannot create key combination action"); - this.keys = keys; - this.action = action; - } - - @Override - public KeyCombination getKey() { return keys; } - - @Override - public Runnable getValue() { return action; } - - @Override - public Runnable setValue(Runnable none) { - throw new UnsupportedOperationException("Reassignment of keyboard shortcut actions is not supported"); - } - - } - - private final EnumMap> shortcuts = new EnumMap<>(SceneInfo.class); + private final EnumMap> shortcuts = new EnumMap<>(SceneInfo.class); private static GlobalKeyShortcuts instance = new GlobalKeyShortcuts(); private GlobalKeyShortcuts() { for (final var sceneInfo : SceneInfo.values()) - shortcuts.put(sceneInfo, new HashSet()); + shortcuts.put(sceneInfo, new HashMap()); } /** @@ -74,10 +36,7 @@ public final class GlobalKeyShortcuts { * @param action the action to perform * @since Envoy Client v0.3-beta */ - public void add(KeyCombination keys, Runnable action) { - final var keyCombinationAction = new KeyCombinationAction(keys, action); - shortcuts.values().forEach(collection -> collection.add(keyCombinationAction)); - } + public void add(KeyCombination keys, Runnable action) { shortcuts.values().forEach(collection -> collection.put(keys, action)); } /** * Adds the given keyboard shortcut and its action to all scenes that are not @@ -102,17 +61,16 @@ public final class GlobalKeyShortcuts { } // Adding the action to the remaining sceneInfos - final var keyCombinationAction = new KeyCombinationAction(keys, action); for (final var sceneInfo : include) - shortcuts.get(sceneInfo).add(keyCombinationAction); + shortcuts.get(sceneInfo).put(keys, action); } /** - * Returns all stored keyboard shortcuts for the given scene constant + * Returns all stored keyboard shortcuts for the given scene constant. * * @param sceneInfo the currently loading scene * @return all stored keyboard shortcuts for this scene * @since Envoy Client v0.3-beta */ - public Collection getKeyboardShortcuts(SceneInfo sceneInfo) { return shortcuts.get(sceneInfo); } + public Map getKeyboardShortcuts(SceneInfo sceneInfo) { return shortcuts.get(sceneInfo); } } diff --git a/client/src/main/java/envoy/client/data/shortcuts/KeyboardMapping.java b/client/src/main/java/envoy/client/data/shortcuts/KeyboardMapping.java index f98c055..4d56f8e 100644 --- a/client/src/main/java/envoy/client/data/shortcuts/KeyboardMapping.java +++ b/client/src/main/java/envoy/client/data/shortcuts/KeyboardMapping.java @@ -8,9 +8,9 @@ import envoy.client.ui.SceneContext; /** * Provides methods to set the keyboard shortcuts for a specific scene. - * Should only be implemented by Controllers of Scenes so that these methods can + * Should only be implemented by controllers of scenes so that these methods can * automatically be called inside {@link SceneContext} as soon - * as the underlying fxml file has been loaded. + * as the underlying FXML file has been loaded. * * @author Leon Hofmeister * @since Envoy Client v0.3-beta diff --git a/client/src/main/java/envoy/client/ui/SceneContext.java b/client/src/main/java/envoy/client/ui/SceneContext.java index eb790c4..70bb662 100644 --- a/client/src/main/java/envoy/client/ui/SceneContext.java +++ b/client/src/main/java/envoy/client/ui/SceneContext.java @@ -106,8 +106,7 @@ public final class SceneContext implements EventListener { stage.setScene(scene); // Supply the global custom keyboard shortcuts for that scene - for (final var shortcut : GlobalKeyShortcuts.getInstance().getKeyboardShortcuts(sceneInfo)) - scene.getAccelerators().put(shortcut.getKey(), shortcut.getValue()); + scene.getAccelerators().putAll(GlobalKeyShortcuts.getInstance().getKeyboardShortcuts(sceneInfo)); // Supply the scene specific keyboard shortcuts if (controller instanceof KeyboardMapping) scene.getAccelerators().putAll(((KeyboardMapping) controller).getKeyboardShortcuts()); diff --git a/client/src/main/java/envoy/client/ui/Startup.java b/client/src/main/java/envoy/client/ui/Startup.java index 391baa7..a93bf81 100644 --- a/client/src/main/java/envoy/client/ui/Startup.java +++ b/client/src/main/java/envoy/client/ui/Startup.java @@ -85,7 +85,7 @@ public final class Startup extends Application { stage.setTitle("Envoy"); stage.getIcons().add(IconUtil.loadIcon("envoy_logo")); - // Configure global shortcuts used + // Configure global shortcuts EnvoyShortcutConfig.initializeEnvoyShortcuts(); // Create scene context diff --git a/client/src/main/java/envoy/client/ui/controller/SettingsScene.java b/client/src/main/java/envoy/client/ui/controller/SettingsScene.java index 13f97e4..7a471e6 100644 --- a/client/src/main/java/envoy/client/ui/controller/SettingsScene.java +++ b/client/src/main/java/envoy/client/ui/controller/SettingsScene.java @@ -1,6 +1,6 @@ package envoy.client.ui.controller; -import java.util.*; +import java.util.Map; import javafx.fxml.FXML; import javafx.scene.control.*; @@ -45,8 +45,6 @@ public final class SettingsScene implements KeyboardMapping { @Override public Map getKeyboardShortcuts() { - final var map = new HashMap(); - map.put(new KeyCodeCombination(KeyCode.B, KeyCombination.CONTROL_DOWN), this::backButtonClicked); - return map; + return Map.of(new KeyCodeCombination(KeyCode.B, KeyCombination.CONTROL_DOWN), this::backButtonClicked); } } -- 2.45.2