From 3f0d882a255b7dc7882f1d27927960bc7e7435e2 Mon Sep 17 00:00:00 2001 From: lukasz Date: Thu, 26 Dec 2019 11:04:40 +0100 Subject: [PATCH 1/2] Use only EUR when creating a SEPA payment account --- .../paymentmethods/GeneralSepaForm.java | 43 ++++--------------- .../components/paymentmethods/SepaForm.java | 4 +- .../paymentmethods/SepaInstantForm.java | 3 +- 3 files changed, 10 insertions(+), 40 deletions(-) diff --git a/desktop/src/main/java/bisq/desktop/components/paymentmethods/GeneralSepaForm.java b/desktop/src/main/java/bisq/desktop/components/paymentmethods/GeneralSepaForm.java index 1b9dc2f6953..9c5ec9e271b 100644 --- a/desktop/src/main/java/bisq/desktop/components/paymentmethods/GeneralSepaForm.java +++ b/desktop/src/main/java/bisq/desktop/components/paymentmethods/GeneralSepaForm.java @@ -25,8 +25,6 @@ import javafx.scene.layout.GridPane; import javafx.scene.layout.HBox; -import javafx.collections.FXCollections; - import javafx.util.StringConverter; import java.util.ArrayList; @@ -82,39 +80,14 @@ void setCountryComboBoxAction(ComboBox countryComboBox, CountryBasedPay }); } - void updateCurrencyFormElements(TradeCurrency currency, boolean isSepaCountry, CountryBasedPaymentAccount paymentAccount) { - if (isSepaCountry) { - currencyTextField.setVisible(true); - currencyTextField.setManaged(true); - currencyComboBox.setVisible(false); - currencyComboBox.setManaged(false); - paymentAccount.setSingleTradeCurrency(currency); - currencyTextField.setText(Res.get("payment.currencyWithSymbol", currency.getNameAndCode())); - } else { - currencyComboBox.setVisible(true); - currencyComboBox.setManaged(true); - currencyTextField.setVisible(false); - currencyTextField.setManaged(false); - currencyComboBox.setItems(FXCollections.observableArrayList(currency, - CurrencyUtil.getFiatCurrency("EUR").get())); - currencyComboBox.setOnAction(e2 -> { - paymentAccount.setSingleTradeCurrency(currencyComboBox.getSelectionModel().getSelectedItem()); - updateCountriesSelection(euroCountryCheckBoxes); - autoFillNameTextField(); - }); - currencyComboBox.setConverter(new StringConverter<>() { - @Override - public String toString(TradeCurrency currency) { - return currency != null ? currency.getNameAndCode() : Res.get("shared.na"); - } - - @Override - public TradeCurrency fromString(String string) { - return null; - } - }); - currencyComboBox.getSelectionModel().select(0); - } + void updateCurrencyFormElements(CountryBasedPaymentAccount paymentAccount) { + TradeCurrency currency = CurrencyUtil.getFiatCurrency("EUR").get(); + currencyTextField.setVisible(true); + currencyTextField.setManaged(true); + currencyComboBox.setVisible(false); + currencyComboBox.setManaged(false); + paymentAccount.setSingleTradeCurrency(currency); + currencyTextField.setText(Res.get("payment.currencyWithSymbol", currency.getNameAndCode())); } void addCountriesGrid(String title, List checkBoxList, diff --git a/desktop/src/main/java/bisq/desktop/components/paymentmethods/SepaForm.java b/desktop/src/main/java/bisq/desktop/components/paymentmethods/SepaForm.java index 5550e8470f4..6eb209e710c 100644 --- a/desktop/src/main/java/bisq/desktop/components/paymentmethods/SepaForm.java +++ b/desktop/src/main/java/bisq/desktop/components/paymentmethods/SepaForm.java @@ -135,9 +135,7 @@ public void addFormForAddAccount() { @Override void setupCurrency(Country country, TradeCurrency currency) { - final boolean isSepaCountry = CountryUtil.getAllSepaEuroCountries().contains(country); - - updateCurrencyFormElements(currency, isSepaCountry, sepaAccount); + updateCurrencyFormElements(sepaAccount); } private void addEuroCountriesGrid() { diff --git a/desktop/src/main/java/bisq/desktop/components/paymentmethods/SepaInstantForm.java b/desktop/src/main/java/bisq/desktop/components/paymentmethods/SepaInstantForm.java index 7a15188f379..d52b5dd1483 100644 --- a/desktop/src/main/java/bisq/desktop/components/paymentmethods/SepaInstantForm.java +++ b/desktop/src/main/java/bisq/desktop/components/paymentmethods/SepaInstantForm.java @@ -135,8 +135,7 @@ public void addFormForAddAccount() { @Override void setupCurrency(Country country, TradeCurrency currency) { - final boolean isSepaInstantCountry = CountryUtil.getAllSepaInstantEuroCountries().contains(country); - updateCurrencyFormElements(currency, isSepaInstantCountry, sepaInstantAccount); + updateCurrencyFormElements(sepaInstantAccount); } private void addEuroCountriesGrid() { From e20a2711f834a4d08826f61f7e67e8edf6c96841 Mon Sep 17 00:00:00 2001 From: lukasz Date: Thu, 26 Dec 2019 11:27:48 +0100 Subject: [PATCH 2/2] Use only EUR when creating a SEPA payment account - additional refactoring --- .../paymentmethods/GeneralSepaForm.java | 29 +++++-------------- .../components/paymentmethods/SepaForm.java | 6 ---- .../paymentmethods/SepaInstantForm.java | 7 ----- 3 files changed, 8 insertions(+), 34 deletions(-) diff --git a/desktop/src/main/java/bisq/desktop/components/paymentmethods/GeneralSepaForm.java b/desktop/src/main/java/bisq/desktop/components/paymentmethods/GeneralSepaForm.java index 9c5ec9e271b..5435e9e4c9f 100644 --- a/desktop/src/main/java/bisq/desktop/components/paymentmethods/GeneralSepaForm.java +++ b/desktop/src/main/java/bisq/desktop/components/paymentmethods/GeneralSepaForm.java @@ -6,6 +6,7 @@ import bisq.core.account.witness.AccountAgeWitnessService; import bisq.core.locale.Country; import bisq.core.locale.CurrencyUtil; +import bisq.core.locale.FiatCurrency; import bisq.core.locale.Res; import bisq.core.locale.TradeCurrency; import bisq.core.payment.CountryBasedPaymentAccount; @@ -40,11 +41,13 @@ public abstract class GeneralSepaForm extends PaymentMethodForm { final List euroCountryCheckBoxes = new ArrayList<>(); final List nonEuroCountryCheckBoxes = new ArrayList<>(); private TextField currencyTextField; - private ComboBox currencyComboBox; InputTextField ibanInputTextField; + private FiatCurrency euroCurrency = CurrencyUtil.getFiatCurrency("EUR").get(); + GeneralSepaForm(PaymentAccount paymentAccount, AccountAgeWitnessService accountAgeWitnessService, InputValidator inputValidator, GridPane gridPane, int gridRow, CoinFormatter formatter) { super(paymentAccount, accountAgeWitnessService, inputValidator, gridPane, gridRow, formatter); + paymentAccount.setSingleTradeCurrency(euroCurrency); } @Override @@ -71,8 +74,6 @@ void setCountryComboBoxAction(ComboBox countryComboBox, CountryBasedPay countryComboBox.setOnAction(e -> { Country selectedItem = countryComboBox.getSelectionModel().getSelectedItem(); paymentAccount.setCountry(selectedItem); - TradeCurrency currency = CurrencyUtil.getCurrencyByCountryCode(selectedItem.code); - setupCurrency(selectedItem, currency); updateCountriesSelection(euroCountryCheckBoxes); updateCountriesSelection(nonEuroCountryCheckBoxes); @@ -80,16 +81,6 @@ void setCountryComboBoxAction(ComboBox countryComboBox, CountryBasedPay }); } - void updateCurrencyFormElements(CountryBasedPaymentAccount paymentAccount) { - TradeCurrency currency = CurrencyUtil.getFiatCurrency("EUR").get(); - currencyTextField.setVisible(true); - currencyTextField.setManaged(true); - currencyComboBox.setVisible(false); - currencyComboBox.setManaged(false); - paymentAccount.setSingleTradeCurrency(currency); - currencyTextField.setText(Res.get("payment.currencyWithSymbol", currency.getNameAndCode())); - } - void addCountriesGrid(String title, List checkBoxList, List dataProvider) { FlowPane flowPane = FormBuilder.addTopLabelFlowPane(gridPane, ++gridRow, title, 0).second; @@ -106,19 +97,17 @@ ComboBox addCountrySelection() { hBox.setSpacing(10); ComboBox countryComboBox = new JFXComboBox<>(); - currencyComboBox = new JFXComboBox<>(); currencyTextField = new JFXTextField(""); currencyTextField.setEditable(false); currencyTextField.setMouseTransparent(true); currencyTextField.setFocusTraversable(false); currencyTextField.setMinWidth(300); - currencyTextField.setVisible(false); - currencyTextField.setManaged(false); - currencyComboBox.setVisible(false); - currencyComboBox.setManaged(false); + currencyTextField.setVisible(true); + currencyTextField.setManaged(true); + currencyTextField.setText(Res.get("payment.currencyWithSymbol", euroCurrency.getNameAndCode())); - hBox.getChildren().addAll(countryComboBox, currencyTextField, currencyComboBox); + hBox.getChildren().addAll(countryComboBox, currencyTextField); addTopLabelWithVBox(gridPane, ++gridRow, Res.get("payment.bank.country"), hBox, 0); @@ -137,8 +126,6 @@ public Country fromString(String s) { return countryComboBox; } - abstract void setupCurrency(Country country, TradeCurrency currency); - abstract void updateCountriesSelection(List checkBoxList); } diff --git a/desktop/src/main/java/bisq/desktop/components/paymentmethods/SepaForm.java b/desktop/src/main/java/bisq/desktop/components/paymentmethods/SepaForm.java index 6eb209e710c..b4e74e47bfc 100644 --- a/desktop/src/main/java/bisq/desktop/components/paymentmethods/SepaForm.java +++ b/desktop/src/main/java/bisq/desktop/components/paymentmethods/SepaForm.java @@ -126,17 +126,11 @@ public void addFormForAddAccount() { if (CountryUtil.getAllSepaCountries().contains(country)) { countryComboBox.getSelectionModel().select(country); sepaAccount.setCountry(country); - TradeCurrency currency = CurrencyUtil.getCurrencyByCountryCode(country.code); - setupCurrency(country, currency); } updateFromInputs(); } - @Override - void setupCurrency(Country country, TradeCurrency currency) { - updateCurrencyFormElements(sepaAccount); - } private void addEuroCountriesGrid() { addCountriesGrid(Res.get("payment.accept.euro"), euroCountryCheckBoxes, diff --git a/desktop/src/main/java/bisq/desktop/components/paymentmethods/SepaInstantForm.java b/desktop/src/main/java/bisq/desktop/components/paymentmethods/SepaInstantForm.java index d52b5dd1483..36de5902292 100644 --- a/desktop/src/main/java/bisq/desktop/components/paymentmethods/SepaInstantForm.java +++ b/desktop/src/main/java/bisq/desktop/components/paymentmethods/SepaInstantForm.java @@ -126,18 +126,11 @@ public void addFormForAddAccount() { if (CountryUtil.getAllSepaInstantCountries().contains(country)) { countryComboBox.getSelectionModel().select(country); sepaInstantAccount.setCountry(country); - TradeCurrency currency = CurrencyUtil.getCurrencyByCountryCode(country.code); - setupCurrency(country, currency); } updateFromInputs(); } - @Override - void setupCurrency(Country country, TradeCurrency currency) { - updateCurrencyFormElements(sepaInstantAccount); - } - private void addEuroCountriesGrid() { addCountriesGrid(Res.get("payment.accept.euro"), euroCountryCheckBoxes, CountryUtil.getAllSepaInstantEuroCountries());