Search in sources :

Example 1 with TextFieldWithCopyIcon

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

the class TradeDetailsWindow method addContent.

private void addContent() {
    Offer offer = trade.getOffer();
    Contract contract = trade.getContract();
    int rows = 5;
    addTitledGroupBg(gridPane, ++rowIndex, rows, Res.get("tradeDetailsWindow.headline"));
    boolean myOffer = tradeManager.isMyOffer(offer);
    String fiatDirectionInfo;
    String btcDirectionInfo;
    String toReceive = " " + Res.get("shared.toReceive");
    String toSpend = " " + Res.get("shared.toSpend");
    String offerType = Res.getWithCol("shared.offerType");
    if (tradeManager.isBuyer(offer)) {
        addLabelTextField(gridPane, rowIndex, offerType, formatter.getDirectionForBuyer(myOffer, offer.getCurrencyCode()), Layout.FIRST_ROW_DISTANCE);
        fiatDirectionInfo = toSpend;
        btcDirectionInfo = toReceive;
    } else {
        addLabelTextField(gridPane, rowIndex, offerType, formatter.getDirectionForSeller(myOffer, offer.getCurrencyCode()), Layout.FIRST_ROW_DISTANCE);
        fiatDirectionInfo = toReceive;
        btcDirectionInfo = toSpend;
    }
    addLabelTextField(gridPane, ++rowIndex, Res.get("shared.btcAmount") + btcDirectionInfo, formatter.formatCoinWithCode(trade.getTradeAmount()));
    addLabelTextField(gridPane, ++rowIndex, formatter.formatVolumeLabel(offer.getCurrencyCode()) + fiatDirectionInfo, formatter.formatVolumeWithCode(trade.getTradeVolume()));
    addLabelTextField(gridPane, ++rowIndex, Res.get("shared.tradePrice"), formatter.formatPrice(trade.getTradePrice()));
    addLabelTextField(gridPane, ++rowIndex, Res.getWithCol("shared.paymentMethod"), Res.get(offer.getPaymentMethod().getId()));
    // second group
    rows = 6;
    PaymentAccountPayload buyerPaymentAccountPayload = null;
    PaymentAccountPayload sellerPaymentAccountPayload = null;
    if (contract != null) {
        rows++;
        buyerPaymentAccountPayload = contract.getBuyerPaymentAccountPayload();
        sellerPaymentAccountPayload = contract.getSellerPaymentAccountPayload();
        if (buyerPaymentAccountPayload != null)
            rows++;
        if (sellerPaymentAccountPayload != null)
            rows++;
        if (buyerPaymentAccountPayload == null && sellerPaymentAccountPayload == null)
            rows++;
    }
    if (trade.getTakerFeeTxId() != null)
        rows++;
    if (trade.getDepositTx() != null)
        rows++;
    if (trade.getPayoutTx() != null)
        rows++;
    boolean showDisputedTx = disputeManager.findOwnDispute(trade.getId()).isPresent() && disputeManager.findOwnDispute(trade.getId()).get().getDisputePayoutTxId() != null;
    if (showDisputedTx)
        rows++;
    if (trade.hasFailed())
        rows += 2;
    if (trade.getTradingPeerNodeAddress() != null)
        rows++;
    addTitledGroupBg(gridPane, ++rowIndex, rows, Res.get("shared.details"), Layout.GROUP_DISTANCE);
    addLabelTextFieldWithCopyIcon(gridPane, rowIndex, Res.get("shared.tradeId"), trade.getId(), Layout.FIRST_ROW_AND_GROUP_DISTANCE);
    addLabelTextField(gridPane, ++rowIndex, Res.get("tradeDetailsWindow.tradeDate"), formatter.formatDateTime(trade.getDate()));
    String securityDeposit = Res.getWithColAndCap("shared.buyer") + " " + formatter.formatCoinWithCode(offer.getBuyerSecurityDeposit()) + " / " + Res.getWithColAndCap("shared.seller") + " " + formatter.formatCoinWithCode(offer.getSellerSecurityDeposit());
    addLabelTextField(gridPane, ++rowIndex, Res.getWithCol("shared.securityDeposit"), securityDeposit);
    String txFee = Res.get("shared.makerTxFee", formatter.formatCoinWithCode(offer.getTxFee())) + " / " + Res.get("shared.takerTxFee", formatter.formatCoinWithCode(offer.getTxFee().multiply(3L)));
    addLabelTextField(gridPane, ++rowIndex, Res.get("tradeDetailsWindow.txFee"), txFee);
    if (trade.getArbitratorNodeAddress() != null)
        addLabelTextFieldWithCopyIcon(gridPane, ++rowIndex, Res.get("shared.arbitrator"), trade.getArbitratorNodeAddress().getFullAddress());
    if (trade.getTradingPeerNodeAddress() != null)
        addLabelTextFieldWithCopyIcon(gridPane, ++rowIndex, Res.get("tradeDetailsWindow.tradingPeersOnion"), trade.getTradingPeerNodeAddress().getFullAddress());
    if (contract != null) {
        if (buyerPaymentAccountPayload != null) {
            TextFieldWithCopyIcon tf = addLabelTextFieldWithCopyIcon(gridPane, ++rowIndex, Res.get("shared.paymentDetails", Res.get("shared.buyer")), buyerPaymentAccountPayload.getPaymentDetails()).second;
            tf.setTooltip(new Tooltip(tf.getText()));
        }
        if (sellerPaymentAccountPayload != null) {
            TextFieldWithCopyIcon tf = addLabelTextFieldWithCopyIcon(gridPane, ++rowIndex, Res.get("shared.paymentDetails", Res.get("shared.seller")), sellerPaymentAccountPayload.getPaymentDetails()).second;
            tf.setTooltip(new Tooltip(tf.getText()));
        }
        if (buyerPaymentAccountPayload == null && sellerPaymentAccountPayload == null)
            addLabelTextField(gridPane, ++rowIndex, Res.getWithCol("shared.paymentMethod"), Res.get(contract.getPaymentMethodId()));
    }
    addLabelTxIdTextField(gridPane, ++rowIndex, Res.get("shared.makerFeeTxId"), offer.getOfferFeePaymentTxId());
    if (trade.getTakerFeeTxId() != null)
        addLabelTxIdTextField(gridPane, ++rowIndex, Res.get("shared.takerFeeTxId"), trade.getTakerFeeTxId());
    if (trade.getDepositTx() != null)
        addLabelTxIdTextField(gridPane, ++rowIndex, Res.getWithCol("shared.depositTransactionId"), trade.getDepositTx().getHashAsString());
    if (trade.getPayoutTx() != null)
        addLabelTxIdTextField(gridPane, ++rowIndex, Res.get("shared.payoutTxId"), trade.getPayoutTx().getHashAsString());
    if (showDisputedTx)
        addLabelTxIdTextField(gridPane, ++rowIndex, Res.get("tradeDetailsWindow.disputedPayoutTxId"), disputeManager.findOwnDispute(trade.getId()).get().getDisputePayoutTxId());
    if (contract != null) {
        Button viewContractButton = addLabelButton(gridPane, ++rowIndex, Res.get("shared.contractAsJson"), Res.get("shared.viewContractAsJson"), 0).second;
        viewContractButton.setDefaultButton(false);
        viewContractButton.setOnAction(e -> {
            TextArea textArea = new TextArea();
            textArea.setText(trade.getContractAsJson());
            String contractAsJson = trade.getContractAsJson();
            contractAsJson += "\n\nBuyerMultiSigPubKeyHex: " + Utils.HEX.encode(contract.getBuyerMultiSigPubKey());
            contractAsJson += "\nSellerMultiSigPubKeyHex: " + Utils.HEX.encode(contract.getSellerMultiSigPubKey());
            textArea.setText(contractAsJson);
            textArea.setPrefHeight(50);
            textArea.setEditable(false);
            textArea.setWrapText(true);
            textArea.setPrefSize(800, 600);
            Scene viewContractScene = new Scene(textArea);
            Stage viewContractStage = new Stage();
            viewContractStage.setTitle(Res.get("shared.contract.title", trade.getShortId()));
            viewContractStage.setScene(viewContractScene);
            if (owner == null)
                owner = MainView.getRootContainer();
            Scene rootScene = owner.getScene();
            viewContractStage.initOwner(rootScene.getWindow());
            viewContractStage.initModality(Modality.NONE);
            viewContractStage.initStyle(StageStyle.UTILITY);
            viewContractStage.show();
            Window window = rootScene.getWindow();
            double titleBarHeight = window.getHeight() - rootScene.getHeight();
            viewContractStage.setX(Math.round(window.getX() + (owner.getWidth() - viewContractStage.getWidth()) / 2) + 200);
            viewContractStage.setY(Math.round(window.getY() + titleBarHeight + (owner.getHeight() - viewContractStage.getHeight()) / 2) + 50);
        });
    }
    if (trade.hasFailed()) {
        textArea = addLabelTextArea(gridPane, ++rowIndex, Res.get("shared.errorMessage"), "").second;
        textArea.setText(trade.getErrorMessage());
        textArea.setEditable(false);
        IntegerProperty count = new SimpleIntegerProperty(20);
        int rowHeight = 10;
        textArea.prefHeightProperty().bindBidirectional(count);
        changeListener = (ov, old, newVal) -> {
            if (newVal.intValue() > rowHeight)
                count.setValue(count.get() + newVal.intValue() + 10);
        };
        textArea.scrollTopProperty().addListener(changeListener);
        textArea.setScrollTop(30);
        TextField state = addLabelTextField(gridPane, ++rowIndex, Res.get("tradeDetailsWindow.tradeState")).second;
        state.setText(trade.getState().getPhase().name());
    }
    Button closeButton = addButtonAfterGroup(gridPane, ++rowIndex, Res.get("shared.close"));
    // TODO app wide focus
    // closeButton.requestFocus();
    closeButton.setOnAction(e -> {
        closeHandlerOptional.ifPresent(Runnable::run);
        hide();
    });
}
Also used : Window(javafx.stage.Window) IntegerProperty(javafx.beans.property.IntegerProperty) SimpleIntegerProperty(javafx.beans.property.SimpleIntegerProperty) TextArea(javafx.scene.control.TextArea) TextFieldWithCopyIcon(bisq.desktop.components.TextFieldWithCopyIcon) Tooltip(javafx.scene.control.Tooltip) PaymentAccountPayload(bisq.core.payment.payload.PaymentAccountPayload) Scene(javafx.scene.Scene) Offer(bisq.core.offer.Offer) Button(javafx.scene.control.Button) Stage(javafx.stage.Stage) TextField(javafx.scene.control.TextField) Contract(bisq.core.trade.Contract) SimpleIntegerProperty(javafx.beans.property.SimpleIntegerProperty)

Example 2 with TextFieldWithCopyIcon

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

the class SellerStep3View method addContent.

// /////////////////////////////////////////////////////////////////////////////////////////
// Content
// /////////////////////////////////////////////////////////////////////////////////////////
@Override
protected void addContent() {
    addTradeInfoBlock();
    TitledGroupBg titledGroupBg = addTitledGroupBg(gridPane, ++gridRow, 3, Res.get("portfolio.pending.step3_seller.confirmPaymentReceipt"), Layout.GROUP_DISTANCE);
    TextFieldWithCopyIcon field = addLabelTextFieldWithCopyIcon(gridPane, gridRow, Res.get("portfolio.pending.step3_seller.amountToReceive"), model.getFiatVolume(), Layout.FIRST_ROW_AND_GROUP_DISTANCE).second;
    field.setCopyWithoutCurrencyPostFix(true);
    String myPaymentDetails = "";
    String peersPaymentDetails = "";
    String myTitle = "";
    String peersTitle = "";
    boolean isBlockChain = false;
    String nameByCode = CurrencyUtil.getNameByCode(trade.getOffer().getCurrencyCode());
    Contract contract = trade.getContract();
    if (contract != null) {
        PaymentAccountPayload myPaymentAccountPayload = contract.getSellerPaymentAccountPayload();
        PaymentAccountPayload peersPaymentAccountPayload = contract.getBuyerPaymentAccountPayload();
        if (myPaymentAccountPayload instanceof CryptoCurrencyAccountPayload) {
            myPaymentDetails = ((CryptoCurrencyAccountPayload) myPaymentAccountPayload).getAddress();
            peersPaymentDetails = ((CryptoCurrencyAccountPayload) peersPaymentAccountPayload).getAddress();
            myTitle = Res.get("portfolio.pending.step3_seller.yourAddress", nameByCode);
            peersTitle = Res.get("portfolio.pending.step3_seller.buyersAddress", nameByCode);
            isBlockChain = true;
        } else {
            myPaymentDetails = myPaymentAccountPayload.getPaymentDetails();
            peersPaymentDetails = peersPaymentAccountPayload.getPaymentDetails();
            myTitle = Res.get("portfolio.pending.step3_seller.yourAccount");
            peersTitle = Res.get("portfolio.pending.step3_seller.buyersAccount");
        }
    }
    TextFieldWithCopyIcon myPaymentDetailsTextField = addLabelTextFieldWithCopyIcon(gridPane, ++gridRow, myTitle, myPaymentDetails).second;
    myPaymentDetailsTextField.setMouseTransparent(false);
    myPaymentDetailsTextField.setTooltip(new Tooltip(myPaymentDetails));
    TextFieldWithCopyIcon peersPaymentDetailsTextField = addLabelTextFieldWithCopyIcon(gridPane, ++gridRow, peersTitle, peersPaymentDetails).second;
    peersPaymentDetailsTextField.setMouseTransparent(false);
    peersPaymentDetailsTextField.setTooltip(new Tooltip(peersPaymentDetails));
    if (!isBlockChain) {
        addLabelTextFieldWithCopyIcon(gridPane, ++gridRow, Res.getWithCol("shared.reasonForPayment"), model.dataModel.getReference());
        GridPane.setRowSpan(titledGroupBg, 4);
    }
    Tuple3<Button, BusyAnimation, Label> tuple = addButtonBusyAnimationLabelAfterGroup(gridPane, ++gridRow, Res.get("portfolio.pending.step3_seller.confirmReceipt"));
    confirmButton = tuple.first;
    confirmButton.setOnAction(e -> onPaymentReceived());
    busyAnimation = tuple.second;
    statusLabel = tuple.third;
}
Also used : BusyAnimation(bisq.desktop.components.BusyAnimation) Button(javafx.scene.control.Button) FormBuilder.addLabelTextFieldWithCopyIcon(bisq.desktop.util.FormBuilder.addLabelTextFieldWithCopyIcon) TextFieldWithCopyIcon(bisq.desktop.components.TextFieldWithCopyIcon) Tooltip(javafx.scene.control.Tooltip) PaymentAccountPayload(bisq.core.payment.payload.PaymentAccountPayload) Label(javafx.scene.control.Label) TitledGroupBg(bisq.desktop.components.TitledGroupBg) FormBuilder.addTitledGroupBg(bisq.desktop.util.FormBuilder.addTitledGroupBg) Contract(bisq.core.trade.Contract) CryptoCurrencyAccountPayload(bisq.core.payment.payload.CryptoCurrencyAccountPayload)

Example 3 with TextFieldWithCopyIcon

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

the class FormBuilder method addLabelTextFieldWithCopyIcon.

public static Tuple2<Label, TextFieldWithCopyIcon> addLabelTextFieldWithCopyIcon(GridPane gridPane, int rowIndex, String title, String value, double top) {
    Label label = addLabel(gridPane, rowIndex, title, top);
    TextFieldWithCopyIcon textFieldWithCopyIcon = new TextFieldWithCopyIcon();
    textFieldWithCopyIcon.setText(value);
    GridPane.setRowIndex(textFieldWithCopyIcon, rowIndex);
    GridPane.setColumnIndex(textFieldWithCopyIcon, 1);
    GridPane.setMargin(textFieldWithCopyIcon, new Insets(top, 0, 0, 0));
    gridPane.getChildren().add(textFieldWithCopyIcon);
    return new Tuple2<>(label, textFieldWithCopyIcon);
}
Also used : Insets(javafx.geometry.Insets) TextFieldWithCopyIcon(bisq.desktop.components.TextFieldWithCopyIcon) Tuple2(bisq.common.util.Tuple2) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) Label(javafx.scene.control.Label)

Example 4 with TextFieldWithCopyIcon

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

the class BuyerStep2View method addContent.

// /////////////////////////////////////////////////////////////////////////////////////////
// Content
// /////////////////////////////////////////////////////////////////////////////////////////
@Override
protected void addContent() {
    addTradeInfoBlock();
    PaymentAccountPayload paymentAccountPayload = model.dataModel.getSellersPaymentAccountPayload();
    String paymentMethodId = paymentAccountPayload != null ? paymentAccountPayload.getPaymentMethodId() : "";
    TitledGroupBg accountTitledGroupBg = FormBuilder.addTitledGroupBg(gridPane, ++gridRow, 1, Res.get("portfolio.pending.step2_buyer.startPaymentUsing", Res.get(paymentMethodId)), Layout.GROUP_DISTANCE);
    TextFieldWithCopyIcon field = FormBuilder.addLabelTextFieldWithCopyIcon(gridPane, gridRow, Res.get("portfolio.pending.step2_buyer.amountToTransfer"), model.getFiatVolume(), Layout.FIRST_ROW_AND_GROUP_DISTANCE).second;
    field.setCopyWithoutCurrencyPostFix(true);
    switch(paymentMethodId) {
        case PaymentMethod.OK_PAY_ID:
            gridRow = OKPayForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload);
            break;
        case PaymentMethod.UPHOLD_ID:
            gridRow = UpholdForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload);
            break;
        case PaymentMethod.CASH_APP_ID:
            gridRow = CashAppForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload);
            break;
        case PaymentMethod.MONEY_BEAM_ID:
            gridRow = MoneyBeamForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload);
            break;
        case PaymentMethod.VENMO_ID:
            gridRow = VenmoForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload);
            break;
        case PaymentMethod.POPMONEY_ID:
            gridRow = PopmoneyForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload);
            break;
        case PaymentMethod.REVOLUT_ID:
            gridRow = RevolutForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload);
            break;
        case PaymentMethod.PERFECT_MONEY_ID:
            gridRow = PerfectMoneyForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload);
            break;
        case PaymentMethod.SEPA_ID:
            gridRow = SepaForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload);
            break;
        case PaymentMethod.FASTER_PAYMENTS_ID:
            gridRow = FasterPaymentsForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload);
            break;
        case PaymentMethod.NATIONAL_BANK_ID:
            gridRow = NationalBankForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload);
            break;
        case PaymentMethod.SAME_BANK_ID:
            gridRow = SameBankForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload);
            break;
        case PaymentMethod.SPECIFIC_BANKS_ID:
            gridRow = SpecificBankForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload);
            break;
        case PaymentMethod.SWISH_ID:
            gridRow = SwishForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload);
            break;
        case PaymentMethod.ALI_PAY_ID:
            gridRow = AliPayForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload);
            break;
        case PaymentMethod.CLEAR_X_CHANGE_ID:
            gridRow = ClearXchangeForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload);
            break;
        case PaymentMethod.CHASE_QUICK_PAY_ID:
            gridRow = ChaseQuickPayForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload);
            break;
        case PaymentMethod.INTERAC_E_TRANSFER_ID:
            gridRow = InteracETransferForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload);
            break;
        case PaymentMethod.US_POSTAL_MONEY_ORDER_ID:
            gridRow = USPostalMoneyOrderForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload);
            break;
        case PaymentMethod.CASH_DEPOSIT_ID:
            gridRow = CashDepositForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload);
            break;
        case PaymentMethod.WESTERN_UNION_ID:
            gridRow = WesternUnionForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload);
            break;
        case PaymentMethod.BLOCK_CHAINS_ID:
            String labelTitle = Res.get("portfolio.pending.step2_buyer.sellersAddress", CurrencyUtil.getNameByCode(trade.getOffer().getCurrencyCode()));
            gridRow = CryptoCurrencyForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload, labelTitle);
            break;
        default:
            log.error("Not supported PaymentMethod: " + paymentMethodId);
    }
    if (!(paymentAccountPayload instanceof CryptoCurrencyAccountPayload))
        FormBuilder.addLabelTextFieldWithCopyIcon(gridPane, ++gridRow, Res.getWithCol("shared.reasonForPayment"), model.dataModel.getReference());
    GridPane.setRowSpan(accountTitledGroupBg, gridRow - 3);
    Tuple3<Button, BusyAnimation, Label> tuple3 = FormBuilder.addButtonBusyAnimationLabelAfterGroup(gridPane, ++gridRow, Res.get("portfolio.pending.step2_buyer.paymentStarted"));
    confirmButton = tuple3.first;
    confirmButton.setOnAction(e -> onPaymentStarted());
    busyAnimation = tuple3.second;
    statusLabel = tuple3.third;
}
Also used : BusyAnimation(bisq.desktop.components.BusyAnimation) Button(javafx.scene.control.Button) TextFieldWithCopyIcon(bisq.desktop.components.TextFieldWithCopyIcon) PaymentAccountPayload(bisq.core.payment.payload.PaymentAccountPayload) Label(javafx.scene.control.Label) TitledGroupBg(bisq.desktop.components.TitledGroupBg) CryptoCurrencyAccountPayload(bisq.core.payment.payload.CryptoCurrencyAccountPayload)

Aggregations

TextFieldWithCopyIcon (bisq.desktop.components.TextFieldWithCopyIcon)4 PaymentAccountPayload (bisq.core.payment.payload.PaymentAccountPayload)3 Button (javafx.scene.control.Button)3 Label (javafx.scene.control.Label)3 CryptoCurrencyAccountPayload (bisq.core.payment.payload.CryptoCurrencyAccountPayload)2 Contract (bisq.core.trade.Contract)2 BusyAnimation (bisq.desktop.components.BusyAnimation)2 TitledGroupBg (bisq.desktop.components.TitledGroupBg)2 Tooltip (javafx.scene.control.Tooltip)2 Tuple2 (bisq.common.util.Tuple2)1 Offer (bisq.core.offer.Offer)1 AutoTooltipLabel (bisq.desktop.components.AutoTooltipLabel)1 FormBuilder.addLabelTextFieldWithCopyIcon (bisq.desktop.util.FormBuilder.addLabelTextFieldWithCopyIcon)1 FormBuilder.addTitledGroupBg (bisq.desktop.util.FormBuilder.addTitledGroupBg)1 IntegerProperty (javafx.beans.property.IntegerProperty)1 SimpleIntegerProperty (javafx.beans.property.SimpleIntegerProperty)1 Insets (javafx.geometry.Insets)1 Scene (javafx.scene.Scene)1 TextArea (javafx.scene.control.TextArea)1 TextField (javafx.scene.control.TextField)1