From 10d90d3d648caceb268d1bcf6cec335712ffe5ba Mon Sep 17 00:00:00 2001 From: Manfred Karrer Date: Mon, 1 Dec 2014 20:37:57 +0100 Subject: [PATCH] Handle Close button in popup title #300 --- .../io/bitsquare/gui/components/Popups.java | 53 +++++++++---------- .../java/io/bitsquare/gui/main/MainView.java | 2 +- .../account/content/fiat/FiatAccountView.java | 4 +- .../registration/RegistrationView.java | 1 - .../main/funds/withdrawal/WithdrawalView.java | 8 ++- .../trade/createoffer/CreateOfferView.java | 3 +- .../main/trade/offerbook/OfferBookView.java | 5 +- .../main/trade/takeoffer/TakeOfferView.java | 3 +- 8 files changed, 36 insertions(+), 43 deletions(-) diff --git a/src/main/java/io/bitsquare/gui/components/Popups.java b/src/main/java/io/bitsquare/gui/components/Popups.java index 0ad9b5806f..bdd73d3c55 100644 --- a/src/main/java/io/bitsquare/gui/components/Popups.java +++ b/src/main/java/io/bitsquare/gui/components/Popups.java @@ -51,6 +51,10 @@ public class Popups { private static OverlayManager overlayManager; + public static void removeBlurContent() { + overlayManager.removeBlurContent(); + } + // Information public static void openInfoPopup(String message) { openInfoPopup(null, message); @@ -64,7 +68,6 @@ public class Popups { public void handle(ActionEvent actionEvent) { getProperties().put("type", "CLOSE"); Dialog.Actions.CLOSE.handle(actionEvent); - overlayManager.removeBlurContent(); } }); openInfoPopup(masthead, message, actions); @@ -77,6 +80,7 @@ public class Popups { .masthead(masthead) .actions(actions) .showInformation(); + removeBlurContent(); } // Confirm @@ -92,16 +96,13 @@ public class Popups { public void handle(ActionEvent actionEvent) { getProperties().put("type", "OK"); Dialog.Actions.OK.handle(actionEvent); - overlayManager.removeBlurContent(); } - }); actions.add(new AbstractAction(BSResources.get("shared.cancel")) { @Override public void handle(ActionEvent actionEvent) { getProperties().put("type", "CANCEL"); Dialog.Actions.CANCEL.handle(actionEvent); - overlayManager.removeBlurContent(); } }); return openConfirmPopup(title, masthead, message, actions); @@ -134,7 +135,6 @@ public class Popups { public void handle(ActionEvent actionEvent) { getProperties().put("type", "CLOSE"); Dialog.Actions.CLOSE.handle(actionEvent); - overlayManager.removeBlurContent(); } }); openWarningPopup(title, masthead, message, actions); @@ -148,18 +148,19 @@ public class Popups { .masthead(masthead) .actions(actions) .showWarning(); + removeBlurContent(); } // Error - public static Action openErrorPopup(String message) { - return openErrorPopup("Error", message); + public static void openErrorPopup(String message) { + openErrorPopup("Error", message); } - public static Action openErrorPopup(String title, String message) { - return openErrorPopup(title, null, message); + public static void openErrorPopup(String title, String message) { + openErrorPopup(title, null, message); } - public static Action openErrorPopup(String title, String masthead, String message) { + public static void openErrorPopup(String title, String masthead, String message) { overlayManager.blurContent(); List actions = new ArrayList<>(); actions.add(new AbstractAction(BSResources.get("shared.close")) { @@ -167,32 +168,32 @@ public class Popups { public void handle(ActionEvent actionEvent) { getProperties().put("type", "CLOSE"); Dialog.Actions.CLOSE.handle(actionEvent); - overlayManager.removeBlurContent(); } }); - return openErrorPopup(title, masthead, message, actions); + openErrorPopup(title, masthead, message, actions); } - private static Action openErrorPopup(String title, String masthead, String message, List actions) { - return Dialogs.create() + private static void openErrorPopup(String title, String masthead, String message, List actions) { + Dialogs.create() .owner(primaryStage) .title(title) .message(message) .masthead(masthead) .actions(actions) .showError(); + removeBlurContent(); } // Exception - public static Action openExceptionPopup(Throwable throwable) { - return openExceptionPopup(throwable, "Exception", "That should not have happened..."); + public static void openExceptionPopup(Throwable throwable) { + openExceptionPopup(throwable, "Exception", "That should not have happened..."); } - public static Action openExceptionPopup(Throwable throwable, String title, String message) { - return openExceptionPopup(throwable, title, null, message); + public static void openExceptionPopup(Throwable throwable, String title, String message) { + openExceptionPopup(throwable, title, null, message); } - private static Action openExceptionPopup(Throwable throwable, String title, String masthead, String message) { + private static void openExceptionPopup(Throwable throwable, String title, String masthead, String message) { overlayManager.blurContent(); List actions = new ArrayList<>(); actions.add(new AbstractAction(BSResources.get("shared.close")) { @@ -200,16 +201,16 @@ public class Popups { public void handle(ActionEvent actionEvent) { getProperties().put("type", "CLOSE"); Dialog.Actions.CLOSE.handle(actionEvent); - overlayManager.removeBlurContent(); } }); - return Dialogs.create() + Dialogs.create() .owner(primaryStage) .title(title) .message(message) .masthead(masthead) .actions(actions) .showException(throwable); + removeBlurContent(); } // Support handling of uncaught exception from any thread (also non gui thread) @@ -221,18 +222,16 @@ public class Popups { Runnable runnable = () -> { if (Throwables.getRootCause(throwable) instanceof BlockStoreException) { - Action response = Popups.openErrorPopup("Error", "Application already running", + Popups.openErrorPopup("Error", "Application already running", "This application is already running and cannot be started twice.\n\n " + "Check your system tray to reopen the window of the running application."); - if (Popups.isOK(response)) - Platform.exit(); + Platform.exit(); } else { - Action response = Popups.openExceptionPopup(throwable, "Exception", "A critical error has occurred.", + Popups.openExceptionPopup(throwable, "Exception", "A critical error has occurred.", "Please copy the exception details and open a bug report at:\n " + "https://github.com/bitsquare/bitsquare/issues."); - if (Popups.isOK(response)) - Platform.exit(); + Platform.exit(); } }; diff --git a/src/main/java/io/bitsquare/gui/main/MainView.java b/src/main/java/io/bitsquare/gui/main/MainView.java index a8dea619c2..2a590f05e8 100644 --- a/src/main/java/io/bitsquare/gui/main/MainView.java +++ b/src/main/java/io/bitsquare/gui/main/MainView.java @@ -316,7 +316,7 @@ public class MainView extends InitializableView { // For alpha vBox.setDisable(true); - + return vBox; } diff --git a/src/main/java/io/bitsquare/gui/main/account/content/fiat/FiatAccountView.java b/src/main/java/io/bitsquare/gui/main/account/content/fiat/FiatAccountView.java index 6166179d71..a9e32943e9 100644 --- a/src/main/java/io/bitsquare/gui/main/account/content/fiat/FiatAccountView.java +++ b/src/main/java/io/bitsquare/gui/main/account/content/fiat/FiatAccountView.java @@ -212,7 +212,6 @@ public class FiatAccountView extends ActivatableViewAndModel