Search in sources :

Example 6 with Volume

use of bisq.core.monetary.Volume in project bisq-desktop by bisq-network.

the class ClosedTradesView method initialize.

@Override
public void initialize() {
    priceColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.price")));
    amountColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.amountWithCur", Res.getBaseCurrencyCode())));
    volumeColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.amount")));
    marketColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.market")));
    directionColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.offerType")));
    dateColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.dateTime")));
    tradeIdColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.tradeId")));
    stateColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.state")));
    avatarColumn.setText("");
    tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    tableView.setPlaceholder(new AutoTooltipLabel(Res.get("table.placeholder.noItems", Res.get("shared.trades"))));
    setTradeIdColumnCellFactory();
    setDirectionColumnCellFactory();
    setAmountColumnCellFactory();
    setPriceColumnCellFactory();
    setVolumeColumnCellFactory();
    setDateColumnCellFactory();
    setMarketColumnCellFactory();
    setStateColumnCellFactory();
    setAvatarColumnCellFactory();
    tradeIdColumn.setComparator(Comparator.comparing(o -> o.getTradable().getId()));
    dateColumn.setComparator(Comparator.comparing(o -> o.getTradable().getDate()));
    directionColumn.setComparator(Comparator.comparing(o -> o.getTradable().getOffer().getDirection()));
    marketColumn.setComparator(Comparator.comparing(model::getMarketLabel));
    priceColumn.setComparator((o1, o2) -> {
        final Tradable tradable1 = o1.getTradable();
        final Tradable tradable2 = o2.getTradable();
        Price price1 = null;
        Price price2 = null;
        if (tradable1 != null)
            price1 = tradable1 instanceof Trade ? ((Trade) tradable1).getTradePrice() : tradable1.getOffer().getPrice();
        if (tradable2 != null)
            price2 = tradable2 instanceof Trade ? ((Trade) tradable2).getTradePrice() : tradable2.getOffer().getPrice();
        return price1 != null && price2 != null ? price1.compareTo(price2) : 0;
    });
    volumeColumn.setComparator((o1, o2) -> {
        if (o1.getTradable() instanceof Trade && o2.getTradable() instanceof Trade) {
            Volume tradeVolume1 = ((Trade) o1.getTradable()).getTradeVolume();
            Volume tradeVolume2 = ((Trade) o2.getTradable()).getTradeVolume();
            return tradeVolume1 != null && tradeVolume2 != null ? tradeVolume1.compareTo(tradeVolume2) : 0;
        } else
            return 0;
    });
    amountColumn.setComparator((o1, o2) -> {
        if (o1.getTradable() instanceof Trade && o2.getTradable() instanceof Trade) {
            Coin amount1 = ((Trade) o1.getTradable()).getTradeAmount();
            Coin amount2 = ((Trade) o2.getTradable()).getTradeAmount();
            return amount1 != null && amount2 != null ? amount1.compareTo(amount2) : 0;
        } else
            return 0;
    });
    avatarColumn.setComparator((o1, o2) -> {
        if (o1.getTradable() instanceof Trade && o2.getTradable() instanceof Trade) {
            NodeAddress tradingPeerNodeAddress1 = ((Trade) o1.getTradable()).getTradingPeerNodeAddress();
            NodeAddress tradingPeerNodeAddress2 = ((Trade) o2.getTradable()).getTradingPeerNodeAddress();
            String address1 = tradingPeerNodeAddress1 != null ? tradingPeerNodeAddress1.getFullAddress() : "";
            String address2 = tradingPeerNodeAddress2 != null ? tradingPeerNodeAddress2.getFullAddress() : "";
            return address1 != null && address2 != null ? address1.compareTo(address2) : 0;
        } else
            return 0;
    });
    stateColumn.setComparator((o1, o2) -> model.getState(o1).compareTo(model.getState(o2)));
    dateColumn.setSortType(TableColumn.SortType.DESCENDING);
    tableView.getSortOrder().add(dateColumn);
    exportButton.setText(Res.get("shared.exportCSV"));
}
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) Trade(bisq.core.trade.Trade) Coin(org.bitcoinj.core.Coin) Price(bisq.core.monetary.Price) Volume(bisq.core.monetary.Volume) Tradable(bisq.core.trade.Tradable) NodeAddress(bisq.network.p2p.NodeAddress) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel)

Example 7 with Volume

use of bisq.core.monetary.Volume in project bisq-desktop by bisq-network.

the class OpenOffersView method initialize.

@Override
public void initialize() {
    priceColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.price")));
    amountColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.BTCMinMax")));
    volumeColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.amountMinMax")));
    marketColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.market")));
    directionColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.offerType")));
    dateColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.dateTime")));
    offerIdColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.offerId")));
    deactivateItemColumn.setGraphic(new AutoTooltipLabel(""));
    removeItemColumn.setGraphic(new AutoTooltipLabel(""));
    setOfferIdColumnCellFactory();
    setDirectionColumnCellFactory();
    setMarketColumnCellFactory();
    setPriceColumnCellFactory();
    setAmountColumnCellFactory();
    setVolumeColumnCellFactory();
    setDateColumnCellFactory();
    setDeactivateColumnCellFactory();
    setRemoveColumnCellFactory();
    tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    tableView.setPlaceholder(new AutoTooltipLabel(Res.get("table.placeholder.noItems", Res.get("shared.openOffers"))));
    offerIdColumn.setComparator((o1, o2) -> o1.getOffer().getId().compareTo(o2.getOffer().getId()));
    directionColumn.setComparator((o1, o2) -> o1.getOffer().getDirection().compareTo(o2.getOffer().getDirection()));
    marketColumn.setComparator((o1, o2) -> model.getMarketLabel(o1).compareTo(model.getMarketLabel(o2)));
    amountColumn.setComparator((o1, o2) -> o1.getOffer().getAmount().compareTo(o2.getOffer().getAmount()));
    priceColumn.setComparator((o1, o2) -> {
        Price price1 = o1.getOffer().getPrice();
        Price price2 = o2.getOffer().getPrice();
        return price1 != null && price2 != null ? price1.compareTo(price2) : 0;
    });
    volumeColumn.setComparator((o1, o2) -> {
        Volume offerVolume1 = o1.getOffer().getVolume();
        Volume offerVolume2 = o2.getOffer().getVolume();
        return offerVolume1 != null && offerVolume2 != null ? offerVolume1.compareTo(offerVolume2) : 0;
    });
    dateColumn.setComparator((o1, o2) -> o1.getOffer().getDate().compareTo(o2.getOffer().getDate()));
    dateColumn.setSortType(TableColumn.SortType.DESCENDING);
    tableView.getSortOrder().add(dateColumn);
}
Also used : Price(bisq.core.monetary.Price) Volume(bisq.core.monetary.Volume) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel)

Aggregations

Volume (bisq.core.monetary.Volume)7 Offer (bisq.core.offer.Offer)4 AutoTooltipLabel (bisq.desktop.components.AutoTooltipLabel)4 Price (bisq.core.monetary.Price)3 PrivateNotificationManager (bisq.core.alert.PrivateNotificationManager)2 AppOptionKeys (bisq.core.app.AppOptionKeys)2 Res (bisq.core.locale.Res)2 VolumeMaker.usdVolume (bisq.core.monetary.VolumeMaker.usdVolume)2 OfferMaker.btcUsdOffer (bisq.core.offer.OfferMaker.btcUsdOffer)2 ActivatableViewAndModel (bisq.desktop.common.view.ActivatableViewAndModel)2 FxmlView (bisq.desktop.common.view.FxmlView)2 AutoTooltipTableColumn (bisq.desktop.components.AutoTooltipTableColumn)2 ColoredDecimalPlacesWithZerosText (bisq.desktop.components.ColoredDecimalPlacesWithZerosText)2 HyperlinkWithIcon (bisq.desktop.components.HyperlinkWithIcon)2 PeerInfoIcon (bisq.desktop.components.PeerInfoIcon)2 OfferDetailsWindow (bisq.desktop.main.overlays.windows.OfferDetailsWindow)2 BSFormatter (bisq.desktop.util.BSFormatter)2 TableCell (javafx.scene.control.TableCell)2 TableColumn (javafx.scene.control.TableColumn)2 Tuple3 (bisq.common.util.Tuple3)1