Add support 3 new types of bank accounts

This commit is contained in:
Manfred Karrer 2016-02-29 23:57:31 +01:00
parent b511267340
commit 31fb0fafa4
40 changed files with 1273 additions and 378 deletions

View file

@ -0,0 +1,285 @@
/*
* This file is part of Bitsquare.
*
* Bitsquare is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
*
* Bitsquare is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
* License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
*/
package io.bitsquare.gui.components.paymentmethods;
import io.bitsquare.common.util.Tuple3;
import io.bitsquare.common.util.Tuple4;
import io.bitsquare.gui.components.InputTextField;
import io.bitsquare.gui.util.Layout;
import io.bitsquare.gui.util.validation.InputValidator;
import io.bitsquare.locale.*;
import io.bitsquare.payment.BankAccountContractData;
import io.bitsquare.payment.PaymentAccount;
import io.bitsquare.payment.PaymentAccountContractData;
import javafx.collections.FXCollections;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.GridPane;
import javafx.util.StringConverter;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static io.bitsquare.gui.util.FormBuilder.*;
abstract class BankForm extends PaymentMethodForm {
private static final Logger log = LoggerFactory.getLogger(BankForm.class);
protected final BankAccountContractData bankAccountContractData;
private InputTextField bankNameInputTextField, bankIdInputTextField, branchIdInputTextField, accountNrInputTextField, holderIdInputTextField;
private TextField currencyTextField;
private Label holderIdLabel;
private InputTextField holderNameInputTextField;
static int addFormForBuyer(GridPane gridPane, int gridRow, PaymentAccountContractData paymentAccountContractData) {
BankAccountContractData bankAccountContractData = (BankAccountContractData) paymentAccountContractData;
addLabelTextFieldWithCopyIcon(gridPane, ++gridRow, "Account holder name:", bankAccountContractData.getHolderName());
addLabelTextFieldWithCopyIcon(gridPane, ++gridRow, "Country of bank:", CountryUtil.getNameAndCode(bankAccountContractData.getCountryCode()));
addLabelTextFieldWithCopyIcon(gridPane, ++gridRow, "Bank name:", bankAccountContractData.getBankName());
addLabelTextFieldWithCopyIcon(gridPane, ++gridRow, "Bank number:", bankAccountContractData.getBankId());
addLabelTextFieldWithCopyIcon(gridPane, ++gridRow, "Branch number:", bankAccountContractData.getBranchId());
addLabelTextFieldWithCopyIcon(gridPane, ++gridRow, "Account number:", bankAccountContractData.getAccountNr());
if (bankAccountContractData.getHolderId() != null)
addLabelTextFieldWithCopyIcon(gridPane, ++gridRow, bankAccountContractData.getHolderIdLabel(), bankAccountContractData.getHolderId());
return gridRow;
}
BankForm(PaymentAccount paymentAccount, InputValidator inputValidator,
GridPane gridPane, int gridRow) {
super(paymentAccount, inputValidator, gridPane, gridRow);
this.bankAccountContractData = (BankAccountContractData) paymentAccount.contractData;
}
@Override
public void addFormForAddAccount() {
gridRowFrom = gridRow + 1;
Tuple3<Label, ComboBox, ComboBox> tuple3 = addLabelComboBoxComboBox(gridPane, ++gridRow, "Country:");
currencyTextField = addLabelTextField(gridPane, ++gridRow, "Currency:").second;
currencyTextField.setMouseTransparent(true);
ComboBox<Region> regionComboBox = tuple3.second;
regionComboBox.setPromptText("Select region");
regionComboBox.setConverter(new StringConverter<Region>() {
@Override
public String toString(Region region) {
return region.name;
}
@Override
public Region fromString(String s) {
return null;
}
});
regionComboBox.setItems(FXCollections.observableArrayList(CountryUtil.getAllRegions()));
ComboBox<Country> countryComboBox = tuple3.third;
countryComboBox.setDisable(true);
countryComboBox.setPromptText("Select 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();
paymentAccount.setCountry(selectedItem);
String countryCode = selectedItem.code;
TradeCurrency currency = CurrencyUtil.getCurrencyByCountryCode(countryCode);
paymentAccount.setSingleTradeCurrency(currency);
currencyTextField.setText(currency.getNameAndCode());
if (holderIdInputTextField != null) {
boolean requiresHolderId = BankUtil.requiresHolderId(countryCode);
if (requiresHolderId) {
holderNameInputTextField.minWidthProperty().unbind();
holderNameInputTextField.setMinWidth(300);
} else {
holderNameInputTextField.minWidthProperty().bind(currencyTextField.widthProperty());
}
holderIdLabel.setText(BankUtil.getHolderIdLabel(countryCode));
holderIdLabel.setVisible(requiresHolderId);
holderIdLabel.setManaged(requiresHolderId);
holderIdInputTextField.resetValidation();
holderIdInputTextField.setVisible(requiresHolderId);
holderIdInputTextField.setManaged(requiresHolderId);
if (!requiresHolderId)
holderIdInputTextField.setText("");
}
updateFromInputs();
onCountryChanged();
});
regionComboBox.setOnAction(e -> {
Region selectedItem = regionComboBox.getSelectionModel().getSelectedItem();
countryComboBox.setDisable(false);
countryComboBox.setItems(FXCollections.observableArrayList(CountryUtil.getAllCountriesForRegion(selectedItem)));
});
addAcceptedBanksForAddAccount();
addHolderNameAndId();
bankNameInputTextField = addLabelInputTextField(gridPane, ++gridRow, "Bank name:").second;
bankNameInputTextField.setValidator(inputValidator);
bankNameInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
bankAccountContractData.setBankName(newValue);
updateFromInputs();
});
bankIdInputTextField = addLabelInputTextField(gridPane, ++gridRow, "Bank number:").second;
bankIdInputTextField.setValidator(inputValidator);
bankIdInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
bankAccountContractData.setBankId(newValue);
updateFromInputs();
});
branchIdInputTextField = addLabelInputTextField(gridPane, ++gridRow, "Branch number:").second;
branchIdInputTextField.setValidator(inputValidator);
branchIdInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
bankAccountContractData.setBranchId(newValue);
updateFromInputs();
});
accountNrInputTextField = addLabelInputTextField(gridPane, ++gridRow, "Account number:").second;
accountNrInputTextField.setValidator(inputValidator);
accountNrInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
bankAccountContractData.setAccountNr(newValue);
updateFromInputs();
});
addAllowedPeriod();
addAccountNameTextFieldWithAutoFillCheckBox();
updateFromInputs();
}
protected void onCountryChanged() {
}
protected void addHolderNameAndId() {
Tuple4<Label, InputTextField, Label, InputTextField> tuple = addLabelInputTextFieldLabelInputTextField(gridPane, ++gridRow, "Account holder name:", BankUtil.getHolderIdLabel(""));
holderNameInputTextField = tuple.second;
holderNameInputTextField.setMinWidth(300);
holderNameInputTextField.setValidator(inputValidator);
holderNameInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
bankAccountContractData.setHolderName(newValue);
updateFromInputs();
});
holderNameInputTextField.minWidthProperty().bind(currencyTextField.widthProperty());
holderIdLabel = tuple.third;
holderIdLabel.setVisible(false);
holderIdLabel.setManaged(false);
holderIdInputTextField = tuple.forth;
holderIdInputTextField.setVisible(false);
holderIdInputTextField.setManaged(false);
holderIdInputTextField.setValidator(inputValidator);
holderIdInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
bankAccountContractData.setHolderId(newValue);
updateFromInputs();
});
}
protected void addAcceptedBanksForAddAccount() {
}
@Override
protected void autoFillNameTextField() {
if (useCustomAccountNameCheckBox != null && !useCustomAccountNameCheckBox.isSelected()) {
String bankName = bankNameInputTextField.getText();
if (bankName.length() > 6)
bankName = StringUtils.abbreviate(bankName, 9);
String accountNr = accountNrInputTextField.getText();
if (accountNr.length() > 6)
accountNr = StringUtils.abbreviate(accountNr, 9);
String method = BSResources.get(paymentAccount.getPaymentMethod().getId());
accountNameTextField.setText(method.concat(", ").concat(bankName).concat(", ").concat(accountNr));
}
}
@Override
public void updateAllInputsValid() {
boolean holderIdValid = true;
if (paymentAccount.getCountry() != null) {
if (BankUtil.requiresHolderId(paymentAccount.getCountry().code))
holderIdValid = inputValidator.validate(bankAccountContractData.getHolderId()).isValid;
}
allInputsValid.set(isAccountNameValid()
&& inputValidator.validate(bankAccountContractData.getHolderName()).isValid
&& inputValidator.validate(bankAccountContractData.getBankName()).isValid
&& inputValidator.validate(bankAccountContractData.getBankId()).isValid
&& inputValidator.validate(bankAccountContractData.getBranchId()).isValid
&& inputValidator.validate(bankAccountContractData.getAccountNr()).isValid
&& holderIdValid
&& paymentAccount.getSingleTradeCurrency() != null
&& paymentAccount.getCountry() != null);
}
@Override
public void addFormForDisplayAccount() {
gridRowFrom = gridRow;
addLabelTextField(gridPane, gridRow, "Account name:", paymentAccount.getAccountName(), Layout.FIRST_ROW_AND_GROUP_DISTANCE);
addLabelTextField(gridPane, ++gridRow, "Payment method:", BSResources.get(paymentAccount.getPaymentMethod().getId()));
addLabelTextField(gridPane, ++gridRow, "Country:", paymentAccount.getCountry() != null ? paymentAccount.getCountry().name : "");
addLabelTextField(gridPane, ++gridRow, "Currency:", paymentAccount.getSingleTradeCurrency().getNameAndCode());
addAcceptedBanksForDisplayAccount();
addHolderNameAndIdForDisplayAccount();
addLabelTextField(gridPane, ++gridRow, "Bank name:", bankAccountContractData.getBankName()).second.setMouseTransparent(false);
addLabelTextField(gridPane, ++gridRow, "Bank number:", bankAccountContractData.getBankId()).second.setMouseTransparent(false);
addLabelTextField(gridPane, ++gridRow, "Branch number:", bankAccountContractData.getBranchId()).second.setMouseTransparent(false);
addLabelTextField(gridPane, ++gridRow, "Account number:", bankAccountContractData.getAccountNr()).second.setMouseTransparent(false);
addAllowedPeriod();
}
protected void addHolderNameAndIdForDisplayAccount() {
if (BankUtil.requiresHolderId(bankAccountContractData.getCountryCode())) {
Tuple4<Label, TextField, Label, TextField> tuple = addLabelTextFieldLabelTextField(gridPane, ++gridRow,
"Account holder name:", BankUtil.getHolderIdLabel(bankAccountContractData.getCountryCode()));
TextField holderNameTextField = tuple.second;
holderNameTextField.setText(bankAccountContractData.getHolderName());
holderNameTextField.setMinWidth(300);
tuple.forth.setText(bankAccountContractData.getHolderId());
} else {
addLabelTextField(gridPane, ++gridRow, "Account holder name:", bankAccountContractData.getHolderName());
}
}
public void addAcceptedBanksForDisplayAccount() {
}
}

View file

@ -0,0 +1,39 @@
/*
* This file is part of Bitsquare.
*
* Bitsquare is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
*
* Bitsquare is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
* License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
*/
package io.bitsquare.gui.components.paymentmethods;
import io.bitsquare.gui.util.validation.InputValidator;
import io.bitsquare.payment.PaymentAccount;
import io.bitsquare.payment.PaymentAccountContractData;
import javafx.scene.layout.GridPane;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class NationalBankForm extends BankForm {
private static final Logger log = LoggerFactory.getLogger(NationalBankForm.class);
public static int addFormForBuyer(GridPane gridPane, int gridRow, PaymentAccountContractData paymentAccountContractData) {
BankForm.addFormForBuyer(gridPane, gridRow, paymentAccountContractData);
return gridRow;
}
public NationalBankForm(PaymentAccount paymentAccount, InputValidator inputValidator,
GridPane gridPane, int gridRow) {
super(paymentAccount, inputValidator, gridPane, gridRow);
}
}

View file

@ -82,9 +82,10 @@ public abstract class PaymentMethodForm {
protected void addAccountNameTextFieldWithAutoFillCheckBox() {
Tuple3<Label, InputTextField, CheckBox> tuple = addLabelInputTextFieldCheckBox(gridPane, ++gridRow, "Account name:", "Use custom account name");
accountNameTextField = tuple.second;
accountNameTextField.setPrefWidth(250);
accountNameTextField.setPrefWidth(300);
accountNameTextField.setEditable(false);
accountNameTextField.setValidator(inputValidator);
accountNameTextField.setFocusTraversable(false);
accountNameTextField.textProperty().addListener((ov, oldValue, newValue) -> {
paymentAccount.setAccountName(newValue);
updateAllInputsValid();
@ -92,7 +93,9 @@ public abstract class PaymentMethodForm {
useCustomAccountNameCheckBox = tuple.third;
useCustomAccountNameCheckBox.setSelected(false);
useCustomAccountNameCheckBox.setOnAction(e -> {
accountNameTextField.setEditable(useCustomAccountNameCheckBox.isSelected());
boolean selected = useCustomAccountNameCheckBox.isSelected();
accountNameTextField.setEditable(selected);
accountNameTextField.setFocusTraversable(selected);
autoFillNameTextField();
});
}

View file

@ -0,0 +1,81 @@
/*
* This file is part of Bitsquare.
*
* Bitsquare is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
*
* Bitsquare is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
* License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
*/
package io.bitsquare.gui.components.paymentmethods;
import io.bitsquare.common.util.Tuple2;
import io.bitsquare.gui.components.InputTextField;
import io.bitsquare.gui.util.validation.InputValidator;
import io.bitsquare.payment.PaymentAccount;
import io.bitsquare.payment.PaymentAccountContractData;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.GridPane;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static io.bitsquare.gui.util.FormBuilder.addLabelInputTextField;
import static io.bitsquare.gui.util.FormBuilder.addLabelTextField;
public class SameBankForm extends BankForm {
private static final Logger log = LoggerFactory.getLogger(SameBankForm.class);
public static int addFormForBuyer(GridPane gridPane, int gridRow, PaymentAccountContractData paymentAccountContractData) {
BankForm.addFormForBuyer(gridPane, gridRow, paymentAccountContractData);
return gridRow;
}
public SameBankForm(PaymentAccount paymentAccount, InputValidator inputValidator,
GridPane gridPane, int gridRow) {
super(paymentAccount, inputValidator, gridPane, gridRow);
}
@Override
protected void addHolderNameAndId() {
Tuple2<Label, InputTextField> tuple = addLabelInputTextField(gridPane, ++gridRow, "Account holder name:");
InputTextField holderNameInputTextField = tuple.second;
holderNameInputTextField.setValidator(inputValidator);
holderNameInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
bankAccountContractData.setHolderName(newValue);
updateFromInputs();
});
}
@Override
public void updateAllInputsValid() {
allInputsValid.set(isAccountNameValid()
&& inputValidator.validate(bankAccountContractData.getHolderName()).isValid
&& inputValidator.validate(bankAccountContractData.getBankName()).isValid
&& inputValidator.validate(bankAccountContractData.getBankId()).isValid
&& inputValidator.validate(bankAccountContractData.getBranchId()).isValid
&& inputValidator.validate(bankAccountContractData.getAccountNr()).isValid
&& paymentAccount.getSingleTradeCurrency() != null
&& paymentAccount.getCountry() != null);
}
@Override
protected void addHolderNameAndIdForDisplayAccount() {
Tuple2<Label, TextField> tuple = addLabelTextField(gridPane, ++gridRow, "Account holder name:");
TextField holderNameTextField = tuple.second;
holderNameTextField.setMinWidth(300);
holderNameTextField.textProperty().addListener((ov, oldValue, newValue) -> {
bankAccountContractData.setHolderName(newValue);
updateFromInputs();
});
}
}

View file

@ -251,10 +251,8 @@ public class SepaForm extends PaymentMethodForm {
addLabelTextField(gridPane, gridRow, "Account name:", sepaAccount.getAccountName(), Layout.FIRST_ROW_AND_GROUP_DISTANCE);
addLabelTextField(gridPane, ++gridRow, "Payment method:", BSResources.get(sepaAccount.getPaymentMethod().getId()));
addLabelTextField(gridPane, ++gridRow, "Account holder name:", sepaAccount.getHolderName());
TextField ibanField = addLabelTextField(gridPane, ++gridRow, "IBAN:", sepaAccount.getIban()).second;
ibanField.setMouseTransparent(false);
TextField bicField = addLabelTextField(gridPane, ++gridRow, "BIC/SWIFT:", sepaAccount.getBic()).second;
bicField.setMouseTransparent(false);
addLabelTextField(gridPane, ++gridRow, "IBAN:", sepaAccount.getIban()).second.setMouseTransparent(false);
addLabelTextField(gridPane, ++gridRow, "BIC/SWIFT:", sepaAccount.getBic()).second.setMouseTransparent(false);
addLabelTextField(gridPane, ++gridRow, "Location of Bank:",
sepaAccount.getCountry() != null ? sepaAccount.getCountry().name : "");
addLabelTextField(gridPane, ++gridRow, "Currency:", sepaAccount.getSingleTradeCurrency().getNameAndCode());

View file

@ -0,0 +1,108 @@
/*
* This file is part of Bitsquare.
*
* Bitsquare is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
*
* Bitsquare is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
* License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
*/
package io.bitsquare.gui.components.paymentmethods;
import com.google.common.base.Joiner;
import io.bitsquare.common.util.Tuple3;
import io.bitsquare.gui.components.InputTextField;
import io.bitsquare.gui.util.validation.InputValidator;
import io.bitsquare.payment.PaymentAccount;
import io.bitsquare.payment.PaymentAccountContractData;
import io.bitsquare.payment.SpecificBanksAccountContractData;
import javafx.beans.binding.Bindings;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.control.Tooltip;
import javafx.scene.layout.GridPane;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static io.bitsquare.gui.util.FormBuilder.*;
public class SpecificBankForm extends BankForm {
private static final Logger log = LoggerFactory.getLogger(SpecificBankForm.class);
private final SpecificBanksAccountContractData specificBanksAccountContractData;
private TextField acceptedBanksTextField;
private Tooltip acceptedBanksTooltip;
public static int addFormForBuyer(GridPane gridPane, int gridRow, PaymentAccountContractData paymentAccountContractData) {
BankForm.addFormForBuyer(gridPane, gridRow, paymentAccountContractData);
return gridRow;
}
public SpecificBankForm(PaymentAccount paymentAccount, InputValidator inputValidator,
GridPane gridPane, int gridRow) {
super(paymentAccount, inputValidator, gridPane, gridRow);
this.specificBanksAccountContractData = (SpecificBanksAccountContractData) paymentAccount.contractData;
}
@Override
protected void addAcceptedBanksForAddAccount() {
Tuple3<Label, InputTextField, Button> addBankTuple = addLabelInputTextFieldButton(gridPane, ++gridRow, "Add name of accepted bank:", "Add accepted bank");
InputTextField addBankInputTextField = addBankTuple.second;
addBankInputTextField.setMinWidth(300);
Button addButton = addBankTuple.third;
addButton.disableProperty().bind(Bindings.createBooleanBinding(() -> addBankInputTextField.getText().isEmpty(), addBankInputTextField.textProperty()));
Tuple3<Label, TextField, Button> acceptedBanksTuple = addLabelTextFieldButton(gridPane, ++gridRow, "Accepted banks:", "Clear accepted banks");
acceptedBanksTextField = acceptedBanksTuple.second;
acceptedBanksTextField.setMinWidth(addBankInputTextField.getMinWidth());
acceptedBanksTextField.setMouseTransparent(false);
acceptedBanksTooltip = new Tooltip();
acceptedBanksTextField.setTooltip(acceptedBanksTooltip);
Button clearButton = acceptedBanksTuple.third;
clearButton.disableProperty().bind(Bindings.createBooleanBinding(() -> acceptedBanksTextField.getText().isEmpty(), acceptedBanksTextField.textProperty()));
addButton.setOnAction(e -> {
specificBanksAccountContractData.addAcceptedBank(addBankInputTextField.getText());
addBankInputTextField.setText("");
String value = Joiner.on(", ").join(specificBanksAccountContractData.getAcceptedBanks());
acceptedBanksTextField.setText(value);
acceptedBanksTooltip.setText(value);
updateAllInputsValid();
});
clearButton.setOnAction(e -> resetAcceptedBanks());
}
private void resetAcceptedBanks() {
specificBanksAccountContractData.clearAcceptedBanks();
acceptedBanksTextField.setText("");
acceptedBanksTooltip.setText("");
updateAllInputsValid();
}
@Override
protected void onCountryChanged() {
resetAcceptedBanks();
}
@Override
public void addAcceptedBanksForDisplayAccount() {
addLabelTextField(gridPane, ++gridRow, "Accepted banks:",
Joiner.on(", ").join(specificBanksAccountContractData.getAcceptedBanks())).second.setMouseTransparent(false);
}
@Override
public void updateAllInputsValid() {
super.updateAllInputsValid();
allInputsValid.set(allInputsValid.get() && inputValidator.validate(acceptedBanksTextField.getText()).isValid);
}
}

View file

@ -28,7 +28,9 @@ import io.bitsquare.gui.util.ImageUtil;
import io.bitsquare.gui.util.Layout;
import io.bitsquare.gui.util.validation.*;
import io.bitsquare.locale.BSResources;
import io.bitsquare.payment.*;
import io.bitsquare.payment.PaymentAccount;
import io.bitsquare.payment.PaymentAccountFactory;
import io.bitsquare.payment.PaymentMethod;
import javafx.beans.value.ChangeListener;
import javafx.collections.FXCollections;
import javafx.geometry.VPos;
@ -238,8 +240,11 @@ public class PaymentAccountView extends ActivatableViewAndModel<GridPane, Paymen
if (paymentMethodForm != null) {
paymentMethodForm.addFormForDisplayAccount();
gridRow = paymentMethodForm.getGridRow();
Button deleteAccountButton = addButtonAfterGroup(root, ++gridRow, "Delete account");
Tuple2<Button, Button> tuple = add2ButtonsAfterGroup(root, ++gridRow, "Delete account", "Cancel");
Button deleteAccountButton = tuple.first;
deleteAccountButton.setOnAction(event -> onDeleteAccount(paymentMethodForm.getPaymentAccount()));
Button cancelButton = tuple.second;
cancelButton.setOnAction(event -> removeSelectAccountForm());
GridPane.setRowSpan(accountTitledGroupBg, paymentMethodForm.getRowSpan());
model.onSelectAccount(paymentAccount);
}
@ -255,32 +260,7 @@ public class PaymentAccountView extends ActivatableViewAndModel<GridPane, Paymen
}
private PaymentMethodForm getPaymentMethodForm(PaymentMethod paymentMethod) {
PaymentAccount paymentAccount;
switch (paymentMethod.getId()) {
case PaymentMethod.OK_PAY_ID:
paymentAccount = new OKPayAccount();
break;
case PaymentMethod.PERFECT_MONEY_ID:
paymentAccount = new PerfectMoneyAccount();
break;
case PaymentMethod.SEPA_ID:
paymentAccount = new SepaAccount();
break;
case PaymentMethod.ALI_PAY_ID:
paymentAccount = new AliPayAccount();
break;
case PaymentMethod.SWISH_ID:
paymentAccount = new SwishAccount();
break;
case PaymentMethod.BLOCK_CHAINS_ID:
paymentAccount = new BlockChainAccount();
break;
default:
log.error("Not supported PaymentMethod: " + paymentMethod);
paymentAccount = null;
break;
}
return getPaymentMethodForm(paymentMethod, paymentAccount);
return getPaymentMethodForm(paymentMethod, PaymentAccountFactory.getPaymentAccount(paymentMethod));
}
private PaymentMethodForm getPaymentMethodForm(PaymentMethod paymentMethod, PaymentAccount paymentAccount) {
@ -291,6 +271,12 @@ public class PaymentAccountView extends ActivatableViewAndModel<GridPane, Paymen
return new PerfectMoneyForm(paymentAccount, perfectMoneyValidator, inputValidator, root, gridRow);
case PaymentMethod.SEPA_ID:
return new SepaForm(paymentAccount, ibanValidator, bicValidator, inputValidator, root, gridRow);
case PaymentMethod.NATIONAL_BANK_ID:
return new NationalBankForm(paymentAccount, inputValidator, root, gridRow);
case PaymentMethod.SAME_BANK_ID:
return new SameBankForm(paymentAccount, inputValidator, root, gridRow);
case PaymentMethod.SPECIFIC_BANKS_ID:
return new SpecificBankForm(paymentAccount, inputValidator, root, gridRow);
case PaymentMethod.ALI_PAY_ID:
return new AliPayForm(paymentAccount, aliPayValidator, inputValidator, root, gridRow);
case PaymentMethod.SWISH_ID:
@ -313,6 +299,7 @@ public class PaymentAccountView extends ActivatableViewAndModel<GridPane, Paymen
FormBuilder.removeRowsFromGridPane(root, 2, gridRow);
gridRow = 1;
addAccountButton.setDisable(false);
paymentAccountsListView.getSelectionModel().clearSelection();
}

View file

@ -172,7 +172,6 @@ public class TransactionsView extends ActivatableView<VBox, Void> {
List<TransactionsListItem> listItems = walletService.getWallet().getRecentTransactions(1000, true).stream()
.map(transaction -> {
log.error("tx ID " + transaction.getHashAsString());
Optional<Tradable> tradableOptional = all.stream()
.filter(tradable -> {
String txId = transaction.getHashAsString();
@ -193,19 +192,12 @@ public class TransactionsView extends ActivatableView<VBox, Void> {
tradable.getId().equals(dispute.getTradeId()))
.findAny()
.isPresent();
log.error("isTakeOfferFeeTx " + isTakeOfferFeeTx);
log.error("isOfferFeeTx " + isOfferFeeTx);
log.error("isDepositTx " + isDepositTx);
log.error("isPayoutTx " + isPayoutTx);
log.error("isDisputedPayoutTx " + isDisputedPayoutTx);
return isTakeOfferFeeTx || isOfferFeeTx || isDepositTx || isPayoutTx || isDisputedPayoutTx;
} else
return false;
})
.findAny();
if (tradableOptional.isPresent())
log.error("tradableOptional " + tradableOptional.get().getId());
return new TransactionsListItem(transaction, walletService, tradableOptional, formatter);
})
.collect(Collectors.toList());

View file

@ -103,6 +103,8 @@ public class Popup {
public void hide() {
animateHide(() -> {
if (owner == null)
owner = MainView.getRootContainer();
Scene rootScene = owner.getScene();
if (rootScene != null) {
Window window = rootScene.getWindow();
@ -308,6 +310,8 @@ public class Popup {
}
protected void layout() {
if (owner == null)
owner = MainView.getRootContainer();
Scene rootScene = owner.getScene();
if (rootScene != null) {
Window window = rootScene.getWindow();

View file

@ -138,6 +138,15 @@ public class BuyerStep2View extends TradeStepView {
case PaymentMethod.SEPA_ID:
gridRow = SepaForm.addFormForBuyer(gridPane, gridRow, paymentAccountContractData);
break;
case PaymentMethod.NATIONAL_BANK_ID:
gridRow = NationalBankForm.addFormForBuyer(gridPane, gridRow, paymentAccountContractData);
break;
case PaymentMethod.SAME_BANK_ID:
gridRow = SameBankForm.addFormForBuyer(gridPane, gridRow, paymentAccountContractData);
break;
case PaymentMethod.SPECIFIC_BANKS_ID:
gridRow = SpecificBankForm.addFormForBuyer(gridPane, gridRow, paymentAccountContractData);
break;
case PaymentMethod.SWISH_ID:
gridRow = SwishForm.addFormForBuyer(gridPane, gridRow, paymentAccountContractData);
break;

View file

@ -20,6 +20,7 @@ package io.bitsquare.gui.util;
import de.jensd.fx.fontawesome.AwesomeIcon;
import io.bitsquare.common.util.Tuple2;
import io.bitsquare.common.util.Tuple3;
import io.bitsquare.common.util.Tuple4;
import io.bitsquare.gui.components.*;
import javafx.geometry.HPos;
import javafx.geometry.Insets;
@ -308,6 +309,104 @@ public class FormBuilder {
return new Tuple3<>(label, inputTextField, checkBox);
}
///////////////////////////////////////////////////////////////////////////////////////////
// Label + InputTextField + Button
///////////////////////////////////////////////////////////////////////////////////////////
public static Tuple3<Label, InputTextField, Button> addLabelInputTextFieldButton(GridPane gridPane, int rowIndex, String title, String buttonTitle) {
Label label = addLabel(gridPane, rowIndex, title, 0);
InputTextField inputTextField = new InputTextField();
Button button = new Button(buttonTitle);
HBox hBox = new HBox();
hBox.setSpacing(10);
hBox.getChildren().addAll(inputTextField, button);
GridPane.setRowIndex(hBox, rowIndex);
GridPane.setColumnIndex(hBox, 1);
gridPane.getChildren().add(hBox);
return new Tuple3<>(label, inputTextField, button);
}
///////////////////////////////////////////////////////////////////////////////////////////
// Label + TextField + Button
///////////////////////////////////////////////////////////////////////////////////////////
public static Tuple3<Label, TextField, Button> addLabelTextFieldButton(GridPane gridPane, int rowIndex, String title, String buttonTitle) {
Label label = addLabel(gridPane, rowIndex, title, 0);
TextField textField = new TextField();
textField.setEditable(false);
textField.setMouseTransparent(true);
textField.setFocusTraversable(false);
Button button = new Button(buttonTitle);
HBox hBox = new HBox();
hBox.setSpacing(10);
hBox.getChildren().addAll(textField, button);
GridPane.setRowIndex(hBox, rowIndex);
GridPane.setColumnIndex(hBox, 1);
gridPane.getChildren().add(hBox);
return new Tuple3<>(label, textField, button);
}
///////////////////////////////////////////////////////////////////////////////////////////
// Label + InputTextField + Label + InputTextField
///////////////////////////////////////////////////////////////////////////////////////////
public static Tuple4<Label, InputTextField, Label, InputTextField> addLabelInputTextFieldLabelInputTextField(GridPane gridPane, int rowIndex, String title1, String title2) {
Label label1 = addLabel(gridPane, rowIndex, title1, 0);
InputTextField inputTextField1 = new InputTextField();
Label label2 = new Label(title2);
HBox.setMargin(label2, new Insets(5, 0, 0, 0));
InputTextField inputTextField2 = new InputTextField();
HBox hBox = new HBox();
hBox.setSpacing(10);
hBox.getChildren().addAll(inputTextField1, label2, inputTextField2);
GridPane.setRowIndex(hBox, rowIndex);
GridPane.setColumnIndex(hBox, 1);
gridPane.getChildren().add(hBox);
return new Tuple4<>(label1, inputTextField1, label2, inputTextField2);
}
///////////////////////////////////////////////////////////////////////////////////////////
// Label + TextField + Label + TextField
///////////////////////////////////////////////////////////////////////////////////////////
public static Tuple4<Label, TextField, Label, TextField> addLabelTextFieldLabelTextField(GridPane gridPane, int rowIndex, String title1, String title2) {
Label label1 = addLabel(gridPane, rowIndex, title1, 0);
TextField textField1 = new TextField();
textField1.setEditable(false);
textField1.setMouseTransparent(true);
textField1.setFocusTraversable(false);
Label label2 = new Label(title2);
HBox.setMargin(label2, new Insets(5, 0, 0, 0));
TextField textField2 = new TextField();
textField2.setEditable(false);
textField2.setMouseTransparent(true);
textField2.setFocusTraversable(false);
HBox hBox = new HBox();
hBox.setSpacing(10);
hBox.getChildren().addAll(textField1, label2, textField2);
GridPane.setRowIndex(hBox, rowIndex);
GridPane.setColumnIndex(hBox, 1);
gridPane.getChildren().add(hBox);
return new Tuple4<>(label1, textField1, label2, textField2);
}
///////////////////////////////////////////////////////////////////////////////////////////
// Button + CheckBox
///////////////////////////////////////////////////////////////////////////////////////////

View file

@ -145,9 +145,11 @@ OK_PAY=OKPay
PERFECT_MONEY=Perfect Money
ALI_PAY=AliPay
SEPA=SEPA
NATIONAL_BANK=National Bank transfer
SAME_BANK=Transfer with same Bank
SPECIFIC_BANKS=Transfers with specific banks
FED_WIRE=Fed Wire
SWISH= Swish
TRANSFER_WISE=TransferWise
US_POSTAL_MONEY_ORDER=US Postal money order
BLOCK_CHAINS=Crypto currencies