Search in sources :

Example 11 with Country

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

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

Aggregations

Country (bisq.core.locale.Country)12 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