Search in sources :

Example 6 with InputTextField

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

the class PaymentMethodForm method addLimitations.

protected void addLimitations() {
    long hours = paymentAccount.getPaymentMethod().getMaxTradePeriod() / 3600_000;
    final TradeCurrency tradeCurrency;
    if (paymentAccount.getSingleTradeCurrency() != null)
        tradeCurrency = paymentAccount.getSingleTradeCurrency();
    else if (paymentAccount.getSelectedTradeCurrency() != null)
        tradeCurrency = paymentAccount.getSelectedTradeCurrency();
    else if (!paymentAccount.getTradeCurrencies().isEmpty())
        tradeCurrency = paymentAccount.getTradeCurrencies().get(0);
    else
        tradeCurrency = paymentAccount instanceof CryptoCurrencyAccount ? CurrencyUtil.getAllSortedCryptoCurrencies().get(0) : CurrencyUtil.getDefaultTradeCurrency();
    final boolean isAddAccountScreen = paymentAccount.getAccountName() == null;
    final long accountAge = !isAddAccountScreen ? accountAgeWitnessService.getMyAccountAge(paymentAccount.getPaymentAccountPayload()) : 0L;
    addLabelTextField(gridPane, ++gridRow, Res.get("payment.limitations"), Res.get("payment.maxPeriodAndLimit", getTimeText(hours), formatter.formatCoinWithCode(Coin.valueOf(accountAgeWitnessService.getMyTradeLimit(paymentAccount, tradeCurrency.getCode()))), formatter.formatAccountAge(accountAge)));
    if (isAddAccountScreen) {
        InputTextField inputTextField = addLabelInputTextField(gridPane, ++gridRow, Res.get("payment.salt"), 0).second;
        inputTextField.setText(Utilities.bytesAsHexString(paymentAccount.getPaymentAccountPayload().getSalt()));
        inputTextField.textProperty().addListener((observable, oldValue, newValue) -> {
            if (!newValue.isEmpty()) {
                try {
                    // test if input is hex
                    Utilities.decodeFromHex(newValue);
                    paymentAccount.setSaltAsHex(newValue);
                } catch (Throwable t) {
                    new Popup().warning(Res.get("payment.error.noHexSalt")).show();
                    inputTextField.setText(Utilities.bytesAsHexString(paymentAccount.getPaymentAccountPayload().getSalt()));
                    log.warn(t.toString());
                }
            }
        });
    } else {
        addLabelTextFieldWithCopyIcon(gridPane, ++gridRow, Res.get("payment.salt", Utilities.bytesAsHexString(paymentAccount.getPaymentAccountPayload().getSalt())), Utilities.bytesAsHexString(paymentAccount.getPaymentAccountPayload().getSalt()));
    }
}
Also used : TradeCurrency(bisq.core.locale.TradeCurrency) InputTextField(bisq.desktop.components.InputTextField) Popup(bisq.desktop.main.overlays.popups.Popup) CryptoCurrencyAccount(bisq.core.payment.CryptoCurrencyAccount)

Example 7 with InputTextField

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

the class PopmoneyForm method addFormForAddAccount.

@Override
public void addFormForAddAccount() {
    gridRowFrom = gridRow + 1;
    InputTextField holderNameInputTextField = addLabelInputTextField(gridPane, ++gridRow, Res.getWithCol("payment.account.owner")).second;
    holderNameInputTextField.setValidator(inputValidator);
    holderNameInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
        account.setHolderName(newValue);
        updateFromInputs();
    });
    accountIdInputTextField = addLabelInputTextField(gridPane, ++gridRow, Res.get("payment.popmoney.accountId")).second;
    accountIdInputTextField.setValidator(validator);
    accountIdInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
        account.setAccountId(newValue);
        updateFromInputs();
    });
    final TradeCurrency singleTradeCurrency = account.getSingleTradeCurrency();
    final String nameAndCode = singleTradeCurrency != null ? singleTradeCurrency.getNameAndCode() : "";
    addLabelTextField(gridPane, ++gridRow, Res.getWithCol("shared.currency"), nameAndCode);
    addLimitations();
    addAccountNameTextFieldWithAutoFillCheckBox();
}
Also used : TradeCurrency(bisq.core.locale.TradeCurrency) FormBuilder.addLabelInputTextField(bisq.desktop.util.FormBuilder.addLabelInputTextField) InputTextField(bisq.desktop.components.InputTextField)

Example 8 with InputTextField

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

the class SepaInstantForm method addFormForAddAccount.

@Override
public void addFormForAddAccount() {
    gridRowFrom = gridRow + 1;
    InputTextField holderNameInputTextField = FormBuilder.addLabelInputTextField(gridPane, ++gridRow, Res.getWithCol("payment.account.owner")).second;
    holderNameInputTextField.setValidator(inputValidator);
    holderNameInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
        sepaInstantAccount.setHolderName(newValue);
        updateFromInputs();
    });
    ibanInputTextField = FormBuilder.addLabelInputTextField(gridPane, ++gridRow, "IBAN:").second;
    ibanInputTextField.setValidator(ibanValidator);
    ibanInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
        sepaInstantAccount.setIban(newValue);
        updateFromInputs();
    });
    InputTextField bicInputTextField = FormBuilder.addLabelInputTextField(gridPane, ++gridRow, "BIC:").second;
    bicInputTextField.setValidator(bicValidator);
    bicInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
        sepaInstantAccount.setBic(newValue);
        updateFromInputs();
    });
    FormBuilder.addLabel(gridPane, ++gridRow, Res.getWithCol("payment.bank.country"));
    HBox hBox = new HBox();
    hBox.setSpacing(10);
    ComboBox<Country> countryComboBox = new ComboBox<>();
    currencyComboBox = new ComboBox<>();
    currencyTextField = new TextField("");
    currencyTextField.setEditable(false);
    currencyTextField.setMouseTransparent(true);
    currencyTextField.setFocusTraversable(false);
    currencyTextField.setMinWidth(300);
    currencyTextField.setVisible(false);
    currencyTextField.setManaged(false);
    currencyComboBox.setVisible(false);
    currencyComboBox.setManaged(false);
    hBox.getChildren().addAll(countryComboBox, currencyTextField, currencyComboBox);
    GridPane.setRowIndex(hBox, gridRow);
    GridPane.setColumnIndex(hBox, 1);
    gridPane.getChildren().add(hBox);
    countryComboBox.setPromptText(Res.get("payment.select.bank.country"));
    countryComboBox.setConverter(new StringConverter<Country>() {

        @Override
        public String toString(Country country) {
            return country.name + " (" + country.code + ")";
        }

        @Override
        public Country fromString(String s) {
            return null;
        }
    });
    countryComboBox.setOnAction(e -> {
        Country selectedItem = countryComboBox.getSelectionModel().getSelectedItem();
        sepaInstantAccount.setCountry(selectedItem);
        TradeCurrency currency = CurrencyUtil.getCurrencyByCountryCode(selectedItem.code);
        setupCurrency(selectedItem, currency);
        updateCountriesSelection(true, euroCountryCheckBoxes);
        updateCountriesSelection(true, nonEuroCountryCheckBoxes);
        updateFromInputs();
    });
    addEuroCountriesGrid(true);
    addNonEuroCountriesGrid(true);
    addLimitations();
    addAccountNameTextFieldWithAutoFillCheckBox();
    countryComboBox.setItems(FXCollections.observableArrayList(CountryUtil.getAllSepaInstantCountries()));
    Country country = CountryUtil.getDefaultCountry();
    if (CountryUtil.getAllSepaInstantCountries().contains(country)) {
        countryComboBox.getSelectionModel().select(country);
        sepaInstantAccount.setCountry(country);
        TradeCurrency currency = CurrencyUtil.getCurrencyByCountryCode(country.code);
        setupCurrency(country, currency);
    }
    updateFromInputs();
}
Also used : HBox(javafx.scene.layout.HBox) TradeCurrency(bisq.core.locale.TradeCurrency) InputTextField(bisq.desktop.components.InputTextField) ComboBox(javafx.scene.control.ComboBox) Country(bisq.core.locale.Country) InputTextField(bisq.desktop.components.InputTextField) TextField(javafx.scene.control.TextField)

Example 9 with InputTextField

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

the class CreateOfferView method addBuyerSecurityDepositRow.

private void addBuyerSecurityDepositRow() {
    final double top = model.dataModel.isBsqForFeeAvailable() ? 0 : Layout.FIRST_ROW_AND_GROUP_DISTANCE;
    buyerSecurityDepositLabel = addLabel(gridPane, ++gridRow, Res.getWithCol("shared.securityDepositBox.description", Res.get("shared.buyer")), top);
    Tuple3<HBox, InputTextField, Label> tuple = getEditableValueCurrencyBox(Res.get("createOffer.securityDeposit.prompt"));
    buyerSecurityDepositValueCurrencyBox = tuple.first;
    buyerSecurityDepositInputTextField = tuple.second;
    Label buyerSecurityDepositBtcLabel = tuple.third;
    editOfferElements.add(buyerSecurityDepositInputTextField);
    editOfferElements.add(buyerSecurityDepositBtcLabel);
    GridPane.setRowIndex(buyerSecurityDepositValueCurrencyBox, gridRow);
    GridPane.setColumnIndex(buyerSecurityDepositValueCurrencyBox, 1);
    GridPane.setColumnSpan(buyerSecurityDepositValueCurrencyBox, 2);
    GridPane.setMargin(buyerSecurityDepositValueCurrencyBox, new Insets(top, 0, 0, 0));
    gridPane.getChildren().add(buyerSecurityDepositValueCurrencyBox);
}
Also used : HBox(javafx.scene.layout.HBox) Insets(javafx.geometry.Insets) InputTextField(bisq.desktop.components.InputTextField) InfoInputTextField(bisq.desktop.components.InfoInputTextField) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) Label(javafx.scene.control.Label)

Example 10 with InputTextField

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

the class CreateOfferView method addAmountPriceFields.

private void addAmountPriceFields() {
    // amountBox
    Tuple3<HBox, InputTextField, Label> amountValueCurrencyBoxTuple = getEditableValueCurrencyBox(Res.get("createOffer.amount.prompt"));
    HBox amountValueCurrencyBox = amountValueCurrencyBoxTuple.first;
    amountTextField = amountValueCurrencyBoxTuple.second;
    editOfferElements.add(amountTextField);
    Label amountBtcLabel = amountValueCurrencyBoxTuple.third;
    editOfferElements.add(amountBtcLabel);
    Tuple2<Label, VBox> amountInputBoxTuple = getTradeInputBox(amountValueCurrencyBox, model.getAmountDescription());
    amountDescriptionLabel = amountInputBoxTuple.first;
    editOfferElements.add(amountDescriptionLabel);
    VBox amountBox = amountInputBoxTuple.second;
    // x
    xLabel = new AutoTooltipLabel();
    xLabel.setFont(Font.font("Helvetica-Bold", 20));
    xLabel.setPadding(new Insets(14, 3, 0, 3));
    xLabel.setMinWidth(14);
    xLabel.setMaxWidth(14);
    // price as percent
    Tuple3<HBox, InfoInputTextField, Label> priceAsPercentageTuple = getEditableValueCurrencyBoxWithInfo(Res.get("createOffer.price.prompt"));
    HBox priceAsPercentageValueCurrencyBox = priceAsPercentageTuple.first;
    marketBasedPriceInfoInputTextField = priceAsPercentageTuple.second;
    marketBasedPriceTextField = marketBasedPriceInfoInputTextField.getTextField();
    marketBasedPriceTextField.setPrefWidth(200);
    editOfferElements.add(marketBasedPriceTextField);
    marketBasedPriceLabel = priceAsPercentageTuple.third;
    editOfferElements.add(marketBasedPriceLabel);
    Tuple2<Label, VBox> priceAsPercentageInputBoxTuple = getTradeInputBox(priceAsPercentageValueCurrencyBox, Res.get("shared.distanceInPercent"));
    percentagePriceDescription = priceAsPercentageInputBoxTuple.first;
    percentagePriceDescription.setPrefWidth(200);
    getSmallIconForLabel(MaterialDesignIcon.CHART_LINE, percentagePriceDescription);
    percentagePriceBox = priceAsPercentageInputBoxTuple.second;
    // Fixed/Percentage toggle
    priceTypeToggleButton = getIconButton(MaterialDesignIcon.SWAP_VERTICAL);
    editOfferElements.add(priceTypeToggleButton);
    priceTypeToggleButton.setOnAction((actionEvent) -> {
        updatePriceToggleButtons(model.dataModel.getUseMarketBasedPrice().getValue());
    });
    // =
    resultLabel = new AutoTooltipLabel("=");
    resultLabel.setFont(Font.font("Helvetica-Bold", 20));
    resultLabel.setPadding(new Insets(14, 2, 0, 2));
    // volume
    Tuple3<HBox, InputTextField, Label> volumeValueCurrencyBoxTuple = getEditableValueCurrencyBox(Res.get("createOffer.volume.prompt"));
    HBox volumeValueCurrencyBox = volumeValueCurrencyBoxTuple.first;
    volumeTextField = volumeValueCurrencyBoxTuple.second;
    editOfferElements.add(volumeTextField);
    volumeCurrencyLabel = volumeValueCurrencyBoxTuple.third;
    editOfferElements.add(volumeCurrencyLabel);
    Tuple2<Label, VBox> volumeInputBoxTuple = getTradeInputBox(volumeValueCurrencyBox, model.volumeDescriptionLabel.get());
    volumeDescriptionLabel = volumeInputBoxTuple.first;
    editOfferElements.add(volumeDescriptionLabel);
    VBox volumeBox = volumeInputBoxTuple.second;
    firstRowHBox = new HBox();
    firstRowHBox.setSpacing(5);
    firstRowHBox.setAlignment(Pos.CENTER_LEFT);
    firstRowHBox.getChildren().addAll(amountBox, xLabel, percentagePriceBox, priceTypeToggleButton, resultLabel, volumeBox);
    GridPane.setRowIndex(firstRowHBox, gridRow);
    GridPane.setColumnIndex(firstRowHBox, 1);
    GridPane.setMargin(firstRowHBox, new Insets(Layout.FIRST_ROW_AND_GROUP_DISTANCE, 10, 0, 0));
    GridPane.setColumnSpan(firstRowHBox, 2);
    gridPane.getChildren().add(firstRowHBox);
}
Also used : HBox(javafx.scene.layout.HBox) Insets(javafx.geometry.Insets) InputTextField(bisq.desktop.components.InputTextField) InfoInputTextField(bisq.desktop.components.InfoInputTextField) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) Label(javafx.scene.control.Label) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) InfoInputTextField(bisq.desktop.components.InfoInputTextField) VBox(javafx.scene.layout.VBox)

Aggregations

InputTextField (bisq.desktop.components.InputTextField)35 Label (javafx.scene.control.Label)23 HBox (javafx.scene.layout.HBox)19 AutoTooltipLabel (bisq.desktop.components.AutoTooltipLabel)17 Insets (javafx.geometry.Insets)15 TradeCurrency (bisq.core.locale.TradeCurrency)11 InfoInputTextField (bisq.desktop.components.InfoInputTextField)11 FormBuilder.addLabelInputTextField (bisq.desktop.util.FormBuilder.addLabelInputTextField)11 Popup (bisq.desktop.main.overlays.popups.Popup)8 Tuple3 (bisq.common.util.Tuple3)6 AutoTooltipButton (bisq.desktop.components.AutoTooltipButton)6 Button (javafx.scene.control.Button)5 TextField (javafx.scene.control.TextField)5 CheckBox (javafx.scene.control.CheckBox)4 Country (bisq.core.locale.Country)3 AddressTextField (bisq.desktop.components.AddressTextField)3 VBox (javafx.scene.layout.VBox)3 BalanceTextField (bisq.desktop.components.BalanceTextField)2 FundsTextField (bisq.desktop.components.FundsTextField)2 TitledGroupBg (bisq.desktop.components.TitledGroupBg)2