mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-23 15:00:30 +01:00
Adapt navigational structure and offerbook handling to buy and sell different assets
Still missing correct create and take offer handling
This commit is contained in:
parent
298806150b
commit
98f355d3fa
27 changed files with 1115 additions and 205 deletions
|
@ -19,6 +19,7 @@ package bisq.core.payment;
|
||||||
|
|
||||||
import bisq.core.account.witness.AccountAgeWitnessService;
|
import bisq.core.account.witness.AccountAgeWitnessService;
|
||||||
import bisq.core.locale.Country;
|
import bisq.core.locale.Country;
|
||||||
|
import bisq.core.locale.TradeCurrency;
|
||||||
import bisq.core.offer.Offer;
|
import bisq.core.offer.Offer;
|
||||||
import bisq.core.payment.payload.PaymentAccountPayload;
|
import bisq.core.payment.payload.PaymentAccountPayload;
|
||||||
import bisq.core.payment.payload.PaymentMethod;
|
import bisq.core.payment.payload.PaymentMethod;
|
||||||
|
@ -29,6 +30,7 @@ import javafx.collections.ObservableList;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -38,6 +40,10 @@ import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import static bisq.core.locale.CurrencyUtil.*;
|
||||||
|
import static bisq.core.payment.payload.PaymentMethod.*;
|
||||||
|
import static java.util.Comparator.comparing;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class PaymentAccountUtil {
|
public class PaymentAccountUtil {
|
||||||
|
|
||||||
|
@ -106,6 +112,39 @@ public class PaymentAccountUtil {
|
||||||
return acceptedCountryCodes;
|
return acceptedCountryCodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<TradeCurrency> getTradeCurrencies(PaymentMethod paymentMethod) {
|
||||||
|
switch (paymentMethod.getId()) {
|
||||||
|
case ADVANCED_CASH_ID:
|
||||||
|
return getAllAdvancedCashCurrencies();
|
||||||
|
case AMAZON_GIFT_CARD_ID:
|
||||||
|
return getAllAmazonGiftCardCurrencies();
|
||||||
|
case CAPITUAL_ID:
|
||||||
|
return getAllCapitualCurrencies();
|
||||||
|
case MONEY_GRAM_ID:
|
||||||
|
return getAllMoneyGramCurrencies();
|
||||||
|
case PAXUM_ID:
|
||||||
|
return getAllPaxumCurrencies();
|
||||||
|
case PAYSERA_ID:
|
||||||
|
return getAllPayseraCurrencies();
|
||||||
|
case REVOLUT_ID:
|
||||||
|
return getAllRevolutCurrencies();
|
||||||
|
case SWIFT_ID:
|
||||||
|
return new ArrayList<>(getAllSortedFiatCurrencies(
|
||||||
|
comparing(TradeCurrency::getCode)));
|
||||||
|
case TRANSFERWISE_ID:
|
||||||
|
return getAllTransferwiseCurrencies();
|
||||||
|
case UPHOLD_ID:
|
||||||
|
return getAllUpholdCurrencies();
|
||||||
|
default:
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean supportsCurrency(PaymentMethod paymentMethod, TradeCurrency selectedTradeCurrency) {
|
||||||
|
return getTradeCurrencies(paymentMethod).stream()
|
||||||
|
.anyMatch(tradeCurrency -> tradeCurrency.equals(selectedTradeCurrency));
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static List<String> getAcceptedBanks(PaymentAccount paymentAccount) {
|
public static List<String> getAcceptedBanks(PaymentAccount paymentAccount) {
|
||||||
List<String> acceptedBanks = null;
|
List<String> acceptedBanks = null;
|
||||||
|
|
|
@ -592,6 +592,16 @@ public final class Preferences implements PersistedDataHost, BridgeAddressProvid
|
||||||
requestPersistence();
|
requestPersistence();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setBuyScreenCryptoCurrencyCode(String buyScreenCurrencyCode) {
|
||||||
|
prefPayload.setBuyScreenCryptoCurrencyCode(buyScreenCurrencyCode);
|
||||||
|
requestPersistence();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSellScreenCryptoCurrencyCode(String sellScreenCurrencyCode) {
|
||||||
|
prefPayload.setSellScreenCryptoCurrencyCode(sellScreenCurrencyCode);
|
||||||
|
requestPersistence();
|
||||||
|
}
|
||||||
|
|
||||||
public void setIgnoreTradersList(List<String> ignoreTradersList) {
|
public void setIgnoreTradersList(List<String> ignoreTradersList) {
|
||||||
prefPayload.setIgnoreTradersList(ignoreTradersList);
|
prefPayload.setIgnoreTradersList(ignoreTradersList);
|
||||||
requestPersistence();
|
requestPersistence();
|
||||||
|
|
|
@ -78,6 +78,10 @@ public final class PreferencesPayload implements PersistableEnvelope {
|
||||||
private String buyScreenCurrencyCode;
|
private String buyScreenCurrencyCode;
|
||||||
@Nullable
|
@Nullable
|
||||||
private String sellScreenCurrencyCode;
|
private String sellScreenCurrencyCode;
|
||||||
|
@Nullable
|
||||||
|
private String buyScreenCryptoCurrencyCode;
|
||||||
|
@Nullable
|
||||||
|
private String sellScreenCryptoCurrencyCode;
|
||||||
private int tradeStatisticsTickUnitIndex = 3;
|
private int tradeStatisticsTickUnitIndex = 3;
|
||||||
private boolean resyncSpvRequested;
|
private boolean resyncSpvRequested;
|
||||||
private boolean sortMarketCurrenciesNumerically = true;
|
private boolean sortMarketCurrenciesNumerically = true;
|
||||||
|
@ -213,6 +217,8 @@ public final class PreferencesPayload implements PersistableEnvelope {
|
||||||
Optional.ofNullable(tradeChartsScreenCurrencyCode).ifPresent(builder::setTradeChartsScreenCurrencyCode);
|
Optional.ofNullable(tradeChartsScreenCurrencyCode).ifPresent(builder::setTradeChartsScreenCurrencyCode);
|
||||||
Optional.ofNullable(buyScreenCurrencyCode).ifPresent(builder::setBuyScreenCurrencyCode);
|
Optional.ofNullable(buyScreenCurrencyCode).ifPresent(builder::setBuyScreenCurrencyCode);
|
||||||
Optional.ofNullable(sellScreenCurrencyCode).ifPresent(builder::setSellScreenCurrencyCode);
|
Optional.ofNullable(sellScreenCurrencyCode).ifPresent(builder::setSellScreenCurrencyCode);
|
||||||
|
Optional.ofNullable(buyScreenCryptoCurrencyCode).ifPresent(builder::setBuyScreenCryptoCurrencyCode);
|
||||||
|
Optional.ofNullable(sellScreenCryptoCurrencyCode).ifPresent(builder::setSellScreenCryptoCurrencyCode);
|
||||||
Optional.ofNullable(selectedPaymentAccountForCreateOffer).ifPresent(
|
Optional.ofNullable(selectedPaymentAccountForCreateOffer).ifPresent(
|
||||||
account -> builder.setSelectedPaymentAccountForCreateOffer(selectedPaymentAccountForCreateOffer.toProtoMessage()));
|
account -> builder.setSelectedPaymentAccountForCreateOffer(selectedPaymentAccountForCreateOffer.toProtoMessage()));
|
||||||
Optional.ofNullable(bridgeAddresses).ifPresent(builder::addAllBridgeAddresses);
|
Optional.ofNullable(bridgeAddresses).ifPresent(builder::addAllBridgeAddresses);
|
||||||
|
@ -261,6 +267,8 @@ public final class PreferencesPayload implements PersistableEnvelope {
|
||||||
ProtoUtil.stringOrNullFromProto(proto.getTradeChartsScreenCurrencyCode()),
|
ProtoUtil.stringOrNullFromProto(proto.getTradeChartsScreenCurrencyCode()),
|
||||||
ProtoUtil.stringOrNullFromProto(proto.getBuyScreenCurrencyCode()),
|
ProtoUtil.stringOrNullFromProto(proto.getBuyScreenCurrencyCode()),
|
||||||
ProtoUtil.stringOrNullFromProto(proto.getSellScreenCurrencyCode()),
|
ProtoUtil.stringOrNullFromProto(proto.getSellScreenCurrencyCode()),
|
||||||
|
ProtoUtil.stringOrNullFromProto(proto.getBuyScreenCryptoCurrencyCode()),
|
||||||
|
ProtoUtil.stringOrNullFromProto(proto.getSellScreenCryptoCurrencyCode()),
|
||||||
proto.getTradeStatisticsTickUnitIndex(),
|
proto.getTradeStatisticsTickUnitIndex(),
|
||||||
proto.getResyncSpvRequested(),
|
proto.getResyncSpvRequested(),
|
||||||
proto.getSortMarketCurrenciesNumerically(),
|
proto.getSortMarketCurrenciesNumerically(),
|
||||||
|
|
|
@ -233,8 +233,8 @@ shared.enabled=Enabled
|
||||||
####################################################################
|
####################################################################
|
||||||
|
|
||||||
mainView.menu.market=Market
|
mainView.menu.market=Market
|
||||||
mainView.menu.buyBtc=Buy BTC
|
mainView.menu.buyBtc=Buy
|
||||||
mainView.menu.sellBtc=Sell BTC
|
mainView.menu.sellBtc=Sell
|
||||||
mainView.menu.portfolio=Portfolio
|
mainView.menu.portfolio=Portfolio
|
||||||
mainView.menu.funds=Funds
|
mainView.menu.funds=Funds
|
||||||
mainView.menu.support=Support
|
mainView.menu.support=Support
|
||||||
|
@ -337,17 +337,16 @@ market.trades.showVolumeInUSD=Show volume in USD
|
||||||
offerbook.createOffer=Create offer
|
offerbook.createOffer=Create offer
|
||||||
offerbook.takeOffer=Take offer
|
offerbook.takeOffer=Take offer
|
||||||
offerbook.takeOffer.createAccount=Create account and take offer
|
offerbook.takeOffer.createAccount=Create account and take offer
|
||||||
offerbook.takeOfferToBuy=Take offer to buy {0}
|
|
||||||
offerbook.takeOfferToSell=Take offer to sell {0}
|
|
||||||
offerbook.trader=Trader
|
offerbook.trader=Trader
|
||||||
offerbook.offerersBankId=Maker''s bank ID (BIC/SWIFT): {0}
|
offerbook.offerersBankId=Maker''s bank ID (BIC/SWIFT): {0}
|
||||||
offerbook.offerersBankName=Maker''s bank name: {0}
|
offerbook.offerersBankName=Maker''s bank name: {0}
|
||||||
offerbook.offerersBankSeat=Maker''s seat of bank country: {0}
|
offerbook.offerersBankSeat=Maker''s seat of bank country: {0}
|
||||||
offerbook.offerersAcceptedBankSeatsEuro=Accepted seat of bank countries (taker): All Euro countries
|
offerbook.offerersAcceptedBankSeatsEuro=Accepted seat of bank countries (taker): All Euro countries
|
||||||
offerbook.offerersAcceptedBankSeats=Accepted seat of bank countries (taker):\n {0}
|
offerbook.offerersAcceptedBankSeats=Accepted seat of bank countries (taker):\n {0}
|
||||||
offerbook.availableOffers=Available offers
|
offerbook.availableOffersToBuy=Buy {0} with {1}
|
||||||
offerbook.filterByCurrency=Filter by currency
|
offerbook.availableOffersToSell=Sell {0} for {1}
|
||||||
offerbook.filterByPaymentMethod=Filter by payment method
|
offerbook.filterByCurrency=Choose currency
|
||||||
|
offerbook.filterByPaymentMethod=Choose payment method
|
||||||
offerbook.matchingOffers=Offers matching my accounts
|
offerbook.matchingOffers=Offers matching my accounts
|
||||||
offerbook.timeSinceSigning=Account info
|
offerbook.timeSinceSigning=Account info
|
||||||
offerbook.timeSinceSigning.info.arbitrator=signed by an arbitrator and can sign peer accounts
|
offerbook.timeSinceSigning.info.arbitrator=signed by an arbitrator and can sign peer accounts
|
||||||
|
@ -380,12 +379,7 @@ offerbook.volume={0} (min - max)
|
||||||
offerbook.deposit=Deposit BTC (%)
|
offerbook.deposit=Deposit BTC (%)
|
||||||
offerbook.deposit.help=Deposit paid by each trader to guarantee the trade. Will be returned when the trade is completed.
|
offerbook.deposit.help=Deposit paid by each trader to guarantee the trade. Will be returned when the trade is completed.
|
||||||
|
|
||||||
offerbook.createOfferToBuy=Create new offer to buy {0}
|
offerbook.createNewOffer=Create new offer
|
||||||
offerbook.createOfferToSell=Create new offer to sell {0}
|
|
||||||
offerbook.createOfferToBuy.withFiat=Create new offer to buy {0} with {1}
|
|
||||||
offerbook.createOfferToSell.forFiat=Create new offer to sell {0} for {1}
|
|
||||||
offerbook.createOfferToBuy.withCrypto=Create new offer to sell {0} (buy {1})
|
|
||||||
offerbook.createOfferToSell.forCrypto=Create new offer to buy {0} (sell {1})
|
|
||||||
offerbook.createOfferDisabled.tooltip=You can only create one offer at a time
|
offerbook.createOfferDisabled.tooltip=You can only create one offer at a time
|
||||||
|
|
||||||
offerbook.takeOfferButton.tooltip=Take offer for {0}
|
offerbook.takeOfferButton.tooltip=Take offer for {0}
|
||||||
|
|
|
@ -323,6 +323,7 @@ public class OfferBookChartView extends ActivatableViewAndModel<VBox, OfferBookC
|
||||||
};
|
};
|
||||||
|
|
||||||
buyTableRowSelectionListener = (observable, oldValue, newValue) -> {
|
buyTableRowSelectionListener = (observable, oldValue, newValue) -> {
|
||||||
|
|
||||||
model.preferences.setSellScreenCurrencyCode(model.getCurrencyCode());
|
model.preferences.setSellScreenCurrencyCode(model.getCurrencyCode());
|
||||||
navigation.navigateTo(MainView.class, SellOfferView.class);
|
navigation.navigateTo(MainView.class, SellOfferView.class);
|
||||||
};
|
};
|
||||||
|
|
|
@ -43,7 +43,6 @@ public class BuyOfferView extends OfferView {
|
||||||
super(viewLoader,
|
super(viewLoader,
|
||||||
navigation,
|
navigation,
|
||||||
preferences,
|
preferences,
|
||||||
arbitratorManager,
|
|
||||||
user,
|
user,
|
||||||
p2PService,
|
p2PService,
|
||||||
OfferDirection.BUY);
|
OfferDirection.BUY);
|
||||||
|
|
|
@ -26,20 +26,21 @@ import bisq.desktop.main.offer.bisq_v1.createoffer.CreateOfferView;
|
||||||
import bisq.desktop.main.offer.bisq_v1.takeoffer.TakeOfferView;
|
import bisq.desktop.main.offer.bisq_v1.takeoffer.TakeOfferView;
|
||||||
import bisq.desktop.main.offer.bsq_swap.create_offer.BsqSwapCreateOfferView;
|
import bisq.desktop.main.offer.bsq_swap.create_offer.BsqSwapCreateOfferView;
|
||||||
import bisq.desktop.main.offer.bsq_swap.take_offer.BsqSwapTakeOfferView;
|
import bisq.desktop.main.offer.bsq_swap.take_offer.BsqSwapTakeOfferView;
|
||||||
|
import bisq.desktop.main.offer.offerbook.BsqOfferBookView;
|
||||||
|
import bisq.desktop.main.offer.offerbook.BtcOfferBookView;
|
||||||
import bisq.desktop.main.offer.offerbook.OfferBookView;
|
import bisq.desktop.main.offer.offerbook.OfferBookView;
|
||||||
import bisq.desktop.main.overlays.popups.Popup;
|
import bisq.desktop.main.offer.offerbook.OtherOfferBookView;
|
||||||
|
import bisq.desktop.main.offer.offerbook.TopAltcoinOfferBookView;
|
||||||
import bisq.desktop.util.GUIUtil;
|
import bisq.desktop.util.GUIUtil;
|
||||||
|
|
||||||
import bisq.core.locale.CurrencyUtil;
|
import bisq.core.locale.CurrencyUtil;
|
||||||
import bisq.core.locale.GlobalSettings;
|
import bisq.core.locale.GlobalSettings;
|
||||||
import bisq.core.locale.LanguageUtil;
|
|
||||||
import bisq.core.locale.Res;
|
import bisq.core.locale.Res;
|
||||||
import bisq.core.locale.TradeCurrency;
|
import bisq.core.locale.TradeCurrency;
|
||||||
import bisq.core.offer.Offer;
|
import bisq.core.offer.Offer;
|
||||||
import bisq.core.offer.OfferDirection;
|
import bisq.core.offer.OfferDirection;
|
||||||
import bisq.core.offer.bsq_swap.BsqSwapOfferPayload;
|
import bisq.core.offer.bsq_swap.BsqSwapOfferPayload;
|
||||||
import bisq.core.payment.payload.PaymentMethod;
|
import bisq.core.payment.payload.PaymentMethod;
|
||||||
import bisq.core.support.dispute.arbitration.arbitrator.ArbitratorManager;
|
|
||||||
import bisq.core.user.Preferences;
|
import bisq.core.user.Preferences;
|
||||||
import bisq.core.user.User;
|
import bisq.core.user.User;
|
||||||
|
|
||||||
|
@ -55,19 +56,18 @@ import javafx.collections.ListChangeListener;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public abstract class OfferView extends ActivatableView<TabPane, Void> {
|
public abstract class OfferView extends ActivatableView<TabPane, Void> {
|
||||||
|
|
||||||
private OfferBookView offerBookView;
|
private OfferBookView btcOfferBookView, bsqOfferBookView, topAltcoinOfferBookView, otherOfferBookView;
|
||||||
private CreateOfferView createOfferView;
|
private CreateOfferView createOfferView;
|
||||||
private BsqSwapCreateOfferView bsqSwapCreateOfferView;
|
private BsqSwapCreateOfferView bsqSwapCreateOfferView;
|
||||||
private TakeOfferView takeOfferView;
|
private TakeOfferView takeOfferView;
|
||||||
private BsqSwapTakeOfferView bsqSwapTakeOfferView;
|
private BsqSwapTakeOfferView bsqSwapTakeOfferView;
|
||||||
private AnchorPane createOfferPane, takeOfferPane;
|
private AnchorPane createOfferPane, takeOfferPane;
|
||||||
private Tab takeOfferTab, createOfferTab, offerBookTab;
|
private Tab takeOfferTab, createOfferTab, btcOfferBookTab, bsqOfferBookTab, topAltcoinOfferBookTab, otherOfferBookTab;
|
||||||
|
|
||||||
private final ViewLoader viewLoader;
|
private final ViewLoader viewLoader;
|
||||||
private final Navigation navigation;
|
private final Navigation navigation;
|
||||||
|
@ -75,7 +75,6 @@ public abstract class OfferView extends ActivatableView<TabPane, Void> {
|
||||||
private final User user;
|
private final User user;
|
||||||
private final P2PService p2PService;
|
private final P2PService p2PService;
|
||||||
private final OfferDirection direction;
|
private final OfferDirection direction;
|
||||||
private final ArbitratorManager arbitratorManager;
|
|
||||||
|
|
||||||
private Offer offer;
|
private Offer offer;
|
||||||
private TradeCurrency tradeCurrency;
|
private TradeCurrency tradeCurrency;
|
||||||
|
@ -88,7 +87,6 @@ public abstract class OfferView extends ActivatableView<TabPane, Void> {
|
||||||
protected OfferView(ViewLoader viewLoader,
|
protected OfferView(ViewLoader viewLoader,
|
||||||
Navigation navigation,
|
Navigation navigation,
|
||||||
Preferences preferences,
|
Preferences preferences,
|
||||||
ArbitratorManager arbitratorManager,
|
|
||||||
User user,
|
User user,
|
||||||
P2PService p2PService,
|
P2PService p2PService,
|
||||||
OfferDirection direction) {
|
OfferDirection direction) {
|
||||||
|
@ -98,7 +96,6 @@ public abstract class OfferView extends ActivatableView<TabPane, Void> {
|
||||||
this.user = user;
|
this.user = user;
|
||||||
this.p2PService = p2PService;
|
this.p2PService = p2PService;
|
||||||
this.direction = direction;
|
this.direction = direction;
|
||||||
this.arbitratorManager = arbitratorManager;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -117,8 +114,30 @@ public abstract class OfferView extends ActivatableView<TabPane, Void> {
|
||||||
takeOfferView.onTabSelected(true);
|
takeOfferView.onTabSelected(true);
|
||||||
} else if (newValue.equals(takeOfferTab) && bsqSwapTakeOfferView != null) {
|
} else if (newValue.equals(takeOfferTab) && bsqSwapTakeOfferView != null) {
|
||||||
bsqSwapTakeOfferView.onTabSelected(true);
|
bsqSwapTakeOfferView.onTabSelected(true);
|
||||||
} else if (newValue.equals(offerBookTab) && offerBookView != null) {
|
} else if (newValue.equals(btcOfferBookTab)) {
|
||||||
offerBookView.onTabSelected(true);
|
if (btcOfferBookView != null) {
|
||||||
|
btcOfferBookView.onTabSelected(true);
|
||||||
|
} else {
|
||||||
|
loadView(BtcOfferBookView.class, null);
|
||||||
|
}
|
||||||
|
} else if (newValue.equals(bsqOfferBookTab)) {
|
||||||
|
if (bsqOfferBookView != null) {
|
||||||
|
bsqOfferBookView.onTabSelected(true);
|
||||||
|
} else {
|
||||||
|
loadView(BsqOfferBookView.class, null);
|
||||||
|
}
|
||||||
|
} else if (newValue.equals(topAltcoinOfferBookTab)) {
|
||||||
|
if (topAltcoinOfferBookView != null) {
|
||||||
|
topAltcoinOfferBookView.onTabSelected(true);
|
||||||
|
} else {
|
||||||
|
loadView(TopAltcoinOfferBookView.class, null);
|
||||||
|
}
|
||||||
|
} else if (newValue.equals(otherOfferBookTab)) {
|
||||||
|
if (otherOfferBookView != null) {
|
||||||
|
otherOfferBookView.onTabSelected(true);
|
||||||
|
} else {
|
||||||
|
loadView(OtherOfferBookView.class, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (oldValue != null) {
|
if (oldValue != null) {
|
||||||
|
@ -130,8 +149,14 @@ public abstract class OfferView extends ActivatableView<TabPane, Void> {
|
||||||
takeOfferView.onTabSelected(false);
|
takeOfferView.onTabSelected(false);
|
||||||
} else if (oldValue.equals(takeOfferTab) && bsqSwapTakeOfferView != null) {
|
} else if (oldValue.equals(takeOfferTab) && bsqSwapTakeOfferView != null) {
|
||||||
bsqSwapTakeOfferView.onTabSelected(false);
|
bsqSwapTakeOfferView.onTabSelected(false);
|
||||||
} else if (oldValue.equals(offerBookTab) && offerBookView != null) {
|
} else if (oldValue.equals(btcOfferBookTab) && btcOfferBookView != null) {
|
||||||
offerBookView.onTabSelected(false);
|
btcOfferBookView.onTabSelected(false);
|
||||||
|
} else if (oldValue.equals(bsqOfferBookTab) && bsqOfferBookView != null) {
|
||||||
|
bsqOfferBookView.onTabSelected(false);
|
||||||
|
} else if (oldValue.equals(topAltcoinOfferBookTab) && topAltcoinOfferBookView != null) {
|
||||||
|
topAltcoinOfferBookView.onTabSelected(false);
|
||||||
|
} else if (oldValue.equals(otherOfferBookTab) && otherOfferBookView != null) {
|
||||||
|
otherOfferBookView.onTabSelected(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -162,7 +187,8 @@ public abstract class OfferView extends ActivatableView<TabPane, Void> {
|
||||||
if (takeOfferViewOpen) {
|
if (takeOfferViewOpen) {
|
||||||
root.getTabs().remove(takeOfferTab);
|
root.getTabs().remove(takeOfferTab);
|
||||||
}
|
}
|
||||||
if (canCreateOrTakeOffer(CurrencyUtil.getTradeCurrency(offer.getCurrencyCode()).get())) {
|
Optional<TradeCurrency> optionalTradeCurrency = CurrencyUtil.getTradeCurrency(offer.getCurrencyCode());
|
||||||
|
if (optionalTradeCurrency.isPresent() && canCreateOrTakeOffer(optionalTradeCurrency.get())) {
|
||||||
openTakeOffer(offer);
|
openTakeOffer(offer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -179,8 +205,8 @@ public abstract class OfferView extends ActivatableView<TabPane, Void> {
|
||||||
root.getSelectionModel().selectedItemProperty().addListener(tabChangeListener);
|
root.getSelectionModel().selectedItemProperty().addListener(tabChangeListener);
|
||||||
root.getTabs().addListener(tabListChangeListener);
|
root.getTabs().addListener(tabListChangeListener);
|
||||||
navigation.addListener(navigationListener);
|
navigation.addListener(navigationListener);
|
||||||
if (offerBookView == null) {
|
if (btcOfferBookView == null) {
|
||||||
navigation.navigateTo(MainView.class, this.getClass(), OfferBookView.class);
|
navigation.navigateTo(MainView.class, this.getClass(), BtcOfferBookView.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,22 +231,55 @@ public abstract class OfferView extends ActivatableView<TabPane, Void> {
|
||||||
TabPane tabPane = root;
|
TabPane tabPane = root;
|
||||||
tabPane.setTabClosingPolicy(TabPane.TabClosingPolicy.ALL_TABS);
|
tabPane.setTabClosingPolicy(TabPane.TabClosingPolicy.ALL_TABS);
|
||||||
View view;
|
View view;
|
||||||
boolean isBuy = direction == OfferDirection.BUY;
|
|
||||||
|
|
||||||
if (viewClass == OfferBookView.class) {
|
if (OfferBookView.class.isAssignableFrom(viewClass)) {
|
||||||
if (offerBookTab != null && offerBookView != null) {
|
|
||||||
tabPane.getSelectionModel().select(offerBookTab);
|
if (viewClass == BtcOfferBookView.class && btcOfferBookTab != null && btcOfferBookView != null) {
|
||||||
|
tabPane.getSelectionModel().select(btcOfferBookTab);
|
||||||
|
} else if (viewClass == BsqOfferBookView.class && bsqOfferBookTab != null && bsqOfferBookView != null) {
|
||||||
|
tabPane.getSelectionModel().select(bsqOfferBookTab);
|
||||||
|
} else if (viewClass == TopAltcoinOfferBookView.class && topAltcoinOfferBookTab != null && topAltcoinOfferBookView != null) {
|
||||||
|
tabPane.getSelectionModel().select(topAltcoinOfferBookTab);
|
||||||
|
} else if (viewClass == OtherOfferBookView.class && otherOfferBookTab != null && otherOfferBookView != null) {
|
||||||
|
tabPane.getSelectionModel().select(topAltcoinOfferBookTab);
|
||||||
} else {
|
} else {
|
||||||
view = viewLoader.load(viewClass);
|
if (btcOfferBookTab == null) {
|
||||||
// Offerbook must not be cached by ViewLoader as we use 2 instances for sell and buy screens.
|
btcOfferBookTab = new Tab("BTC");
|
||||||
offerBookTab = new Tab(isBuy ? Res.get("shared.buyBitcoin").toUpperCase() : Res.get("shared.sellBitcoin").toUpperCase());
|
btcOfferBookTab.setClosable(false);
|
||||||
offerBookTab.setClosable(false);
|
bsqOfferBookTab = new Tab("BSQ");
|
||||||
offerBookTab.setContent(view.getRoot());
|
bsqOfferBookTab.setClosable(false);
|
||||||
tabPane.getTabs().add(offerBookTab);
|
topAltcoinOfferBookTab = new Tab("XMR");
|
||||||
offerBookView = (OfferBookView) view;
|
topAltcoinOfferBookTab.setClosable(false);
|
||||||
offerBookView.onTabSelected(true);
|
otherOfferBookTab = new Tab("OTHER");
|
||||||
offerBookView.setOfferActionHandler(offerActionHandler);
|
otherOfferBookTab.setClosable(false);
|
||||||
offerBookView.setDirection(direction);
|
|
||||||
|
tabPane.getTabs().addAll(btcOfferBookTab, bsqOfferBookTab, topAltcoinOfferBookTab, otherOfferBookTab);
|
||||||
|
}
|
||||||
|
if (viewClass == BtcOfferBookView.class) {
|
||||||
|
btcOfferBookView = (OfferBookView) viewLoader.load(BtcOfferBookView.class);
|
||||||
|
btcOfferBookTab.setContent(btcOfferBookView.getRoot());
|
||||||
|
btcOfferBookView.setOfferActionHandler(offerActionHandler);
|
||||||
|
btcOfferBookView.setDirection(direction);
|
||||||
|
btcOfferBookView.onTabSelected(true);
|
||||||
|
} else if (viewClass == BsqOfferBookView.class) {
|
||||||
|
bsqOfferBookView = (OfferBookView) viewLoader.load(BsqOfferBookView.class);
|
||||||
|
bsqOfferBookView.setOfferActionHandler(offerActionHandler);
|
||||||
|
bsqOfferBookView.setDirection(direction);
|
||||||
|
bsqOfferBookTab.setContent(bsqOfferBookView.getRoot());
|
||||||
|
bsqOfferBookView.onTabSelected(true);
|
||||||
|
} else if (viewClass == TopAltcoinOfferBookView.class) {
|
||||||
|
topAltcoinOfferBookView = (OfferBookView) viewLoader.load(TopAltcoinOfferBookView.class);
|
||||||
|
topAltcoinOfferBookView.setOfferActionHandler(offerActionHandler);
|
||||||
|
topAltcoinOfferBookView.setDirection(direction);
|
||||||
|
topAltcoinOfferBookTab.setContent(topAltcoinOfferBookView.getRoot());
|
||||||
|
topAltcoinOfferBookView.onTabSelected(true);
|
||||||
|
} else if (viewClass == OtherOfferBookView.class) {
|
||||||
|
otherOfferBookView = (OfferBookView) viewLoader.load(OtherOfferBookView.class);
|
||||||
|
otherOfferBookView.setOfferActionHandler(offerActionHandler);
|
||||||
|
otherOfferBookView.setDirection(direction);
|
||||||
|
otherOfferBookTab.setContent(otherOfferBookView.getRoot());
|
||||||
|
otherOfferBookView.onTabSelected(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (viewClass == CreateOfferView.class && createOfferView == null) {
|
} else if (viewClass == CreateOfferView.class && createOfferView == null) {
|
||||||
view = viewLoader.load(viewClass);
|
view = viewLoader.load(viewClass);
|
||||||
|
@ -286,23 +345,6 @@ public abstract class OfferView extends ActivatableView<TabPane, Void> {
|
||||||
GUIUtil.canCreateOrTakeOfferOrShowPopup(user, navigation, tradeCurrency);
|
GUIUtil.canCreateOrTakeOfferOrShowPopup(user, navigation, tradeCurrency);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showNoArbitratorForUserLocaleWarning() {
|
|
||||||
String key = "NoArbitratorForUserLocaleWarning";
|
|
||||||
new Popup().information(Res.get("offerbook.info.noArbitrationInUserLanguage",
|
|
||||||
getArbitrationLanguages(), LanguageUtil.getDisplayName(preferences.getUserLanguage())))
|
|
||||||
.closeButtonText(Res.get("shared.ok"))
|
|
||||||
.dontShowAgainId(key)
|
|
||||||
.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getArbitrationLanguages() {
|
|
||||||
return arbitratorManager.getObservableMap().values().stream()
|
|
||||||
.flatMap(arbitrator -> arbitrator.getLanguageCodes().stream())
|
|
||||||
.distinct()
|
|
||||||
.map(LanguageUtil::getDisplayName)
|
|
||||||
.collect(Collectors.joining(", "));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void openTakeOffer(Offer offer) {
|
private void openTakeOffer(Offer offer) {
|
||||||
takeOfferViewOpen = true;
|
takeOfferViewOpen = true;
|
||||||
this.offer = offer;
|
this.offer = offer;
|
||||||
|
@ -332,9 +374,9 @@ public abstract class OfferView extends ActivatableView<TabPane, Void> {
|
||||||
if (bsqSwapCreateOfferView != null) {
|
if (bsqSwapCreateOfferView != null) {
|
||||||
bsqSwapCreateOfferView = null;
|
bsqSwapCreateOfferView = null;
|
||||||
}
|
}
|
||||||
offerBookView.enableCreateOfferButton();
|
btcOfferBookView.enableCreateOfferButton();
|
||||||
|
//TODO: go to last selected tab
|
||||||
navigation.navigateTo(MainView.class, this.getClass(), OfferBookView.class);
|
navigation.navigateTo(MainView.class, this.getClass(), BtcOfferBookView.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onTakeOfferViewRemoved() {
|
private void onTakeOfferViewRemoved() {
|
||||||
|
@ -347,8 +389,8 @@ public abstract class OfferView extends ActivatableView<TabPane, Void> {
|
||||||
if (bsqSwapTakeOfferView != null) {
|
if (bsqSwapTakeOfferView != null) {
|
||||||
bsqSwapTakeOfferView = null;
|
bsqSwapTakeOfferView = null;
|
||||||
}
|
}
|
||||||
|
//TODO: go to last selected tab
|
||||||
navigation.navigateTo(MainView.class, this.getClass(), OfferBookView.class);
|
navigation.navigateTo(MainView.class, this.getClass(), BtcOfferBookView.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface OfferActionHandler {
|
public interface OfferActionHandler {
|
||||||
|
|
|
@ -22,7 +22,6 @@ import bisq.desktop.common.view.FxmlView;
|
||||||
import bisq.desktop.common.view.ViewLoader;
|
import bisq.desktop.common.view.ViewLoader;
|
||||||
|
|
||||||
import bisq.core.offer.OfferDirection;
|
import bisq.core.offer.OfferDirection;
|
||||||
import bisq.core.support.dispute.arbitration.arbitrator.ArbitratorManager;
|
|
||||||
import bisq.core.user.Preferences;
|
import bisq.core.user.Preferences;
|
||||||
import bisq.core.user.User;
|
import bisq.core.user.User;
|
||||||
|
|
||||||
|
@ -37,13 +36,11 @@ public class SellOfferView extends OfferView {
|
||||||
public SellOfferView(ViewLoader viewLoader,
|
public SellOfferView(ViewLoader viewLoader,
|
||||||
Navigation navigation,
|
Navigation navigation,
|
||||||
Preferences preferences,
|
Preferences preferences,
|
||||||
ArbitratorManager arbitratorManager,
|
|
||||||
User user,
|
User user,
|
||||||
P2PService p2PService) {
|
P2PService p2PService) {
|
||||||
super(viewLoader,
|
super(viewLoader,
|
||||||
navigation,
|
navigation,
|
||||||
preferences,
|
preferences,
|
||||||
arbitratorManager,
|
|
||||||
user,
|
user,
|
||||||
p2PService,
|
p2PService,
|
||||||
OfferDirection.SELL);
|
OfferDirection.SELL);
|
||||||
|
|
|
@ -1031,7 +1031,7 @@ public abstract class MutableOfferView<M extends MutableOfferViewModel<?>> exten
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addPaymentGroup() {
|
private void addPaymentGroup() {
|
||||||
paymentTitledGroupBg = addTitledGroupBg(gridPane, gridRow, 1, Res.get("shared.selectTradingAccount"));
|
paymentTitledGroupBg = addTitledGroupBg(gridPane, gridRow, 1, "Buy BTC with Fiat");
|
||||||
GridPane.setColumnSpan(paymentTitledGroupBg, 2);
|
GridPane.setColumnSpan(paymentTitledGroupBg, 2);
|
||||||
|
|
||||||
HBox paymentGroupBox = new HBox();
|
HBox paymentGroupBox = new HBox();
|
||||||
|
@ -1106,8 +1106,7 @@ public abstract class MutableOfferView<M extends MutableOfferViewModel<?>> exten
|
||||||
GridPane.setMargin(advancedOptionsBox, new Insets(Layout.COMPACT_FIRST_ROW_AND_GROUP_DISTANCE, 0, 0, 0));
|
GridPane.setMargin(advancedOptionsBox, new Insets(Layout.COMPACT_FIRST_ROW_AND_GROUP_DISTANCE, 0, 0, 0));
|
||||||
gridPane.getChildren().add(advancedOptionsBox);
|
gridPane.getChildren().add(advancedOptionsBox);
|
||||||
|
|
||||||
Tuple2<AutoTooltipButton, HBox> buyBsqButtonBox = OfferViewUtil.createBuyBsqButtonBox(
|
Tuple2<AutoTooltipButton, HBox> buyBsqButtonBox = OfferViewUtil.createBuyBsqButtonBox(navigation);
|
||||||
navigation, preferences);
|
|
||||||
buyBsqBox = buyBsqButtonBox.second;
|
buyBsqBox = buyBsqButtonBox.second;
|
||||||
buyBsqBox.setManaged(false);
|
buyBsqBox.setManaged(false);
|
||||||
buyBsqBox.setVisible(false);
|
buyBsqBox.setVisible(false);
|
||||||
|
|
|
@ -23,11 +23,13 @@ import bisq.desktop.components.AutoTooltipLabel;
|
||||||
import bisq.desktop.components.HyperlinkWithIcon;
|
import bisq.desktop.components.HyperlinkWithIcon;
|
||||||
import bisq.desktop.main.MainView;
|
import bisq.desktop.main.MainView;
|
||||||
import bisq.desktop.main.offer.SellOfferView;
|
import bisq.desktop.main.offer.SellOfferView;
|
||||||
import bisq.desktop.main.offer.offerbook.OfferBookView;
|
import bisq.desktop.main.offer.offerbook.BsqOfferBookView;
|
||||||
import bisq.desktop.main.overlays.popups.Popup;
|
import bisq.desktop.main.overlays.popups.Popup;
|
||||||
|
|
||||||
|
import bisq.core.locale.CurrencyUtil;
|
||||||
import bisq.core.locale.Res;
|
import bisq.core.locale.Res;
|
||||||
import bisq.core.user.Preferences;
|
import bisq.core.offer.Offer;
|
||||||
|
import bisq.core.offer.OfferDirection;
|
||||||
|
|
||||||
import bisq.common.UserThread;
|
import bisq.common.UserThread;
|
||||||
import bisq.common.util.Tuple2;
|
import bisq.common.util.Tuple2;
|
||||||
|
@ -84,14 +86,13 @@ public class OfferViewUtil {
|
||||||
infoGridPane.getChildren().addAll(label, textField);
|
infoGridPane.getChildren().addAll(label, textField);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Tuple2<AutoTooltipButton, HBox> createBuyBsqButtonBox(Navigation navigation,
|
public static Tuple2<AutoTooltipButton, HBox> createBuyBsqButtonBox(Navigation navigation) {
|
||||||
Preferences preferences) {
|
|
||||||
String buyBsqText = Res.get("shared.buyCurrency", "BSQ");
|
String buyBsqText = Res.get("shared.buyCurrency", "BSQ");
|
||||||
var buyBsqButton = new AutoTooltipButton(buyBsqText);
|
var buyBsqButton = new AutoTooltipButton(buyBsqText);
|
||||||
buyBsqButton.getStyleClass().add("action-button");
|
buyBsqButton.getStyleClass().add("action-button");
|
||||||
buyBsqButton.getStyleClass().add("tiny-button");
|
buyBsqButton.getStyleClass().add("tiny-button");
|
||||||
buyBsqButton.setMinWidth(60);
|
buyBsqButton.setMinWidth(60);
|
||||||
buyBsqButton.setOnAction(e -> openBuyBsqOfferBook(navigation, preferences)
|
buyBsqButton.setOnAction(e -> openBuyBsqOfferBook(navigation)
|
||||||
);
|
);
|
||||||
|
|
||||||
var info = new AutoTooltipLabel("BSQ is colored BTC that helps fund Bisq developers.");
|
var info = new AutoTooltipLabel("BSQ is colored BTC that helps fund Bisq developers.");
|
||||||
|
@ -100,7 +101,7 @@ public class OfferViewUtil {
|
||||||
.information(Res.get("createOffer.buyBsq.popupMessage"))
|
.information(Res.get("createOffer.buyBsq.popupMessage"))
|
||||||
.actionButtonText(buyBsqText)
|
.actionButtonText(buyBsqText)
|
||||||
.buttonAlignment(HPos.CENTER)
|
.buttonAlignment(HPos.CENTER)
|
||||||
.onAction(() -> openBuyBsqOfferBook(navigation, preferences)).show());
|
.onAction(() -> openBuyBsqOfferBook(navigation)).show());
|
||||||
learnMore.setMinWidth(100);
|
learnMore.setMinWidth(100);
|
||||||
|
|
||||||
HBox buyBsqBox = new HBox(buyBsqButton, info, learnMore);
|
HBox buyBsqBox = new HBox(buyBsqButton, info, learnMore);
|
||||||
|
@ -111,9 +112,12 @@ public class OfferViewUtil {
|
||||||
return new Tuple2<>(buyBsqButton, buyBsqBox);
|
return new Tuple2<>(buyBsqButton, buyBsqBox);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void openBuyBsqOfferBook(Navigation navigation, Preferences preferences) {
|
private static void openBuyBsqOfferBook(Navigation navigation) {
|
||||||
preferences.setSellScreenCurrencyCode("BSQ");
|
|
||||||
navigation.navigateTo(
|
navigation.navigateTo(
|
||||||
MainView.class, SellOfferView.class, OfferBookView.class);
|
MainView.class, SellOfferView.class, BsqOfferBookView.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isShownAsSellOffer(Offer offer) {
|
||||||
|
return CurrencyUtil.isFiatCurrency(offer.getCurrencyCode()) == (offer.getDirection() == OfferDirection.SELL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -307,7 +307,7 @@ public class TakeOfferView extends ActivatableViewAndModel<AnchorPane, TakeOffer
|
||||||
paymentAccountsComboBox.setItems(model.getPossiblePaymentAccounts());
|
paymentAccountsComboBox.setItems(model.getPossiblePaymentAccounts());
|
||||||
paymentAccountsComboBox.getSelectionModel().select(lastPaymentAccount);
|
paymentAccountsComboBox.getSelectionModel().select(lastPaymentAccount);
|
||||||
model.onPaymentAccountSelected(lastPaymentAccount);
|
model.onPaymentAccountSelected(lastPaymentAccount);
|
||||||
paymentAccountTitledGroupBg.setText(Res.get("shared.selectTradingAccount"));
|
paymentAccountTitledGroupBg.setText(Res.get("Buy BTC with EUR (using SEPA)"));
|
||||||
}
|
}
|
||||||
|
|
||||||
balanceTextField.setTargetAmount(model.dataModel.getTotalToPayAsCoin().get());
|
balanceTextField.setTargetAmount(model.dataModel.getTotalToPayAsCoin().get());
|
||||||
|
@ -882,8 +882,7 @@ public class TakeOfferView extends ActivatableViewAndModel<AnchorPane, TakeOffer
|
||||||
GridPane.setMargin(advancedOptionsBox, new Insets(Layout.COMPACT_FIRST_ROW_AND_GROUP_DISTANCE, 0, 0, 0));
|
GridPane.setMargin(advancedOptionsBox, new Insets(Layout.COMPACT_FIRST_ROW_AND_GROUP_DISTANCE, 0, 0, 0));
|
||||||
gridPane.getChildren().add(advancedOptionsBox);
|
gridPane.getChildren().add(advancedOptionsBox);
|
||||||
|
|
||||||
Tuple2<AutoTooltipButton, HBox> buyBsqButtonBox = OfferViewUtil.createBuyBsqButtonBox(
|
Tuple2<AutoTooltipButton, HBox> buyBsqButtonBox = OfferViewUtil.createBuyBsqButtonBox(navigation);
|
||||||
navigation, model.dataModel.preferences);
|
|
||||||
buyBsqBox = buyBsqButtonBox.second;
|
buyBsqBox = buyBsqButtonBox.second;
|
||||||
buyBsqBox.setManaged(false);
|
buyBsqBox.setManaged(false);
|
||||||
buyBsqBox.setVisible(false);
|
buyBsqBox.setVisible(false);
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
<?import javafx.scene.layout.ColumnConstraints?>
|
<?import javafx.scene.layout.ColumnConstraints?>
|
||||||
<?import javafx.scene.layout.GridPane?>
|
<?import javafx.scene.layout.GridPane?>
|
||||||
<GridPane fx:id="root" fx:controller="bisq.desktop.main.offer.offerbook.OfferBookView"
|
<GridPane fx:id="root" fx:controller="bisq.desktop.main.offer.offerbook.BsqOfferBookView"
|
||||||
hgap="5.0" vgap="5"
|
hgap="5.0" vgap="5"
|
||||||
xmlns:fx="http://javafx.com/fxml">
|
xmlns:fx="http://javafx.com/fxml">
|
||||||
|
|
|
@ -0,0 +1,74 @@
|
||||||
|
/*
|
||||||
|
* This file is part of Bisq.
|
||||||
|
*
|
||||||
|
* Bisq 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.
|
||||||
|
*
|
||||||
|
* Bisq 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 Bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package bisq.desktop.main.offer.offerbook;
|
||||||
|
|
||||||
|
import bisq.desktop.Navigation;
|
||||||
|
import bisq.desktop.common.view.FxmlView;
|
||||||
|
import bisq.desktop.main.overlays.windows.BsqSwapOfferDetailsWindow;
|
||||||
|
import bisq.desktop.main.overlays.windows.OfferDetailsWindow;
|
||||||
|
|
||||||
|
import bisq.core.account.sign.SignedWitnessService;
|
||||||
|
import bisq.core.account.witness.AccountAgeWitnessService;
|
||||||
|
import bisq.core.alert.PrivateNotificationManager;
|
||||||
|
import bisq.core.locale.Res;
|
||||||
|
import bisq.core.offer.OfferDirection;
|
||||||
|
import bisq.core.user.Preferences;
|
||||||
|
import bisq.core.util.FormattingUtils;
|
||||||
|
import bisq.core.util.coin.CoinFormatter;
|
||||||
|
|
||||||
|
import bisq.common.config.Config;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
|
|
||||||
|
import javafx.scene.layout.GridPane;
|
||||||
|
|
||||||
|
@FxmlView
|
||||||
|
public class BsqOfferBookView extends OfferBookView<GridPane, BsqOfferBookViewModel> {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
BsqOfferBookView(BsqOfferBookViewModel model,
|
||||||
|
Navigation navigation,
|
||||||
|
OfferDetailsWindow offerDetailsWindow,
|
||||||
|
BsqSwapOfferDetailsWindow bsqSwapOfferDetailsWindow,
|
||||||
|
@Named(FormattingUtils.BTC_FORMATTER_KEY) CoinFormatter formatter,
|
||||||
|
PrivateNotificationManager privateNotificationManager,
|
||||||
|
@Named(Config.USE_DEV_PRIVILEGE_KEYS) boolean useDevPrivilegeKeys,
|
||||||
|
AccountAgeWitnessService accountAgeWitnessService,
|
||||||
|
SignedWitnessService signedWitnessService,
|
||||||
|
Preferences preferences) {
|
||||||
|
super(model, navigation, offerDetailsWindow, bsqSwapOfferDetailsWindow, formatter, privateNotificationManager, useDevPrivilegeKeys, accountAgeWitnessService, signedWitnessService);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getMarketTitle() {
|
||||||
|
return model.getDirection().equals(OfferDirection.BUY) ?
|
||||||
|
Res.get("offerbook.availableOffersToBuy", "BSQ", "BTC") :
|
||||||
|
Res.get("offerbook.availableOffersToSell", "BSQ", "BTC");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void activate() {
|
||||||
|
model.onSetTradeCurrency(BsqOfferBookViewModel.BSQ);
|
||||||
|
|
||||||
|
super.activate();
|
||||||
|
|
||||||
|
currencyComboBoxContainer.setVisible(false);
|
||||||
|
currencyComboBoxContainer.setManaged(false);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,115 @@
|
||||||
|
/*
|
||||||
|
* This file is part of Bisq.
|
||||||
|
*
|
||||||
|
* Bisq 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.
|
||||||
|
*
|
||||||
|
* Bisq 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 Bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package bisq.desktop.main.offer.offerbook;
|
||||||
|
|
||||||
|
import bisq.desktop.Navigation;
|
||||||
|
|
||||||
|
import bisq.core.account.witness.AccountAgeWitnessService;
|
||||||
|
import bisq.core.api.CoreApi;
|
||||||
|
import bisq.core.btc.setup.WalletsSetup;
|
||||||
|
import bisq.core.btc.wallet.BsqWalletService;
|
||||||
|
import bisq.core.locale.CurrencyUtil;
|
||||||
|
import bisq.core.locale.TradeCurrency;
|
||||||
|
import bisq.core.offer.Offer;
|
||||||
|
import bisq.core.offer.OfferDirection;
|
||||||
|
import bisq.core.offer.OfferFilterService;
|
||||||
|
import bisq.core.offer.OpenOfferManager;
|
||||||
|
import bisq.core.payment.payload.PaymentMethod;
|
||||||
|
import bisq.core.provider.price.PriceFeedService;
|
||||||
|
import bisq.core.trade.ClosedTradableManager;
|
||||||
|
import bisq.core.user.Preferences;
|
||||||
|
import bisq.core.user.User;
|
||||||
|
import bisq.core.util.FormattingUtils;
|
||||||
|
import bisq.core.util.PriceUtil;
|
||||||
|
import bisq.core.util.coin.BsqFormatter;
|
||||||
|
import bisq.core.util.coin.CoinFormatter;
|
||||||
|
|
||||||
|
import bisq.network.p2p.P2PService;
|
||||||
|
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
|
import javax.inject.Named;
|
||||||
|
|
||||||
|
import javafx.collections.FXCollections;
|
||||||
|
import javafx.collections.ObservableList;
|
||||||
|
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class BsqOfferBookViewModel extends OfferBookViewModel {
|
||||||
|
|
||||||
|
|
||||||
|
public static final TradeCurrency BSQ = CurrencyUtil.getTradeCurrency("BSQ").get();
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public BsqOfferBookViewModel(User user,
|
||||||
|
OpenOfferManager openOfferManager,
|
||||||
|
OfferBook offerBook,
|
||||||
|
Preferences preferences,
|
||||||
|
WalletsSetup walletsSetup,
|
||||||
|
P2PService p2PService,
|
||||||
|
PriceFeedService priceFeedService,
|
||||||
|
ClosedTradableManager closedTradableManager,
|
||||||
|
AccountAgeWitnessService accountAgeWitnessService,
|
||||||
|
Navigation navigation,
|
||||||
|
PriceUtil priceUtil,
|
||||||
|
OfferFilterService offerFilterService,
|
||||||
|
@Named(FormattingUtils.BTC_FORMATTER_KEY) CoinFormatter btcFormatter,
|
||||||
|
BsqFormatter bsqFormatter,
|
||||||
|
BsqWalletService bsqWalletService, CoreApi coreApi) {
|
||||||
|
super(user, openOfferManager, offerBook, preferences, walletsSetup, p2PService, priceFeedService, closedTradableManager, accountAgeWitnessService, navigation, priceUtil, offerFilterService, btcFormatter, bsqFormatter, bsqWalletService, coreApi);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void saveSelectedCurrencyCodeInPreferences(OfferDirection direction, String code) {
|
||||||
|
// No need to store anything as it is just BSQ offers anyway
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ObservableList<PaymentMethod> filterPaymentMethods(ObservableList<PaymentMethod> list,
|
||||||
|
TradeCurrency selectedTradeCurrency) {
|
||||||
|
return FXCollections.observableArrayList(list.stream().filter(PaymentMethod::isAltcoin).collect(Collectors.toList()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void fillCurrencies(ObservableList<TradeCurrency> tradeCurrencies,
|
||||||
|
ObservableList<TradeCurrency> allCurrencies) {
|
||||||
|
tradeCurrencies.add(BSQ);
|
||||||
|
allCurrencies.add(BSQ);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
Predicate<OfferBookListItem> getCurrencyAndMethodPredicate(OfferDirection direction,
|
||||||
|
TradeCurrency selectedTradeCurrency) {
|
||||||
|
return offerBookListItem -> {
|
||||||
|
Offer offer = offerBookListItem.getOffer();
|
||||||
|
// BUY Altcoin is actually SELL Bitcoin
|
||||||
|
boolean directionResult = offer.getDirection() == direction;
|
||||||
|
boolean currencyResult = offer.getCurrencyCode().equals(BSQ.getCode());
|
||||||
|
boolean paymentMethodResult = showAllPaymentMethods ||
|
||||||
|
offer.getPaymentMethod().equals(selectedPaymentMethod);
|
||||||
|
boolean notMyOfferOrShowMyOffersActivated = !isMyOffer(offerBookListItem.getOffer()) || preferences.isShowOwnOffersInOfferBook();
|
||||||
|
return directionResult && currencyResult && paymentMethodResult && notMyOfferOrShowMyOffersActivated;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
String getCurrencyCodeFromPreferences(OfferDirection direction) {
|
||||||
|
return BSQ.getCode();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
~ This file is part of Bisq.
|
||||||
|
~
|
||||||
|
~ Bisq 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.
|
||||||
|
~
|
||||||
|
~ Bisq 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 Bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<?import javafx.scene.layout.ColumnConstraints?>
|
||||||
|
<?import javafx.scene.layout.GridPane?>
|
||||||
|
<GridPane fx:id="root" fx:controller="bisq.desktop.main.offer.offerbook.BtcOfferBookView"
|
||||||
|
hgap="5.0" vgap="5"
|
||||||
|
xmlns:fx="http://javafx.com/fxml">
|
||||||
|
|
||||||
|
<columnConstraints>
|
||||||
|
<ColumnConstraints halignment="RIGHT" hgrow="SOMETIMES" minWidth="200"/>
|
||||||
|
<ColumnConstraints hgrow="ALWAYS"/>
|
||||||
|
</columnConstraints>
|
||||||
|
</GridPane>
|
|
@ -0,0 +1,64 @@
|
||||||
|
/*
|
||||||
|
* This file is part of Bisq.
|
||||||
|
*
|
||||||
|
* Bisq 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.
|
||||||
|
*
|
||||||
|
* Bisq 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 Bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package bisq.desktop.main.offer.offerbook;
|
||||||
|
|
||||||
|
import bisq.desktop.Navigation;
|
||||||
|
import bisq.desktop.common.view.FxmlView;
|
||||||
|
import bisq.desktop.main.overlays.windows.BsqSwapOfferDetailsWindow;
|
||||||
|
import bisq.desktop.main.overlays.windows.OfferDetailsWindow;
|
||||||
|
|
||||||
|
import bisq.core.account.sign.SignedWitnessService;
|
||||||
|
import bisq.core.account.witness.AccountAgeWitnessService;
|
||||||
|
import bisq.core.alert.PrivateNotificationManager;
|
||||||
|
import bisq.core.locale.Res;
|
||||||
|
import bisq.core.offer.OfferDirection;
|
||||||
|
import bisq.core.util.FormattingUtils;
|
||||||
|
import bisq.core.util.coin.CoinFormatter;
|
||||||
|
|
||||||
|
import bisq.common.config.Config;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
|
|
||||||
|
import javafx.scene.layout.GridPane;
|
||||||
|
|
||||||
|
@FxmlView
|
||||||
|
public class BtcOfferBookView extends OfferBookView<GridPane, BtcOfferBookViewModel> {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
BtcOfferBookView(BtcOfferBookViewModel model,
|
||||||
|
Navigation navigation,
|
||||||
|
OfferDetailsWindow offerDetailsWindow,
|
||||||
|
BsqSwapOfferDetailsWindow bsqSwapOfferDetailsWindow,
|
||||||
|
@Named(FormattingUtils.BTC_FORMATTER_KEY) CoinFormatter formatter,
|
||||||
|
PrivateNotificationManager privateNotificationManager,
|
||||||
|
@Named(Config.USE_DEV_PRIVILEGE_KEYS) boolean useDevPrivilegeKeys,
|
||||||
|
AccountAgeWitnessService accountAgeWitnessService,
|
||||||
|
SignedWitnessService signedWitnessService) {
|
||||||
|
super(model, navigation, offerDetailsWindow, bsqSwapOfferDetailsWindow, formatter, privateNotificationManager, useDevPrivilegeKeys, accountAgeWitnessService, signedWitnessService);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getMarketTitle() {
|
||||||
|
return model.getDirection().equals(OfferDirection.BUY) ?
|
||||||
|
Res.get("offerbook.availableOffersToBuy", "BTC", "Fiat") :
|
||||||
|
Res.get("offerbook.availableOffersToSell", "BTC", "Fiat");
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,133 @@
|
||||||
|
/*
|
||||||
|
* This file is part of Bisq.
|
||||||
|
*
|
||||||
|
* Bisq 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.
|
||||||
|
*
|
||||||
|
* Bisq 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 Bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package bisq.desktop.main.offer.offerbook;
|
||||||
|
|
||||||
|
import bisq.desktop.Navigation;
|
||||||
|
import bisq.desktop.util.GUIUtil;
|
||||||
|
|
||||||
|
import bisq.core.account.witness.AccountAgeWitnessService;
|
||||||
|
import bisq.core.api.CoreApi;
|
||||||
|
import bisq.core.btc.setup.WalletsSetup;
|
||||||
|
import bisq.core.btc.wallet.BsqWalletService;
|
||||||
|
import bisq.core.locale.CryptoCurrency;
|
||||||
|
import bisq.core.locale.CurrencyUtil;
|
||||||
|
import bisq.core.locale.TradeCurrency;
|
||||||
|
import bisq.core.offer.Offer;
|
||||||
|
import bisq.core.offer.OfferDirection;
|
||||||
|
import bisq.core.offer.OfferFilterService;
|
||||||
|
import bisq.core.offer.OpenOfferManager;
|
||||||
|
import bisq.core.payment.PaymentAccountUtil;
|
||||||
|
import bisq.core.payment.payload.PaymentMethod;
|
||||||
|
import bisq.core.provider.price.PriceFeedService;
|
||||||
|
import bisq.core.trade.ClosedTradableManager;
|
||||||
|
import bisq.core.user.Preferences;
|
||||||
|
import bisq.core.user.User;
|
||||||
|
import bisq.core.util.FormattingUtils;
|
||||||
|
import bisq.core.util.PriceUtil;
|
||||||
|
import bisq.core.util.coin.BsqFormatter;
|
||||||
|
import bisq.core.util.coin.CoinFormatter;
|
||||||
|
|
||||||
|
import bisq.network.p2p.P2PService;
|
||||||
|
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
|
import javax.inject.Named;
|
||||||
|
|
||||||
|
import javafx.collections.FXCollections;
|
||||||
|
import javafx.collections.ObservableList;
|
||||||
|
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class BtcOfferBookViewModel extends OfferBookViewModel {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public BtcOfferBookViewModel(User user,
|
||||||
|
OpenOfferManager openOfferManager,
|
||||||
|
OfferBook offerBook,
|
||||||
|
Preferences preferences,
|
||||||
|
WalletsSetup walletsSetup,
|
||||||
|
P2PService p2PService,
|
||||||
|
PriceFeedService priceFeedService,
|
||||||
|
ClosedTradableManager closedTradableManager,
|
||||||
|
AccountAgeWitnessService accountAgeWitnessService,
|
||||||
|
Navigation navigation,
|
||||||
|
PriceUtil priceUtil,
|
||||||
|
OfferFilterService offerFilterService,
|
||||||
|
@Named(FormattingUtils.BTC_FORMATTER_KEY) CoinFormatter btcFormatter,
|
||||||
|
BsqFormatter bsqFormatter,
|
||||||
|
BsqWalletService bsqWalletService, CoreApi coreApi) {
|
||||||
|
super(user, openOfferManager, offerBook, preferences, walletsSetup, p2PService, priceFeedService, closedTradableManager, accountAgeWitnessService, navigation, priceUtil, offerFilterService, btcFormatter, bsqFormatter, bsqWalletService, coreApi);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void saveSelectedCurrencyCodeInPreferences(OfferDirection direction, String code) {
|
||||||
|
if (direction == OfferDirection.BUY) {
|
||||||
|
preferences.setBuyScreenCurrencyCode(code);
|
||||||
|
} else {
|
||||||
|
preferences.setSellScreenCurrencyCode(code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ObservableList<PaymentMethod> filterPaymentMethods(ObservableList<PaymentMethod> list,
|
||||||
|
TradeCurrency selectedTradeCurrency) {
|
||||||
|
return FXCollections.observableArrayList(list.stream()
|
||||||
|
.filter(paymentMethod -> {
|
||||||
|
if (showAllTradeCurrenciesProperty.get()) {
|
||||||
|
return paymentMethod.isFiat();
|
||||||
|
}
|
||||||
|
return paymentMethod.isFiat() &&
|
||||||
|
PaymentAccountUtil.supportsCurrency(paymentMethod, selectedTradeCurrency);
|
||||||
|
})
|
||||||
|
.collect(Collectors.toList()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void fillCurrencies(ObservableList<TradeCurrency> tradeCurrencies,
|
||||||
|
ObservableList<TradeCurrency> allCurrencies) {
|
||||||
|
// Used for ignoring filter (show all)
|
||||||
|
tradeCurrencies.add(new CryptoCurrency(GUIUtil.SHOW_ALL_FLAG, ""));
|
||||||
|
tradeCurrencies.addAll(preferences.getFiatCurrenciesAsObservable());
|
||||||
|
tradeCurrencies.add(new CryptoCurrency(GUIUtil.EDIT_FLAG, ""));
|
||||||
|
|
||||||
|
allCurrencies.add(new CryptoCurrency(GUIUtil.SHOW_ALL_FLAG, ""));
|
||||||
|
allCurrencies.addAll(CurrencyUtil.getAllSortedFiatCurrencies());
|
||||||
|
allCurrencies.add(new CryptoCurrency(GUIUtil.EDIT_FLAG, ""));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
Predicate<OfferBookListItem> getCurrencyAndMethodPredicate(OfferDirection direction,
|
||||||
|
TradeCurrency selectedTradeCurrency) {
|
||||||
|
return offerBookListItem -> {
|
||||||
|
Offer offer = offerBookListItem.getOffer();
|
||||||
|
boolean directionResult = offer.getDirection() != direction;
|
||||||
|
boolean currencyResult = (showAllTradeCurrenciesProperty.get() && CurrencyUtil.isFiatCurrency(offer.getCurrencyCode())) ||
|
||||||
|
offer.getCurrencyCode().equals(selectedTradeCurrency.getCode());
|
||||||
|
boolean paymentMethodResult = showAllPaymentMethods ||
|
||||||
|
offer.getPaymentMethod().equals(selectedPaymentMethod);
|
||||||
|
boolean notMyOfferOrShowMyOffersActivated = !isMyOffer(offerBookListItem.getOffer()) || preferences.isShowOwnOffersInOfferBook();
|
||||||
|
return directionResult && currencyResult && paymentMethodResult && notMyOfferOrShowMyOffersActivated;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
String getCurrencyCodeFromPreferences(OfferDirection direction) {
|
||||||
|
return direction == OfferDirection.BUY ? preferences.getBuyScreenCurrencyCode() : preferences.getSellScreenCurrencyCode();
|
||||||
|
}
|
||||||
|
}
|
|
@ -19,7 +19,6 @@ package bisq.desktop.main.offer.offerbook;
|
||||||
|
|
||||||
import bisq.desktop.Navigation;
|
import bisq.desktop.Navigation;
|
||||||
import bisq.desktop.common.view.ActivatableViewAndModel;
|
import bisq.desktop.common.view.ActivatableViewAndModel;
|
||||||
import bisq.desktop.common.view.FxmlView;
|
|
||||||
import bisq.desktop.components.AccountStatusTooltipLabel;
|
import bisq.desktop.components.AccountStatusTooltipLabel;
|
||||||
import bisq.desktop.components.AutoTooltipButton;
|
import bisq.desktop.components.AutoTooltipButton;
|
||||||
import bisq.desktop.components.AutoTooltipLabel;
|
import bisq.desktop.components.AutoTooltipLabel;
|
||||||
|
@ -38,6 +37,7 @@ import bisq.desktop.main.account.content.fiataccounts.FiatAccountsView;
|
||||||
import bisq.desktop.main.funds.FundsView;
|
import bisq.desktop.main.funds.FundsView;
|
||||||
import bisq.desktop.main.funds.withdrawal.WithdrawalView;
|
import bisq.desktop.main.funds.withdrawal.WithdrawalView;
|
||||||
import bisq.desktop.main.offer.OfferView;
|
import bisq.desktop.main.offer.OfferView;
|
||||||
|
import bisq.desktop.main.offer.bisq_v1.OfferViewUtil;
|
||||||
import bisq.desktop.main.overlays.popups.Popup;
|
import bisq.desktop.main.overlays.popups.Popup;
|
||||||
import bisq.desktop.main.overlays.windows.BsqSwapOfferDetailsWindow;
|
import bisq.desktop.main.overlays.windows.BsqSwapOfferDetailsWindow;
|
||||||
import bisq.desktop.main.overlays.windows.OfferDetailsWindow;
|
import bisq.desktop.main.overlays.windows.OfferDetailsWindow;
|
||||||
|
@ -52,7 +52,6 @@ import bisq.core.account.sign.SignedWitnessService;
|
||||||
import bisq.core.account.witness.AccountAgeWitnessService;
|
import bisq.core.account.witness.AccountAgeWitnessService;
|
||||||
import bisq.core.alert.PrivateNotificationManager;
|
import bisq.core.alert.PrivateNotificationManager;
|
||||||
import bisq.core.locale.CurrencyUtil;
|
import bisq.core.locale.CurrencyUtil;
|
||||||
import bisq.core.locale.FiatCurrency;
|
|
||||||
import bisq.core.locale.Res;
|
import bisq.core.locale.Res;
|
||||||
import bisq.core.locale.TradeCurrency;
|
import bisq.core.locale.TradeCurrency;
|
||||||
import bisq.core.monetary.Price;
|
import bisq.core.monetary.Price;
|
||||||
|
@ -64,20 +63,15 @@ import bisq.core.offer.OpenOffer;
|
||||||
import bisq.core.payment.PaymentAccount;
|
import bisq.core.payment.PaymentAccount;
|
||||||
import bisq.core.payment.payload.PaymentMethod;
|
import bisq.core.payment.payload.PaymentMethod;
|
||||||
import bisq.core.user.DontShowAgainLookup;
|
import bisq.core.user.DontShowAgainLookup;
|
||||||
import bisq.core.util.FormattingUtils;
|
|
||||||
import bisq.core.util.coin.CoinFormatter;
|
import bisq.core.util.coin.CoinFormatter;
|
||||||
|
|
||||||
import bisq.network.p2p.NodeAddress;
|
import bisq.network.p2p.NodeAddress;
|
||||||
|
|
||||||
import bisq.common.app.DevEnv;
|
import bisq.common.app.DevEnv;
|
||||||
import bisq.common.config.Config;
|
|
||||||
import bisq.common.util.Tuple3;
|
import bisq.common.util.Tuple3;
|
||||||
|
|
||||||
import org.bitcoinj.core.Coin;
|
import org.bitcoinj.core.Coin;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.inject.Named;
|
|
||||||
|
|
||||||
import de.jensd.fx.fontawesome.AwesomeIcon;
|
import de.jensd.fx.fontawesome.AwesomeIcon;
|
||||||
import de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIcon;
|
import de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIcon;
|
||||||
|
|
||||||
|
@ -124,8 +118,7 @@ import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import static bisq.desktop.util.FormBuilder.addTitledGroupBg;
|
import static bisq.desktop.util.FormBuilder.addTitledGroupBg;
|
||||||
|
|
||||||
@FxmlView
|
abstract public class OfferBookView<R extends GridPane, M extends OfferBookViewModel> extends ActivatableViewAndModel<R, M> {
|
||||||
public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookViewModel> {
|
|
||||||
|
|
||||||
private final Navigation navigation;
|
private final Navigation navigation;
|
||||||
private final OfferDetailsWindow offerDetailsWindow;
|
private final OfferDetailsWindow offerDetailsWindow;
|
||||||
|
@ -137,7 +130,7 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
|
||||||
private final SignedWitnessService signedWitnessService;
|
private final SignedWitnessService signedWitnessService;
|
||||||
|
|
||||||
private TitledGroupBg titledGroupBg;
|
private TitledGroupBg titledGroupBg;
|
||||||
private AutocompleteComboBox<TradeCurrency> currencyComboBox;
|
protected AutocompleteComboBox<TradeCurrency> currencyComboBox;
|
||||||
private AutocompleteComboBox<PaymentMethod> paymentMethodComboBox;
|
private AutocompleteComboBox<PaymentMethod> paymentMethodComboBox;
|
||||||
private AutoTooltipButton createOfferButton;
|
private AutoTooltipButton createOfferButton;
|
||||||
private AutoTooltipSlideToggleButton matchingOffersToggle;
|
private AutoTooltipSlideToggleButton matchingOffersToggle;
|
||||||
|
@ -157,19 +150,19 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
|
||||||
private Subscription currencySelectionSubscriber;
|
private Subscription currencySelectionSubscriber;
|
||||||
private static final int SHOW_ALL = 0;
|
private static final int SHOW_ALL = 0;
|
||||||
private Label disabledCreateOfferButtonTooltip;
|
private Label disabledCreateOfferButtonTooltip;
|
||||||
|
protected VBox currencyComboBoxContainer;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Constructor, lifecycle
|
// Constructor, lifecycle
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@Inject
|
OfferBookView(M model,
|
||||||
OfferBookView(OfferBookViewModel model,
|
|
||||||
Navigation navigation,
|
Navigation navigation,
|
||||||
OfferDetailsWindow offerDetailsWindow,
|
OfferDetailsWindow offerDetailsWindow,
|
||||||
BsqSwapOfferDetailsWindow bsqSwapOfferDetailsWindow,
|
BsqSwapOfferDetailsWindow bsqSwapOfferDetailsWindow,
|
||||||
@Named(FormattingUtils.BTC_FORMATTER_KEY) CoinFormatter formatter,
|
CoinFormatter formatter,
|
||||||
PrivateNotificationManager privateNotificationManager,
|
PrivateNotificationManager privateNotificationManager,
|
||||||
@Named(Config.USE_DEV_PRIVILEGE_KEYS) boolean useDevPrivilegeKeys,
|
boolean useDevPrivilegeKeys,
|
||||||
AccountAgeWitnessService accountAgeWitnessService,
|
AccountAgeWitnessService accountAgeWitnessService,
|
||||||
SignedWitnessService signedWitnessService) {
|
SignedWitnessService signedWitnessService) {
|
||||||
super(model);
|
super(model);
|
||||||
|
@ -192,7 +185,7 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
|
||||||
root,
|
root,
|
||||||
gridRow,
|
gridRow,
|
||||||
2,
|
2,
|
||||||
Res.get("offerbook.availableOffers")
|
""
|
||||||
);
|
);
|
||||||
titledGroupBg.getStyleClass().add("last");
|
titledGroupBg.getStyleClass().add("last");
|
||||||
|
|
||||||
|
@ -203,6 +196,7 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
|
||||||
|
|
||||||
Tuple3<VBox, Label, AutocompleteComboBox<TradeCurrency>> currencyBoxTuple = FormBuilder.addTopLabelAutocompleteComboBox(
|
Tuple3<VBox, Label, AutocompleteComboBox<TradeCurrency>> currencyBoxTuple = FormBuilder.addTopLabelAutocompleteComboBox(
|
||||||
Res.get("offerbook.filterByCurrency"));
|
Res.get("offerbook.filterByCurrency"));
|
||||||
|
currencyComboBoxContainer = currencyBoxTuple.first;
|
||||||
currencyComboBox = currencyBoxTuple.third;
|
currencyComboBox = currencyBoxTuple.third;
|
||||||
currencyComboBox.setPrefWidth(270);
|
currencyComboBox.setPrefWidth(270);
|
||||||
|
|
||||||
|
@ -216,7 +210,7 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
|
||||||
matchingOffersToggle.setText(Res.get("offerbook.matchingOffers"));
|
matchingOffersToggle.setText(Res.get("offerbook.matchingOffers"));
|
||||||
HBox.setMargin(matchingOffersToggle, new Insets(7, 0, -9, -15));
|
HBox.setMargin(matchingOffersToggle, new Insets(7, 0, -9, -15));
|
||||||
|
|
||||||
createOfferButton = new AutoTooltipButton();
|
createOfferButton = new AutoTooltipButton(Res.get("offerbook.createNewOffer"));
|
||||||
createOfferButton.setMinHeight(40);
|
createOfferButton.setMinHeight(40);
|
||||||
createOfferButton.setGraphicTextGap(10);
|
createOfferButton.setGraphicTextGap(10);
|
||||||
|
|
||||||
|
@ -340,8 +334,11 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
|
||||||
priceFeedUpdateCounterListener = (observable, oldValue, newValue) -> tableView.sort();
|
priceFeedUpdateCounterListener = (observable, oldValue, newValue) -> tableView.sort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
abstract protected String getMarketTitle();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void activate() {
|
protected void activate() {
|
||||||
|
titledGroupBg.setText(getMarketTitle());
|
||||||
titledGroupBg.setHelpUrl(model.getDirection() == OfferDirection.SELL
|
titledGroupBg.setHelpUrl(model.getDirection() == OfferDirection.SELL
|
||||||
? "https://bisq.wiki/Introduction#In_a_nutshell"
|
? "https://bisq.wiki/Introduction#In_a_nutshell"
|
||||||
: "https://bisq.wiki/Taking_an_offer");
|
: "https://bisq.wiki/Taking_an_offer");
|
||||||
|
@ -360,6 +357,8 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
|
||||||
if (currencyComboBox.getEditor().getText().isEmpty())
|
if (currencyComboBox.getEditor().getText().isEmpty())
|
||||||
currencyComboBox.getSelectionModel().select(SHOW_ALL);
|
currencyComboBox.getSelectionModel().select(SHOW_ALL);
|
||||||
model.onSetTradeCurrency(currencyComboBox.getSelectionModel().getSelectedItem());
|
model.onSetTradeCurrency(currencyComboBox.getSelectionModel().getSelectedItem());
|
||||||
|
paymentMethodComboBox.setAutocompleteItems(model.getPaymentMethods());
|
||||||
|
updatePaymentMethodComboBoxEditor();
|
||||||
});
|
});
|
||||||
updateCurrencyComboBoxFromModel();
|
updateCurrencyComboBoxFromModel();
|
||||||
|
|
||||||
|
@ -401,18 +400,13 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
|
||||||
updateSigningStateColumn();
|
updateSigningStateColumn();
|
||||||
});
|
});
|
||||||
|
|
||||||
if (model.showAllPaymentMethods)
|
updatePaymentMethodComboBoxEditor();
|
||||||
paymentMethodComboBox.getSelectionModel().select(SHOW_ALL);
|
|
||||||
else
|
|
||||||
paymentMethodComboBox.getSelectionModel().select(model.selectedPaymentMethod);
|
|
||||||
paymentMethodComboBox.getEditor().setText(new PaymentMethodStringConverter(paymentMethodComboBox).toString(paymentMethodComboBox.getSelectionModel().getSelectedItem()));
|
|
||||||
|
|
||||||
createOfferButton.setOnAction(e -> onCreateOffer());
|
createOfferButton.setOnAction(e -> onCreateOffer());
|
||||||
|
|
||||||
MonadicBinding<Void> currencySelectionBinding = EasyBind.combine(
|
MonadicBinding<Void> currencySelectionBinding = EasyBind.combine(
|
||||||
model.showAllTradeCurrenciesProperty, model.tradeCurrencyCode,
|
model.showAllTradeCurrenciesProperty, model.tradeCurrencyCode,
|
||||||
(showAll, code) -> {
|
(showAll, code) -> {
|
||||||
setDirectionTitles();
|
|
||||||
if (showAll) {
|
if (showAll) {
|
||||||
volumeColumn.setTitleWithHelpText(Res.get("shared.amountMinMax"), Res.get("shared.amountHelp"));
|
volumeColumn.setTitleWithHelpText(Res.get("shared.amountMinMax"), Res.get("shared.amountHelp"));
|
||||||
priceColumn.setTitle(Res.get("shared.price"));
|
priceColumn.setTitle(Res.get("shared.price"));
|
||||||
|
@ -444,7 +438,15 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
|
||||||
model.priceFeedService.updateCounterProperty().addListener(priceFeedUpdateCounterListener);
|
model.priceFeedService.updateCounterProperty().addListener(priceFeedUpdateCounterListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateCurrencyComboBoxFromModel() {
|
private void updatePaymentMethodComboBoxEditor() {
|
||||||
|
if (model.showAllPaymentMethods)
|
||||||
|
paymentMethodComboBox.getSelectionModel().select(SHOW_ALL);
|
||||||
|
else
|
||||||
|
paymentMethodComboBox.getSelectionModel().select(model.selectedPaymentMethod);
|
||||||
|
paymentMethodComboBox.getEditor().setText(new PaymentMethodStringConverter(paymentMethodComboBox).toString(paymentMethodComboBox.getSelectionModel().getSelectedItem()));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void updateCurrencyComboBoxFromModel() {
|
||||||
if (model.showAllTradeCurrenciesProperty.get()) {
|
if (model.showAllTradeCurrenciesProperty.get()) {
|
||||||
currencyComboBox.getSelectionModel().select(SHOW_ALL);
|
currencyComboBox.getSelectionModel().select(SHOW_ALL);
|
||||||
} else {
|
} else {
|
||||||
|
@ -588,36 +590,6 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
|
||||||
iconView.setId(direction == OfferDirection.SELL ? "image-sell-white" : "image-buy-white");
|
iconView.setId(direction == OfferDirection.SELL ? "image-sell-white" : "image-buy-white");
|
||||||
createOfferButton.setId(direction == OfferDirection.SELL ? "sell-button-big" : "buy-button-big");
|
createOfferButton.setId(direction == OfferDirection.SELL ? "sell-button-big" : "buy-button-big");
|
||||||
avatarColumn.setTitle(direction == OfferDirection.SELL ? Res.get("shared.buyerUpperCase") : Res.get("shared.sellerUpperCase"));
|
avatarColumn.setTitle(direction == OfferDirection.SELL ? Res.get("shared.buyerUpperCase") : Res.get("shared.sellerUpperCase"));
|
||||||
setDirectionTitles();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setDirectionTitles() {
|
|
||||||
TradeCurrency selectedTradeCurrency = model.getSelectedTradeCurrency();
|
|
||||||
if (selectedTradeCurrency != null) {
|
|
||||||
OfferDirection direction = model.getDirection();
|
|
||||||
String offerButtonText;
|
|
||||||
String code = selectedTradeCurrency.getCode();
|
|
||||||
|
|
||||||
if (model.showAllTradeCurrenciesProperty.get()) {
|
|
||||||
offerButtonText = direction == OfferDirection.BUY ?
|
|
||||||
Res.get("offerbook.createOfferToBuy",
|
|
||||||
Res.getBaseCurrencyCode()) :
|
|
||||||
Res.get("offerbook.createOfferToSell",
|
|
||||||
Res.getBaseCurrencyCode());
|
|
||||||
} else if (selectedTradeCurrency instanceof FiatCurrency) {
|
|
||||||
offerButtonText = direction == OfferDirection.BUY ?
|
|
||||||
Res.get("offerbook.createOfferToBuy.withFiat",
|
|
||||||
Res.getBaseCurrencyCode(), code) :
|
|
||||||
Res.get("offerbook.createOfferToSell.forFiat", Res.getBaseCurrencyCode(), code);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
offerButtonText = direction == OfferDirection.BUY ?
|
|
||||||
Res.get("offerbook.createOfferToBuy.withCrypto",
|
|
||||||
code, Res.getBaseCurrencyCode()) :
|
|
||||||
Res.get("offerbook.createOfferToSell.forCrypto", code, Res.getBaseCurrencyCode());
|
|
||||||
}
|
|
||||||
createOfferButton.updateText(offerButtonText);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOfferActionHandler(OfferView.OfferActionHandler offerActionHandler) {
|
public void setOfferActionHandler(OfferView.OfferActionHandler offerActionHandler) {
|
||||||
|
@ -1181,19 +1153,11 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
|
||||||
button2.setManaged(true);
|
button2.setManaged(true);
|
||||||
button2.setVisible(true);
|
button2.setVisible(true);
|
||||||
} else {
|
} else {
|
||||||
boolean isSellOffer = offer.getDirection() == OfferDirection.SELL;
|
boolean isSellOffer = OfferViewUtil.isShownAsSellOffer(offer);
|
||||||
iconView.setId(isSellOffer ? "image-buy-white" : "image-sell-white");
|
iconView.setId(isSellOffer ? "image-buy-white" : "image-sell-white");
|
||||||
button.setId(isSellOffer ? "buy-button" : "sell-button");
|
button.setId(isSellOffer ? "buy-button" : "sell-button");
|
||||||
button.setStyle("-fx-text-fill: white");
|
button.setStyle("-fx-text-fill: white");
|
||||||
if (isSellOffer) {
|
title = Res.get("offerbook.takeOffer");
|
||||||
title = CurrencyUtil.isFiatCurrency(offer.getCurrencyCode()) ?
|
|
||||||
Res.get("offerbook.takeOfferToBuy", offer.getBaseCurrencyCode()) :
|
|
||||||
Res.get("offerbook.takeOfferToSell", offer.getCurrencyCode());
|
|
||||||
} else {
|
|
||||||
title = CurrencyUtil.isFiatCurrency(offer.getCurrencyCode()) ?
|
|
||||||
Res.get("offerbook.takeOfferToSell", offer.getBaseCurrencyCode()) :
|
|
||||||
Res.get("offerbook.takeOfferToBuy", offer.getCurrencyCode());
|
|
||||||
}
|
|
||||||
button.setTooltip(new Tooltip(Res.get("offerbook.takeOfferButton.tooltip", model.getDirectionLabelTooltip(offer))));
|
button.setTooltip(new Tooltip(Res.get("offerbook.takeOfferButton.tooltip", model.getDirectionLabelTooltip(offer))));
|
||||||
button.setOnAction(e -> onTakeOffer(offer));
|
button.setOnAction(e -> onTakeOffer(offer));
|
||||||
button2.setManaged(false);
|
button2.setManaged(false);
|
||||||
|
|
|
@ -68,10 +68,6 @@ import bisq.common.handlers.ResultHandler;
|
||||||
|
|
||||||
import org.bitcoinj.core.Coin;
|
import org.bitcoinj.core.Coin;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
|
||||||
|
|
||||||
import javax.inject.Named;
|
|
||||||
|
|
||||||
import com.google.common.base.Joiner;
|
import com.google.common.base.Joiner;
|
||||||
|
|
||||||
import javafx.beans.property.BooleanProperty;
|
import javafx.beans.property.BooleanProperty;
|
||||||
|
@ -102,7 +98,7 @@ import lombok.Getter;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
class OfferBookViewModel extends ActivatableViewModel {
|
abstract class OfferBookViewModel extends ActivatableViewModel {
|
||||||
private final OpenOfferManager openOfferManager;
|
private final OpenOfferManager openOfferManager;
|
||||||
private final User user;
|
private final User user;
|
||||||
private final OfferBook offerBook;
|
private final OfferBook offerBook;
|
||||||
|
@ -156,7 +152,6 @@ class OfferBookViewModel extends ActivatableViewModel {
|
||||||
// Constructor, lifecycle
|
// Constructor, lifecycle
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@Inject
|
|
||||||
public OfferBookViewModel(User user,
|
public OfferBookViewModel(User user,
|
||||||
OpenOfferManager openOfferManager,
|
OpenOfferManager openOfferManager,
|
||||||
OfferBook offerBook,
|
OfferBook offerBook,
|
||||||
|
@ -170,7 +165,7 @@ class OfferBookViewModel extends ActivatableViewModel {
|
||||||
Navigation navigation,
|
Navigation navigation,
|
||||||
PriceUtil priceUtil,
|
PriceUtil priceUtil,
|
||||||
OfferFilterService offerFilterService,
|
OfferFilterService offerFilterService,
|
||||||
@Named(FormattingUtils.BTC_FORMATTER_KEY) CoinFormatter btcFormatter,
|
CoinFormatter btcFormatter,
|
||||||
BsqFormatter bsqFormatter,
|
BsqFormatter bsqFormatter,
|
||||||
BsqWalletService bsqWalletService,
|
BsqWalletService bsqWalletService,
|
||||||
CoreApi coreApi) {
|
CoreApi coreApi) {
|
||||||
|
@ -297,13 +292,12 @@ class OfferBookViewModel extends ActivatableViewModel {
|
||||||
setMarketPriceFeedCurrency();
|
setMarketPriceFeedCurrency();
|
||||||
filterOffers();
|
filterOffers();
|
||||||
|
|
||||||
if (direction == OfferDirection.BUY)
|
saveSelectedCurrencyCodeInPreferences(direction, code);
|
||||||
preferences.setBuyScreenCurrencyCode(code);
|
|
||||||
else
|
|
||||||
preferences.setSellScreenCurrencyCode(code);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
abstract void saveSelectedCurrencyCodeInPreferences(OfferDirection direction, String code);
|
||||||
|
|
||||||
void onSetPaymentMethod(PaymentMethod paymentMethod) {
|
void onSetPaymentMethod(PaymentMethod paymentMethod) {
|
||||||
if (paymentMethod == null)
|
if (paymentMethod == null)
|
||||||
return;
|
return;
|
||||||
|
@ -381,11 +375,16 @@ class OfferBookViewModel extends ActivatableViewModel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
list = filterPaymentMethods(list, selectedTradeCurrency);
|
||||||
|
|
||||||
list.sort(Comparator.naturalOrder());
|
list.sort(Comparator.naturalOrder());
|
||||||
list.add(0, getShowAllEntryForPaymentMethod());
|
list.add(0, getShowAllEntryForPaymentMethod());
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected abstract ObservableList<PaymentMethod> filterPaymentMethods(ObservableList<PaymentMethod> list,
|
||||||
|
TradeCurrency selectedTradeCurrency);
|
||||||
|
|
||||||
String getAmount(OfferBookListItem item) {
|
String getAmount(OfferBookListItem item) {
|
||||||
return formatAmount(item.getOffer(), true);
|
return formatAmount(item.getOffer(), true);
|
||||||
}
|
}
|
||||||
|
@ -557,18 +556,13 @@ class OfferBookViewModel extends ActivatableViewModel {
|
||||||
|
|
||||||
private void fillCurrencies() {
|
private void fillCurrencies() {
|
||||||
tradeCurrencies.clear();
|
tradeCurrencies.clear();
|
||||||
// Used for ignoring filter (show all)
|
|
||||||
tradeCurrencies.add(new CryptoCurrency(GUIUtil.SHOW_ALL_FLAG, ""));
|
|
||||||
tradeCurrencies.addAll(preferences.getTradeCurrenciesAsObservable());
|
|
||||||
tradeCurrencies.add(new CryptoCurrency(GUIUtil.EDIT_FLAG, ""));
|
|
||||||
|
|
||||||
allCurrencies.clear();
|
allCurrencies.clear();
|
||||||
allCurrencies.add(new CryptoCurrency(GUIUtil.SHOW_ALL_FLAG, ""));
|
|
||||||
allCurrencies.addAll(CurrencyUtil.getAllSortedFiatCurrencies());
|
fillCurrencies(tradeCurrencies, allCurrencies);
|
||||||
allCurrencies.addAll(CurrencyUtil.getAllSortedCryptoCurrencies());
|
|
||||||
allCurrencies.add(new CryptoCurrency(GUIUtil.EDIT_FLAG, ""));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
abstract void fillCurrencies(ObservableList<TradeCurrency> tradeCurrencies,
|
||||||
|
ObservableList<TradeCurrency> allCurrencies);
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Checks
|
// Checks
|
||||||
|
@ -594,23 +588,13 @@ class OfferBookViewModel extends ActivatableViewModel {
|
||||||
|
|
||||||
private void filterOffers() {
|
private void filterOffers() {
|
||||||
Predicate<OfferBookListItem> predicate = useOffersMatchingMyAccountsFilter ?
|
Predicate<OfferBookListItem> predicate = useOffersMatchingMyAccountsFilter ?
|
||||||
getCurrencyAndMethodPredicate().and(getOffersMatchingMyAccountsPredicate()) :
|
getCurrencyAndMethodPredicate(direction, selectedTradeCurrency).and(getOffersMatchingMyAccountsPredicate()) :
|
||||||
getCurrencyAndMethodPredicate();
|
getCurrencyAndMethodPredicate(direction, selectedTradeCurrency);
|
||||||
filteredItems.setPredicate(predicate);
|
filteredItems.setPredicate(predicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Predicate<OfferBookListItem> getCurrencyAndMethodPredicate() {
|
abstract Predicate<OfferBookListItem> getCurrencyAndMethodPredicate(OfferDirection direction,
|
||||||
return offerBookListItem -> {
|
TradeCurrency selectedTradeCurrency);
|
||||||
Offer offer = offerBookListItem.getOffer();
|
|
||||||
boolean directionResult = offer.getDirection() != direction;
|
|
||||||
boolean currencyResult = (showAllTradeCurrenciesProperty.get()) ||
|
|
||||||
offer.getCurrencyCode().equals(selectedTradeCurrency.getCode());
|
|
||||||
boolean paymentMethodResult = showAllPaymentMethods ||
|
|
||||||
offer.getPaymentMethod().equals(selectedPaymentMethod);
|
|
||||||
boolean notMyOfferOrShowMyOffersActivated = !isMyOffer(offerBookListItem.getOffer()) || preferences.isShowOwnOffersInOfferBook();
|
|
||||||
return directionResult && currencyResult && paymentMethodResult && notMyOfferOrShowMyOffersActivated;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
private Predicate<OfferBookListItem> getOffersMatchingMyAccountsPredicate() {
|
private Predicate<OfferBookListItem> getOffersMatchingMyAccountsPredicate() {
|
||||||
// This code duplicates code in the view at the button column. We need there the different results for
|
// This code duplicates code in the view at the button column. We need there the different results for
|
||||||
|
@ -706,7 +690,7 @@ class OfferBookViewModel extends ActivatableViewModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateSelectedTradeCurrency() {
|
private void updateSelectedTradeCurrency() {
|
||||||
String code = direction == OfferDirection.BUY ? preferences.getBuyScreenCurrencyCode() : preferences.getSellScreenCurrencyCode();
|
String code = getCurrencyCodeFromPreferences(direction);
|
||||||
if (code != null && !code.isEmpty() && !isShowAllEntry(code) &&
|
if (code != null && !code.isEmpty() && !isShowAllEntry(code) &&
|
||||||
CurrencyUtil.getTradeCurrency(code).isPresent()) {
|
CurrencyUtil.getTradeCurrency(code).isPresent()) {
|
||||||
showAllTradeCurrenciesProperty.set(false);
|
showAllTradeCurrenciesProperty.set(false);
|
||||||
|
@ -718,6 +702,8 @@ class OfferBookViewModel extends ActivatableViewModel {
|
||||||
tradeCurrencyCode.set(selectedTradeCurrency.getCode());
|
tradeCurrencyCode.set(selectedTradeCurrency.getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
abstract String getCurrencyCodeFromPreferences(OfferDirection direction);
|
||||||
|
|
||||||
public OpenOffer getOpenOffer(Offer offer) {
|
public OpenOffer getOpenOffer(Offer offer) {
|
||||||
return openOfferManager.getOpenOfferById(offer.getId()).orElse(null);
|
return openOfferManager.getOpenOfferById(offer.getId()).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
~ This file is part of Bisq.
|
||||||
|
~
|
||||||
|
~ Bisq 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.
|
||||||
|
~
|
||||||
|
~ Bisq 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 Bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<?import javafx.scene.layout.ColumnConstraints?>
|
||||||
|
<?import javafx.scene.layout.GridPane?>
|
||||||
|
<GridPane fx:id="root" fx:controller="bisq.desktop.main.offer.offerbook.OtherOfferBookView"
|
||||||
|
hgap="5.0" vgap="5"
|
||||||
|
xmlns:fx="http://javafx.com/fxml">
|
||||||
|
|
||||||
|
<columnConstraints>
|
||||||
|
<ColumnConstraints halignment="RIGHT" hgrow="SOMETIMES" minWidth="200"/>
|
||||||
|
<ColumnConstraints hgrow="ALWAYS"/>
|
||||||
|
</columnConstraints>
|
||||||
|
</GridPane>
|
|
@ -0,0 +1,62 @@
|
||||||
|
/*
|
||||||
|
* This file is part of Bisq.
|
||||||
|
*
|
||||||
|
* Bisq 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.
|
||||||
|
*
|
||||||
|
* Bisq 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 Bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package bisq.desktop.main.offer.offerbook;
|
||||||
|
|
||||||
|
import bisq.desktop.Navigation;
|
||||||
|
import bisq.desktop.common.view.FxmlView;
|
||||||
|
import bisq.desktop.main.overlays.windows.BsqSwapOfferDetailsWindow;
|
||||||
|
import bisq.desktop.main.overlays.windows.OfferDetailsWindow;
|
||||||
|
|
||||||
|
import bisq.core.account.sign.SignedWitnessService;
|
||||||
|
import bisq.core.account.witness.AccountAgeWitnessService;
|
||||||
|
import bisq.core.alert.PrivateNotificationManager;
|
||||||
|
import bisq.core.locale.Res;
|
||||||
|
import bisq.core.offer.OfferDirection;
|
||||||
|
import bisq.core.util.FormattingUtils;
|
||||||
|
import bisq.core.util.coin.CoinFormatter;
|
||||||
|
|
||||||
|
import bisq.common.config.Config;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
|
|
||||||
|
import javafx.scene.layout.GridPane;
|
||||||
|
|
||||||
|
@FxmlView
|
||||||
|
public class OtherOfferBookView extends OfferBookView<GridPane, OtherOfferBookViewModel> {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
OtherOfferBookView(OtherOfferBookViewModel model,
|
||||||
|
Navigation navigation,
|
||||||
|
OfferDetailsWindow offerDetailsWindow,
|
||||||
|
BsqSwapOfferDetailsWindow bsqSwapOfferDetailsWindow,
|
||||||
|
@Named(FormattingUtils.BTC_FORMATTER_KEY) CoinFormatter formatter,
|
||||||
|
PrivateNotificationManager privateNotificationManager,
|
||||||
|
@Named(Config.USE_DEV_PRIVILEGE_KEYS) boolean useDevPrivilegeKeys,
|
||||||
|
AccountAgeWitnessService accountAgeWitnessService,
|
||||||
|
SignedWitnessService signedWitnessService) {
|
||||||
|
super(model, navigation, offerDetailsWindow, bsqSwapOfferDetailsWindow, formatter, privateNotificationManager, useDevPrivilegeKeys, accountAgeWitnessService, signedWitnessService);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getMarketTitle() {
|
||||||
|
return model.getDirection().equals(OfferDirection.BUY) ?
|
||||||
|
Res.get("offerbook.availableOffersToBuy", "Other assets", "BTC") :
|
||||||
|
Res.get("offerbook.availableOffersToSell", "Other assets", "BTC");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,141 @@
|
||||||
|
/*
|
||||||
|
* This file is part of Bisq.
|
||||||
|
*
|
||||||
|
* Bisq 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.
|
||||||
|
*
|
||||||
|
* Bisq 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 Bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package bisq.desktop.main.offer.offerbook;
|
||||||
|
|
||||||
|
import bisq.desktop.Navigation;
|
||||||
|
import bisq.desktop.util.GUIUtil;
|
||||||
|
|
||||||
|
import bisq.core.account.witness.AccountAgeWitnessService;
|
||||||
|
import bisq.core.api.CoreApi;
|
||||||
|
import bisq.core.btc.setup.WalletsSetup;
|
||||||
|
import bisq.core.btc.wallet.BsqWalletService;
|
||||||
|
import bisq.core.locale.CryptoCurrency;
|
||||||
|
import bisq.core.locale.CurrencyUtil;
|
||||||
|
import bisq.core.locale.TradeCurrency;
|
||||||
|
import bisq.core.offer.Offer;
|
||||||
|
import bisq.core.offer.OfferDirection;
|
||||||
|
import bisq.core.offer.OfferFilterService;
|
||||||
|
import bisq.core.offer.OpenOfferManager;
|
||||||
|
import bisq.core.payment.payload.PaymentMethod;
|
||||||
|
import bisq.core.provider.price.PriceFeedService;
|
||||||
|
import bisq.core.trade.ClosedTradableManager;
|
||||||
|
import bisq.core.user.Preferences;
|
||||||
|
import bisq.core.user.User;
|
||||||
|
import bisq.core.util.FormattingUtils;
|
||||||
|
import bisq.core.util.PriceUtil;
|
||||||
|
import bisq.core.util.coin.BsqFormatter;
|
||||||
|
import bisq.core.util.coin.CoinFormatter;
|
||||||
|
|
||||||
|
import bisq.network.p2p.P2PService;
|
||||||
|
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
|
import javax.inject.Named;
|
||||||
|
|
||||||
|
import javafx.collections.FXCollections;
|
||||||
|
import javafx.collections.ObservableList;
|
||||||
|
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public class OtherOfferBookViewModel extends OfferBookViewModel {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public OtherOfferBookViewModel(User user,
|
||||||
|
OpenOfferManager openOfferManager,
|
||||||
|
OfferBook offerBook,
|
||||||
|
Preferences preferences,
|
||||||
|
WalletsSetup walletsSetup,
|
||||||
|
P2PService p2PService,
|
||||||
|
PriceFeedService priceFeedService,
|
||||||
|
ClosedTradableManager closedTradableManager,
|
||||||
|
AccountAgeWitnessService accountAgeWitnessService,
|
||||||
|
Navigation navigation,
|
||||||
|
PriceUtil priceUtil,
|
||||||
|
OfferFilterService offerFilterService,
|
||||||
|
@Named(FormattingUtils.BTC_FORMATTER_KEY) CoinFormatter btcFormatter,
|
||||||
|
BsqFormatter bsqFormatter,
|
||||||
|
BsqWalletService bsqWalletService, CoreApi coreApi) {
|
||||||
|
super(user, openOfferManager, offerBook, preferences, walletsSetup, p2PService, priceFeedService, closedTradableManager, accountAgeWitnessService, navigation, priceUtil, offerFilterService, btcFormatter, bsqFormatter, bsqWalletService, coreApi);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void saveSelectedCurrencyCodeInPreferences(OfferDirection direction, String code) {
|
||||||
|
if (direction == OfferDirection.BUY) {
|
||||||
|
preferences.setBuyScreenCryptoCurrencyCode(code);
|
||||||
|
} else {
|
||||||
|
preferences.setSellScreenCryptoCurrencyCode(code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ObservableList<PaymentMethod> filterPaymentMethods(ObservableList<PaymentMethod> list,
|
||||||
|
TradeCurrency selectedTradeCurrency) {
|
||||||
|
return FXCollections.observableArrayList(list.stream().filter(PaymentMethod::isBlockchain).collect(Collectors.toList()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void fillCurrencies(ObservableList<TradeCurrency> tradeCurrencies,
|
||||||
|
ObservableList<TradeCurrency> allCurrencies) {
|
||||||
|
|
||||||
|
tradeCurrencies.add(new CryptoCurrency(GUIUtil.SHOW_ALL_FLAG, ""));
|
||||||
|
tradeCurrencies.addAll(preferences.getCryptoCurrenciesAsObservable().stream()
|
||||||
|
.filter(withoutBSQAndTopAltcoin())
|
||||||
|
.collect(Collectors.toList()));
|
||||||
|
tradeCurrencies.add(new CryptoCurrency(GUIUtil.EDIT_FLAG, ""));
|
||||||
|
|
||||||
|
allCurrencies.add(new CryptoCurrency(GUIUtil.SHOW_ALL_FLAG, ""));
|
||||||
|
allCurrencies.addAll(CurrencyUtil.getAllSortedCryptoCurrencies().stream()
|
||||||
|
.filter(withoutBSQAndTopAltcoin())
|
||||||
|
.collect(Collectors.toList()));
|
||||||
|
allCurrencies.add(new CryptoCurrency(GUIUtil.EDIT_FLAG, ""));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
Predicate<OfferBookListItem> getCurrencyAndMethodPredicate(OfferDirection direction,
|
||||||
|
TradeCurrency selectedTradeCurrency) {
|
||||||
|
return offerBookListItem -> {
|
||||||
|
Offer offer = offerBookListItem.getOffer();
|
||||||
|
// BUY Altcoin is actually SELL Bitcoin
|
||||||
|
boolean directionResult = offer.getDirection() == direction;
|
||||||
|
boolean currencyResult = CurrencyUtil.isCryptoCurrency(offer.getCurrencyCode()) &&
|
||||||
|
((showAllTradeCurrenciesProperty.get() &&
|
||||||
|
!offer.getCurrencyCode().equals(TopAltcoinOfferBookViewModel.TOP_ALTCOIN.getCode()) &&
|
||||||
|
!offer.getCurrencyCode().equals(BsqOfferBookViewModel.BSQ.getCode())) ||
|
||||||
|
offer.getCurrencyCode().equals(selectedTradeCurrency.getCode()));
|
||||||
|
boolean paymentMethodResult = showAllPaymentMethods ||
|
||||||
|
offer.getPaymentMethod().equals(selectedPaymentMethod);
|
||||||
|
boolean notMyOfferOrShowMyOffersActivated = !isMyOffer(offerBookListItem.getOffer()) || preferences.isShowOwnOffersInOfferBook();
|
||||||
|
return directionResult && currencyResult && paymentMethodResult && notMyOfferOrShowMyOffersActivated;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
String getCurrencyCodeFromPreferences(OfferDirection direction) {
|
||||||
|
return direction == OfferDirection.BUY ? preferences.getBuyScreenCryptoCurrencyCode() : preferences.getSellScreenCryptoCurrencyCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private Predicate<CryptoCurrency> withoutBSQAndTopAltcoin() {
|
||||||
|
return cryptoCurrency ->
|
||||||
|
!cryptoCurrency.equals(BsqOfferBookViewModel.BSQ) &&
|
||||||
|
!cryptoCurrency.equals(TopAltcoinOfferBookViewModel.TOP_ALTCOIN);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
~ This file is part of Bisq.
|
||||||
|
~
|
||||||
|
~ Bisq 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.
|
||||||
|
~
|
||||||
|
~ Bisq 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 Bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<?import javafx.scene.layout.ColumnConstraints?>
|
||||||
|
<?import javafx.scene.layout.GridPane?>
|
||||||
|
<GridPane fx:id="root" fx:controller="bisq.desktop.main.offer.offerbook.TopAltcoinOfferBookView"
|
||||||
|
hgap="5.0" vgap="5"
|
||||||
|
xmlns:fx="http://javafx.com/fxml">
|
||||||
|
|
||||||
|
<columnConstraints>
|
||||||
|
<ColumnConstraints halignment="RIGHT" hgrow="SOMETIMES" minWidth="200"/>
|
||||||
|
<ColumnConstraints hgrow="ALWAYS"/>
|
||||||
|
</columnConstraints>
|
||||||
|
</GridPane>
|
|
@ -0,0 +1,72 @@
|
||||||
|
/*
|
||||||
|
* This file is part of Bisq.
|
||||||
|
*
|
||||||
|
* Bisq 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.
|
||||||
|
*
|
||||||
|
* Bisq 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 Bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package bisq.desktop.main.offer.offerbook;
|
||||||
|
|
||||||
|
import bisq.desktop.Navigation;
|
||||||
|
import bisq.desktop.common.view.FxmlView;
|
||||||
|
import bisq.desktop.main.overlays.windows.BsqSwapOfferDetailsWindow;
|
||||||
|
import bisq.desktop.main.overlays.windows.OfferDetailsWindow;
|
||||||
|
|
||||||
|
import bisq.core.account.sign.SignedWitnessService;
|
||||||
|
import bisq.core.account.witness.AccountAgeWitnessService;
|
||||||
|
import bisq.core.alert.PrivateNotificationManager;
|
||||||
|
import bisq.core.locale.Res;
|
||||||
|
import bisq.core.offer.OfferDirection;
|
||||||
|
import bisq.core.util.FormattingUtils;
|
||||||
|
import bisq.core.util.coin.CoinFormatter;
|
||||||
|
|
||||||
|
import bisq.common.config.Config;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
|
|
||||||
|
import javafx.scene.layout.GridPane;
|
||||||
|
|
||||||
|
@FxmlView
|
||||||
|
public class TopAltcoinOfferBookView extends OfferBookView<GridPane, TopAltcoinOfferBookViewModel> {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
TopAltcoinOfferBookView(TopAltcoinOfferBookViewModel model,
|
||||||
|
Navigation navigation,
|
||||||
|
OfferDetailsWindow offerDetailsWindow,
|
||||||
|
BsqSwapOfferDetailsWindow bsqSwapOfferDetailsWindow,
|
||||||
|
@Named(FormattingUtils.BTC_FORMATTER_KEY) CoinFormatter formatter,
|
||||||
|
PrivateNotificationManager privateNotificationManager,
|
||||||
|
@Named(Config.USE_DEV_PRIVILEGE_KEYS) boolean useDevPrivilegeKeys,
|
||||||
|
AccountAgeWitnessService accountAgeWitnessService,
|
||||||
|
SignedWitnessService signedWitnessService) {
|
||||||
|
super(model, navigation, offerDetailsWindow, bsqSwapOfferDetailsWindow, formatter, privateNotificationManager, useDevPrivilegeKeys, accountAgeWitnessService, signedWitnessService);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getMarketTitle() {
|
||||||
|
return model.getDirection().equals(OfferDirection.BUY) ?
|
||||||
|
Res.get("offerbook.availableOffersToBuy", TopAltcoinOfferBookViewModel.TOP_ALTCOIN.getCode(), "BTC") :
|
||||||
|
Res.get("offerbook.availableOffersToSell", TopAltcoinOfferBookViewModel.TOP_ALTCOIN.getCode(), "BTC");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void activate() {
|
||||||
|
model.onSetTradeCurrency(TopAltcoinOfferBookViewModel.TOP_ALTCOIN);
|
||||||
|
|
||||||
|
super.activate();
|
||||||
|
|
||||||
|
currencyComboBoxContainer.setVisible(false);
|
||||||
|
currencyComboBoxContainer.setManaged(false);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,115 @@
|
||||||
|
/*
|
||||||
|
* This file is part of Bisq.
|
||||||
|
*
|
||||||
|
* Bisq 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.
|
||||||
|
*
|
||||||
|
* Bisq 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 Bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package bisq.desktop.main.offer.offerbook;
|
||||||
|
|
||||||
|
import bisq.desktop.Navigation;
|
||||||
|
|
||||||
|
import bisq.core.account.witness.AccountAgeWitnessService;
|
||||||
|
import bisq.core.api.CoreApi;
|
||||||
|
import bisq.core.btc.setup.WalletsSetup;
|
||||||
|
import bisq.core.btc.wallet.BsqWalletService;
|
||||||
|
import bisq.core.locale.CurrencyUtil;
|
||||||
|
import bisq.core.locale.TradeCurrency;
|
||||||
|
import bisq.core.offer.Offer;
|
||||||
|
import bisq.core.offer.OfferDirection;
|
||||||
|
import bisq.core.offer.OfferFilterService;
|
||||||
|
import bisq.core.offer.OpenOfferManager;
|
||||||
|
import bisq.core.payment.payload.PaymentMethod;
|
||||||
|
import bisq.core.provider.price.PriceFeedService;
|
||||||
|
import bisq.core.trade.ClosedTradableManager;
|
||||||
|
import bisq.core.user.Preferences;
|
||||||
|
import bisq.core.user.User;
|
||||||
|
import bisq.core.util.FormattingUtils;
|
||||||
|
import bisq.core.util.PriceUtil;
|
||||||
|
import bisq.core.util.coin.BsqFormatter;
|
||||||
|
import bisq.core.util.coin.CoinFormatter;
|
||||||
|
|
||||||
|
import bisq.network.p2p.P2PService;
|
||||||
|
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
|
import javax.inject.Named;
|
||||||
|
|
||||||
|
import javafx.collections.FXCollections;
|
||||||
|
import javafx.collections.ObservableList;
|
||||||
|
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class TopAltcoinOfferBookViewModel extends OfferBookViewModel {
|
||||||
|
|
||||||
|
public static final TradeCurrency TOP_ALTCOIN = CurrencyUtil.getTradeCurrency("XMR").get();
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public TopAltcoinOfferBookViewModel(User user,
|
||||||
|
OpenOfferManager openOfferManager,
|
||||||
|
OfferBook offerBook,
|
||||||
|
Preferences preferences,
|
||||||
|
WalletsSetup walletsSetup,
|
||||||
|
P2PService p2PService,
|
||||||
|
PriceFeedService priceFeedService,
|
||||||
|
ClosedTradableManager closedTradableManager,
|
||||||
|
AccountAgeWitnessService accountAgeWitnessService,
|
||||||
|
Navigation navigation,
|
||||||
|
PriceUtil priceUtil,
|
||||||
|
OfferFilterService offerFilterService,
|
||||||
|
@Named(FormattingUtils.BTC_FORMATTER_KEY) CoinFormatter btcFormatter,
|
||||||
|
BsqFormatter bsqFormatter,
|
||||||
|
BsqWalletService bsqWalletService,
|
||||||
|
CoreApi coreApi) {
|
||||||
|
super(user, openOfferManager, offerBook, preferences, walletsSetup, p2PService, priceFeedService, closedTradableManager, accountAgeWitnessService, navigation, priceUtil, offerFilterService, btcFormatter, bsqFormatter, bsqWalletService, coreApi);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void saveSelectedCurrencyCodeInPreferences(OfferDirection direction, String code) {
|
||||||
|
// No need to store anything as it is just one Altcoin offers anyway
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ObservableList<PaymentMethod> filterPaymentMethods(ObservableList<PaymentMethod> list,
|
||||||
|
TradeCurrency selectedTradeCurrency) {
|
||||||
|
return FXCollections.observableArrayList(list.stream().filter(PaymentMethod::isBlockchain).collect(Collectors.toList()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void fillCurrencies(ObservableList<TradeCurrency> tradeCurrencies,
|
||||||
|
ObservableList<TradeCurrency> allCurrencies) {
|
||||||
|
tradeCurrencies.add(TOP_ALTCOIN);
|
||||||
|
allCurrencies.add(TOP_ALTCOIN);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
Predicate<OfferBookListItem> getCurrencyAndMethodPredicate(OfferDirection direction,
|
||||||
|
TradeCurrency selectedTradeCurrency) {
|
||||||
|
return offerBookListItem -> {
|
||||||
|
Offer offer = offerBookListItem.getOffer();
|
||||||
|
// BUY Altcoin is actually SELL Bitcoin
|
||||||
|
boolean directionResult = offer.getDirection() == direction;
|
||||||
|
boolean currencyResult = offer.getCurrencyCode().equals(TOP_ALTCOIN.getCode());
|
||||||
|
boolean paymentMethodResult = showAllPaymentMethods ||
|
||||||
|
offer.getPaymentMethod().equals(selectedPaymentMethod);
|
||||||
|
boolean notMyOfferOrShowMyOffersActivated = !isMyOffer(offerBookListItem.getOffer()) || preferences.isShowOwnOffersInOfferBook();
|
||||||
|
return directionResult && currencyResult && paymentMethodResult && notMyOfferOrShowMyOffersActivated;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
String getCurrencyCodeFromPreferences(OfferDirection direction) {
|
||||||
|
return TOP_ALTCOIN.getCode();
|
||||||
|
}
|
||||||
|
}
|
|
@ -238,8 +238,8 @@ public class OfferBookViewModelTest {
|
||||||
|
|
||||||
when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems);
|
when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems);
|
||||||
|
|
||||||
final OfferBookViewModel model = new OfferBookViewModel(null, null, offerBook, empty, null, null, null,
|
final OfferBookViewModel model = new BtcOfferBookViewModel(null, null, offerBook, empty, null, null, null,
|
||||||
null, null, null, null, getPriceUtil(), null, coinFormatter, new BsqFormatter(), null, null);
|
null, null, null, getPriceUtil(), null, coinFormatter, new BsqFormatter(), null, null);
|
||||||
assertEquals(0, model.maxPlacesForAmount.intValue());
|
assertEquals(0, model.maxPlacesForAmount.intValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -252,8 +252,8 @@ public class OfferBookViewModelTest {
|
||||||
|
|
||||||
when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems);
|
when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems);
|
||||||
|
|
||||||
final OfferBookViewModel model = new OfferBookViewModel(null, openOfferManager, offerBook, empty, null, null, null,
|
final OfferBookViewModel model = new BtcOfferBookViewModel(null, openOfferManager, offerBook, empty, null, null, null,
|
||||||
null, null, null, null, getPriceUtil(), null, coinFormatter, new BsqFormatter(), null, null);
|
null, null, null, getPriceUtil(), null, coinFormatter, new BsqFormatter(), null, null);
|
||||||
model.activate();
|
model.activate();
|
||||||
|
|
||||||
assertEquals(6, model.maxPlacesForAmount.intValue());
|
assertEquals(6, model.maxPlacesForAmount.intValue());
|
||||||
|
@ -270,8 +270,8 @@ public class OfferBookViewModelTest {
|
||||||
|
|
||||||
when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems);
|
when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems);
|
||||||
|
|
||||||
final OfferBookViewModel model = new OfferBookViewModel(null, openOfferManager, offerBook, empty, null, null, null,
|
final OfferBookViewModel model = new BtcOfferBookViewModel(null, openOfferManager, offerBook, empty, null, null, null,
|
||||||
null, null, null, null, getPriceUtil(), null, coinFormatter, new BsqFormatter(), null, null);
|
null, null, null, getPriceUtil(), null, coinFormatter, new BsqFormatter(), null, null);
|
||||||
model.activate();
|
model.activate();
|
||||||
|
|
||||||
assertEquals(15, model.maxPlacesForAmount.intValue());
|
assertEquals(15, model.maxPlacesForAmount.intValue());
|
||||||
|
@ -289,8 +289,8 @@ public class OfferBookViewModelTest {
|
||||||
|
|
||||||
when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems);
|
when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems);
|
||||||
|
|
||||||
final OfferBookViewModel model = new OfferBookViewModel(null, null, offerBook, empty, null, null, null,
|
final OfferBookViewModel model = new BtcOfferBookViewModel(null, null, offerBook, empty, null, null, null,
|
||||||
null, null, null, null, getPriceUtil(), null, coinFormatter, new BsqFormatter(), null, null);
|
null, null, null, getPriceUtil(), null, coinFormatter, new BsqFormatter(), null, null);
|
||||||
assertEquals(0, model.maxPlacesForVolume.intValue());
|
assertEquals(0, model.maxPlacesForVolume.intValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -303,8 +303,8 @@ public class OfferBookViewModelTest {
|
||||||
|
|
||||||
when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems);
|
when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems);
|
||||||
|
|
||||||
final OfferBookViewModel model = new OfferBookViewModel(null, openOfferManager, offerBook, empty, null, null, null,
|
final OfferBookViewModel model = new BtcOfferBookViewModel(null, openOfferManager, offerBook, empty, null, null, null,
|
||||||
null, null, null, null, getPriceUtil(), null, coinFormatter, new BsqFormatter(), null, null);
|
null, null, null, getPriceUtil(), null, coinFormatter, new BsqFormatter(), null, null);
|
||||||
model.activate();
|
model.activate();
|
||||||
|
|
||||||
assertEquals(5, model.maxPlacesForVolume.intValue());
|
assertEquals(5, model.maxPlacesForVolume.intValue());
|
||||||
|
@ -321,8 +321,8 @@ public class OfferBookViewModelTest {
|
||||||
|
|
||||||
when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems);
|
when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems);
|
||||||
|
|
||||||
final OfferBookViewModel model = new OfferBookViewModel(null, openOfferManager, offerBook, empty, null, null, null,
|
final OfferBookViewModel model = new BtcOfferBookViewModel(null, openOfferManager, offerBook, empty, null, null, null,
|
||||||
null, null, null, null, getPriceUtil(), null, coinFormatter, new BsqFormatter(), null, null);
|
null, null, null, getPriceUtil(), null, coinFormatter, new BsqFormatter(), null, null);
|
||||||
model.activate();
|
model.activate();
|
||||||
|
|
||||||
assertEquals(9, model.maxPlacesForVolume.intValue());
|
assertEquals(9, model.maxPlacesForVolume.intValue());
|
||||||
|
@ -340,8 +340,8 @@ public class OfferBookViewModelTest {
|
||||||
|
|
||||||
when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems);
|
when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems);
|
||||||
|
|
||||||
final OfferBookViewModel model = new OfferBookViewModel(null, null, offerBook, empty, null, null, null,
|
final OfferBookViewModel model = new BtcOfferBookViewModel(null, null, offerBook, empty, null, null, null,
|
||||||
null, null, null, null, getPriceUtil(), null, coinFormatter, new BsqFormatter(), null, null);
|
null, null, null, getPriceUtil(), null, coinFormatter, new BsqFormatter(), null, null);
|
||||||
assertEquals(0, model.maxPlacesForPrice.intValue());
|
assertEquals(0, model.maxPlacesForPrice.intValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -354,8 +354,8 @@ public class OfferBookViewModelTest {
|
||||||
|
|
||||||
when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems);
|
when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems);
|
||||||
|
|
||||||
final OfferBookViewModel model = new OfferBookViewModel(null, openOfferManager, offerBook, empty, null, null, null,
|
final OfferBookViewModel model = new BtcOfferBookViewModel(null, openOfferManager, offerBook, empty, null, null, null,
|
||||||
null, null, null, null, getPriceUtil(), null, coinFormatter, new BsqFormatter(), null, null);
|
null, null, null, getPriceUtil(), null, coinFormatter, new BsqFormatter(), null, null);
|
||||||
model.activate();
|
model.activate();
|
||||||
|
|
||||||
assertEquals(7, model.maxPlacesForPrice.intValue());
|
assertEquals(7, model.maxPlacesForPrice.intValue());
|
||||||
|
@ -372,8 +372,8 @@ public class OfferBookViewModelTest {
|
||||||
|
|
||||||
when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems);
|
when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems);
|
||||||
|
|
||||||
final OfferBookViewModel model = new OfferBookViewModel(null, null, offerBook, empty, null, null, null,
|
final OfferBookViewModel model = new BtcOfferBookViewModel(null, null, offerBook, empty, null, null, null,
|
||||||
null, null, null, null, getPriceUtil(), null, coinFormatter, new BsqFormatter(), null, null);
|
null, null, null, getPriceUtil(), null, coinFormatter, new BsqFormatter(), null, null);
|
||||||
assertEquals(0, model.maxPlacesForMarketPriceMargin.intValue());
|
assertEquals(0, model.maxPlacesForMarketPriceMargin.intValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -407,8 +407,8 @@ public class OfferBookViewModelTest {
|
||||||
item4.getOffer().setPriceFeedService(priceFeedService);
|
item4.getOffer().setPriceFeedService(priceFeedService);
|
||||||
offerBookListItems.addAll(item1, item2);
|
offerBookListItems.addAll(item1, item2);
|
||||||
|
|
||||||
final OfferBookViewModel model = new OfferBookViewModel(null, openOfferManager, offerBook, empty, null, null, priceFeedService,
|
final OfferBookViewModel model = new BtcOfferBookViewModel(null, openOfferManager, offerBook, empty, null, null, priceFeedService,
|
||||||
null, null, null, null, getPriceUtil(), null, coinFormatter, new BsqFormatter(), null, null);
|
null, null, null, getPriceUtil(), null, coinFormatter, new BsqFormatter(), null, null);
|
||||||
model.activate();
|
model.activate();
|
||||||
|
|
||||||
assertEquals(8, model.maxPlacesForMarketPriceMargin.intValue()); //" (1.97%)"
|
assertEquals(8, model.maxPlacesForMarketPriceMargin.intValue()); //" (1.97%)"
|
||||||
|
@ -428,8 +428,8 @@ public class OfferBookViewModelTest {
|
||||||
when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems);
|
when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems);
|
||||||
when(priceFeedService.getMarketPrice(anyString())).thenReturn(new MarketPrice("USD", 12684.0450, Instant.now().getEpochSecond(), true));
|
when(priceFeedService.getMarketPrice(anyString())).thenReturn(new MarketPrice("USD", 12684.0450, Instant.now().getEpochSecond(), true));
|
||||||
|
|
||||||
final OfferBookViewModel model = new OfferBookViewModel(null, openOfferManager, offerBook, empty, null, null, null,
|
final OfferBookViewModel model = new BtcOfferBookViewModel(null, openOfferManager, offerBook, empty, null, null, null,
|
||||||
null, null, null, null, getPriceUtil(), null, coinFormatter, new BsqFormatter(), null, null);
|
null, null, null, getPriceUtil(), null, coinFormatter, new BsqFormatter(), null, null);
|
||||||
|
|
||||||
final OfferBookListItem item = make(btcBuyItem.but(
|
final OfferBookListItem item = make(btcBuyItem.but(
|
||||||
with(useMarketBasedPrice, true),
|
with(useMarketBasedPrice, true),
|
||||||
|
|
|
@ -1952,6 +1952,8 @@ message PreferencesPayload {
|
||||||
bool notify_on_pre_release = 61;
|
bool notify_on_pre_release = 61;
|
||||||
bool use_full_mode_dao_monitor = 62;
|
bool use_full_mode_dao_monitor = 62;
|
||||||
int32 clear_data_after_days = 63;
|
int32 clear_data_after_days = 63;
|
||||||
|
string buy_screen_crypto_currency_code = 64;
|
||||||
|
string sell_screen_crypto_currency_code = 65;
|
||||||
}
|
}
|
||||||
|
|
||||||
message AutoConfirmSettings {
|
message AutoConfirmSettings {
|
||||||
|
|
Loading…
Add table
Reference in a new issue