Handle Close button in popup title #300

This commit is contained in:
Manfred Karrer 2014-12-01 20:37:57 +01:00
parent 5645f9ba10
commit 10d90d3d64
8 changed files with 36 additions and 43 deletions

View File

@ -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<Action> 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<Action> actions) {
return Dialogs.create()
private static void openErrorPopup(String title, String masthead, String message, List<Action> 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<Action> 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();
}
};

View File

@ -316,7 +316,7 @@ public class MainView extends InitializableView<StackPane, MainViewModel> {
// For alpha
vBox.setDisable(true);
return vBox;
}

View File

@ -212,7 +212,6 @@ public class FiatAccountView extends ActivatableViewAndModel<GridPane, FiatAccou
public void handle(ActionEvent actionEvent) {
getProperties().put("type", "NO");
Dialog.Actions.NO.handle(actionEvent);
overlayManager.removeBlurContent();
}
});
@ -221,7 +220,6 @@ public class FiatAccountView extends ActivatableViewAndModel<GridPane, FiatAccou
public void handle(ActionEvent actionEvent) {
getProperties().put("type", "YES");
Dialog.Actions.YES.handle(actionEvent);
overlayManager.removeBlurContent();
}
});
@ -232,6 +230,8 @@ public class FiatAccountView extends ActivatableViewAndModel<GridPane, FiatAccou
if (Popups.isYes(response))
model.addCountryToAcceptedCountriesList();
overlayManager.removeBlurContent();
}
});

View File

@ -112,7 +112,6 @@ public class RegistrationView extends InitializableView<GridPane, RegistrationVi
if (wizard != null)
wizard.nextStep(RegistrationView.this);
Dialog.Actions.CLOSE.handle(actionEvent);
overlayManager.removeBlurContent();
}
});

View File

@ -151,12 +151,12 @@ public class WithdrawalView extends ActivatableViewAndModel {
"You receive in total: " +
formatter.formatCoinWithCode(amount.subtract(FeePolicy.TX_FEE)) + " BTC\n\n" +
"Are you sure you withdraw that amount?");
Popups.removeBlurContent();
if (Popups.isOK(response)) {
try {
walletService.sendFunds(
withdrawFromTextField.getText(), withdrawToTextField.getText(),
walletService.sendFunds(withdrawFromTextField.getText(), withdrawToTextField.getText(),
amount, callback);
fillList();
} catch (AddressFormatException e) {
Popups.openErrorPopup("Address invalid",
@ -168,13 +168,11 @@ public class WithdrawalView extends ActivatableViewAndModel {
Popups.openErrorPopup("Wrong inputs", "Please check the inputs.");
}
}
}
else {
Popups.openErrorPopup("Insufficient amount",
"The amount to transfer is lower the the transaction fee and the min. possible tx value.");
}
}
private void fillList() {

View File

@ -156,7 +156,6 @@ public class CreateOfferView extends ActivatableViewAndModel<AnchorPane, CreateO
public void handle(ActionEvent actionEvent) {
getProperties().put("type", "CLOSE");
Dialog.Actions.CLOSE.handle(actionEvent);
overlayManager.removeBlurContent();
}
});
Popups.openInfoPopup("To ensure that both traders behave fair they need to pay a security deposit.",
@ -296,6 +295,7 @@ public class CreateOfferView extends ActivatableViewAndModel<AnchorPane, CreateO
Popups.openErrorPopup(BSResources.get("shared.error"),
BSResources.get("createOffer.amountPriceBox.error.message",
model.requestPlaceOfferErrorMessage.get()));
Popups.removeBlurContent();
}
});
@ -323,7 +323,6 @@ public class CreateOfferView extends ActivatableViewAndModel<AnchorPane, CreateO
e.printStackTrace();
}
Dialog.Actions.CLOSE.handle(actionEvent);
overlayManager.removeBlurContent();
}
});

View File

@ -206,7 +206,6 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
public void handle(ActionEvent actionEvent) {
getProperties().put("type", "OK");
Dialog.Actions.OK.handle(actionEvent);
overlayManager.removeBlurContent();
navigation.setReturnPath(navigation.getCurrentPath());
navigation.navigateTo(MainView.class, AccountView.class, AccountSetupWizard.class);
}
@ -240,7 +239,6 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
public void handle(ActionEvent actionEvent) {
getProperties().put("type", "YES");
Dialog.Actions.YES.handle(actionEvent);
overlayManager.removeBlurContent();
}
});
actions.add(new AbstractAction(BSResources.get("shared.no")) {
@ -248,7 +246,6 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
public void handle(ActionEvent actionEvent) {
getProperties().put("type", "NO");
Dialog.Actions.NO.handle(actionEvent);
overlayManager.removeBlurContent();
}
});
@ -257,6 +254,8 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
restrictionsInfo,
actions);
Popups.removeBlurContent();
if (Popups.isYes(response))
navigation.navigateTo(MainView.class, AccountView.class, AccountSettingsView.class, RestrictionsView.class);
else

View File

@ -178,7 +178,6 @@ public class TakeOfferView extends ActivatableViewAndModel<AnchorPane, TakeOffer
public void handle(ActionEvent actionEvent) {
getProperties().put("type", "CLOSE");
Dialog.Actions.CLOSE.handle(actionEvent);
overlayManager.removeBlurContent();
}
});
Popups.openInfoPopup("To ensure that both traders behave fair they need to pay a security deposit.",
@ -280,6 +279,7 @@ public class TakeOfferView extends ActivatableViewAndModel<AnchorPane, TakeOffer
Popups.openErrorPopup(BSResources.get("shared.error"),
BSResources.get("takeOffer.amountPriceBox.error.message",
model.requestTakeOfferErrorMessage.get()));
Popups.removeBlurContent();
}
});
@ -308,7 +308,6 @@ public class TakeOfferView extends ActivatableViewAndModel<AnchorPane, TakeOffer
e.printStackTrace();
}
Dialog.Actions.CLOSE.handle(actionEvent);
overlayManager.removeBlurContent();
}
});