use of bisq.desktop.components.paymentmethods.PaymentMethodForm in project bisq-desktop by bisq-network.
the class FiatAccountsView method addNewAccount.
// Add new account form
private void addNewAccount() {
paymentAccountsListView.getSelectionModel().clearSelection();
removeAccountRows();
addAccountButton.setDisable(true);
accountTitledGroupBg = addTitledGroupBg(root, ++gridRow, 1, Res.get("shared.createNewAccount"), Layout.GROUP_DISTANCE);
// noinspection unchecked
paymentMethodComboBox = addLabelComboBox(root, gridRow, Res.getWithCol("shared.paymentMethod"), Layout.FIRST_ROW_AND_GROUP_DISTANCE).second;
paymentMethodComboBox.setPromptText(Res.get("shared.selectPaymentMethod"));
paymentMethodComboBox.setVisibleRowCount(11);
paymentMethodComboBox.setPrefWidth(250);
List<PaymentMethod> list = PaymentMethod.getAllValues().stream().filter(paymentMethod -> !paymentMethod.getId().equals(PaymentMethod.BLOCK_CHAINS_ID)).collect(Collectors.toList());
paymentMethodComboBox.setItems(FXCollections.observableArrayList(list));
paymentMethodComboBox.setConverter(new StringConverter<PaymentMethod>() {
@Override
public String toString(PaymentMethod paymentMethod) {
return paymentMethod != null ? Res.get(paymentMethod.getId()) : "";
}
@Override
public PaymentMethod fromString(String s) {
return null;
}
});
paymentMethodComboBox.setOnAction(e -> {
if (paymentMethodForm != null) {
FormBuilder.removeRowsFromGridPane(root, 3, paymentMethodForm.getGridRow() + 1);
GridPane.setRowSpan(accountTitledGroupBg, paymentMethodForm.getRowSpan() + 1);
}
gridRow = 2;
paymentMethodForm = getPaymentMethodForm(paymentMethodComboBox.getSelectionModel().getSelectedItem());
if (paymentMethodForm != null) {
paymentMethodForm.addFormForAddAccount();
gridRow = paymentMethodForm.getGridRow();
Tuple2<Button, Button> tuple2 = add2ButtonsAfterGroup(root, ++gridRow, Res.get("shared.saveNewAccount"), Res.get("shared.cancel"));
saveNewAccountButton = tuple2.first;
saveNewAccountButton.setOnAction(event -> onSaveNewAccount(paymentMethodForm.getPaymentAccount()));
saveNewAccountButton.disableProperty().bind(paymentMethodForm.allInputsValidProperty().not());
Button cancelButton = tuple2.second;
cancelButton.setOnAction(event -> onCancelNewAccount());
GridPane.setRowSpan(accountTitledGroupBg, paymentMethodForm.getRowSpan() + 1);
}
});
}
Aggregations