Search in sources :

Example 1 with Country

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

the class OfferBookViewModelTest method getSepaAccount.

private PaymentAccount getSepaAccount(String currencyCode, String countryCode, String bic, ArrayList<String> countryCodes) {
    CountryBasedPaymentAccount paymentAccount = new SepaAccount();
    paymentAccount.setSingleTradeCurrency(new FiatCurrency(currencyCode));
    paymentAccount.setCountry(new Country(countryCode, null, null));
    ((SepaAccountPayload) paymentAccount.getPaymentAccountPayload()).setBic(bic);
    countryCodes.forEach(((SepaAccountPayload) paymentAccount.getPaymentAccountPayload())::addAcceptedCountry);
    return paymentAccount;
}
Also used : SepaAccount(bisq.core.payment.SepaAccount) CountryBasedPaymentAccount(bisq.core.payment.CountryBasedPaymentAccount) SepaAccountPayload(bisq.core.payment.payload.SepaAccountPayload) Country(bisq.core.locale.Country) FiatCurrency(bisq.core.locale.FiatCurrency)

Example 2 with Country

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

the class OfferBookViewModelTest method getNationalBankAccount.

private PaymentAccount getNationalBankAccount(String currencyCode, String countryCode, String bankId) {
    CountryBasedPaymentAccount paymentAccount = new NationalBankAccount();
    paymentAccount.setSingleTradeCurrency(new FiatCurrency(currencyCode));
    paymentAccount.setCountry(new Country(countryCode, null, null));
    ((NationalBankAccountPayload) paymentAccount.getPaymentAccountPayload()).setBankId(bankId);
    return paymentAccount;
}
Also used : NationalBankAccount(bisq.core.payment.NationalBankAccount) CountryBasedPaymentAccount(bisq.core.payment.CountryBasedPaymentAccount) Country(bisq.core.locale.Country) FiatCurrency(bisq.core.locale.FiatCurrency) NationalBankAccountPayload(bisq.core.payment.payload.NationalBankAccountPayload)

Example 3 with Country

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

the class OfferBookViewModelTest method getSpecificBanksAccount.

private PaymentAccount getSpecificBanksAccount(String currencyCode, String countryCode, String bankId, ArrayList<String> bankIds) {
    SpecificBanksAccount paymentAccount = new SpecificBanksAccount();
    paymentAccount.setSingleTradeCurrency(new FiatCurrency(currencyCode));
    paymentAccount.setCountry(new Country(countryCode, null, null));
    ((SpecificBanksAccountPayload) paymentAccount.getPaymentAccountPayload()).setBankId(bankId);
    bankIds.forEach(((SpecificBanksAccountPayload) paymentAccount.getPaymentAccountPayload())::addAcceptedBank);
    return paymentAccount;
}
Also used : Country(bisq.core.locale.Country) SpecificBanksAccountPayload(bisq.core.payment.payload.SpecificBanksAccountPayload) FiatCurrency(bisq.core.locale.FiatCurrency) SpecificBanksAccount(bisq.core.payment.SpecificBanksAccount)

Example 4 with Country

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

the class SepaForm method updateCountriesSelection.

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

Example 5 with Country

use of bisq.core.locale.Country 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)

Aggregations

Country (bisq.core.locale.Country)13 FiatCurrency (bisq.core.locale.FiatCurrency)7 TradeCurrency (bisq.core.locale.TradeCurrency)7 ComboBox (javafx.scene.control.ComboBox)5 Region (bisq.core.locale.Region)3 InputTextField (bisq.desktop.components.InputTextField)3 Popup (bisq.desktop.main.overlays.popups.Popup)3 Label (javafx.scene.control.Label)3 CountryBasedPaymentAccount (bisq.core.payment.CountryBasedPaymentAccount)2 AccountNrValidator (bisq.desktop.util.validation.AccountNrValidator)2 BankIdValidator (bisq.desktop.util.validation.BankIdValidator)2 BranchIdValidator (bisq.desktop.util.validation.BranchIdValidator)2 TextField (javafx.scene.control.TextField)2 HBox (javafx.scene.layout.HBox)2 BaseCurrencyNetwork (bisq.core.btc.BaseCurrencyNetwork)1 NationalBankAccount (bisq.core.payment.NationalBankAccount)1 SameBankAccount (bisq.core.payment.SameBankAccount)1 SepaAccount (bisq.core.payment.SepaAccount)1 SpecificBanksAccount (bisq.core.payment.SpecificBanksAccount)1 NationalBankAccountPayload (bisq.core.payment.payload.NationalBankAccountPayload)1