Search in sources :

Example 1 with WalletEventListener

use of org.bitcoinj.wallet.listeners.WalletEventListener in project bisq-desktop by bisq-network.

the class TransactionsView method initialize.

@Override
public void initialize() {
    dateColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.dateTime")));
    detailsColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.details")));
    addressColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.address")));
    transactionColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.txId", Res.getBaseCurrencyCode())));
    amountColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.amountWithCur", Res.getBaseCurrencyCode())));
    confidenceColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.confirmations", Res.getBaseCurrencyCode())));
    revertTxColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.revert", Res.getBaseCurrencyCode())));
    tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    tableView.setPlaceholder(new AutoTooltipLabel(Res.get("funds.tx.noTxAvailable")));
    setDateColumnCellFactory();
    setDetailsColumnCellFactory();
    setAddressColumnCellFactory();
    setTransactionColumnCellFactory();
    setAmountColumnCellFactory();
    setConfidenceColumnCellFactory();
    setRevertTxColumnCellFactory();
    dateColumn.setComparator(Comparator.comparing(TransactionsListItem::getDate));
    detailsColumn.setComparator((o1, o2) -> {
        String id1 = o1.getTradable() != null ? o1.getTradable().getId() : o1.getDetails();
        String id2 = o2.getTradable() != null ? o2.getTradable().getId() : o2.getDetails();
        return id1.compareTo(id2);
    });
    addressColumn.setComparator(Comparator.comparing(TransactionsListItem::getAddressString));
    transactionColumn.setComparator(Comparator.comparing(TransactionsListItem::getTxId));
    amountColumn.setComparator(Comparator.comparing(TransactionsListItem::getAmountAsCoin));
    confidenceColumn.setComparator(Comparator.comparingDouble(item -> item.getTxConfidenceIndicator().getProgress()));
    dateColumn.setSortType(TableColumn.SortType.DESCENDING);
    tableView.getSortOrder().add(dateColumn);
    // noinspection deprecation
    walletEventListener = new WalletEventListener() {

        @Override
        public void onCoinsReceived(Wallet wallet, Transaction tx, Coin prevBalance, Coin newBalance) {
            displayedTransactions.update();
        }

        @Override
        public void onCoinsSent(Wallet wallet, Transaction tx, Coin prevBalance, Coin newBalance) {
            displayedTransactions.update();
        }

        @Override
        public void onReorganize(Wallet wallet) {
            displayedTransactions.update();
        }

        @Override
        public void onTransactionConfidenceChanged(Wallet wallet, Transaction tx) {
        }

        @Override
        public void onWalletChanged(Wallet wallet) {
            displayedTransactions.update();
        }

        @Override
        public void onScriptsChanged(Wallet wallet, List<Script> scripts, boolean isAddingScripts) {
            displayedTransactions.update();
        }

        @Override
        public void onKeysAdded(List<ECKey> keys) {
            displayedTransactions.update();
        }
    };
    keyEventEventHandler = event -> {
        if (Utilities.isAltOrCtrlPressed(KeyCode.R, event))
            revertTxColumn.setVisible(!revertTxColumn.isVisible());
        else if (Utilities.isAltOrCtrlPressed(KeyCode.A, event))
            showStatisticsPopup();
    };
    exportButton.setText(Res.get("shared.exportCSV"));
}
Also used : Button(javafx.scene.control.Button) EventHandler(javafx.event.EventHandler) Transaction(org.bitcoinj.core.Transaction) OpenOffer(bisq.core.offer.OpenOffer) Utilities(bisq.common.util.Utilities) HyperlinkWithIcon(bisq.desktop.components.HyperlinkWithIcon) Coin(org.bitcoinj.core.Coin) Date(java.util.Date) CSVEntryConverter(com.googlecode.jcsv.writer.CSVEntryConverter) VBox(javafx.scene.layout.VBox) BSFormatter(bisq.desktop.util.BSFormatter) ReadOnlyObjectWrapper(javafx.beans.property.ReadOnlyObjectWrapper) Res(bisq.core.locale.Res) Locale(java.util.Locale) Map(java.util.Map) TableView(javafx.scene.control.TableView) DateFormat(java.text.DateFormat) SortedList(javafx.collections.transformation.SortedList) Popup(bisq.desktop.main.overlays.popups.Popup) P2PService(bisq.network.p2p.P2PService) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) KeyEvent(javafx.scene.input.KeyEvent) Collectors(java.util.stream.Collectors) ECKey(org.bitcoinj.core.ECKey) FXML(javafx.fxml.FXML) List(java.util.List) Script(org.bitcoinj.script.Script) WalletsSetup(bisq.core.btc.wallet.WalletsSetup) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) Preferences(bisq.core.user.Preferences) ObservableList(javafx.collections.ObservableList) AwesomeIcon(de.jensd.fx.fontawesome.AwesomeIcon) GUIUtil(bisq.desktop.util.GUIUtil) BtcWalletService(bisq.core.btc.wallet.BtcWalletService) Scene(javafx.scene.Scene) WalletEventListener(org.bitcoinj.wallet.listeners.WalletEventListener) ActivatableView(bisq.desktop.common.view.ActivatableView) TransactionConfidence(org.bitcoinj.core.TransactionConfidence) OfferDetailsWindow(bisq.desktop.main.overlays.windows.OfferDetailsWindow) Wallet(org.bitcoinj.wallet.Wallet) HashMap(java.util.HashMap) Tradable(bisq.core.trade.Tradable) FxmlView(bisq.desktop.common.view.FxmlView) TableColumn(javafx.scene.control.TableColumn) ArrayList(java.util.ArrayList) Tuple4(bisq.common.util.Tuple4) Inject(javax.inject.Inject) Tuple2(bisq.common.util.Tuple2) TableCell(javafx.scene.control.TableCell) AddressWithIconAndDirection(bisq.desktop.components.AddressWithIconAndDirection) Callback(javafx.util.Callback) Tooltip(javafx.scene.control.Tooltip) Nullable(javax.annotation.Nullable) KeyCode(javafx.scene.input.KeyCode) TradeDetailsWindow(bisq.desktop.main.overlays.windows.TradeDetailsWindow) Trade(bisq.core.trade.Trade) Stage(javafx.stage.Stage) Comparator(java.util.Comparator) Script(org.bitcoinj.script.Script) Wallet(org.bitcoinj.wallet.Wallet) ECKey(org.bitcoinj.core.ECKey) Coin(org.bitcoinj.core.Coin) WalletEventListener(org.bitcoinj.wallet.listeners.WalletEventListener) Transaction(org.bitcoinj.core.Transaction) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel)

Aggregations

Tuple2 (bisq.common.util.Tuple2)1 Tuple4 (bisq.common.util.Tuple4)1 Utilities (bisq.common.util.Utilities)1 BtcWalletService (bisq.core.btc.wallet.BtcWalletService)1 WalletsSetup (bisq.core.btc.wallet.WalletsSetup)1 Res (bisq.core.locale.Res)1 OpenOffer (bisq.core.offer.OpenOffer)1 Tradable (bisq.core.trade.Tradable)1 Trade (bisq.core.trade.Trade)1 Preferences (bisq.core.user.Preferences)1 ActivatableView (bisq.desktop.common.view.ActivatableView)1 FxmlView (bisq.desktop.common.view.FxmlView)1 AddressWithIconAndDirection (bisq.desktop.components.AddressWithIconAndDirection)1 AutoTooltipButton (bisq.desktop.components.AutoTooltipButton)1 AutoTooltipLabel (bisq.desktop.components.AutoTooltipLabel)1 HyperlinkWithIcon (bisq.desktop.components.HyperlinkWithIcon)1 Popup (bisq.desktop.main.overlays.popups.Popup)1 OfferDetailsWindow (bisq.desktop.main.overlays.windows.OfferDetailsWindow)1 TradeDetailsWindow (bisq.desktop.main.overlays.windows.TradeDetailsWindow)1 BSFormatter (bisq.desktop.util.BSFormatter)1