Search in sources :

Example 1 with TextFieldWithCopyIcon

use of io.bitsquare.gui.components.TextFieldWithCopyIcon in project bitsquare by bitsquare.

the class BuyerStep2View method addContent.

///////////////////////////////////////////////////////////////////////////////////////////
// Content
///////////////////////////////////////////////////////////////////////////////////////////
@Override
protected void addContent() {
    addTradeInfoBlock();
    PaymentAccountContractData paymentAccountContractData = model.dataModel.getSellersPaymentAccountContractData();
    String paymentMethodName = paymentAccountContractData != null ? paymentAccountContractData.getPaymentMethodName() : "";
    TitledGroupBg accountTitledGroupBg = addTitledGroupBg(gridPane, ++gridRow, 1, "Start payment using " + BSResources.get(paymentMethodName), Layout.GROUP_DISTANCE);
    TextFieldWithCopyIcon field = addLabelTextFieldWithCopyIcon(gridPane, gridRow, "Amount to transfer:", model.getFiatVolume(), Layout.FIRST_ROW_AND_GROUP_DISTANCE).second;
    field.setCopyWithoutCurrencyPostFix(true);
    switch(paymentMethodName) {
        case PaymentMethod.OK_PAY_ID:
            gridRow = OKPayForm.addFormForBuyer(gridPane, gridRow, paymentAccountContractData);
            break;
        case PaymentMethod.PERFECT_MONEY_ID:
            gridRow = PerfectMoneyForm.addFormForBuyer(gridPane, gridRow, paymentAccountContractData);
            break;
        case PaymentMethod.SEPA_ID:
            gridRow = SepaForm.addFormForBuyer(gridPane, gridRow, paymentAccountContractData);
            break;
        case PaymentMethod.FASTER_PAYMENTS_ID:
            gridRow = FasterPaymentsForm.addFormForBuyer(gridPane, gridRow, paymentAccountContractData);
            break;
        case PaymentMethod.NATIONAL_BANK_ID:
            gridRow = NationalBankForm.addFormForBuyer(gridPane, gridRow, paymentAccountContractData);
            break;
        case PaymentMethod.SAME_BANK_ID:
            gridRow = SameBankForm.addFormForBuyer(gridPane, gridRow, paymentAccountContractData);
            break;
        case PaymentMethod.SPECIFIC_BANKS_ID:
            gridRow = SpecificBankForm.addFormForBuyer(gridPane, gridRow, paymentAccountContractData);
            break;
        case PaymentMethod.SWISH_ID:
            gridRow = SwishForm.addFormForBuyer(gridPane, gridRow, paymentAccountContractData);
            break;
        case PaymentMethod.ALI_PAY_ID:
            gridRow = AliPayForm.addFormForBuyer(gridPane, gridRow, paymentAccountContractData);
            break;
        case PaymentMethod.CLEAR_X_CHANGE_ID:
            gridRow = ClearXchangeForm.addFormForBuyer(gridPane, gridRow, paymentAccountContractData);
            break;
        case PaymentMethod.CHASE_QUICK_PAY_ID:
            gridRow = ChaseQuickPayForm.addFormForBuyer(gridPane, gridRow, paymentAccountContractData);
            break;
        case PaymentMethod.INTERAC_E_TRANSFER_ID:
            gridRow = InteracETransferForm.addFormForBuyer(gridPane, gridRow, paymentAccountContractData);
            break;
        case PaymentMethod.US_POSTAL_MONEY_ORDER_ID:
            gridRow = USPostalMoneyOrderForm.addFormForBuyer(gridPane, gridRow, paymentAccountContractData);
            break;
        case PaymentMethod.CASH_DEPOSIT_ID:
            gridRow = CashDepositForm.addFormForBuyer(gridPane, gridRow, paymentAccountContractData);
            break;
        case PaymentMethod.BLOCK_CHAINS_ID:
            String labelTitle = "Sellers " + CurrencyUtil.getNameByCode(trade.getOffer().getCurrencyCode()) + " address:";
            gridRow = CryptoCurrencyForm.addFormForBuyer(gridPane, gridRow, paymentAccountContractData, labelTitle);
            break;
        default:
            log.error("Not supported PaymentMethod: " + paymentMethodName);
    }
    if (!(paymentAccountContractData instanceof CryptoCurrencyAccountContractData))
        addLabelTextFieldWithCopyIcon(gridPane, ++gridRow, "Reason for payment:", model.dataModel.getReference());
    GridPane.setRowSpan(accountTitledGroupBg, gridRow - 3);
    Tuple3<Button, BusyAnimation, Label> tuple3 = addButtonBusyAnimationLabelAfterGroup(gridPane, ++gridRow, "Payment started");
    confirmButton = tuple3.first;
    confirmButton.setOnAction(e -> onPaymentStarted());
    busyAnimation = tuple3.second;
    statusLabel = tuple3.third;
    hideStatusInfo();
}
Also used : BusyAnimation(io.bitsquare.gui.components.BusyAnimation) Button(javafx.scene.control.Button) TextFieldWithCopyIcon(io.bitsquare.gui.components.TextFieldWithCopyIcon) Label(javafx.scene.control.Label) TitledGroupBg(io.bitsquare.gui.components.TitledGroupBg)

Example 2 with TextFieldWithCopyIcon

use of io.bitsquare.gui.components.TextFieldWithCopyIcon in project bitsquare by bitsquare.

the class SellerStep3View method addContent.

///////////////////////////////////////////////////////////////////////////////////////////
// Content
///////////////////////////////////////////////////////////////////////////////////////////
@Override
protected void addContent() {
    addTradeInfoBlock();
    TitledGroupBg titledGroupBg = addTitledGroupBg(gridPane, ++gridRow, 3, "Confirm payment receipt", Layout.GROUP_DISTANCE);
    TextFieldWithCopyIcon field = addLabelTextFieldWithCopyIcon(gridPane, gridRow, "Amount to receive:", 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) {
        PaymentAccountContractData myPaymentAccountContractData = contract.getSellerPaymentAccountContractData();
        PaymentAccountContractData peersPaymentAccountContractData = contract.getBuyerPaymentAccountContractData();
        if (myPaymentAccountContractData instanceof CryptoCurrencyAccountContractData) {
            myPaymentDetails = ((CryptoCurrencyAccountContractData) myPaymentAccountContractData).getAddress();
            peersPaymentDetails = ((CryptoCurrencyAccountContractData) peersPaymentAccountContractData).getAddress();
            myTitle = "Your " + nameByCode + " address:";
            peersTitle = "Buyers " + nameByCode + " address:";
            isBlockChain = true;
        } else {
            myPaymentDetails = myPaymentAccountContractData.getPaymentDetails();
            peersPaymentDetails = peersPaymentAccountContractData.getPaymentDetails();
            myTitle = "Your trading account:";
            peersTitle = "Buyers trading account:";
        }
    }
    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, "Reason for payment:", model.dataModel.getReference());
        GridPane.setRowSpan(titledGroupBg, 4);
    }
    Tuple3<Button, BusyAnimation, Label> tuple = addButtonBusyAnimationLabelAfterGroup(gridPane, ++gridRow, "Confirm payment receipt");
    confirmButton = tuple.first;
    confirmButton.setOnAction(e -> onPaymentReceived());
    busyAnimation = tuple.second;
    statusLabel = tuple.third;
    hideStatusInfo();
}
Also used : BusyAnimation(io.bitsquare.gui.components.BusyAnimation) Button(javafx.scene.control.Button) TextFieldWithCopyIcon(io.bitsquare.gui.components.TextFieldWithCopyIcon) Tooltip(javafx.scene.control.Tooltip) Label(javafx.scene.control.Label) TitledGroupBg(io.bitsquare.gui.components.TitledGroupBg) Contract(io.bitsquare.trade.Contract)

Example 3 with TextFieldWithCopyIcon

use of io.bitsquare.gui.components.TextFieldWithCopyIcon in project bitsquare by bitsquare.

the class TradeDetailsWindow method addContent.

private void addContent() {
    Offer offer = trade.getOffer();
    Contract contract = trade.getContract();
    int rows = 5;
    addTitledGroupBg(gridPane, ++rowIndex, rows, "Trade");
    boolean myOffer = tradeManager.isMyOffer(offer);
    String fiatDirectionInfo;
    String btcDirectionInfo;
    if (tradeManager.isBuyer(offer)) {
        addLabelTextField(gridPane, rowIndex, "Trade type:", formatter.getDirectionForBuyer(myOffer, offer.getCurrencyCode()), Layout.FIRST_ROW_DISTANCE);
        fiatDirectionInfo = " to spend:";
        btcDirectionInfo = " to receive:";
    } else {
        addLabelTextField(gridPane, rowIndex, "Trade type:", formatter.getDirectionForSeller(myOffer, offer.getCurrencyCode()), Layout.FIRST_ROW_DISTANCE);
        fiatDirectionInfo = " to receive:";
        btcDirectionInfo = " to spend:";
    }
    addLabelTextField(gridPane, ++rowIndex, "Bitcoin amount" + btcDirectionInfo, formatter.formatCoinWithCode(trade.getTradeAmount()));
    addLabelTextField(gridPane, ++rowIndex, formatter.formatVolumeLabel(offer.getCurrencyCode()) + fiatDirectionInfo, formatter.formatVolumeWithCode(trade.getTradeVolume()));
    addLabelTextField(gridPane, ++rowIndex, "Trade price:", formatter.formatPrice(trade.getTradePrice()));
    addLabelTextField(gridPane, ++rowIndex, "Payment method:", BSResources.get(offer.getPaymentMethod().getId()));
    // second group
    rows = 5;
    PaymentAccountContractData buyerPaymentAccountContractData = null;
    PaymentAccountContractData sellerPaymentAccountContractData = null;
    if (contract != null) {
        rows++;
        buyerPaymentAccountContractData = contract.getBuyerPaymentAccountContractData();
        sellerPaymentAccountContractData = contract.getSellerPaymentAccountContractData();
        if (buyerPaymentAccountContractData != null)
            rows++;
        if (sellerPaymentAccountContractData != null)
            rows++;
        if (buyerPaymentAccountContractData == null && sellerPaymentAccountContractData == null)
            rows++;
    }
    if (trade.getTakeOfferFeeTxId() != 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.errorMessageProperty().get() != null)
        rows += 2;
    if (trade.getTradingPeerNodeAddress() != null)
        rows++;
    addTitledGroupBg(gridPane, ++rowIndex, rows, "Details", Layout.GROUP_DISTANCE);
    addLabelTextFieldWithCopyIcon(gridPane, rowIndex, "Trade ID:", trade.getId(), Layout.FIRST_ROW_AND_GROUP_DISTANCE);
    addLabelTextField(gridPane, ++rowIndex, "Trade date:", formatter.formatDateTime(trade.getDate()));
    addLabelTextField(gridPane, ++rowIndex, "Security deposit:", formatter.formatCoinWithCode(FeePolicy.getSecurityDeposit(offer)));
    addLabelTextFieldWithCopyIcon(gridPane, ++rowIndex, "Selected arbitrator:", trade.getArbitratorNodeAddress().getFullAddress());
    if (trade.getTradingPeerNodeAddress() != null)
        addLabelTextFieldWithCopyIcon(gridPane, ++rowIndex, "Trading peers onion address:", trade.getTradingPeerNodeAddress().getFullAddress());
    if (contract != null) {
        if (buyerPaymentAccountContractData != null) {
            TextFieldWithCopyIcon tf = addLabelTextFieldWithCopyIcon(gridPane, ++rowIndex, "BTC buyer payment details:", BSResources.get(buyerPaymentAccountContractData.getPaymentDetails())).second;
            tf.setTooltip(new Tooltip(tf.getText()));
        }
        if (sellerPaymentAccountContractData != null) {
            TextFieldWithCopyIcon tf = addLabelTextFieldWithCopyIcon(gridPane, ++rowIndex, "BTC seller payment details:", BSResources.get(sellerPaymentAccountContractData.getPaymentDetails())).second;
            tf.setTooltip(new Tooltip(tf.getText()));
        }
        if (buyerPaymentAccountContractData == null && sellerPaymentAccountContractData == null)
            addLabelTextField(gridPane, ++rowIndex, "Payment method:", BSResources.get(contract.getPaymentMethodName()));
    }
    addLabelTxIdTextField(gridPane, ++rowIndex, "Offer fee transaction ID:", offer.getOfferFeePaymentTxID());
    if (trade.getTakeOfferFeeTxId() != null)
        addLabelTxIdTextField(gridPane, ++rowIndex, "Taker fee transaction ID:", trade.getTakeOfferFeeTxId());
    if (trade.getDepositTx() != null)
        addLabelTxIdTextField(gridPane, ++rowIndex, "Deposit transaction ID:", trade.getDepositTx().getHashAsString());
    if (trade.getPayoutTx() != null)
        addLabelTxIdTextField(gridPane, ++rowIndex, "Payout transaction ID:", trade.getPayoutTx().getHashAsString());
    if (showDisputedTx)
        addLabelTxIdTextField(gridPane, ++rowIndex, "Disputed payout transaction ID:", disputeManager.findOwnDispute(trade.getId()).get().getDisputePayoutTxId());
    if (contract != null) {
        Button viewContractButton = addLabelButton(gridPane, ++rowIndex, "Contract in JSON format:", "View contract", 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("Contract for trade with ID: " + 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.errorMessageProperty().get() != null) {
        textArea = addLabelTextArea(gridPane, ++rowIndex, "Error message:", "").second;
        textArea.setText(trade.errorMessageProperty().get());
        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, "Trade state:").second;
        state.setText(trade.getState().getPhase().name());
    }
    Button cancelButton = addButtonAfterGroup(gridPane, ++rowIndex, "Close");
    //TODO app wide focus
    //cancelButton.requestFocus();
    cancelButton.setOnAction(e -> {
        closeHandlerOptional.ifPresent(closeHandler -> closeHandler.run());
        hide();
    });
}
Also used : Window(javafx.stage.Window) IntegerProperty(javafx.beans.property.IntegerProperty) SimpleIntegerProperty(javafx.beans.property.SimpleIntegerProperty) PaymentAccountContractData(io.bitsquare.payment.PaymentAccountContractData) TextArea(javafx.scene.control.TextArea) TextFieldWithCopyIcon(io.bitsquare.gui.components.TextFieldWithCopyIcon) Tooltip(javafx.scene.control.Tooltip) Scene(javafx.scene.Scene) Offer(io.bitsquare.trade.offer.Offer) Button(javafx.scene.control.Button) Stage(javafx.stage.Stage) TextField(javafx.scene.control.TextField) Contract(io.bitsquare.trade.Contract) SimpleIntegerProperty(javafx.beans.property.SimpleIntegerProperty)

Aggregations

TextFieldWithCopyIcon (io.bitsquare.gui.components.TextFieldWithCopyIcon)3 Button (javafx.scene.control.Button)3 BusyAnimation (io.bitsquare.gui.components.BusyAnimation)2 TitledGroupBg (io.bitsquare.gui.components.TitledGroupBg)2 Contract (io.bitsquare.trade.Contract)2 Label (javafx.scene.control.Label)2 Tooltip (javafx.scene.control.Tooltip)2 PaymentAccountContractData (io.bitsquare.payment.PaymentAccountContractData)1 Offer (io.bitsquare.trade.offer.Offer)1 IntegerProperty (javafx.beans.property.IntegerProperty)1 SimpleIntegerProperty (javafx.beans.property.SimpleIntegerProperty)1 Scene (javafx.scene.Scene)1 TextArea (javafx.scene.control.TextArea)1 TextField (javafx.scene.control.TextField)1 Stage (javafx.stage.Stage)1 Window (javafx.stage.Window)1