mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-04-22 08:29:16 -04:00
Use separate view for altcoin accounts
This commit is contained in:
parent
70e166e99b
commit
4f7becf018
@ -112,7 +112,7 @@ public class BlockChainForm extends PaymentMethodForm {
|
||||
|
||||
@Override
|
||||
protected void addTradeCurrencyComboBox() {
|
||||
currencyComboBox = addLabelComboBox(gridPane, ++gridRow, "Crypto currency:").second;
|
||||
currencyComboBox = addLabelComboBox(gridPane, ++gridRow, "Crypto currency:", Layout.FIRST_ROW_AND_GROUP_DISTANCE).second;
|
||||
currencyComboBox.setPromptText("Select cryptocurrency");
|
||||
currencyComboBox.setItems(FXCollections.observableArrayList(CurrencyUtil.getSortedCryptoCurrencies()));
|
||||
currencyComboBox.setVisibleRowCount(Math.min(currencyComboBox.getItems().size(), 20));
|
||||
|
@ -0,0 +1,79 @@
|
||||
/*
|
||||
* 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.main.account.content.altcoinsaccount;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import io.bitsquare.gui.common.model.ActivatableDataModel;
|
||||
import io.bitsquare.payment.PaymentAccount;
|
||||
import io.bitsquare.payment.PaymentMethod;
|
||||
import io.bitsquare.user.User;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.collections.SetChangeListener;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
class AltCoinsAccountDataModel extends ActivatableDataModel {
|
||||
|
||||
private final User user;
|
||||
final ObservableList<PaymentAccount> paymentAccounts = FXCollections.observableArrayList();
|
||||
private final SetChangeListener<PaymentAccount> setChangeListener;
|
||||
|
||||
@Inject
|
||||
public AltCoinsAccountDataModel(User user) {
|
||||
this.user = user;
|
||||
setChangeListener = change -> fillAndSortPaymentAccounts();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void activate() {
|
||||
user.getPaymentAccountsAsObservable().addListener(setChangeListener);
|
||||
fillAndSortPaymentAccounts();
|
||||
}
|
||||
|
||||
private void fillAndSortPaymentAccounts() {
|
||||
paymentAccounts.setAll(user.getPaymentAccounts().stream()
|
||||
.filter(paymentAccount -> paymentAccount.getPaymentMethod().getId().equals(PaymentMethod.BLOCK_CHAINS_ID))
|
||||
.collect(Collectors.toList()));
|
||||
paymentAccounts.sort((o1, o2) -> o1.getCreationDate().compareTo(o2.getCreationDate()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void deactivate() {
|
||||
user.getPaymentAccountsAsObservable().removeListener(setChangeListener);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// UI actions
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void onSaveNewAccount(PaymentAccount paymentAccount) {
|
||||
user.addPaymentAccount(paymentAccount);
|
||||
}
|
||||
|
||||
public void onDeleteAccount(PaymentAccount paymentAccount) {
|
||||
user.removePaymentAccount(paymentAccount);
|
||||
}
|
||||
|
||||
public void onSelectAccount(PaymentAccount paymentAccount) {
|
||||
user.setCurrentPaymentAccount(paymentAccount);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
~ 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/>.
|
||||
-->
|
||||
|
||||
|
||||
<?import javafx.scene.layout.*?>
|
||||
<GridPane fx:id="root" fx:controller="io.bitsquare.gui.main.account.content.altcoinsaccount.AltCoinsAccountView"
|
||||
hgap="5.0" vgap="5.0"
|
||||
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
|
||||
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="-10.0"
|
||||
xmlns:fx="http://javafx.com/fxml">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints hgrow="SOMETIMES" halignment="RIGHT" minWidth="160.0"/>
|
||||
<ColumnConstraints hgrow="ALWAYS" minWidth="300.0"/>
|
||||
</columnConstraints>
|
||||
</GridPane>
|
@ -0,0 +1,270 @@
|
||||
/*
|
||||
* 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.main.account.content.altcoinsaccount;
|
||||
|
||||
import io.bitsquare.common.util.Tuple2;
|
||||
import io.bitsquare.gui.common.view.ActivatableViewAndModel;
|
||||
import io.bitsquare.gui.common.view.FxmlView;
|
||||
import io.bitsquare.gui.components.TitledGroupBg;
|
||||
import io.bitsquare.gui.components.paymentmethods.BlockChainForm;
|
||||
import io.bitsquare.gui.components.paymentmethods.PaymentMethodForm;
|
||||
import io.bitsquare.gui.main.popups.Popup;
|
||||
import io.bitsquare.gui.util.FormBuilder;
|
||||
import io.bitsquare.gui.util.ImageUtil;
|
||||
import io.bitsquare.gui.util.Layout;
|
||||
import io.bitsquare.gui.util.validation.*;
|
||||
import io.bitsquare.payment.PaymentAccount;
|
||||
import io.bitsquare.payment.PaymentAccountFactory;
|
||||
import io.bitsquare.payment.PaymentMethod;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.geometry.VPos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.ListCell;
|
||||
import javafx.scene.control.ListView;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.layout.GridPane;
|
||||
import javafx.util.Callback;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static io.bitsquare.gui.util.FormBuilder.*;
|
||||
|
||||
@FxmlView
|
||||
public class AltCoinsAccountView extends ActivatableViewAndModel<GridPane, AltCoinsAccountViewModel> {
|
||||
|
||||
private ListView<PaymentAccount> paymentAccountsListView;
|
||||
|
||||
private final IBANValidator ibanValidator;
|
||||
private final BICValidator bicValidator;
|
||||
private final InputValidator inputValidator;
|
||||
private final OKPayValidator okPayValidator;
|
||||
private final AliPayValidator aliPayValidator;
|
||||
private final PerfectMoneyValidator perfectMoneyValidator;
|
||||
private final SwishValidator swishValidator;
|
||||
private final AltCoinAddressValidator altCoinAddressValidator;
|
||||
|
||||
private PaymentMethodForm paymentMethodForm;
|
||||
private TitledGroupBg accountTitledGroupBg;
|
||||
private Button addAccountButton;
|
||||
private Button saveNewAccountButton;
|
||||
private int gridRow = 0;
|
||||
private ChangeListener<PaymentAccount> paymentAccountChangeListener;
|
||||
|
||||
@Inject
|
||||
public AltCoinsAccountView(AltCoinsAccountViewModel model,
|
||||
IBANValidator ibanValidator,
|
||||
BICValidator bicValidator,
|
||||
InputValidator inputValidator,
|
||||
OKPayValidator okPayValidator,
|
||||
AliPayValidator aliPayValidator,
|
||||
PerfectMoneyValidator perfectMoneyValidator,
|
||||
SwishValidator swishValidator,
|
||||
AltCoinAddressValidator altCoinAddressValidator) {
|
||||
super(model);
|
||||
|
||||
this.ibanValidator = ibanValidator;
|
||||
this.bicValidator = bicValidator;
|
||||
this.inputValidator = inputValidator;
|
||||
this.okPayValidator = okPayValidator;
|
||||
this.aliPayValidator = aliPayValidator;
|
||||
this.perfectMoneyValidator = perfectMoneyValidator;
|
||||
this.swishValidator = swishValidator;
|
||||
this.altCoinAddressValidator = altCoinAddressValidator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
buildForm();
|
||||
paymentAccountChangeListener = (observable, oldValue, newValue) -> {
|
||||
if (newValue != null)
|
||||
onSelectAccount(newValue);
|
||||
};
|
||||
Label placeholder = new Label("There are no altcoin accounts set up yet");
|
||||
placeholder.setWrapText(true);
|
||||
paymentAccountsListView.setPlaceholder(placeholder);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void activate() {
|
||||
paymentAccountsListView.setItems(model.getPaymentAccounts());
|
||||
paymentAccountsListView.getSelectionModel().selectedItemProperty().addListener(paymentAccountChangeListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void deactivate() {
|
||||
paymentAccountsListView.getSelectionModel().selectedItemProperty().removeListener(paymentAccountChangeListener);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// UI actions
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private void onSaveNewAccount(PaymentAccount paymentAccount) {
|
||||
if (!model.getPaymentAccounts().stream().filter(e -> {
|
||||
if (e.getAccountName() != null)
|
||||
return e.getAccountName().equals(paymentAccount.getAccountName());
|
||||
else
|
||||
return false;
|
||||
}).findAny().isPresent()) {
|
||||
model.onSaveNewAccount(paymentAccount);
|
||||
removeNewAccountForm();
|
||||
} else {
|
||||
new Popup().error("That account name is already used in a saved account. \nPlease use another name.").show();
|
||||
}
|
||||
}
|
||||
|
||||
private void onCancelNewAccount() {
|
||||
removeNewAccountForm();
|
||||
}
|
||||
|
||||
private void onDeleteAccount(PaymentAccount paymentAccount) {
|
||||
new Popup().warning("Do you really want to delete the selected altcoin account?")
|
||||
.onAction(() -> {
|
||||
model.onDeleteAccount(paymentAccount);
|
||||
removeSelectAccountForm();
|
||||
})
|
||||
.show();
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Base form
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private void buildForm() {
|
||||
addTitledGroupBg(root, gridRow, 1, "Manage altcoin accounts");
|
||||
|
||||
Tuple2<Label, ListView> tuple = addLabelListView(root, gridRow, "Your altcoin accounts:", Layout.FIRST_ROW_DISTANCE);
|
||||
GridPane.setValignment(tuple.first, VPos.TOP);
|
||||
paymentAccountsListView = tuple.second;
|
||||
paymentAccountsListView.setPrefHeight(2 * Layout.LIST_ROW_HEIGHT + 14);
|
||||
paymentAccountsListView.setCellFactory(new Callback<ListView<PaymentAccount>, ListCell<PaymentAccount>>() {
|
||||
@Override
|
||||
public ListCell<PaymentAccount> call(ListView<PaymentAccount> list) {
|
||||
return new ListCell<PaymentAccount>() {
|
||||
final Label label = new Label();
|
||||
final ImageView icon = ImageUtil.getImageViewById(ImageUtil.REMOVE_ICON);
|
||||
final Button removeButton = new Button("", icon);
|
||||
final AnchorPane pane = new AnchorPane(label, removeButton);
|
||||
|
||||
{
|
||||
label.setLayoutY(5);
|
||||
removeButton.setId("icon-button");
|
||||
AnchorPane.setRightAnchor(removeButton, 0d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateItem(final PaymentAccount item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (item != null && !empty) {
|
||||
label.setText(item.getAccountName());
|
||||
removeButton.setOnAction(e -> onDeleteAccount(item));
|
||||
setGraphic(pane);
|
||||
} else {
|
||||
setGraphic(null);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
addAccountButton = addButtonAfterGroup(root, ++gridRow, "Add new account");
|
||||
addAccountButton.setOnAction(event -> addNewAccount());
|
||||
}
|
||||
|
||||
// Add new account form
|
||||
private void addNewAccount() {
|
||||
paymentAccountsListView.getSelectionModel().clearSelection();
|
||||
removeAccountRows();
|
||||
addAccountButton.setDisable(true);
|
||||
accountTitledGroupBg = addTitledGroupBg(root, ++gridRow, 1, "Create new account", Layout.GROUP_DISTANCE);
|
||||
|
||||
if (paymentMethodForm != null) {
|
||||
FormBuilder.removeRowsFromGridPane(root, 3, paymentMethodForm.getGridRow() + 1);
|
||||
GridPane.setRowSpan(accountTitledGroupBg, paymentMethodForm.getRowSpan() + 1);
|
||||
}
|
||||
gridRow = 2;
|
||||
paymentMethodForm = getPaymentMethodForm(PaymentMethod.BLOCK_CHAINS);
|
||||
if (paymentMethodForm != null) {
|
||||
paymentMethodForm.addFormForAddAccount();
|
||||
gridRow = paymentMethodForm.getGridRow();
|
||||
Tuple2<Button, Button> tuple2 = add2ButtonsAfterGroup(root, ++gridRow, "Save new account", "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);
|
||||
}
|
||||
}
|
||||
|
||||
// Select account form
|
||||
private void onSelectAccount(PaymentAccount paymentAccount) {
|
||||
removeAccountRows();
|
||||
addAccountButton.setDisable(false);
|
||||
accountTitledGroupBg = addTitledGroupBg(root, ++gridRow, 1, "Selected account", Layout.GROUP_DISTANCE);
|
||||
paymentMethodForm = getPaymentMethodForm(paymentAccount);
|
||||
if (paymentMethodForm != null) {
|
||||
paymentMethodForm.addFormForDisplayAccount();
|
||||
gridRow = paymentMethodForm.getGridRow();
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Utils
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private PaymentMethodForm getPaymentMethodForm(PaymentMethod paymentMethod) {
|
||||
return getPaymentMethodForm(PaymentAccountFactory.getPaymentAccount(paymentMethod));
|
||||
}
|
||||
|
||||
private PaymentMethodForm getPaymentMethodForm(PaymentAccount paymentAccount) {
|
||||
return new BlockChainForm(paymentAccount, altCoinAddressValidator, inputValidator, root, gridRow);
|
||||
}
|
||||
|
||||
private void removeNewAccountForm() {
|
||||
saveNewAccountButton.disableProperty().unbind();
|
||||
removeAccountRows();
|
||||
addAccountButton.setDisable(false);
|
||||
}
|
||||
|
||||
private void removeSelectAccountForm() {
|
||||
FormBuilder.removeRowsFromGridPane(root, 2, gridRow);
|
||||
gridRow = 1;
|
||||
addAccountButton.setDisable(false);
|
||||
paymentAccountsListView.getSelectionModel().clearSelection();
|
||||
}
|
||||
|
||||
|
||||
private void removeAccountRows() {
|
||||
FormBuilder.removeRowsFromGridPane(root, 2, gridRow);
|
||||
gridRow = 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,66 @@
|
||||
/*
|
||||
* 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.main.account.content.altcoinsaccount;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import io.bitsquare.gui.common.model.ActivatableWithDataModel;
|
||||
import io.bitsquare.gui.common.model.ViewModel;
|
||||
import io.bitsquare.payment.PaymentAccount;
|
||||
import javafx.collections.ObservableList;
|
||||
|
||||
class AltCoinsAccountViewModel extends ActivatableWithDataModel<AltCoinsAccountDataModel> implements ViewModel {
|
||||
|
||||
|
||||
@Inject
|
||||
public AltCoinsAccountViewModel(AltCoinsAccountDataModel dataModel) {
|
||||
super(dataModel);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void activate() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void deactivate() {
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// UI actions
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void onSaveNewAccount(PaymentAccount paymentAccount) {
|
||||
dataModel.onSaveNewAccount(paymentAccount);
|
||||
}
|
||||
|
||||
public void onDeleteAccount(PaymentAccount paymentAccount) {
|
||||
dataModel.onDeleteAccount(paymentAccount);
|
||||
}
|
||||
|
||||
public void onSelectAccount(PaymentAccount paymentAccount) {
|
||||
dataModel.onSelectAccount(paymentAccount);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Getters
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ObservableList<PaymentAccount> getPaymentAccounts() {
|
||||
return dataModel.paymentAccounts;
|
||||
}
|
||||
}
|
@ -20,11 +20,15 @@ package io.bitsquare.gui.main.account.content.paymentsaccount;
|
||||
import com.google.inject.Inject;
|
||||
import io.bitsquare.gui.common.model.ActivatableDataModel;
|
||||
import io.bitsquare.payment.PaymentAccount;
|
||||
import io.bitsquare.payment.PaymentMethod;
|
||||
import io.bitsquare.user.User;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.collections.SetChangeListener;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
class PaymentAccountDataModel extends ActivatableDataModel {
|
||||
|
||||
private final User user;
|
||||
@ -44,7 +48,10 @@ class PaymentAccountDataModel extends ActivatableDataModel {
|
||||
}
|
||||
|
||||
private void fillAndSortPaymentAccounts() {
|
||||
paymentAccounts.setAll(user.getPaymentAccounts());
|
||||
List<PaymentAccount> list = user.getPaymentAccounts().stream()
|
||||
.filter(paymentAccount -> !paymentAccount.getPaymentMethod().getId().equals(PaymentMethod.BLOCK_CHAINS_ID))
|
||||
.collect(Collectors.toList());
|
||||
paymentAccounts.setAll(list);
|
||||
paymentAccounts.sort((o1, o2) -> o1.getCreationDate().compareTo(o2.getCreationDate()));
|
||||
}
|
||||
|
||||
|
@ -42,6 +42,8 @@ import javafx.util.Callback;
|
||||
import javafx.util.StringConverter;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static io.bitsquare.gui.util.FormBuilder.*;
|
||||
|
||||
@ -149,7 +151,7 @@ public class PaymentAccountView extends ActivatableViewAndModel<GridPane, Paymen
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private void buildForm() {
|
||||
addTitledGroupBg(root, gridRow, 2, "Manage payment accounts");
|
||||
addTitledGroupBg(root, gridRow, 1, "Manage payment accounts");
|
||||
|
||||
Tuple2<Label, ListView> tuple = addLabelListView(root, gridRow, "Your payment accounts:", Layout.FIRST_ROW_DISTANCE);
|
||||
GridPane.setValignment(tuple.first, VPos.TOP);
|
||||
@ -185,7 +187,7 @@ public class PaymentAccountView extends ActivatableViewAndModel<GridPane, Paymen
|
||||
}
|
||||
});
|
||||
|
||||
addAccountButton = addButton(root, ++gridRow, "Add new account");
|
||||
addAccountButton = addButtonAfterGroup(root, ++gridRow, "Add new account");
|
||||
addAccountButton.setOnAction(event -> addNewAccount());
|
||||
}
|
||||
|
||||
@ -198,7 +200,10 @@ public class PaymentAccountView extends ActivatableViewAndModel<GridPane, Paymen
|
||||
paymentMethodsComboBox = addLabelComboBox(root, gridRow, "Payment method:", Layout.FIRST_ROW_AND_GROUP_DISTANCE).second;
|
||||
paymentMethodsComboBox.setPromptText("Select payment method");
|
||||
paymentMethodsComboBox.setPrefWidth(250);
|
||||
paymentMethodsComboBox.setItems(FXCollections.observableArrayList(PaymentMethod.ALL_VALUES));
|
||||
List<PaymentMethod> list = PaymentMethod.ALL_VALUES.stream()
|
||||
.filter(paymentMethod -> !paymentMethod.getId().equals(PaymentMethod.BLOCK_CHAINS_ID))
|
||||
.collect(Collectors.toList());
|
||||
paymentMethodsComboBox.setItems(FXCollections.observableArrayList(list));
|
||||
paymentMethodsComboBox.setConverter(new StringConverter<PaymentMethod>() {
|
||||
@Override
|
||||
public String toString(PaymentMethod paymentMethod) {
|
||||
@ -281,8 +286,6 @@ public class PaymentAccountView extends ActivatableViewAndModel<GridPane, Paymen
|
||||
return new AliPayForm(paymentAccount, aliPayValidator, inputValidator, root, gridRow);
|
||||
case PaymentMethod.SWISH_ID:
|
||||
return new SwishForm(paymentAccount, swishValidator, inputValidator, root, gridRow);
|
||||
case PaymentMethod.BLOCK_CHAINS_ID:
|
||||
return new BlockChainForm(paymentAccount, altCoinAddressValidator, inputValidator, root, gridRow);
|
||||
default:
|
||||
log.error("Not supported PaymentMethod: " + paymentMethod);
|
||||
return null;
|
||||
|
@ -23,6 +23,7 @@ import io.bitsquare.gui.Navigation;
|
||||
import io.bitsquare.gui.common.view.*;
|
||||
import io.bitsquare.gui.main.MainView;
|
||||
import io.bitsquare.gui.main.account.AccountView;
|
||||
import io.bitsquare.gui.main.account.content.altcoinsaccount.AltCoinsAccountView;
|
||||
import io.bitsquare.gui.main.account.content.arbitratorselection.ArbitratorSelectionView;
|
||||
import io.bitsquare.gui.main.account.content.backup.BackupView;
|
||||
import io.bitsquare.gui.main.account.content.password.PasswordView;
|
||||
@ -48,7 +49,7 @@ public class AccountSettingsView extends ActivatableViewAndModel {
|
||||
private final ViewLoader viewLoader;
|
||||
private final Navigation navigation;
|
||||
|
||||
private MenuItem password, seedWords, backup, paymentAccount, arbitratorSelection;
|
||||
private MenuItem paymentAccount, altCoinsAccountView, arbitratorSelection, password, seedWords, backup;
|
||||
private Navigation.Listener listener;
|
||||
|
||||
@FXML
|
||||
@ -74,18 +75,20 @@ public class AccountSettingsView extends ActivatableViewAndModel {
|
||||
};
|
||||
|
||||
ToggleGroup toggleGroup = new ToggleGroup();
|
||||
paymentAccount = new MenuItem(navigation, toggleGroup, "Payments account(s)", PaymentAccountView.class, AwesomeIcon.MONEY);
|
||||
paymentAccount = new MenuItem(navigation, toggleGroup, "Payment account(s)", PaymentAccountView.class, AwesomeIcon.MONEY);
|
||||
altCoinsAccountView = new MenuItem(navigation, toggleGroup, "Altcoin account(s)", AltCoinsAccountView.class, AwesomeIcon.LINK);
|
||||
arbitratorSelection = new MenuItem(navigation, toggleGroup, "Arbitrator selection", ArbitratorSelectionView.class, AwesomeIcon.USER_MD);
|
||||
password = new MenuItem(navigation, toggleGroup, "Wallet password", PasswordView.class, AwesomeIcon.UNLOCK_ALT);
|
||||
seedWords = new MenuItem(navigation, toggleGroup, "Wallet seed", SeedWordsView.class, AwesomeIcon.KEY);
|
||||
backup = new MenuItem(navigation, toggleGroup, "Backup", BackupView.class, AwesomeIcon.CLOUD_DOWNLOAD);
|
||||
|
||||
leftVBox.getChildren().addAll(paymentAccount, arbitratorSelection, password, seedWords, backup);
|
||||
leftVBox.getChildren().addAll(paymentAccount, altCoinsAccountView, arbitratorSelection, password, seedWords, backup);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void activate() {
|
||||
paymentAccount.activate();
|
||||
altCoinsAccountView.activate();
|
||||
arbitratorSelection.activate();
|
||||
password.activate();
|
||||
seedWords.activate();
|
||||
@ -107,6 +110,7 @@ public class AccountSettingsView extends ActivatableViewAndModel {
|
||||
navigation.removeListener(listener);
|
||||
|
||||
paymentAccount.deactivate();
|
||||
altCoinsAccountView.deactivate();
|
||||
arbitratorSelection.deactivate();
|
||||
password.deactivate();
|
||||
seedWords.deactivate();
|
||||
@ -117,17 +121,17 @@ public class AccountSettingsView extends ActivatableViewAndModel {
|
||||
View view = viewLoader.load(viewClass);
|
||||
content.getChildren().setAll(view.getRoot());
|
||||
|
||||
if (view instanceof PasswordView) password.setSelected(true);
|
||||
if (view instanceof PaymentAccountView) paymentAccount.setSelected(true);
|
||||
else if (view instanceof AltCoinsAccountView) altCoinsAccountView.setSelected(true);
|
||||
else if (view instanceof ArbitratorSelectionView) arbitratorSelection.setSelected(true);
|
||||
else if (view instanceof PasswordView) password.setSelected(true);
|
||||
else if (view instanceof SeedWordsView) seedWords.setSelected(true);
|
||||
else if (view instanceof BackupView) backup.setSelected(true);
|
||||
else if (view instanceof PaymentAccountView) paymentAccount.setSelected(true);
|
||||
else if (view instanceof ArbitratorSelectionView) arbitratorSelection.setSelected(true);
|
||||
}
|
||||
|
||||
public Class<? extends View> getSelectedViewClass() {
|
||||
return selectedViewClass;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user