mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 18:03:12 +01:00
Extract StringConverter for paymentAccountComboBox to GUIUtils. Handle multicurrency accounts.
This commit is contained in:
parent
e6001b17da
commit
6a3206543d
@ -160,20 +160,7 @@ public class CreateOfferView extends ActivatableViewAndModel<AnchorPane, CreateO
|
||||
|
||||
balanceTextField.setFormatter(model.getBtcFormatter());
|
||||
|
||||
paymentAccountsComboBox.setConverter(new StringConverter<PaymentAccount>() {
|
||||
@Override
|
||||
public String toString(PaymentAccount paymentAccount) {
|
||||
TradeCurrency singleTradeCurrency = paymentAccount.getSingleTradeCurrency();
|
||||
String code = singleTradeCurrency != null ? singleTradeCurrency.getCode() : "";
|
||||
return paymentAccount.getAccountName() + " (" + code + ", " +
|
||||
Res.get(paymentAccount.getPaymentMethod().getId()) + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public PaymentAccount fromString(String s) {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
paymentAccountsComboBox.setConverter(GUIUtil.getPaymentAccountsComboBoxStringConverter());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -22,7 +22,6 @@ import de.jensd.fx.fontawesome.AwesomeIcon;
|
||||
import io.bisq.common.UserThread;
|
||||
import io.bisq.common.app.DevEnv;
|
||||
import io.bisq.common.locale.Res;
|
||||
import io.bisq.common.locale.TradeCurrency;
|
||||
import io.bisq.common.util.Tuple2;
|
||||
import io.bisq.common.util.Tuple3;
|
||||
import io.bisq.common.util.Utilities;
|
||||
@ -62,7 +61,6 @@ import javafx.scene.image.ImageView;
|
||||
import javafx.scene.layout.*;
|
||||
import javafx.scene.text.Font;
|
||||
import javafx.stage.Window;
|
||||
import javafx.util.StringConverter;
|
||||
import net.glxn.qrgen.QRCode;
|
||||
import net.glxn.qrgen.image.ImageType;
|
||||
import org.bitcoinj.core.Coin;
|
||||
@ -672,20 +670,7 @@ public class TakeOfferView extends ActivatableViewAndModel<AnchorPane, TakeOffer
|
||||
//noinspection unchecked
|
||||
paymentAccountsComboBox = tuple.second;
|
||||
paymentAccountsComboBox.setPromptText(Res.get("shared.selectTradingAccount"));
|
||||
paymentAccountsComboBox.setConverter(new StringConverter<PaymentAccount>() {
|
||||
@Override
|
||||
public String toString(PaymentAccount paymentAccount) {
|
||||
TradeCurrency singleTradeCurrency = paymentAccount.getSingleTradeCurrency();
|
||||
String code = singleTradeCurrency != null ? singleTradeCurrency.getCode() : "";
|
||||
return paymentAccount.getAccountName() + " (" + code + ", " +
|
||||
Res.get(paymentAccount.getPaymentMethod().getId()) + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public PaymentAccount fromString(String s) {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
paymentAccountsComboBox.setConverter(GUIUtil.getPaymentAccountsComboBoxStringConverter());
|
||||
paymentAccountsComboBox.setVisible(false);
|
||||
paymentAccountsComboBox.setManaged(false);
|
||||
paymentAccountsComboBox.setOnAction(e -> {
|
||||
|
@ -484,4 +484,25 @@ public class GUIUtil {
|
||||
.show();
|
||||
}));
|
||||
}
|
||||
|
||||
public static StringConverter<PaymentAccount> getPaymentAccountsComboBoxStringConverter() {
|
||||
return new StringConverter<PaymentAccount>() {
|
||||
@Override
|
||||
public String toString(PaymentAccount paymentAccount) {
|
||||
if (paymentAccount.hasMultipleCurrencies()) {
|
||||
return paymentAccount.getAccountName() + " (" + Res.get(paymentAccount.getPaymentMethod().getId()) + ")";
|
||||
} else {
|
||||
TradeCurrency singleTradeCurrency = paymentAccount.getSingleTradeCurrency();
|
||||
String prefix = singleTradeCurrency != null ? singleTradeCurrency.getCode() + ", " : "";
|
||||
return paymentAccount.getAccountName() + " (" + prefix +
|
||||
Res.get(paymentAccount.getPaymentMethod().getId()) + ")";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PaymentAccount fromString(String s) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user