use of bisq.core.trade.Trade in project bisq-desktop by bisq-network.
the class ClosedTradesView method setTradeIdColumnCellFactory.
private void setTradeIdColumnCellFactory() {
tradeIdColumn.setCellValueFactory((offerListItem) -> new ReadOnlyObjectWrapper<>(offerListItem.getValue()));
tradeIdColumn.setCellFactory(new Callback<TableColumn<ClosedTradableListItem, ClosedTradableListItem>, TableCell<ClosedTradableListItem, ClosedTradableListItem>>() {
@Override
public TableCell<ClosedTradableListItem, ClosedTradableListItem> call(TableColumn<ClosedTradableListItem, ClosedTradableListItem> column) {
return new TableCell<ClosedTradableListItem, ClosedTradableListItem>() {
private HyperlinkWithIcon field;
@Override
public void updateItem(final ClosedTradableListItem item, boolean empty) {
super.updateItem(item, empty);
if (item != null && !empty) {
field = new HyperlinkWithIcon(model.getTradeId(item));
field.setOnAction(event -> {
Tradable tradable = item.getTradable();
if (tradable instanceof Trade)
tradeDetailsWindow.show((Trade) tradable);
else if (tradable instanceof OpenOffer)
offerDetailsWindow.show(tradable.getOffer());
});
field.setTooltip(new Tooltip(Res.get("tooltip.openPopupForDetails")));
setGraphic(field);
} else {
setGraphic(null);
if (field != null)
field.setOnAction(null);
}
}
};
}
});
}
use of bisq.core.trade.Trade in project bisq-desktop by bisq-network.
the class PendingTradesView method setAvatarColumnCellFactory.
@SuppressWarnings("UnusedReturnValue")
private TableColumn<PendingTradesListItem, PendingTradesListItem> setAvatarColumnCellFactory() {
avatarColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
avatarColumn.setCellFactory(new Callback<TableColumn<PendingTradesListItem, PendingTradesListItem>, TableCell<PendingTradesListItem, PendingTradesListItem>>() {
@Override
public TableCell<PendingTradesListItem, PendingTradesListItem> call(TableColumn<PendingTradesListItem, PendingTradesListItem> column) {
return new TableCell<PendingTradesListItem, PendingTradesListItem>() {
@Override
public void updateItem(final PendingTradesListItem newItem, boolean empty) {
super.updateItem(newItem, empty);
if (!empty && newItem != null) {
final Trade trade = newItem.getTrade();
final NodeAddress tradingPeerNodeAddress = trade.getTradingPeerNodeAddress();
int numPastTrades = model.getNumPastTrades(trade);
final Offer offer = trade.getOffer();
String role = Res.get("peerInfoIcon.tooltip.tradePeer");
Node peerInfoIcon = new PeerInfoIcon(tradingPeerNodeAddress, role, numPastTrades, privateNotificationManager, offer, preferences, model.accountAgeWitnessService, formatter, useDevPrivilegeKeys);
setPadding(new Insets(1, 0, 0, 0));
setGraphic(peerInfoIcon);
} else {
setGraphic(null);
}
}
};
}
});
return avatarColumn;
}
use of bisq.core.trade.Trade in project bisq-desktop by bisq-network.
the class PendingTradesViewModel method getMyRole.
//
String getMyRole(PendingTradesListItem item) {
Trade trade = item.getTrade();
Contract contract = trade.getContract();
if (contract != null) {
Offer offer = trade.getOffer();
return btcFormatter.getRole(contract.isBuyerMakerAndSellerTaker(), dataModel.isMaker(offer), offer.getCurrencyCode());
} else {
return "";
}
}
use of bisq.core.trade.Trade in project bisq-core by bisq-network.
the class TradeStatisticsManager method publishTradeStatistics.
public void publishTradeStatistics(List<Trade> trades) {
for (int i = 0; i < trades.size(); i++) {
Trade trade = trades.get(i);
TradeStatistics2 tradeStatistics = new TradeStatistics2(trade.getOffer().getOfferPayload(), trade.getTradePrice(), trade.getTradeAmount(), trade.getDate(), (trade.getDepositTx() != null ? trade.getDepositTx().getHashAsString() : ""));
addToMap(tradeStatistics, true);
// We only republish trades from last 10 days
if ((new Date().getTime() - trade.getDate().getTime()) < TimeUnit.DAYS.toMillis(10)) {
long delay = 5000;
long minDelay = (i + 1) * delay;
long maxDelay = (i + 2) * delay;
UserThread.runAfterRandomDelay(() -> {
p2PService.addPersistableNetworkPayload(tradeStatistics, true);
}, minDelay, maxDelay, TimeUnit.MILLISECONDS);
}
}
}
use of bisq.core.trade.Trade in project bisq-core by bisq-network.
the class ClosedTradableManager method readPersisted.
@Override
public void readPersisted() {
closedTradables = new TradableList<>(tradableListStorage, "ClosedTrades");
closedTradables.forEach(tradable -> {
tradable.getOffer().setPriceFeedService(priceFeedService);
if (tradable instanceof Trade) {
Trade trade = (Trade) tradable;
trade.setTransientFields(tradableListStorage, btcWalletService);
}
});
}
Aggregations