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();
}
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();
}
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));
}
}
}
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);
});
}
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;
}
};
}
Aggregations