Merge branch 'ripcurlx-redesign' into release-candidate-0.9.0

This commit is contained in:
Manfred Karrer 2018-10-27 22:28:33 -05:00
commit f005f22cba
No known key found for this signature in database
GPG key ID: 401250966A6B2C46
16 changed files with 392 additions and 577 deletions

View file

@ -17,12 +17,9 @@
package bisq.desktop.components.paymentmethods; package bisq.desktop.components.paymentmethods;
import bisq.desktop.components.InputTextField;
import bisq.desktop.util.FormBuilder;
import bisq.desktop.util.validation.AliPayValidator; import bisq.desktop.util.validation.AliPayValidator;
import bisq.core.locale.Res; import bisq.core.locale.Res;
import bisq.core.locale.TradeCurrency;
import bisq.core.payment.AccountAgeWitnessService; import bisq.core.payment.AccountAgeWitnessService;
import bisq.core.payment.AliPayAccount; import bisq.core.payment.AliPayAccount;
import bisq.core.payment.PaymentAccount; import bisq.core.payment.PaymentAccount;
@ -31,21 +28,13 @@ import bisq.core.payment.payload.PaymentAccountPayload;
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 javafx.scene.layout.GridPane; import javafx.scene.layout.GridPane;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static bisq.desktop.util.FormBuilder.addTopLabelTextFieldWithCopyIcon; import static bisq.desktop.util.FormBuilder.addTopLabelTextFieldWithCopyIcon;
public class AliPayForm extends PaymentMethodForm { public class AliPayForm extends GeneralAccountNumberForm {
private static final Logger log = LoggerFactory.getLogger(AliPayForm.class);
private final AliPayAccount aliPayAccount; private final AliPayAccount aliPayAccount;
private final AliPayValidator aliPayValidator;
private InputTextField accountNrInputTextField;
public static int addFormForBuyer(GridPane gridPane, int gridRow, PaymentAccountPayload paymentAccountPayload) { public static int addFormForBuyer(GridPane gridPane, int gridRow, PaymentAccountPayload paymentAccountPayload) {
addTopLabelTextFieldWithCopyIcon(gridPane, ++gridRow, Res.get("payment.account.no"), ((AliPayAccountPayload) paymentAccountPayload).getAccountNr()); addTopLabelTextFieldWithCopyIcon(gridPane, ++gridRow, Res.get("payment.account.no"), ((AliPayAccountPayload) paymentAccountPayload).getAccountNr());
@ -55,49 +44,15 @@ public class AliPayForm extends PaymentMethodForm {
public AliPayForm(PaymentAccount paymentAccount, AccountAgeWitnessService accountAgeWitnessService, AliPayValidator aliPayValidator, InputValidator inputValidator, GridPane gridPane, int gridRow, BSFormatter formatter) { public AliPayForm(PaymentAccount paymentAccount, AccountAgeWitnessService accountAgeWitnessService, AliPayValidator aliPayValidator, InputValidator inputValidator, GridPane gridPane, int gridRow, BSFormatter formatter) {
super(paymentAccount, accountAgeWitnessService, inputValidator, gridPane, gridRow, formatter); super(paymentAccount, accountAgeWitnessService, inputValidator, gridPane, gridRow, formatter);
this.aliPayAccount = (AliPayAccount) paymentAccount; this.aliPayAccount = (AliPayAccount) paymentAccount;
this.aliPayValidator = aliPayValidator;
} }
@Override @Override
public void addFormForAddAccount() { void setAccountNumber(String newValue) {
gridRowFrom = gridRow + 1; aliPayAccount.setAccountNr(newValue);
accountNrInputTextField = FormBuilder.addInputTextField(gridPane, ++gridRow, Res.get("payment.account.no"));
accountNrInputTextField.setValidator(aliPayValidator);
accountNrInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
aliPayAccount.setAccountNr(newValue);
updateFromInputs();
});
final TradeCurrency singleTradeCurrency = aliPayAccount.getSingleTradeCurrency();
final String nameAndCode = singleTradeCurrency != null ? singleTradeCurrency.getNameAndCode() : "";
FormBuilder.addTopLabelTextField(gridPane, ++gridRow, Res.get("shared.currency"), nameAndCode);
addLimitations();
addAccountNameTextFieldWithAutoFillToggleButton();
} }
@Override @Override
protected void autoFillNameTextField() { String getAccountNr() {
if (useCustomAccountNameToggleButton != null && !useCustomAccountNameToggleButton.isSelected()) { return aliPayAccount.getAccountNr();
String accountNr = accountNrInputTextField.getText();
accountNr = StringUtils.abbreviate(accountNr, 9);
String method = Res.get(paymentAccount.getPaymentMethod().getId());
accountNameTextField.setText(method.concat(": ").concat(accountNr));
}
} }
@Override
public void addFormForDisplayAccount() {
addFormForAccountNumberDisplayAccount(aliPayAccount.getAccountName(),
aliPayAccount.getPaymentMethod(), aliPayAccount.getAccountNr(),
aliPayAccount.getSingleTradeCurrency());
}
@Override
public void updateAllInputsValid() {
allInputsValid.set(isAccountNameValid()
&& aliPayValidator.validate(aliPayAccount.getAccountNr()).isValid
&& aliPayAccount.getTradeCurrencies().size() > 0);
}
} }

View file

@ -32,8 +32,6 @@ import bisq.core.payment.payload.PaymentAccountPayload;
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 javafx.scene.control.TextField; import javafx.scene.control.TextField;
import javafx.scene.layout.GridPane; import javafx.scene.layout.GridPane;
@ -85,12 +83,7 @@ public class ClearXchangeForm extends PaymentMethodForm {
@Override @Override
protected void autoFillNameTextField() { protected void autoFillNameTextField() {
if (useCustomAccountNameToggleButton != null && !useCustomAccountNameToggleButton.isSelected()) { setAccountNameWithString(mobileNrInputTextField.getText());
String mobileNr = mobileNrInputTextField.getText();
mobileNr = StringUtils.abbreviate(mobileNr, 9);
String method = Res.get(paymentAccount.getPaymentMethod().getId());
accountNameTextField.setText(method.concat(": ").concat(mobileNr));
}
} }
@Override @Override

View file

@ -0,0 +1,67 @@
package bisq.desktop.components.paymentmethods;
import bisq.desktop.components.InputTextField;
import bisq.desktop.util.FormBuilder;
import bisq.core.locale.Res;
import bisq.core.locale.TradeCurrency;
import bisq.core.payment.AccountAgeWitnessService;
import bisq.core.payment.PaymentAccount;
import bisq.core.util.BSFormatter;
import bisq.core.util.validation.InputValidator;
import javafx.scene.layout.GridPane;
abstract public class GeneralAccountNumberForm extends PaymentMethodForm {
private InputTextField accountNrInputTextField;
public GeneralAccountNumberForm(PaymentAccount paymentAccount, AccountAgeWitnessService accountAgeWitnessService, InputValidator inputValidator, GridPane gridPane, int gridRow, BSFormatter formatter) {
super(paymentAccount, accountAgeWitnessService, inputValidator, gridPane, gridRow, formatter);
}
@Override
public void addFormForAddAccount() {
gridRowFrom = gridRow + 1;
accountNrInputTextField = FormBuilder.addInputTextField(gridPane, ++gridRow, Res.get("payment.account.no"));
accountNrInputTextField.setValidator(inputValidator);
accountNrInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
setAccountNumber(newValue);
updateFromInputs();
});
addTradeCurrency();
addLimitations();
addAccountNameTextFieldWithAutoFillToggleButton();
}
public void addTradeCurrency() {
final TradeCurrency singleTradeCurrency = paymentAccount.getSingleTradeCurrency();
final String nameAndCode = singleTradeCurrency != null ? singleTradeCurrency.getNameAndCode() : "";
FormBuilder.addTopLabelTextField(gridPane, ++gridRow, Res.get("shared.currency"), nameAndCode);
}
@Override
protected void autoFillNameTextField() {
setAccountNameWithString(accountNrInputTextField.getText());
}
@Override
public void addFormForDisplayAccount() {
addFormForAccountNumberDisplayAccount(paymentAccount.getAccountName(), paymentAccount.getPaymentMethod(), getAccountNr(),
paymentAccount.getSingleTradeCurrency());
}
@Override
public void updateAllInputsValid() {
allInputsValid.set(isAccountNameValid()
&& inputValidator.validate(getAccountNr()).isValid
&& paymentAccount.getTradeCurrencies().size() > 0);
}
abstract void setAccountNumber(String newValue);
abstract String getAccountNr();
}

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(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.*;
@ -89,10 +92,10 @@ public abstract class PaymentMethodForm {
} }
protected void addTradeCurrencyComboBox() { protected void addTradeCurrencyComboBox() {
currencyComboBox = FormBuilder.<TradeCurrency>addComboBox(gridPane, ++gridRow, Res.get("shared.currency")); currencyComboBox = FormBuilder.addComboBox(gridPane, ++gridRow, Res.get("shared.currency"));
currencyComboBox.setPromptText(Res.get("list.currency.select")); currencyComboBox.setPromptText(Res.get("list.currency.select"));
currencyComboBox.setItems(FXCollections.observableArrayList(CurrencyUtil.getMainFiatCurrencies())); currencyComboBox.setItems(FXCollections.observableArrayList(CurrencyUtil.getMainFiatCurrencies()));
currencyComboBox.setConverter(new StringConverter<TradeCurrency>() { currencyComboBox.setConverter(new StringConverter<>() {
@Override @Override
public String toString(TradeCurrency tradeCurrency) { public String toString(TradeCurrency tradeCurrency) {
return tradeCurrency.getNameAndCode(); return tradeCurrency.getNameAndCode();
@ -249,6 +252,27 @@ public abstract class PaymentMethodForm {
flowPane.getChildren().add(checkBox); flowPane.getChildren().add(checkBox);
} }
void fillUpFlowPaneWithCountries(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(false);
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,8 +17,6 @@
package bisq.desktop.components.paymentmethods; package bisq.desktop.components.paymentmethods;
import bisq.desktop.components.InputTextField;
import bisq.desktop.util.FormBuilder;
import bisq.desktop.util.validation.PerfectMoneyValidator; import bisq.desktop.util.validation.PerfectMoneyValidator;
import bisq.core.locale.FiatCurrency; import bisq.core.locale.FiatCurrency;
@ -37,11 +35,9 @@ import javafx.collections.FXCollections;
import static bisq.desktop.util.FormBuilder.addTopLabelTextFieldWithCopyIcon; import static bisq.desktop.util.FormBuilder.addTopLabelTextFieldWithCopyIcon;
public class PerfectMoneyForm extends PaymentMethodForm { public class PerfectMoneyForm extends GeneralAccountNumberForm {
private final PerfectMoneyAccount perfectMoneyAccount; private final PerfectMoneyAccount perfectMoneyAccount;
private final PerfectMoneyValidator perfectMoneyValidator;
private InputTextField accountNrInputTextField;
public static int addFormForBuyer(GridPane gridPane, int gridRow, PaymentAccountPayload paymentAccountPayload) { public static int addFormForBuyer(GridPane gridPane, int gridRow, PaymentAccountPayload paymentAccountPayload) {
addTopLabelTextFieldWithCopyIcon(gridPane, ++gridRow, Res.get("payment.account.no"), ((PerfectMoneyAccountPayload) paymentAccountPayload).getAccountNr()); addTopLabelTextFieldWithCopyIcon(gridPane, ++gridRow, Res.get("payment.account.no"), ((PerfectMoneyAccountPayload) paymentAccountPayload).getAccountNr());
@ -52,44 +48,22 @@ public class PerfectMoneyForm extends PaymentMethodForm {
gridRow, BSFormatter formatter) { gridRow, BSFormatter formatter) {
super(paymentAccount, accountAgeWitnessService, inputValidator, gridPane, gridRow, formatter); super(paymentAccount, accountAgeWitnessService, inputValidator, gridPane, gridRow, formatter);
this.perfectMoneyAccount = (PerfectMoneyAccount) paymentAccount; this.perfectMoneyAccount = (PerfectMoneyAccount) paymentAccount;
this.perfectMoneyValidator = perfectMoneyValidator;
} }
@Override @Override
public void addFormForAddAccount() { public void addTradeCurrency() {
gridRowFrom = gridRow + 1;
accountNrInputTextField = FormBuilder.addInputTextField(gridPane, ++gridRow, Res.get("payment.account.no"));
accountNrInputTextField.setValidator(perfectMoneyValidator);
accountNrInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
perfectMoneyAccount.setAccountNr(newValue);
updateFromInputs();
});
addTradeCurrencyComboBox(); addTradeCurrencyComboBox();
currencyComboBox.setItems(FXCollections.observableArrayList(new FiatCurrency("USD"), new FiatCurrency("EUR"))); currencyComboBox.setItems(FXCollections.observableArrayList(new FiatCurrency("USD"), new FiatCurrency("EUR")));
currencyComboBox.getSelectionModel().select(0); currencyComboBox.getSelectionModel().select(0);
addLimitations();
addAccountNameTextFieldWithAutoFillToggleButton();
} }
@Override @Override
protected void autoFillNameTextField() { void setAccountNumber(String newValue) {
setAccountNameWithString(accountNrInputTextField.getText()); perfectMoneyAccount.setAccountNr(newValue);
} }
@Override @Override
public void addFormForDisplayAccount() { String getAccountNr() {
addFormForAccountNumberDisplayAccount(perfectMoneyAccount.getAccountName(), return perfectMoneyAccount.getAccountNr();
perfectMoneyAccount.getPaymentMethod(), perfectMoneyAccount.getAccountNr(),
perfectMoneyAccount.getSingleTradeCurrency());
}
@Override
public void updateAllInputsValid() {
allInputsValid.set(isAccountNameValid()
&& perfectMoneyValidator.validate(perfectMoneyAccount.getAccountNr()).isValid
&& perfectMoneyAccount.getTradeCurrencies().size() > 0);
} }
} }

View file

@ -25,11 +25,7 @@ import bisq.core.util.validation.InputValidator;
import javafx.scene.layout.GridPane; import javafx.scene.layout.GridPane;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class SameBankForm extends BankForm { public class SameBankForm extends BankForm {
private static final Logger log = LoggerFactory.getLogger(SameBankForm.class);
public static int addFormForBuyer(GridPane gridPane, int gridRow, PaymentAccountPayload paymentAccountPayload) { public static int addFormForBuyer(GridPane gridPane, int gridRow, PaymentAccountPayload paymentAccountPayload) {
return BankForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload); return BankForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload);

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

@ -40,8 +40,8 @@ import javafx.scene.layout.GridPane;
import javafx.beans.binding.Bindings; import javafx.beans.binding.Bindings;
import static bisq.desktop.util.FormBuilder.addLabelInputTextFieldButton; import static bisq.desktop.util.FormBuilder.addTopLabelInputTextFieldButton;
import static bisq.desktop.util.FormBuilder.addLabelTextFieldButton; import static bisq.desktop.util.FormBuilder.addTopLabelTextFieldButton;
public class SpecificBankForm extends BankForm { public class SpecificBankForm extends BankForm {
private final SpecificBanksAccountPayload specificBanksAccountPayload; private final SpecificBanksAccountPayload specificBanksAccountPayload;
@ -60,7 +60,7 @@ public class SpecificBankForm extends BankForm {
@Override @Override
protected void addAcceptedBanksForAddAccount() { protected void addAcceptedBanksForAddAccount() {
Tuple3<Label, InputTextField, Button> addBankTuple = addLabelInputTextFieldButton(gridPane, ++gridRow, Tuple3<Label, InputTextField, Button> addBankTuple = addTopLabelInputTextFieldButton(gridPane, ++gridRow,
Res.get("payment.nameOfAcceptedBank"), Res.get("payment.addAcceptedBank")); Res.get("payment.nameOfAcceptedBank"), Res.get("payment.addAcceptedBank"));
InputTextField addBankInputTextField = addBankTuple.second; InputTextField addBankInputTextField = addBankTuple.second;
Button addButton = addBankTuple.third; Button addButton = addBankTuple.third;
@ -68,7 +68,7 @@ public class SpecificBankForm extends BankForm {
addButton.disableProperty().bind(Bindings.createBooleanBinding(() -> addBankInputTextField.getText().isEmpty(), addButton.disableProperty().bind(Bindings.createBooleanBinding(() -> addBankInputTextField.getText().isEmpty(),
addBankInputTextField.textProperty())); addBankInputTextField.textProperty()));
Tuple3<Label, TextField, Button> acceptedBanksTuple = addLabelTextFieldButton(gridPane, ++gridRow, Tuple3<Label, TextField, Button> acceptedBanksTuple = addTopLabelTextFieldButton(gridPane, ++gridRow,
Res.get("payment.accepted.banks"), Res.get("payment.clearAcceptedBanks")); Res.get("payment.accepted.banks"), Res.get("payment.clearAcceptedBanks"));
acceptedBanksTextField = acceptedBanksTuple.second; acceptedBanksTextField = acceptedBanksTuple.second;
acceptedBanksTextField.setMouseTransparent(false); acceptedBanksTextField.setMouseTransparent(false);

View file

@ -32,8 +32,6 @@ import bisq.core.payment.payload.SwishAccountPayload;
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 javafx.scene.control.TextField; import javafx.scene.control.TextField;
import javafx.scene.layout.GridPane; import javafx.scene.layout.GridPane;
@ -94,12 +92,7 @@ public class SwishForm extends PaymentMethodForm {
@Override @Override
protected void autoFillNameTextField() { protected void autoFillNameTextField() {
if (useCustomAccountNameToggleButton != null && !useCustomAccountNameToggleButton.isSelected()) { setAccountNameWithString(mobileNrInputTextField.getText());
String mobileNr = mobileNrInputTextField.getText();
mobileNr = StringUtils.abbreviate(mobileNr, 9);
String method = Res.get(paymentAccount.getPaymentMethod().getId());
accountNameTextField.setText(method.concat(": ").concat(mobileNr));
}
} }
@Override @Override

View file

@ -32,8 +32,6 @@ import bisq.core.payment.payload.USPostalMoneyOrderAccountPayload;
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 javafx.scene.control.TextArea; import javafx.scene.control.TextArea;
import javafx.scene.layout.GridPane; import javafx.scene.layout.GridPane;
@ -98,12 +96,7 @@ public class USPostalMoneyOrderForm extends PaymentMethodForm {
@Override @Override
protected void autoFillNameTextField() { protected void autoFillNameTextField() {
if (useCustomAccountNameToggleButton != null && !useCustomAccountNameToggleButton.isSelected()) { setAccountNameWithString(postalAddressTextArea.getText());
String postalAddress = postalAddressTextArea.getText();
postalAddress = StringUtils.abbreviate(postalAddress, 9);
String method = Res.get(paymentAccount.getPaymentMethod().getId());
accountNameTextField.setText(method.concat(": ").concat(postalAddress));
}
} }
@Override @Override

View file

@ -32,15 +32,10 @@ import bisq.core.payment.payload.UpholdAccountPayload;
import bisq.core.util.BSFormatter; import bisq.core.util.BSFormatter;
import bisq.core.util.validation.InputValidator; import bisq.core.util.validation.InputValidator;
import javafx.scene.control.Label;
import javafx.scene.control.TextField; import javafx.scene.control.TextField;
import javafx.scene.layout.FlowPane; import javafx.scene.layout.FlowPane;
import javafx.scene.layout.GridPane; import javafx.scene.layout.GridPane;
import javafx.geometry.Insets;
import javafx.geometry.VPos;
import static bisq.desktop.util.FormBuilder.addLabel;
import static bisq.desktop.util.FormBuilder.addTopLabelTextField; import static bisq.desktop.util.FormBuilder.addTopLabelTextField;
import static bisq.desktop.util.FormBuilder.addTopLabelTextFieldWithCopyIcon; import static bisq.desktop.util.FormBuilder.addTopLabelTextFieldWithCopyIcon;
@ -81,24 +76,17 @@ public class UpholdForm extends PaymentMethodForm {
} }
private void addCurrenciesGrid(boolean isEditable) { private void addCurrenciesGrid(boolean isEditable) {
Label label = addLabel(gridPane, ++gridRow, Res.get("payment.supportedCurrencies"), 0);
GridPane.setValignment(label, VPos.TOP); FlowPane flowPane = FormBuilder.addTopLabelFlowPane(gridPane, ++gridRow,
FlowPane flowPane = new FlowPane(); Res.get("payment.supportedCurrencies"), 0).second;
flowPane.setPadding(new Insets(10, 10, 10, 10));
flowPane.setVgap(10);
flowPane.setHgap(10);
if (isEditable) if (isEditable)
flowPane.setId("flow-pane-checkboxes-bg"); flowPane.setId("flow-pane-checkboxes-bg");
else else
flowPane.setId("flow-pane-checkboxes-non-editable-bg"); flowPane.setId("flow-pane-checkboxes-non-editable-bg");
CurrencyUtil.getAllUpholdCurrencies().stream().forEach(e -> CurrencyUtil.getAllUpholdCurrencies().forEach(e ->
fillUpFlowPaneWithCurrencies(isEditable, flowPane, e, upholdAccount)); fillUpFlowPaneWithCurrencies(isEditable, flowPane, e, upholdAccount));
GridPane.setRowIndex(flowPane, gridRow);
GridPane.setColumnIndex(flowPane, 1);
gridPane.getChildren().add(flowPane);
} }
@Override @Override

View file

@ -17,13 +17,9 @@
package bisq.desktop.components.paymentmethods; package bisq.desktop.components.paymentmethods;
import bisq.desktop.components.InputTextField;
import bisq.desktop.util.FormBuilder;
import bisq.desktop.util.Layout;
import bisq.desktop.util.validation.WeChatPayValidator; import bisq.desktop.util.validation.WeChatPayValidator;
import bisq.core.locale.Res; import bisq.core.locale.Res;
import bisq.core.locale.TradeCurrency;
import bisq.core.payment.AccountAgeWitnessService; import bisq.core.payment.AccountAgeWitnessService;
import bisq.core.payment.PaymentAccount; import bisq.core.payment.PaymentAccount;
import bisq.core.payment.WeChatPayAccount; import bisq.core.payment.WeChatPayAccount;
@ -32,19 +28,13 @@ import bisq.core.payment.payload.WeChatPayAccountPayload;
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 javafx.scene.control.TextField;
import javafx.scene.layout.GridPane; import javafx.scene.layout.GridPane;
import static bisq.desktop.util.FormBuilder.addTopLabelTextField;
import static bisq.desktop.util.FormBuilder.addTopLabelTextFieldWithCopyIcon; import static bisq.desktop.util.FormBuilder.addTopLabelTextFieldWithCopyIcon;
public class WeChatPayForm extends PaymentMethodForm { public class WeChatPayForm extends GeneralAccountNumberForm {
private final WeChatPayAccount weChatPayAccount; private final WeChatPayAccount weChatPayAccount;
private final WeChatPayValidator weChatPayValidator;
private InputTextField accountNrInputTextField;
public static int addFormForBuyer(GridPane gridPane, int gridRow, PaymentAccountPayload paymentAccountPayload) { public static int addFormForBuyer(GridPane gridPane, int gridRow, PaymentAccountPayload paymentAccountPayload) {
addTopLabelTextFieldWithCopyIcon(gridPane, ++gridRow, Res.get("payment.account.no"), ((WeChatPayAccountPayload) paymentAccountPayload).getAccountNr()); addTopLabelTextFieldWithCopyIcon(gridPane, ++gridRow, Res.get("payment.account.no"), ((WeChatPayAccountPayload) paymentAccountPayload).getAccountNr());
@ -54,54 +44,15 @@ public class WeChatPayForm extends PaymentMethodForm {
public WeChatPayForm(PaymentAccount paymentAccount, AccountAgeWitnessService accountAgeWitnessService, WeChatPayValidator weChatPayValidator, InputValidator inputValidator, GridPane gridPane, int gridRow, BSFormatter formatter) { public WeChatPayForm(PaymentAccount paymentAccount, AccountAgeWitnessService accountAgeWitnessService, WeChatPayValidator weChatPayValidator, InputValidator inputValidator, GridPane gridPane, int gridRow, BSFormatter formatter) {
super(paymentAccount, accountAgeWitnessService, inputValidator, gridPane, gridRow, formatter); super(paymentAccount, accountAgeWitnessService, inputValidator, gridPane, gridRow, formatter);
this.weChatPayAccount = (WeChatPayAccount) paymentAccount; this.weChatPayAccount = (WeChatPayAccount) paymentAccount;
this.weChatPayValidator = weChatPayValidator;
} }
@Override @Override
public void addFormForAddAccount() { void setAccountNumber(String newValue) {
gridRowFrom = gridRow + 1; weChatPayAccount.setAccountNr(newValue);
accountNrInputTextField = FormBuilder.addInputTextField(gridPane, ++gridRow, Res.get("payment.account.no"));
accountNrInputTextField.setValidator(weChatPayValidator);
accountNrInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
weChatPayAccount.setAccountNr(newValue);
updateFromInputs();
});
final TradeCurrency singleTradeCurrency = weChatPayAccount.getSingleTradeCurrency();
final String nameAndCode = singleTradeCurrency != null ? singleTradeCurrency.getNameAndCode() : "";
FormBuilder.addTopLabelTextField(gridPane, ++gridRow, Res.get("shared.currency"), nameAndCode);
addLimitations();
addAccountNameTextFieldWithAutoFillToggleButton();
} }
@Override @Override
protected void autoFillNameTextField() { String getAccountNr() {
if (useCustomAccountNameToggleButton != null && !useCustomAccountNameToggleButton.isSelected()) { return weChatPayAccount.getAccountNr();
String accountNr = accountNrInputTextField.getText();
accountNr = StringUtils.abbreviate(accountNr, 9);
String method = Res.get(paymentAccount.getPaymentMethod().getId());
accountNameTextField.setText(method.concat(": ").concat(accountNr));
}
}
@Override
public void addFormForDisplayAccount() {
gridRowFrom = gridRow;
addTopLabelTextField(gridPane, gridRow, Res.get("payment.account.name"), weChatPayAccount.getAccountName(), Layout.FIRST_ROW_AND_GROUP_DISTANCE);
FormBuilder.addTopLabelTextField(gridPane, ++gridRow, Res.get("shared.paymentMethod"), Res.get(weChatPayAccount.getPaymentMethod().getId()));
TextField field = FormBuilder.addTopLabelTextField(gridPane, ++gridRow, Res.get("payment.account.no"), weChatPayAccount.getAccountNr()).second;
field.setMouseTransparent(false);
final TradeCurrency singleTradeCurrency = weChatPayAccount.getSingleTradeCurrency();
final String nameAndCode = singleTradeCurrency != null ? singleTradeCurrency.getNameAndCode() : "";
FormBuilder.addTopLabelTextField(gridPane, ++gridRow, Res.get("shared.currency"), nameAndCode);
addLimitations();
}
@Override
public void updateAllInputsValid() {
allInputsValid.set(isAccountNameValid()
&& weChatPayValidator.validate(weChatPayAccount.getAccountNr()).isValid
&& weChatPayAccount.getTradeCurrencies().size() > 0);
} }
} }

View file

@ -67,7 +67,9 @@ public class WesternUnionForm extends PaymentMethodForm {
} }
private final WesternUnionAccountPayload westernUnionAccountPayload; private final WesternUnionAccountPayload westernUnionAccountPayload;
private InputTextField holderNameInputTextField, emailInputTextField, cityInputTextField, stateInputTextField; private InputTextField holderNameInputTextField;
private InputTextField cityInputTextField;
private InputTextField stateInputTextField;
private final EmailValidator emailValidator; private final EmailValidator emailValidator;
private Country selectedCountry; private Country selectedCountry;
@ -82,7 +84,6 @@ public class WesternUnionForm extends PaymentMethodForm {
@Override @Override
public void addFormForDisplayAccount() { public void addFormForDisplayAccount() {
gridRowFrom = gridRow; gridRowFrom = gridRow;
String countryCode = westernUnionAccountPayload.getCountryCode();
FormBuilder.addTopLabelTextField(gridPane, gridRow, Res.get("payment.account.name"), paymentAccount.getAccountName(), Layout.FIRST_ROW_AND_GROUP_DISTANCE); FormBuilder.addTopLabelTextField(gridPane, gridRow, Res.get("payment.account.name"), paymentAccount.getAccountName(), Layout.FIRST_ROW_AND_GROUP_DISTANCE);
FormBuilder.addTopLabelTextField(gridPane, ++gridRow, Res.get("shared.paymentMethod"), FormBuilder.addTopLabelTextField(gridPane, ++gridRow, Res.get("shared.paymentMethod"),
@ -157,7 +158,7 @@ public class WesternUnionForm extends PaymentMethodForm {
}); });
applyIsStateRequired(); applyIsStateRequired();
emailInputTextField = FormBuilder.addInputTextField(gridPane, ++gridRow, Res.get("payment.email")); InputTextField emailInputTextField = FormBuilder.addInputTextField(gridPane, ++gridRow, Res.get("payment.email"));
emailInputTextField.textProperty().addListener((ov, oldValue, newValue) -> { emailInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
westernUnionAccountPayload.setEmail(newValue); westernUnionAccountPayload.setEmail(newValue);
updateFromInputs(); updateFromInputs();

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);
@ -469,9 +469,7 @@ public class FormBuilder {
// Label + InputTextField + Button // Label + InputTextField + Button
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
public static Tuple3<Label, InputTextField, Button> addLabelInputTextFieldButton(GridPane gridPane, int rowIndex, String title, String buttonTitle) { public static Tuple3<Label, InputTextField, Button> addTopLabelInputTextFieldButton(GridPane gridPane, int rowIndex, String title, String buttonTitle) {
Label label = addLabel(gridPane, rowIndex, title, 0);
InputTextField inputTextField = new InputTextField(); InputTextField inputTextField = new InputTextField();
Button button = new AutoTooltipButton(buttonTitle); Button button = new AutoTooltipButton(buttonTitle);
button.setDefaultButton(true); button.setDefaultButton(true);
@ -480,11 +478,10 @@ public class FormBuilder {
hBox.setSpacing(10); hBox.setSpacing(10);
hBox.getChildren().addAll(inputTextField, button); hBox.getChildren().addAll(inputTextField, button);
HBox.setHgrow(inputTextField, Priority.ALWAYS); HBox.setHgrow(inputTextField, Priority.ALWAYS);
GridPane.setRowIndex(hBox, rowIndex);
GridPane.setColumnIndex(hBox, 1);
gridPane.getChildren().add(hBox);
return new Tuple3<>(label, inputTextField, button); final Tuple2<Label, VBox> labelVBoxTuple2 = addTopLabelWithVBox(gridPane, rowIndex, title, hBox, 0);
return new Tuple3<>(labelVBoxTuple2.first, inputTextField, button);
} }
@ -492,12 +489,11 @@ public class FormBuilder {
// Label + TextField + Button // Label + TextField + Button
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
public static Tuple3<Label, TextField, Button> addLabelTextFieldButton(GridPane gridPane, int rowIndex, String title, String buttonTitle) { public static Tuple3<Label, TextField, Button> addTopLabelTextFieldButton(GridPane gridPane, int rowIndex, String title, String buttonTitle) {
return addLabelTextFieldButton(gridPane, rowIndex, title, buttonTitle, 0); return addTopLabelTextFieldButton(gridPane, rowIndex, title, buttonTitle, 0);
} }
public static Tuple3<Label, TextField, Button> addLabelTextFieldButton(GridPane gridPane, int rowIndex, String title, String buttonTitle, double top) { public static Tuple3<Label, TextField, Button> addTopLabelTextFieldButton(GridPane gridPane, int rowIndex, String title, String buttonTitle, double top) {
Label label = addLabel(gridPane, rowIndex, title, top);
TextField textField = new JFXTextField(); TextField textField = new JFXTextField();
textField.setEditable(false); textField.setEditable(false);
@ -510,12 +506,10 @@ public class FormBuilder {
hBox.setSpacing(10); hBox.setSpacing(10);
hBox.getChildren().addAll(textField, button); hBox.getChildren().addAll(textField, button);
HBox.setHgrow(textField, Priority.ALWAYS); HBox.setHgrow(textField, Priority.ALWAYS);
GridPane.setRowIndex(hBox, rowIndex);
GridPane.setColumnIndex(hBox, 1);
GridPane.setMargin(hBox, new Insets(top, 0, 0, 0));
gridPane.getChildren().add(hBox);
return new Tuple3<>(label, textField, button); final Tuple2<Label, VBox> labelVBoxTuple2 = addTopLabelWithVBox(gridPane, rowIndex, title, hBox, 0);
return new Tuple3<>(labelVBoxTuple2.first, textField, button);
} }
@ -652,7 +646,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,7 +751,7 @@ 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);
@ -837,7 +831,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 +945,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 +1060,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 +1077,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 +1334,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 +1347,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);
} }