From 8a266b16bb618ffc806f22ad8070c0b3e0d603e1 Mon Sep 17 00:00:00 2001 From: Manfred Karrer Date: Sat, 7 Apr 2018 15:53:52 -0500 Subject: [PATCH] Add addSceneKeyEventHandler and checkForCorrectOSArchitecture methods --- src/main/java/bisq/desktop/app/BisqApp.java | 101 +++++++++++--------- 1 file changed, 55 insertions(+), 46 deletions(-) diff --git a/src/main/java/bisq/desktop/app/BisqApp.java b/src/main/java/bisq/desktop/app/BisqApp.java index cc50adb3c1..63b2943478 100644 --- a/src/main/java/bisq/desktop/app/BisqApp.java +++ b/src/main/java/bisq/desktop/app/BisqApp.java @@ -200,42 +200,7 @@ public class BisqApp extends Application { event.consume(); stop(); }); - scene.addEventHandler(KeyEvent.KEY_RELEASED, keyEvent -> { - Utilities.isAltOrCtrlPressed(KeyCode.W, keyEvent); - if (Utilities.isCtrlPressed(KeyCode.W, keyEvent) || - Utilities.isCtrlPressed(KeyCode.Q, keyEvent)) { - stop(); - } else { - if (Utilities.isAltOrCtrlPressed(KeyCode.E, keyEvent)) { - showEmptyWalletPopup(injector.getInstance(BtcWalletService.class)); - } else if (Utilities.isAltOrCtrlPressed(KeyCode.M, keyEvent)) { - showSendAlertMessagePopup(); - } else if (Utilities.isAltOrCtrlPressed(KeyCode.F, keyEvent)) { - showFilterPopup(); - } else if (Utilities.isAltOrCtrlPressed(KeyCode.J, keyEvent)) { - WalletsManager walletsManager = injector.getInstance(WalletsManager.class); - if (walletsManager.areWalletsAvailable()) - new ShowWalletDataWindow(walletsManager).show(); - else - new Popup<>().warning(Res.get("popup.warning.walletNotInitialized")).show(); - } else if (Utilities.isAltOrCtrlPressed(KeyCode.G, keyEvent)) { - if (injector.getInstance(BtcWalletService.class).isWalletReady()) - injector.getInstance(ManualPayoutTxWindow.class).show(); - else - new Popup<>().warning(Res.get("popup.warning.walletNotInitialized")).show(); - } else if (DevEnv.isDevMode()) { - // dev ode only - if (Utilities.isAltOrCtrlPressed(KeyCode.B, keyEvent)) { - // BSQ empty wallet not public yet - showEmptyWalletPopup(injector.getInstance(BsqWalletService.class)); - } else if (Utilities.isAltOrCtrlPressed(KeyCode.P, keyEvent)) { - showFPSWindow(); - } else if (Utilities.isAltOrCtrlPressed(KeyCode.Z, keyEvent)) { - showDebugWindow(); - } - } - } - }); + addSceneKeyEventHandler(); // configure the primary stage primaryStage.setTitle(bisqEnvironment.getRequiredProperty(AppOptionKeys.APP_NAME_KEY)); @@ -258,16 +223,7 @@ public class BisqApp extends Application { // make the UI visible primaryStage.show(); - if (!Utilities.isCorrectOSArchitecture()) { - String osArchitecture = Utilities.getOSArchitecture(); - // We don't force a shutdown as the osArchitecture might in strange cases return a wrong value. - // Needs at least more testing on different machines... - new Popup<>().warning(Res.get("popup.warning.wrongVersion", - osArchitecture, - Utilities.getJVMArchitecture(), - osArchitecture)) - .show(); - } + checkForCorrectOSArchitecture(); UserThread.runPeriodically(() -> Profiler.printSystemLoad(log), LOG_MEMORY_PERIOD_MIN, TimeUnit.MINUTES); } catch (Throwable throwable) { log.error("Error during app init", throwable); @@ -275,6 +231,46 @@ public class BisqApp extends Application { } } + + private void addSceneKeyEventHandler() { + scene.addEventHandler(KeyEvent.KEY_RELEASED, keyEvent -> { + Utilities.isAltOrCtrlPressed(KeyCode.W, keyEvent); + if (Utilities.isCtrlPressed(KeyCode.W, keyEvent) || + Utilities.isCtrlPressed(KeyCode.Q, keyEvent)) { + stop(); + } else { + if (Utilities.isAltOrCtrlPressed(KeyCode.E, keyEvent)) { + showEmptyWalletPopup(injector.getInstance(BtcWalletService.class)); + } else if (Utilities.isAltOrCtrlPressed(KeyCode.M, keyEvent)) { + showSendAlertMessagePopup(); + } else if (Utilities.isAltOrCtrlPressed(KeyCode.F, keyEvent)) { + showFilterPopup(); + } else if (Utilities.isAltOrCtrlPressed(KeyCode.J, keyEvent)) { + WalletsManager walletsManager = injector.getInstance(WalletsManager.class); + if (walletsManager.areWalletsAvailable()) + new ShowWalletDataWindow(walletsManager).show(); + else + new Popup<>().warning(Res.get("popup.warning.walletNotInitialized")).show(); + } else if (Utilities.isAltOrCtrlPressed(KeyCode.G, keyEvent)) { + if (injector.getInstance(BtcWalletService.class).isWalletReady()) + injector.getInstance(ManualPayoutTxWindow.class).show(); + else + new Popup<>().warning(Res.get("popup.warning.walletNotInitialized")).show(); + } else if (DevEnv.isDevMode()) { + // dev ode only + if (Utilities.isAltOrCtrlPressed(KeyCode.B, keyEvent)) { + // BSQ empty wallet not public yet + showEmptyWalletPopup(injector.getInstance(BsqWalletService.class)); + } else if (Utilities.isAltOrCtrlPressed(KeyCode.P, keyEvent)) { + showFPSWindow(); + } else if (Utilities.isAltOrCtrlPressed(KeyCode.Z, keyEvent)) { + showDebugWindow(); + } + } + } + }); + } + private void showSendAlertMessagePopup() { AlertManager alertManager = injector.getInstance(AlertManager.class); boolean useDevPrivilegeKeys = injector.getInstance(Key.get(Boolean.class, Names.named(AppOptionKeys.USE_DEV_PRIVILEGE_KEYS))); @@ -377,6 +373,19 @@ public class BisqApp extends Application { stage.show(); } + private void checkForCorrectOSArchitecture() { + if (!Utilities.isCorrectOSArchitecture()) { + String osArchitecture = Utilities.getOSArchitecture(); + // We don't force a shutdown as the osArchitecture might in strange cases return a wrong value. + // Needs at least more testing on different machines... + new Popup<>().warning(Res.get("popup.warning.wrongVersion", + osArchitecture, + Utilities.getJVMArchitecture(), + osArchitecture)) + .show(); + } + } + @SuppressWarnings("CodeBlock2Expr") @Override public void stop() {