Search in sources :

Example 51 with TradeCurrency

use of bisq.core.locale.TradeCurrency in project bisq-desktop by bisq-network.

the class MoneyBeamForm method addFormForDisplayAccount.

@Override
public void addFormForDisplayAccount() {
    gridRowFrom = gridRow;
    addLabelTextField(gridPane, gridRow, Res.get("payment.account.name"), account.getAccountName(), Layout.FIRST_ROW_AND_GROUP_DISTANCE);
    addLabelTextField(gridPane, ++gridRow, Res.getWithCol("shared.paymentMethod"), Res.get(account.getPaymentMethod().getId()));
    TextField field = addLabelTextField(gridPane, ++gridRow, Res.get("payment.moneyBeam.accountId"), account.getAccountId()).second;
    field.setMouseTransparent(false);
    final TradeCurrency singleTradeCurrency = account.getSingleTradeCurrency();
    final String nameAndCode = singleTradeCurrency != null ? singleTradeCurrency.getNameAndCode() : "";
    addLabelTextField(gridPane, ++gridRow, Res.getWithCol("shared.currency"), nameAndCode);
    addLimitations();
}
Also used : TradeCurrency(bisq.core.locale.TradeCurrency) TextField(javafx.scene.control.TextField) FormBuilder.addLabelInputTextField(bisq.desktop.util.FormBuilder.addLabelInputTextField) FormBuilder.addLabelTextField(bisq.desktop.util.FormBuilder.addLabelTextField) InputTextField(bisq.desktop.components.InputTextField)

Example 52 with TradeCurrency

use of bisq.core.locale.TradeCurrency in project bisq-desktop by bisq-network.

the class SepaForm 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) -> {
        sepaAccount.setHolderName(newValue);
        updateFromInputs();
    });
    ibanInputTextField = FormBuilder.addLabelInputTextField(gridPane, ++gridRow, "IBAN:").second;
    ibanInputTextField.setValidator(ibanValidator);
    ibanInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
        sepaAccount.setIban(newValue);
        updateFromInputs();
    });
    InputTextField bicInputTextField = FormBuilder.addLabelInputTextField(gridPane, ++gridRow, "BIC:").second;
    bicInputTextField.setValidator(bicValidator);
    bicInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
        sepaAccount.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();
        sepaAccount.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.getAllSepaCountries()));
    Country country = CountryUtil.getDefaultCountry();
    if (CountryUtil.getAllSepaCountries().contains(country)) {
        countryComboBox.getSelectionModel().select(country);
        sepaAccount.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 53 with TradeCurrency

use of bisq.core.locale.TradeCurrency in project bisq-desktop by bisq-network.

the class SepaForm method autoFillNameTextField.

@Override
protected void autoFillNameTextField() {
    if (useCustomAccountNameCheckBox != null && !useCustomAccountNameCheckBox.isSelected()) {
        TradeCurrency singleTradeCurrency = this.paymentAccount.getSingleTradeCurrency();
        String currency = singleTradeCurrency != null ? singleTradeCurrency.getCode() : null;
        if (currency != null) {
            String iban = ibanInputTextField.getText();
            if (iban.length() > 9)
                iban = StringUtils.abbreviate(iban, 9);
            String method = Res.get(paymentAccount.getPaymentMethod().getId());
            CountryBasedPaymentAccount countryBasedPaymentAccount = (CountryBasedPaymentAccount) this.paymentAccount;
            String country = countryBasedPaymentAccount.getCountry() != null ? countryBasedPaymentAccount.getCountry().code : null;
            if (country != null)
                accountNameTextField.setText(method.concat(" (").concat(currency).concat("/").concat(country).concat("): ").concat(iban));
        }
    }
}
Also used : TradeCurrency(bisq.core.locale.TradeCurrency) CountryBasedPaymentAccount(bisq.core.payment.CountryBasedPaymentAccount)

Example 54 with TradeCurrency

use of bisq.core.locale.TradeCurrency in project bisq-desktop by bisq-network.

the class SepaInstantForm method updateCountriesSelection.

private void updateCountriesSelection(boolean isEditable, List<CheckBox> checkBoxList) {
    checkBoxList.stream().forEach(checkBox -> {
        String countryCode = (String) checkBox.getUserData();
        TradeCurrency selectedCurrency = sepaInstantAccount.getSelectedTradeCurrency();
        if (selectedCurrency == null) {
            Country country = CountryUtil.getDefaultCountry();
            if (CountryUtil.getAllSepaInstantCountries().contains(country))
                selectedCurrency = CurrencyUtil.getCurrencyByCountryCode(country.code);
        }
        boolean selected;
        if (isEditable && selectedCurrency != null) {
            selected = true;
            sepaInstantAccount.addAcceptedCountry(countryCode);
        } else {
            selected = sepaInstantAccount.getAcceptedCountryCodes().contains(countryCode);
        }
        checkBox.setSelected(selected);
    });
}
Also used : TradeCurrency(bisq.core.locale.TradeCurrency) Country(bisq.core.locale.Country)

Example 55 with TradeCurrency

use of bisq.core.locale.TradeCurrency in project bisq-desktop by bisq-network.

the class GUIUtil method getPaymentAccountsComboBoxStringConverter.

public static StringConverter<PaymentAccount> getPaymentAccountsComboBoxStringConverter() {
    return new StringConverter<PaymentAccount>() {

        @Override
        public String toString(PaymentAccount paymentAccount) {
            if (paymentAccount.hasMultipleCurrencies()) {
                return paymentAccount.getAccountName() + " (" + Res.get(paymentAccount.getPaymentMethod().getId()) + ")";
            } else {
                TradeCurrency singleTradeCurrency = paymentAccount.getSingleTradeCurrency();
                String prefix = singleTradeCurrency != null ? singleTradeCurrency.getCode() + ", " : "";
                return paymentAccount.getAccountName() + " (" + prefix + Res.get(paymentAccount.getPaymentMethod().getId()) + ")";
            }
        }

        @Override
        public PaymentAccount fromString(String s) {
            return null;
        }
    };
}
Also used : TradeCurrency(bisq.core.locale.TradeCurrency) PaymentAccount(bisq.core.payment.PaymentAccount) StringConverter(javafx.util.StringConverter)

Aggregations

TradeCurrency (bisq.core.locale.TradeCurrency)57 InputTextField (bisq.desktop.components.InputTextField)26 TextField (javafx.scene.control.TextField)16 FormBuilder.addLabelInputTextField (bisq.desktop.util.FormBuilder.addLabelInputTextField)13 FiatCurrency (bisq.core.locale.FiatCurrency)11 Country (bisq.core.locale.Country)10 FormBuilder.addLabelTextField (bisq.desktop.util.FormBuilder.addLabelTextField)9 CryptoCurrency (bisq.core.locale.CryptoCurrency)8 PaymentAccount (bisq.core.payment.PaymentAccount)7 ComboBox (javafx.scene.control.ComboBox)6 Label (javafx.scene.control.Label)6 CryptoCurrencyAccount (bisq.core.payment.CryptoCurrencyAccount)5 Popup (bisq.desktop.main.overlays.popups.Popup)5 List (java.util.List)5 Tuple2 (bisq.common.util.Tuple2)4 CurrencyUtil (bisq.core.locale.CurrencyUtil)4 OpenOfferManager (bisq.core.offer.OpenOfferManager)4 AccountAgeWitnessService (bisq.core.payment.AccountAgeWitnessService)4 TradeManager (bisq.core.trade.TradeManager)4 User (bisq.core.user.User)4