Search in sources :

Example 16 with Trade

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);
                    }
                }
            };
        }
    });
}
Also used : Button(javafx.scene.control.Button) GUIUtil(bisq.desktop.util.GUIUtil) OfferDetailsWindow(bisq.desktop.main.overlays.windows.OfferDetailsWindow) OpenOffer(bisq.core.offer.OpenOffer) HyperlinkWithIcon(bisq.desktop.components.HyperlinkWithIcon) Coin(org.bitcoinj.core.Coin) Tradable(bisq.core.trade.Tradable) CSVEntryConverter(com.googlecode.jcsv.writer.CSVEntryConverter) VBox(javafx.scene.layout.VBox) Volume(bisq.core.monetary.Volume) FxmlView(bisq.desktop.common.view.FxmlView) BSFormatter(bisq.desktop.util.BSFormatter) TableColumn(javafx.scene.control.TableColumn) Inject(javax.inject.Inject) TableCell(javafx.scene.control.TableCell) Insets(javafx.geometry.Insets) ReadOnlyObjectWrapper(javafx.beans.property.ReadOnlyObjectWrapper) Res(bisq.core.locale.Res) TableView(javafx.scene.control.TableView) Callback(javafx.util.Callback) Tooltip(javafx.scene.control.Tooltip) PrivateNotificationManager(bisq.core.alert.PrivateNotificationManager) SortedList(javafx.collections.transformation.SortedList) Offer(bisq.core.offer.Offer) TradeDetailsWindow(bisq.desktop.main.overlays.windows.TradeDetailsWindow) Trade(bisq.core.trade.Trade) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) Node(javafx.scene.Node) PeerInfoIcon(bisq.desktop.components.PeerInfoIcon) FXML(javafx.fxml.FXML) Stage(javafx.stage.Stage) NodeAddress(bisq.network.p2p.NodeAddress) AppOptionKeys(bisq.core.app.AppOptionKeys) Preferences(bisq.core.user.Preferences) Price(bisq.core.monetary.Price) Named(com.google.inject.name.Named) ObservableList(javafx.collections.ObservableList) ActivatableViewAndModel(bisq.desktop.common.view.ActivatableViewAndModel) Comparator(java.util.Comparator) Tradable(bisq.core.trade.Tradable) OpenOffer(bisq.core.offer.OpenOffer) Tooltip(javafx.scene.control.Tooltip) TableColumn(javafx.scene.control.TableColumn) Trade(bisq.core.trade.Trade) TableCell(javafx.scene.control.TableCell) HyperlinkWithIcon(bisq.desktop.components.HyperlinkWithIcon)

Example 17 with Trade

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;
}
Also used : Insets(javafx.geometry.Insets) Node(javafx.scene.Node) PeerInfoIcon(bisq.desktop.components.PeerInfoIcon) TableColumn(javafx.scene.control.TableColumn) Trade(bisq.core.trade.Trade) TableCell(javafx.scene.control.TableCell) Offer(bisq.core.offer.Offer) NodeAddress(bisq.network.p2p.NodeAddress)

Example 18 with Trade

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 "";
    }
}
Also used : Trade(bisq.core.trade.Trade) Offer(bisq.core.offer.Offer) Contract(bisq.core.trade.Contract)

Example 19 with Trade

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);
        }
    }
}
Also used : Trade(bisq.core.trade.Trade) Date(java.util.Date)

Example 20 with Trade

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);
        }
    });
}
Also used : Trade(bisq.core.trade.Trade)

Aggregations

Trade (bisq.core.trade.Trade)20 Coin (org.bitcoinj.core.Coin)8 Res (bisq.core.locale.Res)7 Offer (bisq.core.offer.Offer)7 OpenOffer (bisq.core.offer.OpenOffer)6 Preferences (bisq.core.user.Preferences)6 Popup (bisq.desktop.main.overlays.popups.Popup)6 GUIUtil (bisq.desktop.util.GUIUtil)6 ObservableList (javafx.collections.ObservableList)6 PrivateNotificationManager (bisq.core.alert.PrivateNotificationManager)5 AppOptionKeys (bisq.core.app.AppOptionKeys)5 DisputeManager (bisq.core.arbitration.DisputeManager)5 TradeManager (bisq.core.trade.TradeManager)5 Dispute (bisq.core.arbitration.Dispute)4 BuyerTrade (bisq.core.trade.BuyerTrade)4 SellerTrade (bisq.core.trade.SellerTrade)4 List (java.util.List)4 ListChangeListener (javafx.collections.ListChangeListener)4 Nullable (javax.annotation.Nullable)4 Transaction (org.bitcoinj.core.Transaction)4