use of io.bitsquare.payment.CashDepositAccountContractData in project bitsquare by bitsquare.
the class CashDepositForm method addFormForBuyer.
public static int addFormForBuyer(GridPane gridPane, int gridRow, PaymentAccountContractData paymentAccountContractData) {
CashDepositAccountContractData data = (CashDepositAccountContractData) paymentAccountContractData;
String countryCode = data.getCountryCode();
String requirements = data.getRequirements();
boolean showRequirements = requirements != null && !requirements.isEmpty();
if (data.getHolderTaxId() != null)
addLabelTextFieldWithCopyIcon(gridPane, ++gridRow, "Account holder name / email / " + BankUtil.getHolderIdLabel(countryCode), data.getHolderName() + " / " + data.getHolderEmail() + " / " + data.getHolderTaxId());
else
addLabelTextFieldWithCopyIcon(gridPane, ++gridRow, "Account holder name / email:", data.getHolderName() + " / " + data.getHolderEmail());
if (!showRequirements)
addLabelTextFieldWithCopyIcon(gridPane, ++gridRow, "Country of bank:", CountryUtil.getNameAndCode(countryCode));
else
requirements += "\nCountry of bank: " + CountryUtil.getNameAndCode(countryCode);
// We don't want to display more than 6 rows to avoid scrolling, so if we get too many fields we combine them horizontally
int nrRows = 0;
if (BankUtil.isBankNameRequired(countryCode))
nrRows++;
if (BankUtil.isBankIdRequired(countryCode))
nrRows++;
if (BankUtil.isBranchIdRequired(countryCode))
nrRows++;
if (BankUtil.isAccountNrRequired(countryCode))
nrRows++;
if (BankUtil.isAccountTypeRequired(countryCode))
nrRows++;
String bankNameLabel = BankUtil.getBankNameLabel(countryCode);
String bankIdLabel = BankUtil.getBankIdLabel(countryCode);
String branchIdLabel = BankUtil.getBranchIdLabel(countryCode);
String accountNrLabel = BankUtil.getAccountNrLabel(countryCode);
String accountTypeLabel = BankUtil.getAccountTypeLabel(countryCode);
boolean accountNrAccountTypeCombined = false;
boolean bankNameBankIdCombined = false;
boolean bankIdBranchIdCombined = false;
boolean bankNameBranchIdCombined = false;
boolean branchIdAccountNrCombined = false;
if (nrRows > 2) {
// Try combine AccountNr + AccountType
accountNrAccountTypeCombined = BankUtil.isAccountNrRequired(countryCode) && BankUtil.isAccountTypeRequired(countryCode);
if (accountNrAccountTypeCombined)
nrRows--;
if (nrRows > 2) {
// Next we try BankName + BankId
bankNameBankIdCombined = BankUtil.isBankNameRequired(countryCode) && BankUtil.isBankIdRequired(countryCode);
if (bankNameBankIdCombined)
nrRows--;
if (nrRows > 2) {
// Next we try BankId + BranchId
bankIdBranchIdCombined = !bankNameBankIdCombined && BankUtil.isBankIdRequired(countryCode) && BankUtil.isBranchIdRequired(countryCode);
if (bankIdBranchIdCombined)
nrRows--;
if (nrRows > 2) {
// Next we try BankId + BranchId
bankNameBranchIdCombined = !bankNameBankIdCombined && !bankIdBranchIdCombined && BankUtil.isBankNameRequired(countryCode) && BankUtil.isBranchIdRequired(countryCode);
if (bankNameBranchIdCombined)
nrRows--;
if (nrRows > 2) {
branchIdAccountNrCombined = !bankNameBranchIdCombined && !bankIdBranchIdCombined && !accountNrAccountTypeCombined && BankUtil.isBranchIdRequired(countryCode) && BankUtil.isAccountNrRequired(countryCode);
if (branchIdAccountNrCombined)
nrRows--;
if (nrRows > 2)
log.warn("We still have too many rows....");
}
}
}
}
}
if (bankNameBankIdCombined) {
addLabelTextFieldWithCopyIcon(gridPane, ++gridRow, bankNameLabel.substring(0, bankNameLabel.length() - 1) + " / " + bankIdLabel.substring(0, bankIdLabel.length() - 1) + ":", data.getBankName() + " / " + data.getBankId());
}
if (bankNameBranchIdCombined) {
addLabelTextFieldWithCopyIcon(gridPane, ++gridRow, bankNameLabel.substring(0, bankNameLabel.length() - 1) + " / " + branchIdLabel.substring(0, branchIdLabel.length() - 1) + ":", data.getBankName() + " / " + data.getBranchId());
}
if (!bankNameBankIdCombined && !bankNameBranchIdCombined && BankUtil.isBankNameRequired(countryCode))
addLabelTextFieldWithCopyIcon(gridPane, ++gridRow, bankNameLabel, data.getBankName());
if (!bankNameBankIdCombined && !bankNameBranchIdCombined && !branchIdAccountNrCombined && bankIdBranchIdCombined) {
addLabelTextFieldWithCopyIcon(gridPane, ++gridRow, bankIdLabel.substring(0, bankIdLabel.length() - 1) + " / " + branchIdLabel.substring(0, branchIdLabel.length() - 1) + ":", data.getBankId() + " / " + data.getBranchId());
}
if (!bankNameBankIdCombined && !bankIdBranchIdCombined && BankUtil.isBankIdRequired(countryCode))
addLabelTextFieldWithCopyIcon(gridPane, ++gridRow, bankIdLabel, data.getBankId());
if (!bankNameBranchIdCombined && !bankIdBranchIdCombined && branchIdAccountNrCombined) {
addLabelTextFieldWithCopyIcon(gridPane, ++gridRow, branchIdLabel.substring(0, branchIdLabel.length() - 1) + " / " + accountNrLabel.substring(0, accountNrLabel.length() - 1) + ":", data.getBranchId() + " / " + data.getAccountNr());
}
if (!bankNameBranchIdCombined && !bankIdBranchIdCombined && !branchIdAccountNrCombined && BankUtil.isBranchIdRequired(countryCode))
addLabelTextFieldWithCopyIcon(gridPane, ++gridRow, branchIdLabel, data.getBranchId());
if (!branchIdAccountNrCombined && accountNrAccountTypeCombined) {
addLabelTextFieldWithCopyIcon(gridPane, ++gridRow, accountNrLabel.substring(0, accountNrLabel.length() - 1) + " / " + accountTypeLabel, data.getAccountNr() + " / " + data.getAccountType());
}
if (!branchIdAccountNrCombined && !accountNrAccountTypeCombined && BankUtil.isAccountNrRequired(countryCode))
addLabelTextFieldWithCopyIcon(gridPane, ++gridRow, accountNrLabel, data.getAccountNr());
if (!accountNrAccountTypeCombined && BankUtil.isAccountTypeRequired(countryCode))
addLabelTextFieldWithCopyIcon(gridPane, ++gridRow, accountTypeLabel, data.getAccountType());
if (showRequirements) {
TextArea textArea = addLabelTextArea(gridPane, ++gridRow, "Extra requirements:", "").second;
textArea.setMinHeight(45);
textArea.setMaxHeight(45);
textArea.setEditable(false);
textArea.setId("text-area-disabled");
textArea.setText(requirements);
}
return gridRow;
}
Aggregations