Fix problem with popup response not recognized

This commit is contained in:
Manfred Karrer 2014-10-23 18:24:42 +02:00
parent 98b6f72f90
commit 3df091c406
8 changed files with 39 additions and 9 deletions

View file

@ -17,7 +17,6 @@
package io.bitsquare.gui.components; package io.bitsquare.gui.components;
import io.bitsquare.BitSquare;
import io.bitsquare.BitSquareUI; import io.bitsquare.BitSquareUI;
import io.bitsquare.gui.OverlayManager; import io.bitsquare.gui.OverlayManager;
import io.bitsquare.locale.BSResources; import io.bitsquare.locale.BSResources;
@ -61,6 +60,7 @@ public class Popups {
actions.add(new AbstractAction(BSResources.get("shared.close")) { actions.add(new AbstractAction(BSResources.get("shared.close")) {
@Override @Override
public void handle(ActionEvent actionEvent) { public void handle(ActionEvent actionEvent) {
getProperties().put("type", "CLOSE");
Dialog.Actions.CLOSE.handle(actionEvent); Dialog.Actions.CLOSE.handle(actionEvent);
overlayManager.removeBlurContent(); overlayManager.removeBlurContent();
} }
@ -88,13 +88,16 @@ public class Popups {
actions.add(new AbstractAction(BSResources.get("shared.ok")) { actions.add(new AbstractAction(BSResources.get("shared.ok")) {
@Override @Override
public void handle(ActionEvent actionEvent) { public void handle(ActionEvent actionEvent) {
getProperties().put("type", "OK");
Dialog.Actions.OK.handle(actionEvent); Dialog.Actions.OK.handle(actionEvent);
overlayManager.removeBlurContent(); overlayManager.removeBlurContent();
} }
}); });
actions.add(new AbstractAction(BSResources.get("shared.cancel")) { actions.add(new AbstractAction(BSResources.get("shared.cancel")) {
@Override @Override
public void handle(ActionEvent actionEvent) { public void handle(ActionEvent actionEvent) {
getProperties().put("type", "CANCEL");
Dialog.Actions.CANCEL.handle(actionEvent); Dialog.Actions.CANCEL.handle(actionEvent);
overlayManager.removeBlurContent(); overlayManager.removeBlurContent();
} }
@ -127,6 +130,7 @@ public class Popups {
actions.add(new AbstractAction(BSResources.get("shared.close")) { actions.add(new AbstractAction(BSResources.get("shared.close")) {
@Override @Override
public void handle(ActionEvent actionEvent) { public void handle(ActionEvent actionEvent) {
getProperties().put("type", "CLOSE");
Dialog.Actions.CLOSE.handle(actionEvent); Dialog.Actions.CLOSE.handle(actionEvent);
overlayManager.removeBlurContent(); overlayManager.removeBlurContent();
} }
@ -159,6 +163,7 @@ public class Popups {
actions.add(new AbstractAction(BSResources.get("shared.close")) { actions.add(new AbstractAction(BSResources.get("shared.close")) {
@Override @Override
public void handle(ActionEvent actionEvent) { public void handle(ActionEvent actionEvent) {
getProperties().put("type", "CLOSE");
Dialog.Actions.CLOSE.handle(actionEvent); Dialog.Actions.CLOSE.handle(actionEvent);
overlayManager.removeBlurContent(); overlayManager.removeBlurContent();
} }
@ -191,6 +196,7 @@ public class Popups {
actions.add(new AbstractAction(BSResources.get("shared.close")) { actions.add(new AbstractAction(BSResources.get("shared.close")) {
@Override @Override
public void handle(ActionEvent actionEvent) { public void handle(ActionEvent actionEvent) {
getProperties().put("type", "CLOSE");
Dialog.Actions.CLOSE.handle(actionEvent); Dialog.Actions.CLOSE.handle(actionEvent);
overlayManager.removeBlurContent(); overlayManager.removeBlurContent();
} }
@ -216,14 +222,14 @@ public class Popups {
Action response = Popups.openErrorPopup("Error", "Application already running", Action response = Popups.openErrorPopup("Error", "Application already running",
"This application is already running and cannot be started twice.\n\n " + "This application is already running and cannot be started twice.\n\n " +
"Check your system tray to reopen the window of the running application."); "Check your system tray to reopen the window of the running application.");
if (response == Dialog.Actions.OK) if (Popups.isOK(response))
Platform.exit(); Platform.exit();
} }
else { else {
Action response = Popups.openExceptionPopup(throwable, "Exception", "A critical error has occurred.", Action response = Popups.openExceptionPopup(throwable, "Exception", "A critical error has occurred.",
"Please copy the exception details and open a bug report at:\n " + "Please copy the exception details and open a bug report at:\n " +
"https://github.com/bitsquare/bitsquare/issues."); "https://github.com/bitsquare/bitsquare/issues.");
if (response == Dialog.Actions.OK) if (Popups.isOK(response))
Platform.exit(); Platform.exit();
} }
}; };
@ -239,4 +245,13 @@ public class Popups {
openWarningPopup("Warning", "There is not enough money available", openWarningPopup("Warning", "There is not enough money available",
"Please pay in first to your wallet."); "Please pay in first to your wallet.");
} }
public static boolean isOK(Action response) {
return response.getProperties().get("type").equals("OK");
}
public static boolean isYes(Action response) {
return response.getProperties().get("type").equals("YES");
}
} }

View file

@ -247,6 +247,7 @@ public class FiatAccountViewCB extends CachedViewCB<FiatAccountPm> implements Co
actions.add(new AbstractAction(BSResources.get("shared.no")) { actions.add(new AbstractAction(BSResources.get("shared.no")) {
@Override @Override
public void handle(ActionEvent actionEvent) { public void handle(ActionEvent actionEvent) {
getProperties().put("type", "NO");
Dialog.Actions.NO.handle(actionEvent); Dialog.Actions.NO.handle(actionEvent);
overlayManager.removeBlurContent(); overlayManager.removeBlurContent();
} }
@ -255,6 +256,7 @@ public class FiatAccountViewCB extends CachedViewCB<FiatAccountPm> implements Co
actions.add(new AbstractAction(BSResources.get("shared.yes")) { actions.add(new AbstractAction(BSResources.get("shared.yes")) {
@Override @Override
public void handle(ActionEvent actionEvent) { public void handle(ActionEvent actionEvent) {
getProperties().put("type", "YES");
Dialog.Actions.YES.handle(actionEvent); Dialog.Actions.YES.handle(actionEvent);
overlayManager.removeBlurContent(); overlayManager.removeBlurContent();
} }
@ -265,7 +267,7 @@ public class FiatAccountViewCB extends CachedViewCB<FiatAccountPm> implements Co
".\n\nDo you want to add it automatically?", ".\n\nDo you want to add it automatically?",
actions); actions);
if (response == Dialog.Actions.YES) if (Popups.isYes(response))
presentationModel.addCountryToAcceptedCountriesList(); presentationModel.addCountryToAcceptedCountriesList();
} }
}); });

View file

@ -109,6 +109,7 @@ public class RegistrationViewCB extends CachedViewCB<RegistrationPM> implements
actions.add(new AbstractAction(BSResources.get("shared.copyTxId")) { actions.add(new AbstractAction(BSResources.get("shared.copyTxId")) {
@Override @Override
public void handle(ActionEvent actionEvent) { public void handle(ActionEvent actionEvent) {
getProperties().put("type", "COPY");
Clipboard clipboard = Clipboard.getSystemClipboard(); Clipboard clipboard = Clipboard.getSystemClipboard();
ClipboardContent content = new ClipboardContent(); ClipboardContent content = new ClipboardContent();
content.putString(presentationModel.getTransactionId()); content.putString(presentationModel.getTransactionId());
@ -118,6 +119,7 @@ public class RegistrationViewCB extends CachedViewCB<RegistrationPM> implements
actions.add(new AbstractAction(BSResources.get("shared.close")) { actions.add(new AbstractAction(BSResources.get("shared.close")) {
@Override @Override
public void handle(ActionEvent actionEvent) { public void handle(ActionEvent actionEvent) {
getProperties().put("type", "CLOSE");
try { try {
if (parent instanceof MultiStepNavigation) if (parent instanceof MultiStepNavigation)
((MultiStepNavigation) parent).nextStep(RegistrationViewCB.this); ((MultiStepNavigation) parent).nextStep(RegistrationViewCB.this);

View file

@ -53,7 +53,6 @@ import de.jensd.fx.fontawesome.AwesomeDude;
import de.jensd.fx.fontawesome.AwesomeIcon; import de.jensd.fx.fontawesome.AwesomeIcon;
import org.controlsfx.control.action.Action; import org.controlsfx.control.action.Action;
import org.controlsfx.dialog.Dialog;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -162,11 +161,14 @@ public class WithdrawalViewCB extends CachedViewCB {
if (transaction != null) { if (transaction != null) {
log.info("onWithdraw onSuccess tx ID:" + transaction.getHashAsString()); log.info("onWithdraw onSuccess tx ID:" + transaction.getHashAsString());
} }
else {
log.error("onWithdraw transaction is null");
}
} }
@Override @Override
public void onFailure(@NotNull Throwable t) { public void onFailure(@NotNull Throwable t) {
log.debug("onWithdraw onFailure"); log.error("onWithdraw onFailure");
} }
}; };
@ -179,7 +181,7 @@ public class WithdrawalViewCB extends CachedViewCB {
"You receive in total: " + "You receive in total: " +
formatter.formatCoinWithCode(amount.subtract(FeePolicy.TX_FEE)) + " BTC\n\n" + formatter.formatCoinWithCode(amount.subtract(FeePolicy.TX_FEE)) + " BTC\n\n" +
"Are you sure you withdraw that amount?"); "Are you sure you withdraw that amount?");
if (response == Dialog.Actions.OK) { if (Popups.isOK(response)) {
try { try {
walletFacade.sendFunds( walletFacade.sendFunds(
withdrawFromTextField.getText(), withdrawToTextField.getText(), withdrawFromTextField.getText(), withdrawToTextField.getText(),

View file

@ -251,7 +251,7 @@ class PendingTradesModel extends UIModel {
formatter.formatCoinWithCode(amount.subtract(FeePolicy.TX_FEE)) + " BTC\n\n" + formatter.formatCoinWithCode(amount.subtract(FeePolicy.TX_FEE)) + " BTC\n\n" +
"Are you sure you withdraw that amount?"); "Are you sure you withdraw that amount?");
if (response == Dialog.Actions.OK) { if (Popups.isOK(response)) {
try { try {
walletFacade.sendFunds( walletFacade.sendFunds(
withdrawFromTextField.getText(), withdrawToTextField.getText(), withdrawFromTextField.getText(), withdrawToTextField.getText(),

View file

@ -191,6 +191,7 @@ public class CreateOfferViewCB extends CachedViewCB<CreateOfferPM> {
actions.add(new AbstractAction(BSResources.get("shared.close")) { actions.add(new AbstractAction(BSResources.get("shared.close")) {
@Override @Override
public void handle(ActionEvent actionEvent) { public void handle(ActionEvent actionEvent) {
getProperties().put("type", "CLOSE");
Dialog.Actions.CLOSE.handle(actionEvent); Dialog.Actions.CLOSE.handle(actionEvent);
overlayManager.removeBlurContent(); overlayManager.removeBlurContent();
} }
@ -353,6 +354,7 @@ public class CreateOfferViewCB extends CachedViewCB<CreateOfferPM> {
actions.add(new AbstractAction(BSResources.get("shared.copyTxId")) { actions.add(new AbstractAction(BSResources.get("shared.copyTxId")) {
@Override @Override
public void handle(ActionEvent actionEvent) { public void handle(ActionEvent actionEvent) {
getProperties().put("type", "COPY");
Clipboard clipboard = Clipboard.getSystemClipboard(); Clipboard clipboard = Clipboard.getSystemClipboard();
ClipboardContent content = new ClipboardContent(); ClipboardContent content = new ClipboardContent();
content.putString(presentationModel.transactionId.get()); content.putString(presentationModel.transactionId.get());
@ -362,6 +364,7 @@ public class CreateOfferViewCB extends CachedViewCB<CreateOfferPM> {
actions.add(new AbstractAction(BSResources.get("shared.close")) { actions.add(new AbstractAction(BSResources.get("shared.close")) {
@Override @Override
public void handle(ActionEvent actionEvent) { public void handle(ActionEvent actionEvent) {
getProperties().put("type", "CLOSE");
try { try {
close(); close();
} catch (Exception e) { } catch (Exception e) {

View file

@ -243,6 +243,7 @@ public class OrderBookViewCB extends CachedViewCB<OrderBookPM> {
actions.add(new AbstractAction(BSResources.get("shared.ok")) { actions.add(new AbstractAction(BSResources.get("shared.ok")) {
@Override @Override
public void handle(ActionEvent actionEvent) { public void handle(ActionEvent actionEvent) {
getProperties().put("type", "OK");
Dialog.Actions.OK.handle(actionEvent); Dialog.Actions.OK.handle(actionEvent);
overlayManager.removeBlurContent(); overlayManager.removeBlurContent();
navigation.setItemsForReturning(navigation.getCurrentItems()); navigation.setItemsForReturning(navigation.getCurrentItems());
@ -271,6 +272,7 @@ public class OrderBookViewCB extends CachedViewCB<OrderBookPM> {
actions.add(new AbstractAction(BSResources.get("shared.yes")) { actions.add(new AbstractAction(BSResources.get("shared.yes")) {
@Override @Override
public void handle(ActionEvent actionEvent) { public void handle(ActionEvent actionEvent) {
getProperties().put("type", "YES");
Dialog.Actions.YES.handle(actionEvent); Dialog.Actions.YES.handle(actionEvent);
overlayManager.removeBlurContent(); overlayManager.removeBlurContent();
} }
@ -278,6 +280,7 @@ public class OrderBookViewCB extends CachedViewCB<OrderBookPM> {
actions.add(new AbstractAction(BSResources.get("shared.no")) { actions.add(new AbstractAction(BSResources.get("shared.no")) {
@Override @Override
public void handle(ActionEvent actionEvent) { public void handle(ActionEvent actionEvent) {
getProperties().put("type", "NO");
Dialog.Actions.NO.handle(actionEvent); Dialog.Actions.NO.handle(actionEvent);
overlayManager.removeBlurContent(); overlayManager.removeBlurContent();
} }
@ -288,7 +291,7 @@ public class OrderBookViewCB extends CachedViewCB<OrderBookPM> {
restrictionsInfo, restrictionsInfo,
actions); actions);
if (response == Dialog.Actions.YES) if (Popups.isYes(response))
navigation.navigationTo(Navigation.Item.MAIN, Navigation.Item.ACCOUNT, navigation.navigationTo(Navigation.Item.MAIN, Navigation.Item.ACCOUNT,
Navigation.Item.ACCOUNT_SETTINGS, Navigation.Item.ACCOUNT_SETTINGS,
Navigation.Item.RESTRICTIONS); Navigation.Item.RESTRICTIONS);

View file

@ -207,6 +207,7 @@ public class TakeOfferViewCB extends CachedViewCB<TakeOfferPM> {
actions.add(new AbstractAction(BSResources.get("shared.close")) { actions.add(new AbstractAction(BSResources.get("shared.close")) {
@Override @Override
public void handle(ActionEvent actionEvent) { public void handle(ActionEvent actionEvent) {
getProperties().put("type", "CLOSE");
Dialog.Actions.CLOSE.handle(actionEvent); Dialog.Actions.CLOSE.handle(actionEvent);
overlayManager.removeBlurContent(); overlayManager.removeBlurContent();
} }
@ -327,6 +328,7 @@ public class TakeOfferViewCB extends CachedViewCB<TakeOfferPM> {
actions.add(new AbstractAction(BSResources.get("shared.copyTxId")) { actions.add(new AbstractAction(BSResources.get("shared.copyTxId")) {
@Override @Override
public void handle(ActionEvent actionEvent) { public void handle(ActionEvent actionEvent) {
getProperties().put("type", "COPY");
Clipboard clipboard = Clipboard.getSystemClipboard(); Clipboard clipboard = Clipboard.getSystemClipboard();
ClipboardContent content = new ClipboardContent(); ClipboardContent content = new ClipboardContent();
content.putString(presentationModel.transactionId.get()); content.putString(presentationModel.transactionId.get());
@ -336,6 +338,7 @@ public class TakeOfferViewCB extends CachedViewCB<TakeOfferPM> {
actions.add(new AbstractAction(BSResources.get("shared.close")) { actions.add(new AbstractAction(BSResources.get("shared.close")) {
@Override @Override
public void handle(ActionEvent actionEvent) { public void handle(ActionEvent actionEvent) {
getProperties().put("type", "CLOSE");
try { try {
close(); close();
navigation.navigationTo(Navigation.Item.MAIN, Navigation.Item.ORDERS, navigation.navigationTo(Navigation.Item.MAIN, Navigation.Item.ORDERS,