mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-06-26 15:50:42 -04:00
Add show all currency filter option in offerbook views
This commit is contained in:
parent
485b33acf6
commit
f5a61f9924
9 changed files with 106 additions and 79 deletions
|
@ -41,10 +41,10 @@ public class CurrencyUtil {
|
||||||
set.addAll(getSortedSEPACurrencyCodes());
|
set.addAll(getSortedSEPACurrencyCodes());
|
||||||
|
|
||||||
// PerfectMoney:
|
// PerfectMoney:
|
||||||
set.add(new TradeCurrency("USD"));
|
set.add(new FiatCurrency("USD"));
|
||||||
|
|
||||||
// Alipay:
|
// Alipay:
|
||||||
set.add(new TradeCurrency("CNY"));
|
set.add(new FiatCurrency("CNY"));
|
||||||
|
|
||||||
// OKPay: We want to maintain the order so we don't use a Set but add items if nto already in list
|
// OKPay: We want to maintain the order so we don't use a Set but add items if nto already in list
|
||||||
getAllOKPayCurrencies().stream().forEach(set::add);
|
getAllOKPayCurrencies().stream().forEach(set::add);
|
||||||
|
|
|
@ -109,7 +109,10 @@ public final class PaymentMethod implements Persistable, Comparable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(@NotNull Object other) {
|
public int compareTo(@NotNull Object other) {
|
||||||
return this.id.compareTo(((PaymentMethod) other).id);
|
if (id != null)
|
||||||
|
return this.id.compareTo(((PaymentMethod) other).id);
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -119,24 +122,24 @@ public final class PaymentMethod implements Persistable, Comparable {
|
||||||
|
|
||||||
PaymentMethod that = (PaymentMethod) o;
|
PaymentMethod that = (PaymentMethod) o;
|
||||||
|
|
||||||
if (getLockTime() != that.getLockTime()) return false;
|
if (lockTime != that.lockTime) return false;
|
||||||
if (getMaxTradePeriod() != that.getMaxTradePeriod()) return false;
|
if (maxTradePeriod != that.maxTradePeriod) return false;
|
||||||
return !(getId() != null ? !getId().equals(that.getId()) : that.getId() != null);
|
return !(id != null ? !id.equals(that.id) : that.id != null);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int result = getId() != null ? getId().hashCode() : 0;
|
int result = id != null ? id.hashCode() : 0;
|
||||||
result = 31 * result + (int) (getLockTime() ^ (getLockTime() >>> 32));
|
result = 31 * result + (int) (lockTime ^ (lockTime >>> 32));
|
||||||
result = 31 * result + getMaxTradePeriod();
|
result = 31 * result + maxTradePeriod;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "PaymentMethod{" +
|
return "PaymentMethod{" +
|
||||||
"name='" + id + '\'' +
|
"id='" + id + '\'' +
|
||||||
", lockTime=" + lockTime +
|
", lockTime=" + lockTime +
|
||||||
", waitPeriodForOpenDispute=" + maxTradePeriod +
|
", waitPeriodForOpenDispute=" + maxTradePeriod +
|
||||||
'}';
|
'}';
|
||||||
|
|
|
@ -24,6 +24,7 @@ import io.bitsquare.btc.FeePolicy;
|
||||||
import io.bitsquare.common.persistance.Persistable;
|
import io.bitsquare.common.persistance.Persistable;
|
||||||
import io.bitsquare.locale.CountryUtil;
|
import io.bitsquare.locale.CountryUtil;
|
||||||
import io.bitsquare.locale.CurrencyUtil;
|
import io.bitsquare.locale.CurrencyUtil;
|
||||||
|
import io.bitsquare.locale.FiatCurrency;
|
||||||
import io.bitsquare.locale.TradeCurrency;
|
import io.bitsquare.locale.TradeCurrency;
|
||||||
import io.bitsquare.storage.Storage;
|
import io.bitsquare.storage.Storage;
|
||||||
import javafx.beans.Observable;
|
import javafx.beans.Observable;
|
||||||
|
@ -78,7 +79,7 @@ public final class Preferences implements Persistable {
|
||||||
return defaultLocale;
|
return defaultLocale;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static TradeCurrency defaultTradeCurrency = new TradeCurrency(CurrencyUtil.getCurrencyByCountryCode(CountryUtil.getDefaultCountryCode()).getCurrency().getCurrencyCode());
|
private static TradeCurrency defaultTradeCurrency = new FiatCurrency(CurrencyUtil.getCurrencyByCountryCode(CountryUtil.getDefaultCountryCode()).getCurrency().getCurrencyCode());
|
||||||
|
|
||||||
public static TradeCurrency getDefaultTradeCurrency() {
|
public static TradeCurrency getDefaultTradeCurrency() {
|
||||||
return defaultTradeCurrency;
|
return defaultTradeCurrency;
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
/*
|
|
||||||
* 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.offer.offerbook;
|
|
||||||
|
|
||||||
import io.bitsquare.payment.PaymentMethod;
|
|
||||||
|
|
||||||
public class AllPaymentMethodsEntry extends PaymentMethod {
|
|
||||||
public AllPaymentMethodsEntry() {
|
|
||||||
super("All", 0, 0);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -89,7 +89,10 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
|
||||||
currencyComboBox.setConverter(new StringConverter<TradeCurrency>() {
|
currencyComboBox.setConverter(new StringConverter<TradeCurrency>() {
|
||||||
@Override
|
@Override
|
||||||
public String toString(TradeCurrency tradeCurrency) {
|
public String toString(TradeCurrency tradeCurrency) {
|
||||||
return tradeCurrency.getNameAndCode();
|
if (!tradeCurrency.getCode().equals(OfferBookViewModel.SHOW_ALL_FLAG))
|
||||||
|
return tradeCurrency.getNameAndCode();
|
||||||
|
else
|
||||||
|
return "Show all";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -103,7 +106,8 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
|
||||||
paymentMethodComboBox.setConverter(new StringConverter<PaymentMethod>() {
|
paymentMethodComboBox.setConverter(new StringConverter<PaymentMethod>() {
|
||||||
@Override
|
@Override
|
||||||
public String toString(PaymentMethod paymentMethod) {
|
public String toString(PaymentMethod paymentMethod) {
|
||||||
return BSResources.get(paymentMethod.getId());
|
String id = paymentMethod.getId();
|
||||||
|
return BSResources.get(!id.equals(OfferBookViewModel.SHOW_ALL_FLAG) ? id : "Show all");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -152,7 +156,7 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
|
||||||
@Override
|
@Override
|
||||||
protected void activate() {
|
protected void activate() {
|
||||||
currencyComboBox.setItems(model.getTradeCurrencies());
|
currencyComboBox.setItems(model.getTradeCurrencies());
|
||||||
currencyComboBox.getSelectionModel().select(model.getTradeCurrency());
|
currencyComboBox.getSelectionModel().select(model.getSelectedTradeCurrency());
|
||||||
currencyComboBox.setVisibleRowCount(Math.min(currencyComboBox.getItems().size(), 25));
|
currencyComboBox.setVisibleRowCount(Math.min(currencyComboBox.getItems().size(), 25));
|
||||||
paymentMethodComboBox.setItems(model.getPaymentMethods());
|
paymentMethodComboBox.setItems(model.getPaymentMethods());
|
||||||
paymentMethodComboBox.getSelectionModel().select(0);
|
paymentMethodComboBox.getSelectionModel().select(0);
|
||||||
|
@ -160,8 +164,14 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
|
||||||
currencyComboBox.setOnAction(e -> model.onSetTradeCurrency(currencyComboBox.getSelectionModel().getSelectedItem()));
|
currencyComboBox.setOnAction(e -> model.onSetTradeCurrency(currencyComboBox.getSelectionModel().getSelectedItem()));
|
||||||
paymentMethodComboBox.setOnAction(e -> model.onSetPaymentMethod(paymentMethodComboBox.getSelectionModel().getSelectedItem()));
|
paymentMethodComboBox.setOnAction(e -> model.onSetPaymentMethod(paymentMethodComboBox.getSelectionModel().getSelectedItem()));
|
||||||
createOfferButton.setOnAction(e -> onCreateOffer());
|
createOfferButton.setOnAction(e -> onCreateOffer());
|
||||||
|
|
||||||
priceColumn.textProperty().bind(createStringBinding(
|
priceColumn.textProperty().bind(createStringBinding(
|
||||||
() -> "Price in " + model.tradeCurrencyCode.get() + "/BTC", model.tradeCurrencyCode));
|
() -> !model.showAllTradeCurrenciesProperty.get() ?
|
||||||
|
"Price in " + model.tradeCurrencyCode.get() + "/BTC" :
|
||||||
|
"Price (mixed currencies)",
|
||||||
|
model.tradeCurrencyCode,
|
||||||
|
model.showAllTradeCurrenciesProperty));
|
||||||
|
|
||||||
volumeColumn.textProperty().bind(createStringBinding(
|
volumeColumn.textProperty().bind(createStringBinding(
|
||||||
() -> "Amount in " + model.tradeCurrencyCode.get() + " (Min.)", model.tradeCurrencyCode));
|
() -> "Amount in " + model.tradeCurrencyCode.get() + " (Min.)", model.tradeCurrencyCode));
|
||||||
model.getOfferList().comparatorProperty().bind(tableView.comparatorProperty());
|
model.getOfferList().comparatorProperty().bind(tableView.comparatorProperty());
|
||||||
|
@ -213,7 +223,8 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
|
||||||
showWarning("You don't have setup a payment account yet.",
|
showWarning("You don't have setup a payment account yet.",
|
||||||
"You need to setup your payment account before you can trade.\nDo you want to do this now?", PaymentAccountView.class);
|
"You need to setup your payment account before you can trade.\nDo you want to do this now?", PaymentAccountView.class);
|
||||||
} else if (!model.hasPaymentAccountForCurrency()) {
|
} else if (!model.hasPaymentAccountForCurrency()) {
|
||||||
showWarning("You don't have a payment account with that selected currency.",
|
showWarning("You don't have a payment account for the currency:\n" +
|
||||||
|
model.getSelectedTradeCurrency().getCodeAndName(),
|
||||||
"You need to setup a payment account for the selected currency to be able to trade in that currency.\n" +
|
"You need to setup a payment account for the selected currency to be able to trade in that currency.\n" +
|
||||||
"Do you want to do this now?", PaymentAccountView.class);
|
"Do you want to do this now?", PaymentAccountView.class);
|
||||||
} else if (!model.hasAcceptedArbitrators()) {
|
} else if (!model.hasAcceptedArbitrators()) {
|
||||||
|
@ -222,7 +233,7 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
|
||||||
"Do you want to do this now?", ArbitratorSelectionView.class);
|
"Do you want to do this now?", ArbitratorSelectionView.class);
|
||||||
} else {
|
} else {
|
||||||
createOfferButton.setDisable(true);
|
createOfferButton.setDisable(true);
|
||||||
offerActionHandler.onCreateOffer(model.getTradeCurrency());
|
offerActionHandler.onCreateOffer(model.getSelectedTradeCurrency());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,10 +24,7 @@ import io.bitsquare.common.handlers.ErrorMessageHandler;
|
||||||
import io.bitsquare.common.handlers.ResultHandler;
|
import io.bitsquare.common.handlers.ResultHandler;
|
||||||
import io.bitsquare.gui.common.model.ActivatableViewModel;
|
import io.bitsquare.gui.common.model.ActivatableViewModel;
|
||||||
import io.bitsquare.gui.util.BSFormatter;
|
import io.bitsquare.gui.util.BSFormatter;
|
||||||
import io.bitsquare.locale.BSResources;
|
import io.bitsquare.locale.*;
|
||||||
import io.bitsquare.locale.CountryUtil;
|
|
||||||
import io.bitsquare.locale.CurrencyUtil;
|
|
||||||
import io.bitsquare.locale.TradeCurrency;
|
|
||||||
import io.bitsquare.p2p.NodeAddress;
|
import io.bitsquare.p2p.NodeAddress;
|
||||||
import io.bitsquare.p2p.P2PService;
|
import io.bitsquare.p2p.P2PService;
|
||||||
import io.bitsquare.payment.PaymentMethod;
|
import io.bitsquare.payment.PaymentMethod;
|
||||||
|
@ -36,6 +33,8 @@ import io.bitsquare.trade.offer.Offer;
|
||||||
import io.bitsquare.trade.offer.OpenOfferManager;
|
import io.bitsquare.trade.offer.OpenOfferManager;
|
||||||
import io.bitsquare.user.Preferences;
|
import io.bitsquare.user.Preferences;
|
||||||
import io.bitsquare.user.User;
|
import io.bitsquare.user.User;
|
||||||
|
import javafx.beans.property.BooleanProperty;
|
||||||
|
import javafx.beans.property.SimpleBooleanProperty;
|
||||||
import javafx.beans.property.SimpleStringProperty;
|
import javafx.beans.property.SimpleStringProperty;
|
||||||
import javafx.beans.property.StringProperty;
|
import javafx.beans.property.StringProperty;
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
|
@ -48,6 +47,8 @@ import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
class OfferBookViewModel extends ActivatableViewModel {
|
class OfferBookViewModel extends ActivatableViewModel {
|
||||||
|
final static String SHOW_ALL_FLAG = "XXX";
|
||||||
|
|
||||||
private final OpenOfferManager openOfferManager;
|
private final OpenOfferManager openOfferManager;
|
||||||
private final User user;
|
private final User user;
|
||||||
private final OfferBook offerBook;
|
private final OfferBook offerBook;
|
||||||
|
@ -58,16 +59,24 @@ class OfferBookViewModel extends ActivatableViewModel {
|
||||||
|
|
||||||
private final FilteredList<OfferBookListItem> filteredItems;
|
private final FilteredList<OfferBookListItem> filteredItems;
|
||||||
private final SortedList<OfferBookListItem> sortedItems;
|
private final SortedList<OfferBookListItem> sortedItems;
|
||||||
private TradeCurrency tradeCurrency;
|
private TradeCurrency selectedTradeCurrency;
|
||||||
|
private final ObservableList<TradeCurrency> allTradeCurrencies = FXCollections.observableArrayList();
|
||||||
|
|
||||||
private Offer.Direction direction;
|
private Offer.Direction direction;
|
||||||
|
|
||||||
private final StringProperty btcCode = new SimpleStringProperty();
|
private final StringProperty btcCode = new SimpleStringProperty();
|
||||||
final StringProperty tradeCurrencyCode = new SimpleStringProperty();
|
final StringProperty tradeCurrencyCode = new SimpleStringProperty();
|
||||||
private PaymentMethod paymentMethod = new AllPaymentMethodsEntry();
|
|
||||||
|
// If id is empty string we ignore filter (display all methods)
|
||||||
|
|
||||||
|
private PaymentMethod selectedPaymentMethod = new PaymentMethod(SHOW_ALL_FLAG, 0, 0);
|
||||||
|
|
||||||
private final ObservableList<OfferBookListItem> offerBookListItems;
|
private final ObservableList<OfferBookListItem> offerBookListItems;
|
||||||
private final ListChangeListener<OfferBookListItem> listChangeListener;
|
private final ListChangeListener<OfferBookListItem> listChangeListener;
|
||||||
private boolean isTabSelected;
|
private boolean isTabSelected;
|
||||||
|
final BooleanProperty showAllTradeCurrenciesProperty = new SimpleBooleanProperty();
|
||||||
|
private boolean showAllPaymentMethods = true;
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Constructor, lifecycle
|
// Constructor, lifecycle
|
||||||
|
@ -93,12 +102,21 @@ class OfferBookViewModel extends ActivatableViewModel {
|
||||||
this.filteredItems = new FilteredList<>(offerBookListItems);
|
this.filteredItems = new FilteredList<>(offerBookListItems);
|
||||||
this.sortedItems = new SortedList<>(filteredItems);
|
this.sortedItems = new SortedList<>(filteredItems);
|
||||||
|
|
||||||
tradeCurrency = CurrencyUtil.getDefaultTradeCurrency();
|
selectedTradeCurrency = CurrencyUtil.getDefaultTradeCurrency();
|
||||||
tradeCurrencyCode.set(tradeCurrency.getCode());
|
tradeCurrencyCode.set(selectedTradeCurrency.getCode());
|
||||||
|
|
||||||
|
preferences.getTradeCurrenciesAsObservable().addListener(new ListChangeListener<TradeCurrency>() {
|
||||||
|
@Override
|
||||||
|
public void onChanged(Change<? extends TradeCurrency> c) {
|
||||||
|
fillAllTradeCurrencies();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void activate() {
|
protected void activate() {
|
||||||
|
fillAllTradeCurrencies();
|
||||||
btcCode.bind(preferences.btcDenominationProperty());
|
btcCode.bind(preferences.btcDenominationProperty());
|
||||||
offerBookListItems.addListener(listChangeListener);
|
offerBookListItems.addListener(listChangeListener);
|
||||||
offerBook.fillOfferBookListItems();
|
offerBook.fillOfferBookListItems();
|
||||||
|
@ -113,6 +131,13 @@ class OfferBookViewModel extends ActivatableViewModel {
|
||||||
offerBookListItems.removeListener(listChangeListener);
|
offerBookListItems.removeListener(listChangeListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void fillAllTradeCurrencies() {
|
||||||
|
allTradeCurrencies.clear();
|
||||||
|
// Used for ignoring filter (show all)
|
||||||
|
TradeCurrency dummy = new FiatCurrency(SHOW_ALL_FLAG);
|
||||||
|
allTradeCurrencies.add(dummy);
|
||||||
|
allTradeCurrencies.addAll(preferences.getTradeCurrenciesAsObservable());
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// API
|
// API
|
||||||
|
@ -134,15 +159,22 @@ class OfferBookViewModel extends ActivatableViewModel {
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
public void onSetTradeCurrency(TradeCurrency tradeCurrency) {
|
public void onSetTradeCurrency(TradeCurrency tradeCurrency) {
|
||||||
this.tradeCurrency = tradeCurrency;
|
|
||||||
String code = tradeCurrency.getCode();
|
String code = tradeCurrency.getCode();
|
||||||
tradeCurrencyCode.set(code);
|
showAllTradeCurrenciesProperty.set(isShowAllEntry(code));
|
||||||
marketPriceFeed.setCurrencyCode(code);
|
if (!showAllTradeCurrenciesProperty.get()) {
|
||||||
|
this.selectedTradeCurrency = tradeCurrency;
|
||||||
|
tradeCurrencyCode.set(code);
|
||||||
|
marketPriceFeed.setCurrencyCode(code);
|
||||||
|
}
|
||||||
|
|
||||||
filterList();
|
filterList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onSetPaymentMethod(PaymentMethod paymentMethod) {
|
public void onSetPaymentMethod(PaymentMethod paymentMethod) {
|
||||||
this.paymentMethod = paymentMethod;
|
showAllPaymentMethods = isShowAllEntry(paymentMethod.getId());
|
||||||
|
if (!showAllPaymentMethods)
|
||||||
|
this.selectedPaymentMethod = paymentMethod;
|
||||||
|
|
||||||
filterList();
|
filterList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,20 +200,20 @@ class OfferBookViewModel extends ActivatableViewModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ObservableList<TradeCurrency> getTradeCurrencies() {
|
public ObservableList<TradeCurrency> getTradeCurrencies() {
|
||||||
return preferences.getTradeCurrenciesAsObservable();
|
return allTradeCurrencies;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isBootstrapped() {
|
boolean isBootstrapped() {
|
||||||
return p2PService.isBootstrapped();
|
return p2PService.isBootstrapped();
|
||||||
}
|
}
|
||||||
|
|
||||||
public TradeCurrency getTradeCurrency() {
|
public TradeCurrency getSelectedTradeCurrency() {
|
||||||
return tradeCurrency;
|
return selectedTradeCurrency;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ObservableList<PaymentMethod> getPaymentMethods() {
|
public ObservableList<PaymentMethod> getPaymentMethods() {
|
||||||
ObservableList<PaymentMethod> list = FXCollections.observableArrayList(PaymentMethod.ALL_VALUES);
|
ObservableList<PaymentMethod> list = FXCollections.observableArrayList(PaymentMethod.ALL_VALUES);
|
||||||
list.add(0, paymentMethod);
|
list.add(0, selectedPaymentMethod);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,7 +224,10 @@ class OfferBookViewModel extends ActivatableViewModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
String getPrice(OfferBookListItem item) {
|
String getPrice(OfferBookListItem item) {
|
||||||
return (item != null) ? formatter.formatFiat(item.getOffer().getPrice()) : "";
|
if (showAllTradeCurrenciesProperty.get())
|
||||||
|
return (item != null) ? formatter.formatFiatWithCode(item.getOffer().getPrice()) : "";
|
||||||
|
else
|
||||||
|
return (item != null) ? formatter.formatFiat(item.getOffer().getPrice()) : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
String getVolume(OfferBookListItem item) {
|
String getVolume(OfferBookListItem item) {
|
||||||
|
@ -271,7 +306,7 @@ class OfferBookViewModel extends ActivatableViewModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasPaymentAccountForCurrency() {
|
public boolean hasPaymentAccountForCurrency() {
|
||||||
return user.hasPaymentAccountForCurrency(tradeCurrency);
|
return user.hasPaymentAccountForCurrency(selectedTradeCurrency);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean hasAcceptedArbitrators() {
|
boolean hasAcceptedArbitrators() {
|
||||||
|
@ -286,11 +321,10 @@ class OfferBookViewModel extends ActivatableViewModel {
|
||||||
filteredItems.setPredicate(offerBookListItem -> {
|
filteredItems.setPredicate(offerBookListItem -> {
|
||||||
Offer offer = offerBookListItem.getOffer();
|
Offer offer = offerBookListItem.getOffer();
|
||||||
boolean directionResult = offer.getDirection() != direction;
|
boolean directionResult = offer.getDirection() != direction;
|
||||||
boolean currencyResult = offer.getCurrencyCode().equals(tradeCurrency.getCode());
|
boolean currencyResult = showAllTradeCurrenciesProperty.get() ||
|
||||||
boolean paymentMethodResult = true;
|
offer.getCurrencyCode().equals(selectedTradeCurrency.getCode());
|
||||||
if (!(paymentMethod instanceof AllPaymentMethodsEntry))
|
boolean paymentMethodResult = showAllPaymentMethods ||
|
||||||
paymentMethodResult = offer.getPaymentMethod().equals(paymentMethod);
|
offer.getPaymentMethod().equals(selectedPaymentMethod);
|
||||||
|
|
||||||
return directionResult && currencyResult && paymentMethodResult;
|
return directionResult && currencyResult && paymentMethodResult;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -308,4 +342,8 @@ class OfferBookViewModel extends ActivatableViewModel {
|
||||||
public boolean hasSameProtocolVersion(Offer offer) {
|
public boolean hasSameProtocolVersion(Offer offer) {
|
||||||
return offer.getProtocolVersion() == Version.TRADE_PROTOCOL_VERSION;
|
return offer.getProtocolVersion() == Version.TRADE_PROTOCOL_VERSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isShowAllEntry(String id) {
|
||||||
|
return id.equals(SHOW_ALL_FLAG);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ import io.bitsquare.gui.common.model.ActivatableDataModel;
|
||||||
import io.bitsquare.gui.main.popups.Popup;
|
import io.bitsquare.gui.main.popups.Popup;
|
||||||
import io.bitsquare.gui.main.popups.WalletPasswordPopup;
|
import io.bitsquare.gui.main.popups.WalletPasswordPopup;
|
||||||
import io.bitsquare.gui.util.BSFormatter;
|
import io.bitsquare.gui.util.BSFormatter;
|
||||||
|
import io.bitsquare.locale.CurrencyUtil;
|
||||||
import io.bitsquare.locale.TradeCurrency;
|
import io.bitsquare.locale.TradeCurrency;
|
||||||
import io.bitsquare.payment.PaymentAccount;
|
import io.bitsquare.payment.PaymentAccount;
|
||||||
import io.bitsquare.payment.PaymentMethod;
|
import io.bitsquare.payment.PaymentMethod;
|
||||||
|
@ -356,8 +357,12 @@ class TakeOfferDataModel extends ActivatableDataModel {
|
||||||
return offer.getPaymentMethod();
|
return offer.getPaymentMethod();
|
||||||
}
|
}
|
||||||
|
|
||||||
public TradeCurrency getTradeCurrency() {
|
public String getCurrencyCode() {
|
||||||
return new TradeCurrency(offer.getCurrencyCode());
|
return offer.getCurrencyCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCurrencyNameAndCode() {
|
||||||
|
return CurrencyUtil.getNameByCode(offer.getCurrencyCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Coin getSecurityDepositAsCoin() {
|
public Coin getSecurityDepositAsCoin() {
|
||||||
|
|
|
@ -150,12 +150,12 @@ public class TakeOfferView extends ActivatableViewAndModel<AnchorPane, TakeOffer
|
||||||
takeOfferSpinnerInfoLabel.visibleProperty().bind(model.isTakeOfferSpinnerVisible);
|
takeOfferSpinnerInfoLabel.visibleProperty().bind(model.isTakeOfferSpinnerVisible);
|
||||||
|
|
||||||
priceCurrencyLabel.textProperty().bind(createStringBinding(() ->
|
priceCurrencyLabel.textProperty().bind(createStringBinding(() ->
|
||||||
model.getTradeCurrency().getCode() + "/" + model.btcCode.get(), model.btcCode));
|
model.dataModel.getCurrencyCode() + "/" + model.btcCode.get(), model.btcCode));
|
||||||
|
|
||||||
volumeCurrencyLabel.setText(model.getTradeCurrency().getCode());
|
volumeCurrencyLabel.setText(model.dataModel.getCurrencyCode());
|
||||||
amountRangeBtcLabel.textProperty().bind(model.btcCode);
|
amountRangeBtcLabel.textProperty().bind(model.btcCode);
|
||||||
|
|
||||||
priceDescriptionLabel.setText(BSResources.get("createOffer.amountPriceBox.priceDescription", model.getTradeCurrency().getCode()));
|
priceDescriptionLabel.setText(BSResources.get("createOffer.amountPriceBox.priceDescription", model.dataModel.getCurrencyCode()));
|
||||||
volumeDescriptionLabel.setText(model.volumeDescriptionLabel.get());
|
volumeDescriptionLabel.setText(model.volumeDescriptionLabel.get());
|
||||||
|
|
||||||
errorPopupDisplayed = new SimpleBooleanProperty();
|
errorPopupDisplayed = new SimpleBooleanProperty();
|
||||||
|
@ -321,7 +321,7 @@ public class TakeOfferView extends ActivatableViewAndModel<AnchorPane, TakeOffer
|
||||||
paymentMethodLabel.setManaged(!showComboBox);
|
paymentMethodLabel.setManaged(!showComboBox);
|
||||||
if (!showComboBox)
|
if (!showComboBox)
|
||||||
paymentMethodTextField.setText(BSResources.get(model.getPaymentMethod().getId()));
|
paymentMethodTextField.setText(BSResources.get(model.getPaymentMethod().getId()));
|
||||||
currencyTextField.setText(model.getTradeCurrency().getNameAndCode());
|
currencyTextField.setText(model.dataModel.getCurrencyNameAndCode());
|
||||||
buyLabel.setText(model.getDirectionLabel());
|
buyLabel.setText(model.getDirectionLabel());
|
||||||
amountDescriptionLabel.setText(model.getAmountDescription());
|
amountDescriptionLabel.setText(model.getAmountDescription());
|
||||||
amountRangeTextField.setText(model.getAmountRange());
|
amountRangeTextField.setText(model.getAmountRange());
|
||||||
|
|
|
@ -25,7 +25,6 @@ import io.bitsquare.gui.util.BSFormatter;
|
||||||
import io.bitsquare.gui.util.validation.BtcValidator;
|
import io.bitsquare.gui.util.validation.BtcValidator;
|
||||||
import io.bitsquare.gui.util.validation.InputValidator;
|
import io.bitsquare.gui.util.validation.InputValidator;
|
||||||
import io.bitsquare.locale.BSResources;
|
import io.bitsquare.locale.BSResources;
|
||||||
import io.bitsquare.locale.TradeCurrency;
|
|
||||||
import io.bitsquare.p2p.P2PService;
|
import io.bitsquare.p2p.P2PService;
|
||||||
import io.bitsquare.p2p.network.CloseConnectionReason;
|
import io.bitsquare.p2p.network.CloseConnectionReason;
|
||||||
import io.bitsquare.p2p.network.Connection;
|
import io.bitsquare.p2p.network.Connection;
|
||||||
|
@ -360,9 +359,9 @@ class TakeOfferViewModel extends ActivatableWithDataModel<TakeOfferDataModel> im
|
||||||
|
|
||||||
|
|
||||||
if (dataModel.getDirection() == Offer.Direction.BUY) {
|
if (dataModel.getDirection() == Offer.Direction.BUY) {
|
||||||
volumeDescriptionLabel.set(BSResources.get("createOffer.amountPriceBox.buy.volumeDescription", dataModel.getTradeCurrency().getCode()));
|
volumeDescriptionLabel.set(BSResources.get("createOffer.amountPriceBox.buy.volumeDescription", dataModel.getCurrencyCode()));
|
||||||
} else {
|
} else {
|
||||||
volumeDescriptionLabel.set(BSResources.get("createOffer.amountPriceBox.sell.volumeDescription", dataModel.getTradeCurrency().getCode()));
|
volumeDescriptionLabel.set(BSResources.get("createOffer.amountPriceBox.sell.volumeDescription", dataModel.getCurrencyCode()));
|
||||||
}
|
}
|
||||||
totalToPay.bind(createStringBinding(() -> formatter.formatCoinWithCode(dataModel.totalToPayAsCoin.get()), dataModel.totalToPayAsCoin));
|
totalToPay.bind(createStringBinding(() -> formatter.formatCoinWithCode(dataModel.totalToPayAsCoin.get()), dataModel.totalToPayAsCoin));
|
||||||
totalToPayAsCoin.bind(dataModel.totalToPayAsCoin);
|
totalToPayAsCoin.bind(dataModel.totalToPayAsCoin);
|
||||||
|
@ -539,10 +538,6 @@ class TakeOfferViewModel extends ActivatableWithDataModel<TakeOfferDataModel> im
|
||||||
return dataModel.getPossiblePaymentAccounts();
|
return dataModel.getPossiblePaymentAccounts();
|
||||||
}
|
}
|
||||||
|
|
||||||
public TradeCurrency getTradeCurrency() {
|
|
||||||
return dataModel.getTradeCurrency();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Arbitrator> getArbitrators() {
|
public List<Arbitrator> getArbitrators() {
|
||||||
return dataModel.getArbitrators();
|
return dataModel.getArbitrators();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue