Use generics for FormBuilder.ListView

This commit is contained in:
Manfred Karrer 2018-07-25 14:54:40 +02:00
parent f4beb7e911
commit 8d70aad2a1
No known key found for this signature in database
GPG Key ID: 401250966A6B2C46
7 changed files with 18 additions and 17 deletions

View File

@ -64,7 +64,10 @@ import javafx.collections.ListChangeListener;
import javafx.util.Callback;
import javafx.util.StringConverter;
import static bisq.desktop.util.FormBuilder.*;
import static bisq.desktop.util.FormBuilder.addButton;
import static bisq.desktop.util.FormBuilder.addButtonAfterGroup;
import static bisq.desktop.util.FormBuilder.addMultilineLabel;
import static bisq.desktop.util.FormBuilder.addTitledGroupBg;
@FxmlView
public class ArbitratorRegistrationView extends ActivatableViewAndModel<VBox, ArbitratorRegistrationViewModel> {
@ -153,7 +156,7 @@ public class ArbitratorRegistrationView extends ActivatableViewAndModel<VBox, Ar
pubKeyTextField.textProperty().bind(model.registrationPubKeyAsHex);
Tuple2<Label, ListView> tuple = addLabelListView(gridPane, ++gridRow, Res.get("shared.yourLanguage"));
Tuple2<Label, ListView<String>> tuple = FormBuilder.addLabelListView(gridPane, ++gridRow, Res.get("shared.yourLanguage"));
GridPane.setValignment(tuple.first, VPos.TOP);
languagesListView = tuple.second;
languagesListView.disableProperty().bind(model.registrationEditDisabled);

View File

@ -66,7 +66,6 @@ import java.util.concurrent.TimeUnit;
import static bisq.desktop.util.FormBuilder.add2ButtonsAfterGroup;
import static bisq.desktop.util.FormBuilder.add3ButtonsAfterGroup;
import static bisq.desktop.util.FormBuilder.addLabelListView;
import static bisq.desktop.util.FormBuilder.addTitledGroupBg;
@FxmlView
@ -213,7 +212,7 @@ public class AltCoinAccountsView extends ActivatableViewAndModel<GridPane, AltCo
private void buildForm() {
addTitledGroupBg(root, gridRow, 1, Res.get("shared.manageAccounts"));
Tuple2<Label, ListView> tuple = addLabelListView(root, gridRow, Res.get("account.altcoin.yourAltcoinAccounts"), Layout.FIRST_ROW_DISTANCE);
Tuple2<Label, ListView<PaymentAccount>> tuple = FormBuilder.addLabelListView(root, gridRow, Res.get("account.altcoin.yourAltcoinAccounts"), Layout.FIRST_ROW_DISTANCE);
GridPane.setValignment(tuple.first, VPos.TOP);
paymentAccountsListView = tuple.second;
paymentAccountsListView.setPrefHeight(2 * Layout.LIST_ROW_HEIGHT + 14);

View File

@ -66,7 +66,6 @@ import javafx.util.Callback;
import javafx.util.StringConverter;
import static bisq.desktop.util.FormBuilder.addCheckBox;
import static bisq.desktop.util.FormBuilder.addLabelListView;
import static bisq.desktop.util.FormBuilder.addTitledGroupBg;
@FxmlView
@ -157,7 +156,7 @@ public class ArbitratorSelectionView extends ActivatableViewAndModel<GridPane, A
private void addLanguageGroup() {
addTitledGroupBg(root, gridRow, 1, Res.get("account.arbitratorSelection.whichLanguages"));
Tuple2<Label, ListView> tuple = addLabelListView(root, gridRow, Res.get("shared.yourLanguage"), Layout.FIRST_ROW_DISTANCE);
Tuple2<Label, ListView<String>> tuple = FormBuilder.addLabelListView(root, gridRow, Res.get("shared.yourLanguage"), Layout.FIRST_ROW_DISTANCE);
GridPane.setValignment(tuple.first, VPos.TOP);
languagesListView = tuple.second;
languagesListView.setMinHeight(3 * Layout.LIST_ROW_HEIGHT + 2);

View File

@ -120,7 +120,6 @@ import java.util.stream.Collectors;
import static bisq.desktop.util.FormBuilder.add2ButtonsAfterGroup;
import static bisq.desktop.util.FormBuilder.add3ButtonsAfterGroup;
import static bisq.desktop.util.FormBuilder.addLabelListView;
import static bisq.desktop.util.FormBuilder.addTitledGroupBg;
@FxmlView
@ -326,7 +325,7 @@ public class FiatAccountsView extends ActivatableViewAndModel<GridPane, FiatAcco
private void buildForm() {
addTitledGroupBg(root, gridRow, 1, Res.get("shared.manageAccounts"));
Tuple2<Label, ListView> tuple = addLabelListView(root, gridRow, Res.get("account.fiat.yourFiatAccounts"), Layout.FIRST_ROW_DISTANCE);
Tuple2<Label, ListView<PaymentAccount>> tuple = FormBuilder.addLabelListView(root, gridRow, Res.get("account.fiat.yourFiatAccounts"), Layout.FIRST_ROW_DISTANCE);
GridPane.setValignment(tuple.first, VPos.TOP);
tuple.first.setTextAlignment(TextAlignment.RIGHT);
paymentAccountsListView = tuple.second;

View File

@ -226,18 +226,19 @@ public class OfferDetailsWindow extends Overlay<OfferDetailsWindow> {
final boolean isSepa = paymentMethod.equals(PaymentMethod.SEPA);
final String makerPaymentAccountId = offer.getMakerPaymentAccountId();
final PaymentAccount myPaymentAccount = user.getPaymentAccount(makerPaymentAccountId);
String countryCode = offer.getCountryCode();
if (offer.isMyOffer(keyRing) && makerPaymentAccountId != null && myPaymentAccount != null) {
addLabelTextField(gridPane, ++rowIndex, Res.get("offerDetailsWindow.myTradingAccount"), myPaymentAccount.getAccountName());
} else {
final String method = Res.get(paymentMethod.getId());
String methodWithBankId = method + bankId;
String paymentMethodLabel = Res.get("shared.paymentMethod");
if (isNationalBanks || isSpecificBanks || isSepa) {
if (BankUtil.isBankIdRequired(offer.getCountryCode()))
if (countryCode != null && (isNationalBanks || isSpecificBanks || isSepa)) {
if (BankUtil.isBankIdRequired(countryCode))
addLabelTextField(gridPane, ++rowIndex,
paymentMethodLabel + " " + Res.get("offerDetailsWindow.offererBankId"),
methodWithBankId);
else if (BankUtil.isBankNameRequired(offer.getCountryCode()))
else if (BankUtil.isBankNameRequired(countryCode))
addLabelTextField(gridPane, ++rowIndex,
paymentMethodLabel + " " + Res.get("offerDetailsWindow.offerersBankName"),
methodWithBankId);
@ -293,7 +294,7 @@ public class OfferDetailsWindow extends Overlay<OfferDetailsWindow> {
}
rows = 4;
String paymentMethodCountryCode = offer.getCountryCode();
String paymentMethodCountryCode = countryCode;
if (paymentMethodCountryCode != null)
rows++;
if (offer.getOfferFeePaymentTxId() != null)

View File

@ -320,7 +320,7 @@ public class PreferencesView extends ActivatableViewAndModel<GridPane, Activatab
}
});
Tuple2<Label, ListView> fiatTuple = addLabelListView(root, ++gridRow, Res.get("setting.preferences.displayFiat"));
Tuple2<Label, ListView<FiatCurrency>> fiatTuple = FormBuilder.addLabelListView(root, ++gridRow, Res.get("setting.preferences.displayFiat"));
GridPane.setValignment(fiatTuple.first, VPos.TOP);
fiatCurrenciesListView = fiatTuple.second;
fiatCurrenciesListView.setMinHeight(2 * Layout.LIST_ROW_HEIGHT + 2);
@ -367,7 +367,7 @@ public class PreferencesView extends ActivatableViewAndModel<GridPane, Activatab
}
});
Tuple2<Label, ListView> cryptoCurrenciesTuple = addLabelListView(root, gridRow, Res.get("setting.preferences.displayAltcoins"));
Tuple2<Label, ListView<CryptoCurrency>> cryptoCurrenciesTuple = FormBuilder.addLabelListView(root, gridRow, Res.get("setting.preferences.displayAltcoins"));
GridPane.setValignment(cryptoCurrenciesTuple.first, VPos.TOP);
GridPane.setMargin(cryptoCurrenciesTuple.first, new Insets(0, 0, 0, 20));
cryptoCurrenciesListView = cryptoCurrenciesTuple.second;

View File

@ -1200,14 +1200,14 @@ public class FormBuilder {
// Label + List
///////////////////////////////////////////////////////////////////////////////////////////
public static Tuple2<Label, ListView> addLabelListView(GridPane gridPane, int rowIndex, String title) {
public static <T> Tuple2<Label, ListView<T>> addLabelListView(GridPane gridPane, int rowIndex, String title) {
return addLabelListView(gridPane, rowIndex, title, 0);
}
public static Tuple2<Label, ListView> addLabelListView(GridPane gridPane, int rowIndex, String title, double top) {
public static <T> Tuple2<Label, ListView<T>> addLabelListView(GridPane gridPane, int rowIndex, String title, double top) {
Label label = addLabel(gridPane, rowIndex, title, top);
ListView listView = new ListView();
ListView<T> listView = new ListView<>();
GridPane.setRowIndex(listView, rowIndex);
GridPane.setColumnIndex(listView, 1);
GridPane.setMargin(listView, new Insets(top, 0, 0, 0));