Clean up SepaForm and SepaInstantForm

This commit is contained in:
Christoph Atteneder 2018-10-26 16:27:47 +02:00
parent 8ecd53fab4
commit 9395e5cef5
No known key found for this signature in database
GPG Key ID: CD5DC1C529CDFD3B
5 changed files with 284 additions and 374 deletions

View File

@ -0,0 +1,171 @@
package bisq.desktop.components.paymentmethods;
import bisq.desktop.components.InputTextField;
import bisq.desktop.util.FormBuilder;
import bisq.core.locale.Country;
import bisq.core.locale.CurrencyUtil;
import bisq.core.locale.Res;
import bisq.core.locale.TradeCurrency;
import bisq.core.payment.AccountAgeWitnessService;
import bisq.core.payment.CountryBasedPaymentAccount;
import bisq.core.payment.PaymentAccount;
import bisq.core.util.BSFormatter;
import bisq.core.util.validation.InputValidator;
import org.apache.commons.lang3.StringUtils;
import com.jfoenix.controls.JFXComboBox;
import com.jfoenix.controls.JFXTextField;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ComboBox;
import javafx.scene.control.TextField;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.collections.FXCollections;
import javafx.util.StringConverter;
import java.util.ArrayList;
import java.util.List;
import static bisq.desktop.util.FormBuilder.addTopLabelWithVBox;
public abstract class GeneralSepaForm extends PaymentMethodForm {
static final String BIC = "BIC";
static final String IBAN = "IBAN";
final List<CheckBox> euroCountryCheckBoxes = new ArrayList<>();
final List<CheckBox> nonEuroCountryCheckBoxes = new ArrayList<>();
private TextField currencyTextField;
private ComboBox<TradeCurrency> currencyComboBox;
InputTextField ibanInputTextField;
GeneralSepaForm(PaymentAccount paymentAccount, AccountAgeWitnessService accountAgeWitnessService, InputValidator inputValidator, GridPane gridPane, int gridRow, BSFormatter formatter) {
super(paymentAccount, accountAgeWitnessService, inputValidator, gridPane, gridRow, formatter);
}
@Override
protected void autoFillNameTextField() {
if (useCustomAccountNameToggleButton != null && !useCustomAccountNameToggleButton.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));
}
}
}
void setCountryComboBoxAction(ComboBox<Country> countryComboBox, CountryBasedPaymentAccount paymentAccount) {
countryComboBox.setOnAction(e -> {
Country selectedItem = countryComboBox.getSelectionModel().getSelectedItem();
paymentAccount.setCountry(selectedItem);
TradeCurrency currency = CurrencyUtil.getCurrencyByCountryCode(selectedItem.code);
setupCurrency(selectedItem, currency);
updateCountriesSelection(euroCountryCheckBoxes);
updateCountriesSelection(nonEuroCountryCheckBoxes);
updateFromInputs();
});
}
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.getNameAndCode();
}
@Override
public TradeCurrency fromString(String string) {
return null;
}
});
currencyComboBox.getSelectionModel().select(0);
}
}
void addCountriesGrid(String title, List<CheckBox> checkBoxList,
List<Country> dataProvider) {
FlowPane flowPane = FormBuilder.addTopLabelFlowPane(gridPane, ++gridRow, title, 0).second;
flowPane.setId("flow-pane-checkboxes-bg");
dataProvider.forEach(country ->
fillUpFlowPaneWithCountries(true, checkBoxList, flowPane, country));
updateCountriesSelection(checkBoxList);
}
ComboBox<Country> addCountrySelection() {
HBox hBox = new HBox();
hBox.setSpacing(10);
ComboBox<Country> 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);
hBox.getChildren().addAll(countryComboBox, currencyTextField, currencyComboBox);
addTopLabelWithVBox(gridPane, ++gridRow, Res.get("payment.bank.country"), hBox, 0);
countryComboBox.setPromptText(Res.get("payment.select.bank.country"));
countryComboBox.setConverter(new StringConverter<>() {
@Override
public String toString(Country country) {
return country.name + " (" + country.code + ")";
}
@Override
public Country fromString(String s) {
return null;
}
});
return countryComboBox;
}
abstract void setupCurrency(Country country, TradeCurrency currency);
abstract void updateCountriesSelection(List<CheckBox> checkBoxList);
}

View File

@ -24,6 +24,7 @@ import bisq.desktop.main.overlays.popups.Popup;
import bisq.desktop.util.FormBuilder; import bisq.desktop.util.FormBuilder;
import bisq.desktop.util.Layout; import bisq.desktop.util.Layout;
import bisq.core.locale.Country;
import bisq.core.locale.CurrencyUtil; import bisq.core.locale.CurrencyUtil;
import bisq.core.locale.FiatCurrency; import bisq.core.locale.FiatCurrency;
import bisq.core.locale.Res; import bisq.core.locale.Res;
@ -59,6 +60,8 @@ import javafx.collections.FXCollections;
import javafx.util.StringConverter; import javafx.util.StringConverter;
import java.util.List;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import static bisq.desktop.util.FormBuilder.*; import static bisq.desktop.util.FormBuilder.*;
@ -249,6 +252,27 @@ public abstract class PaymentMethodForm {
flowPane.getChildren().add(checkBox); flowPane.getChildren().add(checkBox);
} }
void fillUpFlowPaneWithCountries(boolean isEditable, List<CheckBox> checkBoxList, FlowPane flowPane, Country country) {
final String countryCode = country.code;
CheckBox checkBox = new AutoTooltipCheckBox(countryCode);
checkBox.setUserData(countryCode);
checkBoxList.add(checkBox);
checkBox.setMouseTransparent(!isEditable);
checkBox.setMinWidth(45);
checkBox.setMaxWidth(45);
checkBox.setTooltip(new Tooltip(country.name));
checkBox.setOnAction(event -> {
if (checkBox.isSelected()) {
addAcceptedCountry(countryCode);
} else {
removeAcceptedCountry(countryCode);
}
updateAllInputsValid();
});
flowPane.getChildren().add(checkBox);
}
void addFormForAccountNumberDisplayAccount(String accountName, PaymentMethod paymentMethod, String accountNr, void addFormForAccountNumberDisplayAccount(String accountName, PaymentMethod paymentMethod, String accountNr,
TradeCurrency singleTradeCurrency) { TradeCurrency singleTradeCurrency) {
gridRowFrom = gridRow; gridRowFrom = gridRow;
@ -295,4 +319,10 @@ public abstract class PaymentMethodForm {
public BooleanProperty allInputsValidProperty() { public BooleanProperty allInputsValidProperty() {
return allInputsValid; return allInputsValid;
} }
void removeAcceptedCountry(String countryCode) {
}
void addAcceptedCountry(String countryCode) {
}
} }

View File

@ -17,7 +17,6 @@
package bisq.desktop.components.paymentmethods; package bisq.desktop.components.paymentmethods;
import bisq.desktop.components.AutoTooltipCheckBox;
import bisq.desktop.components.InputTextField; import bisq.desktop.components.InputTextField;
import bisq.desktop.util.FormBuilder; import bisq.desktop.util.FormBuilder;
import bisq.desktop.util.Layout; import bisq.desktop.util.Layout;
@ -30,7 +29,6 @@ import bisq.core.locale.CurrencyUtil;
import bisq.core.locale.Res; import bisq.core.locale.Res;
import bisq.core.locale.TradeCurrency; import bisq.core.locale.TradeCurrency;
import bisq.core.payment.AccountAgeWitnessService; import bisq.core.payment.AccountAgeWitnessService;
import bisq.core.payment.CountryBasedPaymentAccount;
import bisq.core.payment.PaymentAccount; import bisq.core.payment.PaymentAccount;
import bisq.core.payment.SepaAccount; import bisq.core.payment.SepaAccount;
import bisq.core.payment.payload.PaymentAccountPayload; import bisq.core.payment.payload.PaymentAccountPayload;
@ -38,34 +36,20 @@ import bisq.core.payment.payload.SepaAccountPayload;
import bisq.core.util.BSFormatter; import bisq.core.util.BSFormatter;
import bisq.core.util.validation.InputValidator; import bisq.core.util.validation.InputValidator;
import org.apache.commons.lang3.StringUtils;
import com.jfoenix.controls.JFXComboBox;
import javafx.scene.control.CheckBox; import javafx.scene.control.CheckBox;
import javafx.scene.control.ComboBox; import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.TextField; import javafx.scene.control.TextField;
import javafx.scene.control.Tooltip; import javafx.scene.control.Tooltip;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.GridPane; import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.text.TextAlignment;
import javafx.geometry.HPos;
import javafx.geometry.Insets;
import javafx.geometry.VPos;
import javafx.collections.FXCollections; import javafx.collections.FXCollections;
import javafx.util.StringConverter;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import static bisq.desktop.util.FormBuilder.addTopLabelTextFieldWithCopyIcon; import static bisq.desktop.util.FormBuilder.addTopLabelTextFieldWithCopyIcon;
public class SepaForm extends PaymentMethodForm { public class SepaForm extends GeneralSepaForm {
public static int addFormForBuyer(GridPane gridPane, int gridRow, public static int addFormForBuyer(GridPane gridPane, int gridRow,
PaymentAccountPayload paymentAccountPayload) { PaymentAccountPayload paymentAccountPayload) {
SepaAccountPayload sepaAccountPayload = (SepaAccountPayload) paymentAccountPayload; SepaAccountPayload sepaAccountPayload = (SepaAccountPayload) paymentAccountPayload;
@ -78,19 +62,14 @@ public class SepaForm extends PaymentMethodForm {
Res.get("payment.bank.country"), Res.get("payment.bank.country"),
CountryUtil.getNameAndCode(sepaAccountPayload.getCountryCode())); CountryUtil.getNameAndCode(sepaAccountPayload.getCountryCode()));
// IBAN, BIC will not be translated // IBAN, BIC will not be translated
FormBuilder.addTopLabelTextFieldWithCopyIcon(gridPane, ++gridRow, "IBAN:", sepaAccountPayload.getIban()); FormBuilder.addTopLabelTextFieldWithCopyIcon(gridPane, ++gridRow, IBAN, sepaAccountPayload.getIban());
FormBuilder.addTopLabelTextFieldWithCopyIcon(gridPane, ++gridRow, "BIC:", sepaAccountPayload.getBic()); FormBuilder.addTopLabelTextFieldWithCopyIcon(gridPane, ++gridRow, BIC, sepaAccountPayload.getBic());
return gridRow; return gridRow;
} }
private final SepaAccount sepaAccount; private final SepaAccount sepaAccount;
private final IBANValidator ibanValidator; private final IBANValidator ibanValidator;
private final BICValidator bicValidator; private final BICValidator bicValidator;
private InputTextField ibanInputTextField;
private TextField currencyTextField;
private final List<CheckBox> euroCountryCheckBoxes = new ArrayList<>();
private final List<CheckBox> nonEuroCountryCheckBoxes = new ArrayList<>();
private ComboBox<TradeCurrency> currencyComboBox;
public SepaForm(PaymentAccount paymentAccount, AccountAgeWitnessService accountAgeWitnessService, IBANValidator ibanValidator, public SepaForm(PaymentAccount paymentAccount, AccountAgeWitnessService accountAgeWitnessService, IBANValidator ibanValidator,
BICValidator bicValidator, InputValidator inputValidator, BICValidator bicValidator, InputValidator inputValidator,
@ -113,14 +92,14 @@ public class SepaForm extends PaymentMethodForm {
updateFromInputs(); updateFromInputs();
}); });
ibanInputTextField = FormBuilder.addInputTextField(gridPane, ++gridRow, "IBAN:"); ibanInputTextField = FormBuilder.addInputTextField(gridPane, ++gridRow, IBAN);
ibanInputTextField.setValidator(ibanValidator); ibanInputTextField.setValidator(ibanValidator);
ibanInputTextField.textProperty().addListener((ov, oldValue, newValue) -> { ibanInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
sepaAccount.setIban(newValue); sepaAccount.setIban(newValue);
updateFromInputs(); updateFromInputs();
}); });
InputTextField bicInputTextField = FormBuilder.addInputTextField(gridPane, ++gridRow, "BIC:"); InputTextField bicInputTextField = FormBuilder.addInputTextField(gridPane, ++gridRow, BIC);
bicInputTextField.setValidator(bicValidator); bicInputTextField.setValidator(bicValidator);
bicInputTextField.textProperty().addListener((ov, oldValue, newValue) -> { bicInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
sepaAccount.setBic(newValue); sepaAccount.setBic(newValue);
@ -128,54 +107,12 @@ public class SepaForm extends PaymentMethodForm {
}); });
ComboBox<Country> countryComboBox = addCountrySelection();
FormBuilder.addLabel(gridPane, ++gridRow, Res.get("payment.bank.country")); setCountryComboBoxAction(countryComboBox, sepaAccount);
HBox hBox = new HBox();
hBox.setSpacing(10);
ComboBox<Country> countryComboBox = new JFXComboBox<>();
currencyComboBox = new JFXComboBox<>();
currencyTextField = new TextField("");
currencyTextField.setEditable(false);
currencyTextField.setMouseTransparent(true);
currencyTextField.setFocusTraversable(false);
currencyTextField.setMinWidth(300);
currencyTextField.setVisible(false); addEuroCountriesGrid();
currencyTextField.setManaged(false); addNonEuroCountriesGrid();
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(); addLimitations();
addAccountNameTextFieldWithAutoFillToggleButton(); addAccountNameTextFieldWithAutoFillToggleButton();
@ -191,98 +128,26 @@ public class SepaForm extends PaymentMethodForm {
updateFromInputs(); updateFromInputs();
} }
private void setupCurrency(Country country, TradeCurrency currency) { @Override
if (CountryUtil.getAllSepaEuroCountries().contains(country)) { void setupCurrency(Country country, TradeCurrency currency) {
currencyTextField.setVisible(true); final boolean isSepaCountry = CountryUtil.getAllSepaEuroCountries().contains(country);
currencyTextField.setManaged(true);
currencyComboBox.setVisible(false);
currencyComboBox.setManaged(false);
sepaAccount.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 -> {
sepaAccount.setSingleTradeCurrency(currencyComboBox.getSelectionModel().getSelectedItem());
updateCountriesSelection(true, euroCountryCheckBoxes);
autoFillNameTextField();
});
currencyComboBox.setConverter(new StringConverter<TradeCurrency>() {
@Override
public String toString(TradeCurrency currency) {
return currency.getNameAndCode();
}
@Override updateCurrencyFormElements(currency, isSepaCountry, sepaAccount);
public TradeCurrency fromString(String string) {
return null;
}
});
currencyComboBox.getSelectionModel().select(0);
}
} }
private void addEuroCountriesGrid(boolean isEditable) { private void addEuroCountriesGrid() {
addCountriesGrid(isEditable, Res.get("payment.accept.euro"), euroCountryCheckBoxes, addCountriesGrid(Res.get("payment.accept.euro"), euroCountryCheckBoxes,
CountryUtil.getAllSepaEuroCountries()); CountryUtil.getAllSepaEuroCountries());
} }
private void addNonEuroCountriesGrid(boolean isEditable) { private void addNonEuroCountriesGrid() {
addCountriesGrid(isEditable, Res.get("payment.accept.nonEuro"), nonEuroCountryCheckBoxes, addCountriesGrid(Res.get("payment.accept.nonEuro"), nonEuroCountryCheckBoxes,
CountryUtil.getAllSepaNonEuroCountries()); CountryUtil.getAllSepaNonEuroCountries());
} }
private void addCountriesGrid(boolean isEditable, String title, List<CheckBox> checkBoxList, List<Country> dataProvider) { @Override
Label label = FormBuilder.addLabel(gridPane, ++gridRow, title, 0); void updateCountriesSelection(List<CheckBox> checkBoxList) {
label.setWrapText(true); checkBoxList.forEach(checkBox -> {
label.setMaxWidth(180);
label.setTextAlignment(TextAlignment.RIGHT);
GridPane.setHalignment(label, HPos.RIGHT);
GridPane.setValignment(label, VPos.TOP);
FlowPane flowPane = new FlowPane();
flowPane.setPadding(new Insets(10, 10, 10, 10));
flowPane.setVgap(10);
flowPane.setHgap(10);
flowPane.setMinHeight(55);
if (isEditable)
flowPane.setId("flow-pane-checkboxes-bg");
else
flowPane.setId("flow-pane-checkboxes-non-editable-bg");
dataProvider.stream().forEach(country ->
{
final String countryCode = country.code;
CheckBox checkBox = new AutoTooltipCheckBox(countryCode);
checkBox.setUserData(countryCode);
checkBoxList.add(checkBox);
checkBox.setMouseTransparent(!isEditable);
checkBox.setMinWidth(45);
checkBox.setMaxWidth(45);
checkBox.setTooltip(new Tooltip(country.name));
checkBox.setOnAction(event -> {
if (checkBox.isSelected())
sepaAccount.addAcceptedCountry(countryCode);
else
sepaAccount.removeAcceptedCountry(countryCode);
updateAllInputsValid();
});
flowPane.getChildren().add(checkBox);
});
updateCountriesSelection(isEditable, checkBoxList);
GridPane.setRowIndex(flowPane, gridRow);
GridPane.setColumnIndex(flowPane, 1);
gridPane.getChildren().add(flowPane);
}
private void updateCountriesSelection(boolean isEditable, List<CheckBox> checkBoxList) {
checkBoxList.stream().forEach(checkBox -> {
String countryCode = (String) checkBox.getUserData(); String countryCode = (String) checkBox.getUserData();
TradeCurrency selectedCurrency = sepaAccount.getSelectedTradeCurrency(); TradeCurrency selectedCurrency = sepaAccount.getSelectedTradeCurrency();
if (selectedCurrency == null) { if (selectedCurrency == null) {
@ -292,7 +157,7 @@ public class SepaForm extends PaymentMethodForm {
} }
boolean selected; boolean selected;
if (isEditable && selectedCurrency != null) { if (selectedCurrency != null) {
selected = true; selected = true;
sepaAccount.addAcceptedCountry(countryCode); sepaAccount.addAcceptedCountry(countryCode);
} else { } else {
@ -302,26 +167,6 @@ public class SepaForm extends PaymentMethodForm {
}); });
} }
@Override
protected void autoFillNameTextField() {
if (useCustomAccountNameToggleButton != null && !useCustomAccountNameToggleButton.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));
}
}
}
@Override @Override
public void updateAllInputsValid() { public void updateAllInputsValid() {
allInputsValid.set(isAccountNameValid() allInputsValid.set(isAccountNameValid()
@ -340,8 +185,8 @@ public class SepaForm extends PaymentMethodForm {
FormBuilder.addTopLabelTextField(gridPane, ++gridRow, Res.get("shared.paymentMethod"), FormBuilder.addTopLabelTextField(gridPane, ++gridRow, Res.get("shared.paymentMethod"),
Res.get(sepaAccount.getPaymentMethod().getId())); Res.get(sepaAccount.getPaymentMethod().getId()));
FormBuilder.addTopLabelTextField(gridPane, ++gridRow, Res.get("payment.account.owner"), sepaAccount.getHolderName()); FormBuilder.addTopLabelTextField(gridPane, ++gridRow, Res.get("payment.account.owner"), sepaAccount.getHolderName());
FormBuilder.addTopLabelTextField(gridPane, ++gridRow, "IBAN:", sepaAccount.getIban()).second.setMouseTransparent(false); FormBuilder.addTopLabelTextField(gridPane, ++gridRow, IBAN, sepaAccount.getIban()).second.setMouseTransparent(false);
FormBuilder.addTopLabelTextField(gridPane, ++gridRow, "BIC:", sepaAccount.getBic()).second.setMouseTransparent(false); FormBuilder.addTopLabelTextField(gridPane, ++gridRow, BIC, sepaAccount.getBic()).second.setMouseTransparent(false);
FormBuilder.addTopLabelTextField(gridPane, ++gridRow, Res.get("payment.bank.country"), FormBuilder.addTopLabelTextField(gridPane, ++gridRow, Res.get("payment.bank.country"),
sepaAccount.getCountry() != null ? sepaAccount.getCountry().name : ""); sepaAccount.getCountry() != null ? sepaAccount.getCountry().name : "");
TradeCurrency singleTradeCurrency = sepaAccount.getSingleTradeCurrency(); TradeCurrency singleTradeCurrency = sepaAccount.getSingleTradeCurrency();
@ -362,4 +207,14 @@ public class SepaForm extends PaymentMethodForm {
} }
addLimitations(); addLimitations();
} }
@Override
void removeAcceptedCountry(String countryCode) {
sepaAccount.removeAcceptedCountry(countryCode);
}
@Override
void addAcceptedCountry(String countryCode) {
sepaAccount.addAcceptedCountry(countryCode);
}
} }

View File

@ -17,7 +17,6 @@
package bisq.desktop.components.paymentmethods; package bisq.desktop.components.paymentmethods;
import bisq.desktop.components.AutoTooltipCheckBox;
import bisq.desktop.components.InputTextField; import bisq.desktop.components.InputTextField;
import bisq.desktop.util.FormBuilder; import bisq.desktop.util.FormBuilder;
import bisq.desktop.util.Layout; import bisq.desktop.util.Layout;
@ -30,7 +29,6 @@ import bisq.core.locale.CurrencyUtil;
import bisq.core.locale.Res; import bisq.core.locale.Res;
import bisq.core.locale.TradeCurrency; import bisq.core.locale.TradeCurrency;
import bisq.core.payment.AccountAgeWitnessService; import bisq.core.payment.AccountAgeWitnessService;
import bisq.core.payment.CountryBasedPaymentAccount;
import bisq.core.payment.PaymentAccount; import bisq.core.payment.PaymentAccount;
import bisq.core.payment.SepaInstantAccount; import bisq.core.payment.SepaInstantAccount;
import bisq.core.payment.payload.PaymentAccountPayload; import bisq.core.payment.payload.PaymentAccountPayload;
@ -38,34 +36,20 @@ import bisq.core.payment.payload.SepaInstantAccountPayload;
import bisq.core.util.BSFormatter; import bisq.core.util.BSFormatter;
import bisq.core.util.validation.InputValidator; import bisq.core.util.validation.InputValidator;
import org.apache.commons.lang3.StringUtils;
import com.jfoenix.controls.JFXComboBox;
import javafx.scene.control.CheckBox; import javafx.scene.control.CheckBox;
import javafx.scene.control.ComboBox; import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.TextField; import javafx.scene.control.TextField;
import javafx.scene.control.Tooltip; import javafx.scene.control.Tooltip;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.GridPane; import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.text.TextAlignment;
import javafx.geometry.HPos;
import javafx.geometry.Insets;
import javafx.geometry.VPos;
import javafx.collections.FXCollections; import javafx.collections.FXCollections;
import javafx.util.StringConverter;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import static bisq.desktop.util.FormBuilder.addTopLabelTextFieldWithCopyIcon; import static bisq.desktop.util.FormBuilder.addTopLabelTextFieldWithCopyIcon;
public class SepaInstantForm extends PaymentMethodForm { public class SepaInstantForm extends GeneralSepaForm {
public static int addFormForBuyer(GridPane gridPane, int gridRow, public static int addFormForBuyer(GridPane gridPane, int gridRow,
PaymentAccountPayload paymentAccountPayload) { PaymentAccountPayload paymentAccountPayload) {
SepaInstantAccountPayload sepaInstantAccountPayload = (SepaInstantAccountPayload) paymentAccountPayload; SepaInstantAccountPayload sepaInstantAccountPayload = (SepaInstantAccountPayload) paymentAccountPayload;
@ -78,19 +62,14 @@ public class SepaInstantForm extends PaymentMethodForm {
Res.get("payment.bank.country"), Res.get("payment.bank.country"),
CountryUtil.getNameAndCode(sepaInstantAccountPayload.getCountryCode())); CountryUtil.getNameAndCode(sepaInstantAccountPayload.getCountryCode()));
// IBAN, BIC will not be translated // IBAN, BIC will not be translated
FormBuilder.addTopLabelTextFieldWithCopyIcon(gridPane, ++gridRow, "IBAN:", sepaInstantAccountPayload.getIban()); FormBuilder.addTopLabelTextFieldWithCopyIcon(gridPane, ++gridRow, IBAN, sepaInstantAccountPayload.getIban());
FormBuilder.addTopLabelTextFieldWithCopyIcon(gridPane, ++gridRow, "BIC:", sepaInstantAccountPayload.getBic()); FormBuilder.addTopLabelTextFieldWithCopyIcon(gridPane, ++gridRow, BIC, sepaInstantAccountPayload.getBic());
return gridRow; return gridRow;
} }
private final SepaInstantAccount sepaInstantAccount; private final SepaInstantAccount sepaInstantAccount;
private final IBANValidator ibanValidator; private final IBANValidator ibanValidator;
private final BICValidator bicValidator; private final BICValidator bicValidator;
private InputTextField ibanInputTextField;
private TextField currencyTextField;
private final List<CheckBox> euroCountryCheckBoxes = new ArrayList<>();
private final List<CheckBox> nonEuroCountryCheckBoxes = new ArrayList<>();
private ComboBox<TradeCurrency> currencyComboBox;
public SepaInstantForm(PaymentAccount paymentAccount, AccountAgeWitnessService accountAgeWitnessService, IBANValidator ibanValidator, public SepaInstantForm(PaymentAccount paymentAccount, AccountAgeWitnessService accountAgeWitnessService, IBANValidator ibanValidator,
BICValidator bicValidator, InputValidator inputValidator, BICValidator bicValidator, InputValidator inputValidator,
@ -113,14 +92,14 @@ public class SepaInstantForm extends PaymentMethodForm {
updateFromInputs(); updateFromInputs();
}); });
ibanInputTextField = FormBuilder.addInputTextField(gridPane, ++gridRow, "IBAN:"); ibanInputTextField = FormBuilder.addInputTextField(gridPane, ++gridRow, IBAN);
ibanInputTextField.setValidator(ibanValidator); ibanInputTextField.setValidator(ibanValidator);
ibanInputTextField.textProperty().addListener((ov, oldValue, newValue) -> { ibanInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
sepaInstantAccount.setIban(newValue); sepaInstantAccount.setIban(newValue);
updateFromInputs(); updateFromInputs();
}); });
InputTextField bicInputTextField = FormBuilder.addInputTextField(gridPane, ++gridRow, "BIC:"); InputTextField bicInputTextField = FormBuilder.addInputTextField(gridPane, ++gridRow, BIC);
bicInputTextField.setValidator(bicValidator); bicInputTextField.setValidator(bicValidator);
bicInputTextField.textProperty().addListener((ov, oldValue, newValue) -> { bicInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
sepaInstantAccount.setBic(newValue); sepaInstantAccount.setBic(newValue);
@ -128,54 +107,12 @@ public class SepaInstantForm extends PaymentMethodForm {
}); });
ComboBox<Country> countryComboBox = addCountrySelection();
FormBuilder.addLabel(gridPane, ++gridRow, Res.get("payment.bank.country")); setCountryComboBoxAction(countryComboBox, sepaInstantAccount);
HBox hBox = new HBox();
hBox.setSpacing(10);
ComboBox<Country> countryComboBox = new JFXComboBox<>();
currencyComboBox = new JFXComboBox<>();
currencyTextField = new TextField("");
currencyTextField.setEditable(false);
currencyTextField.setMouseTransparent(true);
currencyTextField.setFocusTraversable(false);
currencyTextField.setMinWidth(300);
currencyTextField.setVisible(false); addEuroCountriesGrid();
currencyTextField.setManaged(false); addNonEuroCountriesGrid();
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(); addLimitations();
addAccountNameTextFieldWithAutoFillToggleButton(); addAccountNameTextFieldWithAutoFillToggleButton();
@ -191,98 +128,25 @@ public class SepaInstantForm extends PaymentMethodForm {
updateFromInputs(); updateFromInputs();
} }
private void setupCurrency(Country country, TradeCurrency currency) { @Override
if (CountryUtil.getAllSepaInstantEuroCountries().contains(country)) { void setupCurrency(Country country, TradeCurrency currency) {
currencyTextField.setVisible(true); final boolean isSepaInstantCountry = CountryUtil.getAllSepaInstantEuroCountries().contains(country);
currencyTextField.setManaged(true); updateCurrencyFormElements(currency, isSepaInstantCountry, sepaInstantAccount);
currencyComboBox.setVisible(false);
currencyComboBox.setManaged(false);
sepaInstantAccount.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 -> {
sepaInstantAccount.setSingleTradeCurrency(currencyComboBox.getSelectionModel().getSelectedItem());
updateCountriesSelection(true, euroCountryCheckBoxes);
autoFillNameTextField();
});
currencyComboBox.setConverter(new StringConverter<TradeCurrency>() {
@Override
public String toString(TradeCurrency currency) {
return currency.getNameAndCode();
}
@Override
public TradeCurrency fromString(String string) {
return null;
}
});
currencyComboBox.getSelectionModel().select(0);
}
} }
private void addEuroCountriesGrid(boolean isEditable) { private void addEuroCountriesGrid() {
addCountriesGrid(isEditable, Res.get("payment.accept.euro"), euroCountryCheckBoxes, addCountriesGrid(Res.get("payment.accept.euro"), euroCountryCheckBoxes,
CountryUtil.getAllSepaInstantEuroCountries()); CountryUtil.getAllSepaInstantEuroCountries());
} }
private void addNonEuroCountriesGrid(boolean isEditable) { private void addNonEuroCountriesGrid() {
addCountriesGrid(isEditable, Res.get("payment.accept.nonEuro"), nonEuroCountryCheckBoxes, addCountriesGrid(Res.get("payment.accept.nonEuro"), nonEuroCountryCheckBoxes,
CountryUtil.getAllSepaInstantNonEuroCountries()); CountryUtil.getAllSepaInstantNonEuroCountries());
} }
private void addCountriesGrid(boolean isEditable, String title, List<CheckBox> checkBoxList, List<Country> dataProvider) { @Override
Label label = FormBuilder.addLabel(gridPane, ++gridRow, title, 0); void updateCountriesSelection(List<CheckBox> checkBoxList) {
label.setWrapText(true); checkBoxList.forEach(checkBox -> {
label.setMaxWidth(180);
label.setTextAlignment(TextAlignment.RIGHT);
GridPane.setHalignment(label, HPos.RIGHT);
GridPane.setValignment(label, VPos.TOP);
FlowPane flowPane = new FlowPane();
flowPane.setPadding(new Insets(10, 10, 10, 10));
flowPane.setVgap(10);
flowPane.setHgap(10);
flowPane.setMinHeight(55);
if (isEditable)
flowPane.setId("flow-pane-checkboxes-bg");
else
flowPane.setId("flow-pane-checkboxes-non-editable-bg");
dataProvider.stream().forEach(country ->
{
final String countryCode = country.code;
CheckBox checkBox = new AutoTooltipCheckBox(countryCode);
checkBox.setUserData(countryCode);
checkBoxList.add(checkBox);
checkBox.setMouseTransparent(!isEditable);
checkBox.setMinWidth(45);
checkBox.setMaxWidth(45);
checkBox.setTooltip(new Tooltip(country.name));
checkBox.setOnAction(event -> {
if (checkBox.isSelected())
sepaInstantAccount.addAcceptedCountry(countryCode);
else
sepaInstantAccount.removeAcceptedCountry(countryCode);
updateAllInputsValid();
});
flowPane.getChildren().add(checkBox);
});
updateCountriesSelection(isEditable, checkBoxList);
GridPane.setRowIndex(flowPane, gridRow);
GridPane.setColumnIndex(flowPane, 1);
gridPane.getChildren().add(flowPane);
}
private void updateCountriesSelection(boolean isEditable, List<CheckBox> checkBoxList) {
checkBoxList.stream().forEach(checkBox -> {
String countryCode = (String) checkBox.getUserData(); String countryCode = (String) checkBox.getUserData();
TradeCurrency selectedCurrency = sepaInstantAccount.getSelectedTradeCurrency(); TradeCurrency selectedCurrency = sepaInstantAccount.getSelectedTradeCurrency();
if (selectedCurrency == null) { if (selectedCurrency == null) {
@ -292,7 +156,7 @@ public class SepaInstantForm extends PaymentMethodForm {
} }
boolean selected; boolean selected;
if (isEditable && selectedCurrency != null) { if (selectedCurrency != null) {
selected = true; selected = true;
sepaInstantAccount.addAcceptedCountry(countryCode); sepaInstantAccount.addAcceptedCountry(countryCode);
} else { } else {
@ -302,26 +166,6 @@ public class SepaInstantForm extends PaymentMethodForm {
}); });
} }
@Override
protected void autoFillNameTextField() {
if (useCustomAccountNameToggleButton != null && !useCustomAccountNameToggleButton.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));
}
}
}
@Override @Override
public void updateAllInputsValid() { public void updateAllInputsValid() {
allInputsValid.set(isAccountNameValid() allInputsValid.set(isAccountNameValid()
@ -340,8 +184,8 @@ public class SepaInstantForm extends PaymentMethodForm {
FormBuilder.addTopLabelTextField(gridPane, ++gridRow, Res.get("shared.paymentMethod"), FormBuilder.addTopLabelTextField(gridPane, ++gridRow, Res.get("shared.paymentMethod"),
Res.get(sepaInstantAccount.getPaymentMethod().getId())); Res.get(sepaInstantAccount.getPaymentMethod().getId()));
FormBuilder.addTopLabelTextField(gridPane, ++gridRow, Res.get("payment.account.owner"), sepaInstantAccount.getHolderName()); FormBuilder.addTopLabelTextField(gridPane, ++gridRow, Res.get("payment.account.owner"), sepaInstantAccount.getHolderName());
FormBuilder.addTopLabelTextField(gridPane, ++gridRow, "IBAN:", sepaInstantAccount.getIban()).second.setMouseTransparent(false); FormBuilder.addTopLabelTextField(gridPane, ++gridRow, IBAN, sepaInstantAccount.getIban()).second.setMouseTransparent(false);
FormBuilder.addTopLabelTextField(gridPane, ++gridRow, "BIC:", sepaInstantAccount.getBic()).second.setMouseTransparent(false); FormBuilder.addTopLabelTextField(gridPane, ++gridRow, BIC, sepaInstantAccount.getBic()).second.setMouseTransparent(false);
FormBuilder.addTopLabelTextField(gridPane, ++gridRow, Res.get("payment.bank.country"), FormBuilder.addTopLabelTextField(gridPane, ++gridRow, Res.get("payment.bank.country"),
sepaInstantAccount.getCountry() != null ? sepaInstantAccount.getCountry().name : ""); sepaInstantAccount.getCountry() != null ? sepaInstantAccount.getCountry().name : "");
TradeCurrency singleTradeCurrency = sepaInstantAccount.getSingleTradeCurrency(); TradeCurrency singleTradeCurrency = sepaInstantAccount.getSingleTradeCurrency();
@ -362,4 +206,14 @@ public class SepaInstantForm extends PaymentMethodForm {
} }
addLimitations(); addLimitations();
} }
@Override
void removeAcceptedCountry(String countryCode) {
sepaInstantAccount.removeAcceptedCountry(countryCode);
}
@Override
void addAcceptedCountry(String countryCode) {
sepaInstantAccount.addAcceptedCountry(countryCode);
}
} }

View File

@ -230,7 +230,7 @@ public class FormBuilder {
textField.setMouseTransparent(true); textField.setMouseTransparent(true);
textField.setFocusTraversable(false); textField.setFocusTraversable(false);
final Tuple2<Label, VBox> topLabelWithVBox = getTopLabelWithVBox(gridPane, rowIndex, title, textField, top); final Tuple2<Label, VBox> topLabelWithVBox = addTopLabelWithVBox(gridPane, rowIndex, title, textField, top);
return new Tuple3<>(topLabelWithVBox.first, textField, topLabelWithVBox.second); return new Tuple3<>(topLabelWithVBox.first, textField, topLabelWithVBox.second);
} }
@ -344,7 +344,7 @@ public class FormBuilder {
((JFXTextArea) textArea).setLabelFloat(true); ((JFXTextArea) textArea).setLabelFloat(true);
textArea.setWrapText(true); textArea.setWrapText(true);
final Tuple2<Label, VBox> topLabelWithVBox = getTopLabelWithVBox(gridPane, rowIndex, title, textArea, top); final Tuple2<Label, VBox> topLabelWithVBox = addTopLabelWithVBox(gridPane, rowIndex, title, textArea, top);
return new Tuple2<>(topLabelWithVBox.first, textArea); return new Tuple2<>(topLabelWithVBox.first, textArea);
} }
@ -357,7 +357,7 @@ public class FormBuilder {
public static Tuple2<Label, DatePicker> addTopLabelDatePicker(GridPane gridPane, int rowIndex, String title, double top) { public static Tuple2<Label, DatePicker> addTopLabelDatePicker(GridPane gridPane, int rowIndex, String title, double top) {
DatePicker datePicker = new JFXDatePicker(); DatePicker datePicker = new JFXDatePicker();
final Tuple2<Label, VBox> topLabelWithVBox = getTopLabelWithVBox(gridPane, rowIndex, title, datePicker, top); final Tuple2<Label, VBox> topLabelWithVBox = addTopLabelWithVBox(gridPane, rowIndex, title, datePicker, top);
return new Tuple2<>(topLabelWithVBox.first, datePicker); return new Tuple2<>(topLabelWithVBox.first, datePicker);
} }
@ -419,7 +419,7 @@ public class FormBuilder {
InfoInputTextField inputTextField = new InfoInputTextField(); InfoInputTextField inputTextField = new InfoInputTextField();
final Tuple2<Label, VBox> topLabelWithVBox = getTopLabelWithVBox(gridPane, rowIndex, title, inputTextField, top); final Tuple2<Label, VBox> topLabelWithVBox = addTopLabelWithVBox(gridPane, rowIndex, title, inputTextField, top);
return new Tuple2<>(topLabelWithVBox.first, inputTextField); return new Tuple2<>(topLabelWithVBox.first, inputTextField);
} }
@ -457,7 +457,7 @@ public class FormBuilder {
toggleButton.setText(toggleButtonTitle); toggleButton.setText(toggleButtonTitle);
VBox.setMargin(toggleButton, new Insets(4, 0, 0, 0)); VBox.setMargin(toggleButton, new Insets(4, 0, 0, 0));
final Tuple2<Label, VBox> topLabelWithVBox = getTopLabelWithVBox(gridPane, rowIndex, title, inputTextField, 0); final Tuple2<Label, VBox> topLabelWithVBox = addTopLabelWithVBox(gridPane, rowIndex, title, inputTextField, 0);
topLabelWithVBox.second.getChildren().add(toggleButton); topLabelWithVBox.second.getChildren().add(toggleButton);
@ -652,7 +652,7 @@ public class FormBuilder {
hBox.setSpacing(10); hBox.setSpacing(10);
hBox.getChildren().addAll(radioButton1, radioButton2); hBox.getChildren().addAll(radioButton1, radioButton2);
final Tuple2<Label, VBox> topLabelWithVBox = getTopLabelWithVBox(gridPane, rowIndex, title, hBox, top); final Tuple2<Label, VBox> topLabelWithVBox = addTopLabelWithVBox(gridPane, rowIndex, title, hBox, top);
return new Tuple3<>(topLabelWithVBox.first, radioButton1, radioButton2); return new Tuple3<>(topLabelWithVBox.first, radioButton1, radioButton2);
} }
@ -757,9 +757,9 @@ public class FormBuilder {
} }
@NotNull @NotNull
public static Tuple2 <Label, VBox> getTopLabelWithVBox(GridPane gridPane, int rowIndex, public static Tuple2<Label, VBox> addTopLabelWithVBox(GridPane gridPane, int rowIndex,
String title, Node node, String title, Node node,
double top) { double top) {
Label label = getTopLabel(title); Label label = getTopLabel(title);
VBox vBox = getTopLabelVBox(0); VBox vBox = getTopLabelVBox(0);
vBox.getChildren().addAll(label, node); vBox.getChildren().addAll(label, node);
@ -837,7 +837,7 @@ public class FormBuilder {
ComboBox<R> comboBox2 = new JFXComboBox<>(); ComboBox<R> comboBox2 = new JFXComboBox<>();
hBox.getChildren().addAll(comboBox1, comboBox2); hBox.getChildren().addAll(comboBox1, comboBox2);
final Tuple2<Label, VBox> topLabelWithVBox = getTopLabelWithVBox(gridPane, rowIndex, title, hBox, top); final Tuple2<Label, VBox> topLabelWithVBox = addTopLabelWithVBox(gridPane, rowIndex, title, hBox, top);
return new Tuple3<>(topLabelWithVBox.first, comboBox1, comboBox2); return new Tuple3<>(topLabelWithVBox.first, comboBox1, comboBox2);
} }
@ -951,7 +951,7 @@ public class FormBuilder {
TextFieldWithCopyIcon textFieldWithCopyIcon = new TextFieldWithCopyIcon(); TextFieldWithCopyIcon textFieldWithCopyIcon = new TextFieldWithCopyIcon();
textFieldWithCopyIcon.setText(value); textFieldWithCopyIcon.setText(value);
final Tuple2<Label, VBox> topLabelWithVBox = getTopLabelWithVBox(gridPane, rowIndex, title, textFieldWithCopyIcon, top); final Tuple2<Label, VBox> topLabelWithVBox = addTopLabelWithVBox(gridPane, rowIndex, title, textFieldWithCopyIcon, top);
return new Tuple2<>(topLabelWithVBox.first, textFieldWithCopyIcon); return new Tuple2<>(topLabelWithVBox.first, textFieldWithCopyIcon);
} }
@ -1066,7 +1066,7 @@ public class FormBuilder {
Button button = new AutoTooltipButton(buttonTitle); Button button = new AutoTooltipButton(buttonTitle);
button.setDefaultButton(true); button.setDefaultButton(true);
final Tuple2<Label, VBox> topLabelWithVBox = getTopLabelWithVBox(gridPane, rowIndex, labelText, button, top); final Tuple2<Label, VBox> topLabelWithVBox = addTopLabelWithVBox(gridPane, rowIndex, labelText, button, top);
return new Tuple2<>(topLabelWithVBox.first, button); return new Tuple2<>(topLabelWithVBox.first, button);
} }
@ -1083,7 +1083,7 @@ public class FormBuilder {
Button button2 = new AutoTooltipButton(title2); Button button2 = new AutoTooltipButton(title2);
hBox.getChildren().addAll(button1, button2); hBox.getChildren().addAll(button1, button2);
final Tuple2<Label, VBox> topLabelWithVBox = getTopLabelWithVBox(gridPane, rowIndex, labelText, hBox, top); final Tuple2<Label, VBox> topLabelWithVBox = addTopLabelWithVBox(gridPane, rowIndex, labelText, hBox, top);
return new Tuple3<>(topLabelWithVBox.first, button1, button2); return new Tuple3<>(topLabelWithVBox.first, button1, button2);
} }
@ -1340,7 +1340,7 @@ public class FormBuilder {
public static <T> Tuple3<Label, ListView<T>, VBox> addTopLabelListView(GridPane gridPane, int rowIndex, String title, double top) { public static <T> Tuple3<Label, ListView<T>, VBox> addTopLabelListView(GridPane gridPane, int rowIndex, String title, double top) {
ListView<T> listView = new ListView<>(); ListView<T> listView = new ListView<>();
final Tuple2<Label, VBox> topLabelWithVBox = getTopLabelWithVBox(gridPane, rowIndex, title, listView, top); final Tuple2<Label, VBox> topLabelWithVBox = addTopLabelWithVBox(gridPane, rowIndex, title, listView, top);
return new Tuple3<>(topLabelWithVBox.first, listView, topLabelWithVBox.second); return new Tuple3<>(topLabelWithVBox.first, listView, topLabelWithVBox.second);
} }
@ -1353,7 +1353,7 @@ public class FormBuilder {
flowPane.setPadding(new Insets(10, 10, 10, 10)); flowPane.setPadding(new Insets(10, 10, 10, 10));
flowPane.setVgap(10); flowPane.setVgap(10);
flowPane.setHgap(10); flowPane.setHgap(10);
final Tuple2<Label, VBox> topLabelWithVBox = getTopLabelWithVBox(gridPane, rowIndex, title, flowPane, top); final Tuple2<Label, VBox> topLabelWithVBox = addTopLabelWithVBox(gridPane, rowIndex, title, flowPane, top);
return new Tuple2<>(topLabelWithVBox.first, flowPane); return new Tuple2<>(topLabelWithVBox.first, flowPane);
} }