Search in sources :

Example 1 with Notification

use of bisq.desktop.main.overlays.notifications.Notification in project bisq-desktop by bisq-network.

the class CreateOfferView method createListeners.

private void createListeners() {
    amountFocusedListener = (o, oldValue, newValue) -> {
        model.onFocusOutAmountTextField(oldValue, newValue);
        amountTextField.setText(model.amount.get());
    };
    minAmountFocusedListener = (o, oldValue, newValue) -> {
        model.onFocusOutMinAmountTextField(oldValue, newValue);
        minAmountTextField.setText(model.minAmount.get());
    };
    priceFocusedListener = (o, oldValue, newValue) -> {
        model.onFocusOutPriceTextField(oldValue, newValue);
        fixedPriceTextField.setText(model.price.get());
    };
    priceAsPercentageFocusedListener = (o, oldValue, newValue) -> {
        model.onFocusOutPriceAsPercentageTextField(oldValue, newValue);
        marketBasedPriceTextField.setText(model.marketPriceMargin.get());
    };
    volumeFocusedListener = (o, oldValue, newValue) -> {
        model.onFocusOutVolumeTextField(oldValue, newValue);
        volumeTextField.setText(model.volume.get());
    };
    buyerSecurityDepositFocusedListener = (o, oldValue, newValue) -> {
        model.onFocusOutBuyerSecurityDepositTextField(oldValue, newValue);
        buyerSecurityDepositInputTextField.setText(model.buyerSecurityDeposit.get());
    };
    errorMessageListener = (o, oldValue, newValue) -> {
        if (newValue != null)
            UserThread.runAfter(() -> new Popup<>().error(Res.get("createOffer.amountPriceBox.error.message", model.errorMessage.get())).show(), 100, TimeUnit.MILLISECONDS);
    };
    paymentAccountsComboBoxSelectionHandler = e -> onPaymentAccountsComboBoxSelected();
    currencyComboBoxSelectionHandler = e -> onCurrencyComboBoxSelected();
    tradeCurrencyCodeListener = (observable, oldValue, newValue) -> {
        fixedPriceTextField.clear();
        marketBasedPriceTextField.clear();
        volumeTextField.clear();
    };
    placeOfferCompletedListener = (o, oldValue, newValue) -> {
        if (DevEnv.isDevMode()) {
            close();
        } else if (newValue) {
            // We need a bit of delay to avoid issues with fade out/fade in of 2 popups
            String key = "createOfferSuccessInfo";
            if (DontShowAgainLookup.showAgain(key)) {
                UserThread.runAfter(() -> new Popup<>().headLine(Res.get("createOffer.success.headline")).feedback(Res.get("createOffer.success.info")).dontShowAgainId(key).actionButtonTextWithGoTo("navigation.portfolio.myOpenOffers").onAction(() -> {
                    // noinspection unchecked
                    UserThread.runAfter(() -> navigation.navigateTo(MainView.class, PortfolioView.class, OpenOffersView.class), 100, TimeUnit.MILLISECONDS);
                    close();
                }).onClose(this::close).show(), 1);
            } else {
                close();
            }
        }
    };
    marketPriceAvailableListener = (observable, oldValue, newValue) -> updateMarketPriceAvailable();
    getShowWalletFundedNotificationListener = (observable, oldValue, newValue) -> {
        if (newValue) {
            Notification walletFundedNotification = new Notification().headLine(Res.get("notification.walletUpdate.headline")).notification(Res.get("notification.walletUpdate.msg", btcFormatter.formatCoinWithCode(model.dataModel.getTotalToPayAsCoin().get()))).autoClose();
            walletFundedNotification.show();
        }
    };
    marketPriceMarginListener = (observable, oldValue, newValue) -> {
        if (marketBasedPriceInfoInputTextField != null) {
            String tooltip;
            if (newValue.equals("0.00")) {
                if (model.isSellOffer()) {
                    tooltip = Res.get("createOffer.info.sellAtMarketPrice");
                } else {
                    tooltip = Res.get("createOffer.info.buyAtMarketPrice");
                }
                final Label atMarketPriceLabel = createPopoverLabel(tooltip);
                marketBasedPriceInfoInputTextField.setContentForInfoPopOver(atMarketPriceLabel);
            } else if (newValue.contains("-")) {
                if (model.isSellOffer()) {
                    tooltip = Res.get("createOffer.warning.sellBelowMarketPrice", newValue.substring(1));
                } else {
                    tooltip = Res.get("createOffer.warning.buyAboveMarketPrice", newValue.substring(1));
                }
                final Label negativePercentageLabel = createPopoverLabel(tooltip);
                marketBasedPriceInfoInputTextField.setContentForWarningPopOver(negativePercentageLabel);
            } else if (!newValue.equals("")) {
                if (model.isSellOffer()) {
                    tooltip = Res.get("createOffer.info.sellAboveMarketPrice", newValue);
                } else {
                    tooltip = Res.get("createOffer.info.buyBelowMarketPrice", newValue);
                }
                final Label positivePercentageLabel = createPopoverLabel(tooltip);
                marketBasedPriceInfoInputTextField.setContentForInfoPopOver(positivePercentageLabel);
            }
        }
    };
}
Also used : MainView(bisq.desktop.main.MainView) OpenOffersView(bisq.desktop.main.portfolio.openoffer.OpenOffersView) Popup(bisq.desktop.main.overlays.popups.Popup) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) Label(javafx.scene.control.Label) PortfolioView(bisq.desktop.main.portfolio.PortfolioView) Notification(bisq.desktop.main.overlays.notifications.Notification)

Example 2 with Notification

use of bisq.desktop.main.overlays.notifications.Notification in project bisq-desktop by bisq-network.

the class TakeOfferView method onShowPayFundsScreen.

@SuppressWarnings("PointlessBooleanExpression")
private void onShowPayFundsScreen() {
    nextButton.setVisible(false);
    nextButton.setManaged(false);
    nextButton.setOnAction(null);
    cancelButton1.setVisible(false);
    cancelButton1.setManaged(false);
    cancelButton1.setOnAction(null);
    model.onShowPayFundsScreen();
    amountTextField.setMouseTransparent(true);
    amountTextField.setFocusTraversable(false);
    priceTextField.setMouseTransparent(true);
    priceAsPercentageTextField.setMouseTransparent(true);
    volumeTextField.setMouseTransparent(true);
    balanceTextField.setTargetAmount(model.dataModel.getTotalToPayAsCoin().get());
    if (!DevEnv.isDevMode()) {
        String key = "securityDepositInfo";
        new Popup<>().backgroundInfo(Res.get("popup.info.securityDepositInfo")).actionButtonText(Res.get("shared.faq")).onAction(() -> GUIUtil.openWebPage("https://bisq.network/faq#6")).useIUnderstandButton().dontShowAgainId(key).show();
        String tradeAmountText = model.isSeller() ? Res.get("takeOffer.takeOfferFundWalletInfo.tradeAmount", model.getTradeAmount()) : "";
        String message = Res.get("takeOffer.takeOfferFundWalletInfo.msg", model.totalToPay.get(), tradeAmountText, model.getSecurityDepositInfo(), model.getTakerFee(), model.getTxFee());
        key = "takeOfferFundWalletInfo";
        new Popup<>().headLine(Res.get("takeOffer.takeOfferFundWalletInfo.headline")).instruction(message).dontShowAgainId(key).show();
    }
    offerAvailabilityBusyAnimation.stop();
    cancelButton2.setVisible(true);
    waitingForFundsBusyAnimation.play();
    payFundsPane.setVisible(true);
    totalToPayLabel.setVisible(true);
    totalToPayTextField.setVisible(true);
    addressLabel.setVisible(true);
    addressTextField.setVisible(true);
    qrCodeImageView.setVisible(true);
    balanceLabel.setVisible(true);
    balanceTextField.setVisible(true);
    totalToPayTextField.setFundsStructure(Res.get("takeOffer.fundsBox.fundsStructure", model.getSecurityDepositWithCode(), model.getMakerFeePercentage(), model.getTxFeePercentage()));
    totalToPayTextField.setContentForInfoPopOver(createInfoPopover());
    if (model.dataModel.getIsBtcWalletFunded().get()) {
        if (walletFundedNotification == null) {
            walletFundedNotification = new Notification().headLine(Res.get("notification.walletUpdate.headline")).notification(Res.get("notification.takeOffer.walletUpdate.msg", formatter.formatCoinWithCode(model.dataModel.getTotalToPayAsCoin().get()))).autoClose();
            walletFundedNotification.show();
        }
    }
    final byte[] imageBytes = QRCode.from(getBitcoinURI()).withSize(98, // code has 41 elements 8 px is border with 98 we get double scale and min. border
    98).to(ImageType.PNG).stream().toByteArray();
    Image qrImage = new Image(new ByteArrayInputStream(imageBytes));
    qrCodeImageView.setImage(qrImage);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) Popup(bisq.desktop.main.overlays.popups.Popup) Image(javafx.scene.image.Image) Notification(bisq.desktop.main.overlays.notifications.Notification)

Example 3 with Notification

use of bisq.desktop.main.overlays.notifications.Notification in project bisq-desktop by bisq-network.

the class TakeOfferView method initialize.

@Override
protected void initialize() {
    addScrollPane();
    addGridPane();
    addPaymentGroup();
    addAmountPriceGroup();
    addButtons();
    addOfferAvailabilityLabel();
    addFundingGroup();
    balanceTextField.setFormatter(model.getBtcFormatter());
    amountFocusedListener = (o, oldValue, newValue) -> {
        model.onFocusOutAmountTextField(oldValue, newValue, amountTextField.getText());
        amountTextField.setText(model.amount.get());
    };
    getShowWalletFundedNotificationListener = (observable, oldValue, newValue) -> {
        if (newValue) {
            Notification walletFundedNotification = new Notification().headLine(Res.get("notification.walletUpdate.headline")).notification(Res.get("notification.walletUpdate.msg", formatter.formatCoinWithCode(model.dataModel.getTotalToPayAsCoin().get()))).autoClose();
            walletFundedNotification.show();
        }
    };
    GUIUtil.focusWhenAddedToScene(amountTextField);
}
Also used : Notification(bisq.desktop.main.overlays.notifications.Notification)

Example 4 with Notification

use of bisq.desktop.main.overlays.notifications.Notification in project bisq-desktop by bisq-network.

the class BuyerStep4View method addContent.

// /////////////////////////////////////////////////////////////////////////////////////////
// Content
// /////////////////////////////////////////////////////////////////////////////////////////
@SuppressWarnings("PointlessBooleanExpression")
@Override
protected void addContent() {
    FormBuilder.addTitledGroupBg(gridPane, gridRow, 5, Res.get("portfolio.pending.step5_buyer.groupTitle"), 0);
    FormBuilder.addLabelTextField(gridPane, gridRow, getBtcTradeAmountLabel(), model.getTradeVolume(), Layout.FIRST_ROW_DISTANCE);
    FormBuilder.addLabelTextField(gridPane, ++gridRow, getFiatTradeAmountLabel(), model.getFiatVolume());
    FormBuilder.addLabelTextField(gridPane, ++gridRow, Res.get("portfolio.pending.step5_buyer.refunded"), model.getSecurityDeposit());
    FormBuilder.addLabelTextField(gridPane, ++gridRow, Res.get("portfolio.pending.step5_buyer.tradeFee"), model.getTradeFee());
    final String miningFee = model.dataModel.isMaker() ? Res.get("portfolio.pending.step5_buyer.makersMiningFee") : Res.get("portfolio.pending.step5_buyer.takersMiningFee");
    FormBuilder.addLabelTextField(gridPane, ++gridRow, miningFee, model.getTxFee());
    withdrawTitledGroupBg = FormBuilder.addTitledGroupBg(gridPane, ++gridRow, 1, Res.get("portfolio.pending.step5_buyer.withdrawBTC"), Layout.GROUP_DISTANCE);
    FormBuilder.addLabelTextField(gridPane, gridRow, Res.get("portfolio.pending.step5_buyer.amount"), model.getPayoutAmount(), Layout.FIRST_ROW_AND_GROUP_DISTANCE);
    final Tuple2<Label, InputTextField> tuple2 = FormBuilder.addLabelInputTextField(gridPane, ++gridRow, Res.get("portfolio.pending.step5_buyer.withdrawToAddress"));
    withdrawAddressLabel = tuple2.first;
    withdrawAddressLabel.setManaged(false);
    withdrawAddressLabel.setVisible(false);
    withdrawAddressTextField = tuple2.second;
    withdrawAddressTextField.setManaged(false);
    withdrawAddressTextField.setVisible(false);
    HBox hBox = new HBox();
    hBox.setSpacing(10);
    useSavingsWalletButton = new AutoTooltipButton(Res.get("portfolio.pending.step5_buyer.moveToBisqWallet"));
    useSavingsWalletButton.setDefaultButton(false);
    Label label = new AutoTooltipLabel(Res.get("shared.OR"));
    label.setPadding(new Insets(5, 0, 0, 0));
    withdrawToExternalWalletButton = new AutoTooltipButton(Res.get("portfolio.pending.step5_buyer.withdrawExternal"));
    withdrawToExternalWalletButton.setDefaultButton(false);
    hBox.getChildren().addAll(useSavingsWalletButton, label, withdrawToExternalWalletButton);
    GridPane.setRowIndex(hBox, ++gridRow);
    GridPane.setColumnIndex(hBox, 1);
    GridPane.setMargin(hBox, new Insets(15, 10, 0, 0));
    gridPane.getChildren().add(hBox);
    useSavingsWalletButton.setOnAction(e -> {
        handleTradeCompleted();
        model.dataModel.tradeManager.addTradeToClosedTrades(trade);
    });
    withdrawToExternalWalletButton.setOnAction(e -> onWithdrawal());
    String key = "tradeCompleted" + trade.getId();
    // noinspection ConstantConditions
    if (!DevEnv.isDevMode() && DontShowAgainLookup.showAgain(key)) {
        DontShowAgainLookup.dontShowAgain(key, true);
        new Notification().headLine(Res.get("notification.tradeCompleted.headline")).notification(Res.get("notification.tradeCompleted.msg")).autoClose().show();
    }
}
Also used : HBox(javafx.scene.layout.HBox) Insets(javafx.geometry.Insets) InputTextField(bisq.desktop.components.InputTextField) Label(javafx.scene.control.Label) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) Notification(bisq.desktop.main.overlays.notifications.Notification)

Aggregations

Notification (bisq.desktop.main.overlays.notifications.Notification)4 AutoTooltipLabel (bisq.desktop.components.AutoTooltipLabel)2 Popup (bisq.desktop.main.overlays.popups.Popup)2 Label (javafx.scene.control.Label)2 AutoTooltipButton (bisq.desktop.components.AutoTooltipButton)1 InputTextField (bisq.desktop.components.InputTextField)1 MainView (bisq.desktop.main.MainView)1 PortfolioView (bisq.desktop.main.portfolio.PortfolioView)1 OpenOffersView (bisq.desktop.main.portfolio.openoffer.OpenOffersView)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 Insets (javafx.geometry.Insets)1 Image (javafx.scene.image.Image)1 HBox (javafx.scene.layout.HBox)1