Search in sources :

Example 1 with BalanceTextField

use of bisq.desktop.components.BalanceTextField in project bisq-desktop by bisq-network.

the class TakeOfferView method addFundingGroup.

private void addFundingGroup() {
    // don't increase gridRow as we removed button when this gets visible
    payFundsPane = FormBuilder.addTitledGroupBg(gridPane, gridRow, 3, Res.get("takeOffer.fundsBox.title"), Layout.GROUP_DISTANCE);
    GridPane.setColumnSpan(payFundsPane, 3);
    payFundsPane.setVisible(false);
    Tuple2<Label, FundsTextField> fundsTuple = addLabelFundsTextfield(gridPane, gridRow, Res.get("shared.totalsNeeded"), Layout.FIRST_ROW_AND_GROUP_DISTANCE);
    totalToPayLabel = fundsTuple.first;
    totalToPayLabel.setVisible(false);
    totalToPayTextField = fundsTuple.second;
    totalToPayTextField.setVisible(false);
    qrCodeImageView = new ImageView();
    qrCodeImageView.setVisible(false);
    qrCodeImageView.getStyleClass().add("qr-code");
    Tooltip.install(qrCodeImageView, new Tooltip(Res.get("shared.openLargeQRWindow")));
    qrCodeImageView.setOnMouseClicked(e -> GUIUtil.showFeeInfoBeforeExecute(() -> UserThread.runAfter(() -> new QRCodeWindow(getBitcoinURI()).show(), 200, TimeUnit.MILLISECONDS)));
    GridPane.setRowIndex(qrCodeImageView, gridRow);
    GridPane.setColumnIndex(qrCodeImageView, 2);
    GridPane.setRowSpan(qrCodeImageView, 3);
    GridPane.setMargin(qrCodeImageView, new Insets(Layout.FIRST_ROW_AND_GROUP_DISTANCE - 9, 0, 0, 5));
    gridPane.getChildren().add(qrCodeImageView);
    Tuple2<Label, AddressTextField> addressTuple = FormBuilder.addLabelAddressTextField(gridPane, ++gridRow, Res.get("shared.tradeWalletAddress"));
    addressLabel = addressTuple.first;
    addressLabel.setVisible(false);
    addressTextField = addressTuple.second;
    addressTextField.setVisible(false);
    Tuple2<Label, BalanceTextField> balanceTuple = FormBuilder.addLabelBalanceTextField(gridPane, ++gridRow, Res.get("shared.tradeWalletBalance"));
    balanceLabel = balanceTuple.first;
    balanceLabel.setVisible(false);
    balanceTextField = balanceTuple.second;
    balanceTextField.setVisible(false);
    fundingHBox = new HBox();
    fundingHBox.setVisible(false);
    fundingHBox.setManaged(false);
    fundingHBox.setSpacing(10);
    Button fundFromSavingsWalletButton = new AutoTooltipButton(Res.get("shared.fundFromSavingsWalletButton"));
    fundFromSavingsWalletButton.setDefaultButton(true);
    fundFromSavingsWalletButton.setDefaultButton(false);
    fundFromSavingsWalletButton.setOnAction(e -> model.fundFromSavingsWallet());
    Label label = new AutoTooltipLabel(Res.get("shared.OR"));
    label.setPadding(new Insets(5, 0, 0, 0));
    Button fundFromExternalWalletButton = new AutoTooltipButton(Res.get("shared.fundFromExternalWalletButton"));
    fundFromExternalWalletButton.setDefaultButton(false);
    fundFromExternalWalletButton.setOnAction(e -> GUIUtil.showFeeInfoBeforeExecute(this::openWallet));
    waitingForFundsBusyAnimation = new BusyAnimation(false);
    waitingForFundsLabel = new AutoTooltipLabel();
    waitingForFundsLabel.setPadding(new Insets(5, 0, 0, 0));
    fundingHBox.getChildren().addAll(fundFromSavingsWalletButton, label, fundFromExternalWalletButton, waitingForFundsBusyAnimation, waitingForFundsLabel);
    GridPane.setRowIndex(fundingHBox, ++gridRow);
    GridPane.setColumnIndex(fundingHBox, 1);
    GridPane.setMargin(fundingHBox, new Insets(15, 10, 0, 0));
    gridPane.getChildren().add(fundingHBox);
    takeOfferButton = FormBuilder.addButtonAfterGroup(gridPane, gridRow, "");
    takeOfferButton.setVisible(false);
    takeOfferButton.setManaged(false);
    takeOfferButton.setMinHeight(40);
    takeOfferButton.setPadding(new Insets(0, 20, 0, 20));
    takeOfferButton.setOnAction(e -> onTakeOffer());
    cancelButton2 = FormBuilder.addButton(gridPane, ++gridRow, Res.get("shared.cancel"));
    cancelButton2.setOnAction(e -> {
        if (model.dataModel.getIsBtcWalletFunded().get()) {
            new Popup<>().warning(Res.get("takeOffer.alreadyFunded.askCancel")).closeButtonText(Res.get("shared.no")).actionButtonText(Res.get("shared.yesCancel")).onAction(() -> {
                model.dataModel.swapTradeToSavings();
                close();
            }).show();
        } else {
            close();
            model.dataModel.swapTradeToSavings();
        }
    });
    cancelButton2.setDefaultButton(false);
    cancelButton2.setVisible(false);
}
Also used : HBox(javafx.scene.layout.HBox) Insets(javafx.geometry.Insets) BusyAnimation(bisq.desktop.components.BusyAnimation) AddressTextField(bisq.desktop.components.AddressTextField) Tooltip(javafx.scene.control.Tooltip) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) Label(javafx.scene.control.Label) QRCodeWindow(bisq.desktop.main.overlays.windows.QRCodeWindow) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) Button(javafx.scene.control.Button) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) BalanceTextField(bisq.desktop.components.BalanceTextField) FundsTextField(bisq.desktop.components.FundsTextField) ImageView(javafx.scene.image.ImageView) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel)

Example 2 with BalanceTextField

use of bisq.desktop.components.BalanceTextField in project bisq-desktop by bisq-network.

the class TakeOfferView method addSubscriptions.

@SuppressWarnings("PointlessBooleanExpression")
private void addSubscriptions() {
    errorPopupDisplayed = new SimpleBooleanProperty();
    offerWarningSubscription = EasyBind.subscribe(model.offerWarning, newValue -> {
        if (newValue != null) {
            if (offerDetailsWindowDisplayed)
                offerDetailsWindow.hide();
            UserThread.runAfter(() -> new Popup<>().warning(newValue + "\n\n" + Res.get("takeOffer.alreadyPaidInFunds")).actionButtonTextWithGoTo("navigation.funds.availableForWithdrawal").onAction(() -> {
                errorPopupDisplayed.set(true);
                model.resetOfferWarning();
                close();
                // noinspection unchecked
                navigation.navigateTo(MainView.class, FundsView.class, WithdrawalView.class);
            }).onClose(() -> {
                errorPopupDisplayed.set(true);
                model.resetOfferWarning();
                close();
            }).show(), 100, TimeUnit.MILLISECONDS);
        }
    });
    errorMessageSubscription = EasyBind.subscribe(model.errorMessage, newValue -> {
        if (newValue != null) {
            new Popup<>().error(Res.get("takeOffer.error.message", model.errorMessage.get()) + Res.get("popup.error.tryRestart")).onClose(() -> {
                errorPopupDisplayed.set(true);
                model.resetErrorMessage();
                close();
            }).show();
        }
    });
    isOfferAvailableSubscription = EasyBind.subscribe(model.isOfferAvailable, isOfferAvailable -> {
        if (isOfferAvailable)
            offerAvailabilityBusyAnimation.stop();
        offerAvailabilityLabel.setVisible(!isOfferAvailable);
        offerAvailabilityLabel.setManaged(!isOfferAvailable);
    });
    isWaitingForFundsSubscription = EasyBind.subscribe(model.isWaitingForFunds, isWaitingForFunds -> {
        waitingForFundsBusyAnimation.setIsRunning(isWaitingForFunds);
        waitingForFundsLabel.setVisible(isWaitingForFunds);
        waitingForFundsLabel.setManaged(isWaitingForFunds);
    });
    showWarningInvalidBtcDecimalPlacesSubscription = EasyBind.subscribe(model.showWarningInvalidBtcDecimalPlaces, newValue -> {
        if (newValue) {
            new Popup<>().warning(Res.get("takeOffer.amountPriceBox.warning.invalidBtcDecimalPlaces")).show();
            model.showWarningInvalidBtcDecimalPlaces.set(false);
        }
    });
    showTransactionPublishedScreenSubscription = EasyBind.subscribe(model.showTransactionPublishedScreen, newValue -> {
        // noinspection ConstantConditions
        if (newValue && DevEnv.isDevMode()) {
            close();
        } else // noinspection ConstantConditions,ConstantConditions
        if (newValue && model.getTrade() != null && !model.getTrade().hasFailed()) {
            String key = "takeOfferSuccessInfo";
            if (DontShowAgainLookup.showAgain(key)) {
                UserThread.runAfter(() -> new Popup<>().headLine(Res.get("takeOffer.success.headline")).feedback(Res.get("takeOffer.success.info")).actionButtonTextWithGoTo("navigation.portfolio.pending").dontShowAgainId(key).onAction(() -> {
                    // noinspection unchecked
                    UserThread.runAfter(() -> navigation.navigateTo(MainView.class, PortfolioView.class, PendingTradesView.class), 100, TimeUnit.MILLISECONDS);
                    close();
                }).onClose(this::close).show(), 1);
            } else {
                close();
            }
        }
    });
    /*       noSufficientFeeBinding = EasyBind.combine(model.dataModel.getIsWalletFunded(), model.dataModel.isMainNet, model.dataModel.isFeeFromFundingTxSufficient,
                (getIsWalletFunded(), isMainNet, isFeeSufficient) -> getIsWalletFunded() && isMainNet && !isFeeSufficient);
        noSufficientFeeSubscription = noSufficientFeeBinding.subscribe((observable, oldValue, newValue) -> {
            if (newValue)
                new Popup<>().warning("The mining fee from your funding transaction is not sufficiently high.\n\n" +
                        "You need to use at least a mining fee of " +
                        model.formatter.formatCoinWithCode(FeePolicy.getMinRequiredFeeForFundingTx()) + ".\n\n" +
                        "The fee used in your funding transaction was only " +
                        model.formatter.formatCoinWithCode(model.dataModel.feeFromFundingTx) + ".\n\n" +
                        "The trade transactions might take too much time to be included in " +
                        "a block if the fee is too low.\n" +
                        "Please check at your external wallet that you set the required fee and " +
                        "do a funding again with the correct fee.\n\n" +
                        "In the \"Funds/Open for withdrawal\" section you can withdraw those funds.")
                        .closeButtonText(Res.get("shared.close"))
                        .onClose(() -> {
                            close();
                            navigation.navigateTo(MainView.class, FundsView.class, WithdrawalView.class);
                        })
                        .show();
        });*/
    balanceSubscription = EasyBind.subscribe(model.dataModel.getBalance(), balanceTextField::setBalance);
    cancelButton2StyleSubscription = EasyBind.subscribe(takeOfferButton.visibleProperty(), isVisible -> cancelButton2.setId(isVisible ? "cancel-button" : null));
}
Also used : Button(javafx.scene.control.Button) HPos(javafx.geometry.HPos) Pos(javafx.geometry.Pos) BusyAnimation(bisq.desktop.components.BusyAnimation) QRCodeWindow(bisq.desktop.main.overlays.windows.QRCodeWindow) Utilities(bisq.common.util.Utilities) ArbitratorSelectionView(bisq.desktop.main.account.content.arbitratorselection.ArbitratorSelectionView) Coin(org.bitcoinj.core.Coin) BalanceTextField(bisq.desktop.components.BalanceTextField) FormBuilder.addLabelFundsTextfield(bisq.desktop.util.FormBuilder.addLabelFundsTextfield) Layout(bisq.desktop.util.Layout) VBox(javafx.scene.layout.VBox) BSFormatter(bisq.desktop.util.BSFormatter) FeeOptionWindow(bisq.desktop.main.overlays.windows.FeeOptionWindow) ScrollPane(javafx.scene.control.ScrollPane) InputTextField(bisq.desktop.components.InputTextField) QRCode(net.glxn.qrgen.QRCode) ComboBox(javafx.scene.control.ComboBox) ByteArrayInputStream(java.io.ByteArrayInputStream) Res(bisq.core.locale.Res) ImageType(net.glxn.qrgen.image.ImageType) URI(java.net.URI) BsqWalletView(bisq.desktop.main.dao.wallet.BsqWalletView) Navigation(bisq.desktop.Navigation) HBox(javafx.scene.layout.HBox) Orientation(javafx.geometry.Orientation) Popup(bisq.desktop.main.overlays.popups.Popup) Offer(bisq.core.offer.Offer) TextField(javafx.scene.control.TextField) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) Font(javafx.scene.text.Font) FormBuilder(bisq.desktop.util.FormBuilder) Subscription(org.fxmisc.easybind.Subscription) PaymentMethod(bisq.core.payment.payload.PaymentMethod) Separator(javafx.scene.control.Separator) Priority(javafx.scene.layout.Priority) PaymentAccount(bisq.core.payment.PaymentAccount) DevEnv(bisq.common.app.DevEnv) AnchorPane(javafx.scene.layout.AnchorPane) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) UserThread(bisq.common.UserThread) AccountSettingsView(bisq.desktop.main.account.settings.AccountSettingsView) NotNull(org.jetbrains.annotations.NotNull) PortfolioView(bisq.desktop.main.portfolio.PortfolioView) GUIUtil(bisq.desktop.util.GUIUtil) ColumnConstraints(javafx.scene.layout.ColumnConstraints) OfferDetailsWindow(bisq.desktop.main.overlays.windows.OfferDetailsWindow) FormBuilder.getNonEditableValueCurrencyBox(bisq.desktop.util.FormBuilder.getNonEditableValueCurrencyBox) FundsTextField(bisq.desktop.components.FundsTextField) PendingTradesView(bisq.desktop.main.portfolio.pendingtrades.PendingTradesView) FormBuilder.getAmountCurrencyBox(bisq.desktop.util.FormBuilder.getAmountCurrencyBox) Notification(bisq.desktop.main.overlays.notifications.Notification) FxmlView(bisq.desktop.common.view.FxmlView) Inject(javax.inject.Inject) Tuple2(bisq.common.util.Tuple2) WithdrawalView(bisq.desktop.main.funds.withdrawal.WithdrawalView) OfferPayload(bisq.core.offer.OfferPayload) Tuple3(bisq.common.util.Tuple3) Insets(javafx.geometry.Insets) VPos(javafx.geometry.VPos) FundsView(bisq.desktop.main.funds.FundsView) Tooltip(javafx.scene.control.Tooltip) TitledGroupBg(bisq.desktop.components.TitledGroupBg) AccountView(bisq.desktop.main.account.AccountView) GridPane(javafx.scene.layout.GridPane) BsqReceiveView(bisq.desktop.main.dao.wallet.receive.BsqReceiveView) DaoView(bisq.desktop.main.dao.DaoView) Label(javafx.scene.control.Label) DontShowAgainLookup(bisq.core.user.DontShowAgainLookup) OfferView(bisq.desktop.main.offer.OfferView) AddressTextField(bisq.desktop.components.AddressTextField) BsqFormatter(bisq.desktop.util.BsqFormatter) TimeUnit(java.util.concurrent.TimeUnit) MainView(bisq.desktop.main.MainView) Bindings.createStringBinding(javafx.beans.binding.Bindings.createStringBinding) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) EasyBind(org.fxmisc.easybind.EasyBind) ImageView(javafx.scene.image.ImageView) ActivatableViewAndModel(bisq.desktop.common.view.ActivatableViewAndModel) ChangeListener(javafx.beans.value.ChangeListener) Image(javafx.scene.image.Image) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) Popup(bisq.desktop.main.overlays.popups.Popup)

Example 3 with BalanceTextField

use of bisq.desktop.components.BalanceTextField in project bisq-desktop by bisq-network.

the class CreateOfferView method addFundingGroup.

private void addFundingGroup() {
    // don't increase gridRow as we removed button when this gets visible
    payFundsTitledGroupBg = addTitledGroupBg(gridPane, gridRow, 3, Res.get("createOffer.fundsBox.title"), Layout.GROUP_DISTANCE);
    GridPane.setColumnSpan(payFundsTitledGroupBg, 3);
    payFundsTitledGroupBg.setVisible(false);
    Tuple2<Label, FundsTextField> fundsTuple = addLabelFundsTextfield(gridPane, gridRow, Res.get("shared.totalsNeeded"), Layout.FIRST_ROW_AND_GROUP_DISTANCE);
    totalToPayLabel = fundsTuple.first;
    totalToPayLabel.setVisible(false);
    totalToPayTextField = fundsTuple.second;
    totalToPayTextField.setVisible(false);
    qrCodeImageView = new ImageView();
    qrCodeImageView.setVisible(false);
    qrCodeImageView.getStyleClass().add("qr-code");
    Tooltip.install(qrCodeImageView, new Tooltip(Res.get("shared.openLargeQRWindow")));
    qrCodeImageView.setOnMouseClicked(e -> GUIUtil.showFeeInfoBeforeExecute(() -> UserThread.runAfter(() -> new QRCodeWindow(getBitcoinURI()).show(), 200, TimeUnit.MILLISECONDS)));
    GridPane.setRowIndex(qrCodeImageView, gridRow);
    GridPane.setColumnIndex(qrCodeImageView, 2);
    GridPane.setRowSpan(qrCodeImageView, 3);
    GridPane.setMargin(qrCodeImageView, new Insets(Layout.FIRST_ROW_AND_GROUP_DISTANCE - 9, 0, 0, 5));
    gridPane.getChildren().add(qrCodeImageView);
    Tuple2<Label, AddressTextField> addressTuple = addLabelAddressTextField(gridPane, ++gridRow, Res.get("shared.tradeWalletAddress"));
    addressLabel = addressTuple.first;
    addressLabel.setVisible(false);
    addressTextField = addressTuple.second;
    addressTextField.setVisible(false);
    Tuple2<Label, BalanceTextField> balanceTuple = addLabelBalanceTextField(gridPane, ++gridRow, Res.get("shared.tradeWalletBalance"));
    balanceLabel = balanceTuple.first;
    balanceLabel.setVisible(false);
    balanceTextField = balanceTuple.second;
    balanceTextField.setVisible(false);
    fundingHBox = new HBox();
    fundingHBox.setVisible(false);
    fundingHBox.setManaged(false);
    fundingHBox.setSpacing(10);
    Button fundFromSavingsWalletButton = new AutoTooltipButton(Res.get("shared.fundFromSavingsWalletButton"));
    fundFromSavingsWalletButton.setDefaultButton(false);
    fundFromSavingsWalletButton.setOnAction(e -> model.fundFromSavingsWallet());
    Label label = new AutoTooltipLabel(Res.get("shared.OR"));
    label.setPadding(new Insets(5, 0, 0, 0));
    Button fundFromExternalWalletButton = new AutoTooltipButton(Res.get("shared.fundFromExternalWalletButton"));
    fundFromExternalWalletButton.setDefaultButton(false);
    fundFromExternalWalletButton.setOnAction(e -> GUIUtil.showFeeInfoBeforeExecute(this::openWallet));
    waitingForFundsBusyAnimation = new BusyAnimation();
    waitingForFundsLabel = new AutoTooltipLabel();
    waitingForFundsLabel.setPadding(new Insets(5, 0, 0, 0));
    fundingHBox.getChildren().addAll(fundFromSavingsWalletButton, label, fundFromExternalWalletButton, waitingForFundsBusyAnimation, waitingForFundsLabel);
    GridPane.setRowIndex(fundingHBox, ++gridRow);
    GridPane.setColumnIndex(fundingHBox, 1);
    GridPane.setMargin(fundingHBox, new Insets(15, 10, 0, 0));
    gridPane.getChildren().add(fundingHBox);
    placeOfferButton = addButtonAfterGroup(gridPane, gridRow, "");
    placeOfferButton.setOnAction(e -> onPlaceOffer());
    placeOfferButton.setMinHeight(40);
    placeOfferButton.setPadding(new Insets(0, 20, 0, 20));
    cancelButton2 = addButton(gridPane, ++gridRow, Res.get("shared.cancel"));
    cancelButton2.setOnAction(e -> {
        if (model.dataModel.getIsBtcWalletFunded().get()) {
            new Popup<>().warning(Res.get("createOffer.warnCancelOffer")).closeButtonText(Res.get("shared.no")).actionButtonText(Res.get("shared.yesCancel")).onAction(() -> {
                close();
                model.dataModel.swapTradeToSavings();
            }).show();
        } else {
            close();
            model.dataModel.swapTradeToSavings();
        }
    });
    cancelButton2.setDefaultButton(false);
    cancelButton2.setVisible(false);
}
Also used : HBox(javafx.scene.layout.HBox) Insets(javafx.geometry.Insets) BusyAnimation(bisq.desktop.components.BusyAnimation) AddressTextField(bisq.desktop.components.AddressTextField) Tooltip(javafx.scene.control.Tooltip) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) Label(javafx.scene.control.Label) QRCodeWindow(bisq.desktop.main.overlays.windows.QRCodeWindow) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) Button(javafx.scene.control.Button) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) BalanceTextField(bisq.desktop.components.BalanceTextField) FundsTextField(bisq.desktop.components.FundsTextField) ImageView(javafx.scene.image.ImageView) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel)

Example 4 with BalanceTextField

use of bisq.desktop.components.BalanceTextField in project bisq-desktop by bisq-network.

the class FormBuilder method addLabelBalanceTextField.

// /////////////////////////////////////////////////////////////////////////////////////////
// Label  + BalanceTextField
// /////////////////////////////////////////////////////////////////////////////////////////
public static Tuple2<Label, BalanceTextField> addLabelBalanceTextField(GridPane gridPane, int rowIndex, String title) {
    Label label = addLabel(gridPane, rowIndex, title, 0);
    BalanceTextField balanceTextField = new BalanceTextField();
    GridPane.setRowIndex(balanceTextField, rowIndex);
    GridPane.setColumnIndex(balanceTextField, 1);
    gridPane.getChildren().add(balanceTextField);
    return new Tuple2<>(label, balanceTextField);
}
Also used : Tuple2(bisq.common.util.Tuple2) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) Label(javafx.scene.control.Label) BalanceTextField(bisq.desktop.components.BalanceTextField)

Aggregations

AutoTooltipLabel (bisq.desktop.components.AutoTooltipLabel)4 BalanceTextField (bisq.desktop.components.BalanceTextField)4 Label (javafx.scene.control.Label)4 AddressTextField (bisq.desktop.components.AddressTextField)3 AutoTooltipButton (bisq.desktop.components.AutoTooltipButton)3 BusyAnimation (bisq.desktop.components.BusyAnimation)3 FundsTextField (bisq.desktop.components.FundsTextField)3 QRCodeWindow (bisq.desktop.main.overlays.windows.QRCodeWindow)3 Insets (javafx.geometry.Insets)3 Button (javafx.scene.control.Button)3 Tooltip (javafx.scene.control.Tooltip)3 ImageView (javafx.scene.image.ImageView)3 HBox (javafx.scene.layout.HBox)3 Tuple2 (bisq.common.util.Tuple2)2 UserThread (bisq.common.UserThread)1 DevEnv (bisq.common.app.DevEnv)1 Tuple3 (bisq.common.util.Tuple3)1 Utilities (bisq.common.util.Utilities)1 Res (bisq.core.locale.Res)1 Offer (bisq.core.offer.Offer)1