mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 09:52:23 +01:00
Add deposit column to OfferBookView
This commit is contained in:
parent
a54eeeabcc
commit
3121f6f2fe
@ -357,6 +357,8 @@ shared.notSigned.noNeed=This account type doesn't use signing
|
||||
|
||||
offerbook.nrOffers=No. of offers: {0}
|
||||
offerbook.volume={0} (min - max)
|
||||
offerbook.deposit=Deposit
|
||||
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.createOfferToSell=Create new offer to sell {0}
|
||||
|
@ -38,7 +38,6 @@ import bisq.desktop.main.offer.OfferView;
|
||||
import bisq.desktop.main.overlays.popups.Popup;
|
||||
import bisq.desktop.main.overlays.windows.OfferDetailsWindow;
|
||||
import bisq.desktop.util.CssTheme;
|
||||
import bisq.desktop.util.DisplayUtils;
|
||||
import bisq.desktop.util.FormBuilder;
|
||||
import bisq.desktop.util.GUIUtil;
|
||||
import bisq.desktop.util.Layout;
|
||||
@ -130,7 +129,7 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
|
||||
private AutocompleteComboBox<PaymentMethod> paymentMethodComboBox;
|
||||
private AutoTooltipButton createOfferButton;
|
||||
private AutoTooltipTableColumn<OfferBookListItem, OfferBookListItem> amountColumn, volumeColumn, marketColumn,
|
||||
priceColumn, paymentMethodColumn, signingStateColumn, avatarColumn;
|
||||
priceColumn, paymentMethodColumn, depositColumn, signingStateColumn, avatarColumn;
|
||||
private TableView<OfferBookListItem> tableView;
|
||||
|
||||
private OfferView.OfferActionHandler offerActionHandler;
|
||||
@ -224,6 +223,8 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
|
||||
tableView.getColumns().add(volumeColumn);
|
||||
paymentMethodColumn = getPaymentMethodColumn();
|
||||
tableView.getColumns().add(paymentMethodColumn);
|
||||
depositColumn = getDepositColumn();
|
||||
tableView.getColumns().add(depositColumn);
|
||||
signingStateColumn = getSigningStateColumn();
|
||||
tableView.getColumns().add(signingStateColumn);
|
||||
avatarColumn = getAvatarColumn();
|
||||
@ -927,6 +928,52 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
|
||||
return column;
|
||||
}
|
||||
|
||||
|
||||
private AutoTooltipTableColumn<OfferBookListItem, OfferBookListItem> getDepositColumn() {
|
||||
AutoTooltipTableColumn<OfferBookListItem, OfferBookListItem> column = new AutoTooltipTableColumn<>(
|
||||
Res.get("offerbook.deposit"),
|
||||
Res.get("offerbook.deposit.help")) {
|
||||
{
|
||||
setMinWidth(70);
|
||||
setSortable(true);
|
||||
}
|
||||
};
|
||||
|
||||
column.getStyleClass().add("number-column");
|
||||
column.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
|
||||
column.setCellFactory(
|
||||
new Callback<>() {
|
||||
@Override
|
||||
public TableCell<OfferBookListItem, OfferBookListItem> call(
|
||||
TableColumn<OfferBookListItem, OfferBookListItem> column) {
|
||||
return new TableCell<>() {
|
||||
@Override
|
||||
public void updateItem(final OfferBookListItem item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (item != null && !empty) {
|
||||
var isSellOffer = item.getOffer().getDirection() == OfferPayload.Direction.SELL;
|
||||
var deposit = isSellOffer ? item.getOffer().getBuyerSecurityDeposit() :
|
||||
item.getOffer().getSellerSecurityDeposit();
|
||||
if (deposit == null) {
|
||||
setText(Res.get("shared.na"));
|
||||
setGraphic(null);
|
||||
} else {
|
||||
setText("");
|
||||
setGraphic(new ColoredDecimalPlacesWithZerosText(model.formatDepositString(
|
||||
deposit, item.getOffer().getAmount().getValue()),
|
||||
GUIUtil.AMOUNT_DECIMALS_WITH_ZEROS));
|
||||
}
|
||||
} else {
|
||||
setText("");
|
||||
setGraphic(null);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
return column;
|
||||
}
|
||||
|
||||
private TableColumn<OfferBookListItem, OfferBookListItem> getActionColumn() {
|
||||
TableColumn<OfferBookListItem, OfferBookListItem> column = new AutoTooltipTableColumn<>(Res.get("shared.actions")) {
|
||||
{
|
||||
|
@ -47,8 +47,8 @@ import bisq.core.trade.Trade;
|
||||
import bisq.core.trade.closed.ClosedTradableManager;
|
||||
import bisq.core.user.Preferences;
|
||||
import bisq.core.user.User;
|
||||
import bisq.core.util.coin.BsqFormatter;
|
||||
import bisq.core.util.FormattingUtils;
|
||||
import bisq.core.util.coin.BsqFormatter;
|
||||
import bisq.core.util.coin.CoinFormatter;
|
||||
|
||||
import bisq.network.p2p.NodeAddress;
|
||||
@ -168,9 +168,7 @@ class OfferBookViewModel extends ActivatableViewModel {
|
||||
this.filteredItems = new FilteredList<>(offerBook.getOfferBookListItems());
|
||||
this.sortedItems = new SortedList<>(filteredItems);
|
||||
|
||||
tradeCurrencyListChangeListener = c -> {
|
||||
fillAllTradeCurrencies();
|
||||
};
|
||||
tradeCurrencyListChangeListener = c -> fillAllTradeCurrencies();
|
||||
|
||||
filterItemsListener = c -> {
|
||||
final Optional<OfferBookListItem> highestAmountOffer = filteredItems.stream()
|
||||
@ -645,4 +643,9 @@ class OfferBookViewModel extends ActivatableViewModel {
|
||||
else
|
||||
return (direction == OfferPayload.Direction.SELL) ? Res.get("shared.buyingCurrency", currencyCode) : Res.get("shared.sellingCurrency", currencyCode);
|
||||
}
|
||||
|
||||
public String formatDepositString(Coin deposit, long amount) {
|
||||
return btcFormatter.formatCoinWithCode(deposit) + " (" + deposit.getValue() / (double) amount + "%)";
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user