Java Code Examples for org.fxmisc.easybind.EasyBind#subscribe()

The following examples show how to use org.fxmisc.easybind.EasyBind#subscribe() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PendingTradesViewModel.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
public void onSelectedItemChanged(PendingTradesListItem selectedItem) {
    if (tradeStateSubscription != null) {
        tradeStateSubscription.unsubscribe();
        sellerState.set(SellerState.UNDEFINED);
        buyerState.set(BuyerState.UNDEFINED);
    }

    if (messageStateSubscription != null) {
        messageStateSubscription.unsubscribe();
        messageStateProperty.set(MessageState.UNDEFINED);
    }

    if (selectedItem != null) {
        this.trade = selectedItem.getTrade();
        tradeStateSubscription = EasyBind.subscribe(trade.stateProperty(), this::onTradeStateChanged);

        messageStateSubscription = EasyBind.subscribe(trade.getProcessModel().getPaymentStartedMessageStateProperty(), this::onMessageStateChanged);
    }
}
 
Example 2
Source File: DepositView.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
protected void activate() {
    tableView.getSelectionModel().selectedItemProperty().addListener(tableViewSelectionListener);
    sortedList.comparatorProperty().bind(tableView.comparatorProperty());

    updateList();

    walletService.addBalanceListener(balanceListener);
    amountTextFieldSubscription = EasyBind.subscribe(amountTextField.textProperty(), t -> {
        addressTextField.setAmountAsCoin(ParsingUtils.parseToCoin(t, formatter));
        updateQRCode();
    });

    if (tableView.getSelectionModel().getSelectedItem() == null && !sortedList.isEmpty())
        tableView.getSelectionModel().select(0);
}
 
Example 3
Source File: StateMonitorView.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
protected void activate() {
    selectedItemSubscription = EasyBind.subscribe(tableView.getSelectionModel().selectedItemProperty(), this::onSelectItem);

    sortedList.comparatorProperty().bind(tableView.comparatorProperty());
    sortedConflictList.comparatorProperty().bind(conflictTableView.comparatorProperty());

    daoStateService.addDaoStateListener(this);

    resyncButton.visibleProperty().bind(isInConflictWithSeedNode);
    resyncButton.managedProperty().bind(isInConflictWithSeedNode);

    resyncButton.setOnAction(ev -> resyncDaoState());

    if (daoStateService.isParseBlockChainComplete()) {
        onDataUpdate();
    }

    GUIUtil.setFitToRowsForTableView(tableView, 25, 28, 2, 5);
    GUIUtil.setFitToRowsForTableView(conflictTableView, 38, 28, 2, 4);
}
 
Example 4
Source File: VoteResultView.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
protected void activate() {
    super.activate();

    phasesView.activate();

    daoFacade.addBsqStateListener(this);
    cyclesTableView.getSelectionModel().selectedItemProperty().addListener(selectedVoteResultListItemListener);

    if (daoStateService.isParseBlockChainComplete()) {
        checkForResultPhase(daoStateService.getChainHeight());
        fillCycleList();
    }

    exportButton.setOnAction(event -> {
        JsonElement cyclesJsonArray = getVotingHistoryJson();
        GUIUtil.exportJSON("voteResultsHistory.json", cyclesJsonArray, (Stage) root.getScene().getWindow());
    });
    if (proposalsTableView != null) {
        GUIUtil.setFitToRowsForTableView(proposalsTableView, 25, 28, 6, 6);

        selectedProposalSubscription = EasyBind.subscribe(proposalsTableView.getSelectionModel().selectedItemProperty(),
                this::onSelectProposalResultListItem);
    }
    GUIUtil.setFitToRowsForTableView(cyclesTableView, 25, 28, 6, 6);
}
 
Example 5
Source File: BuyerSetupPayoutTxListener.java    From bisq-core with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected void run() {
    try {
        runInterceptHook();
        if (!trade.isPayoutPublished()) {
            BtcWalletService walletService = processModel.getBtcWalletService();
            final String id = processModel.getOffer().getId();
            Address address = walletService.getOrCreateAddressEntry(id, AddressEntry.Context.TRADE_PAYOUT).getAddress();

            final TransactionConfidence confidence = walletService.getConfidenceForAddress(address);
            if (isInNetwork(confidence)) {
                applyConfidence(confidence);
            } else {
                confidenceListener = new AddressConfidenceListener(address) {
                    @Override
                    public void onTransactionConfidenceChanged(TransactionConfidence confidence) {
                        if (isInNetwork(confidence))
                            applyConfidence(confidence);
                    }
                };
                walletService.addAddressConfidenceListener(confidenceListener);

                tradeStateSubscription = EasyBind.subscribe(trade.stateProperty(), newValue -> {
                    if (trade.isPayoutPublished()) {
                        swapMultiSigEntry();

                        // hack to remove tradeStateSubscription at callback
                        UserThread.execute(this::unSubscribe);
                    }
                });
            }
        }

        // we complete immediately, our object stays alive because the balanceListener is stored in the WalletService
        complete();
    } catch (Throwable t) {
        failed(t);
    }
}
 
Example 6
Source File: P2pNetworkListItem.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
P2pNetworkListItem(Connection connection, ClockWatcher clockWatcher) {
    this.connection = connection;
    this.clockWatcher = clockWatcher;
    this.statistic = connection.getStatistic();

    sentBytesSubscription = EasyBind.subscribe(statistic.sentBytesProperty(),
            e -> sentBytes.set(FormattingUtils.formatBytes((long) e)));
    receivedBytesSubscription = EasyBind.subscribe(statistic.receivedBytesProperty(),
            e -> receivedBytes.set(FormattingUtils.formatBytes((long) e)));
    onionAddressSubscription = EasyBind.subscribe(connection.getPeersNodeAddressProperty(),
            nodeAddress -> onionAddress.set(nodeAddress != null ? nodeAddress.getFullAddress() : Res.get("settings.net.notKnownYet")));
    roundTripTimeSubscription = EasyBind.subscribe(statistic.roundTripTimeProperty(),
            roundTripTime -> this.roundTripTime.set((int) roundTripTime == 0 ? "-" : roundTripTime + " ms"));

    listener = new ClockWatcher.Listener() {
        @Override
        public void onSecondTick() {
            onLastActivityChanged(statistic.getLastActivityTimestamp());
            updatePeerType();
            updateConnectionType();
        }

        @Override
        public void onMinuteTick() {
        }
    };
    clockWatcher.addListener(listener);
    onLastActivityChanged(statistic.getLastActivityTimestamp());
    updatePeerType();
    updateConnectionType();
}
 
Example 7
Source File: MutableOfferView.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
private void addSubscriptions() {
    isWaitingForFundsSubscription = EasyBind.subscribe(model.isWaitingForFunds, isWaitingForFunds -> {

        if (isWaitingForFunds) {
            waitingForFundsSpinner.play();
        } else {
            waitingForFundsSpinner.stop();
        }

        waitingForFundsLabel.setVisible(isWaitingForFunds);
        waitingForFundsLabel.setManaged(isWaitingForFunds);
    });

    balanceSubscription = EasyBind.subscribe(model.getDataModel().getBalance(), balanceTextField::setBalance);
}
 
Example 8
Source File: NotificationCenter.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
@Inject
public NotificationCenter(TradeManager tradeManager,
                          MediationManager mediationManager,
                          RefundManager refundManager,
                          Preferences preferences,
                          Navigation navigation) {
    this.tradeManager = tradeManager;
    this.mediationManager = mediationManager;
    this.refundManager = refundManager;
    this.navigation = navigation;

    EasyBind.subscribe(preferences.getUseAnimationsProperty(), useAnimations -> NotificationCenter.useAnimations = useAnimations);
}
 
Example 9
Source File: ProposalsView.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected void activate() {
    phasesView.activate();

    selectedProposalSubscription = EasyBind.subscribe(tableView.getSelectionModel().selectedItemProperty(), this::onSelectProposal);

    daoFacade.addBsqStateListener(this);

    sortedList.comparatorProperty().bind(tableView.comparatorProperty());
    tableView.setPrefHeight(100);
    root.getScene().heightProperty().addListener(sceneHeightListener);
    UserThread.execute(() -> {
        if (root.getScene() != null)
            updateTableHeight(root.getScene().getHeight());
    });

    stakeInputTextField.textProperty().addListener(stakeListener);
    voteButton.setOnAction(e -> onVote());

    onUpdateBalances(bsqWalletService.getAvailableConfirmedBalance(),
            bsqWalletService.getAvailableNonBsqBalance(),
            bsqWalletService.getUnverifiedBalance(),
            bsqWalletService.getUnconfirmedChangeBalance(),
            bsqWalletService.getLockedForVotingBalance(),
            bsqWalletService.getLockupBondsBalance(),
            bsqWalletService.getUnlockingBondsBalance());

    if (daoStateService.isParseBlockChainComplete()) {
        addListenersAfterParseBlockChainComplete();

        updateListItems();
        applyMerit();
        updateViews();
    }
}
 
Example 10
Source File: TradeStepView.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
private void registerSubscriptions() {
    disputeStateSubscription = EasyBind.subscribe(trade.disputeStateProperty(), newValue -> {
        if (newValue != null) {
            updateDisputeState(newValue);
        }
    });

    mediationResultStateSubscription = EasyBind.subscribe(trade.mediationResultStateProperty(), newValue -> {
        if (newValue != null) {
            updateMediationResultState(true);
        }
    });

    UserThread.execute(() -> model.p2PService.removeP2PServiceListener(bootstrapListener));
}
 
Example 11
Source File: SellerSubView.java    From bisq with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
protected void activate() {
    viewStateSubscription = EasyBind.subscribe(model.getSellerState(), this::onViewStateChanged);
    super.activate();
}
 
Example 12
Source File: PendingTradesView.java    From bisq with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
protected void activate() {
    sortedList = new SortedList<>(model.dataModel.list);
    sortedList.comparatorProperty().bind(tableView.comparatorProperty());
    tableView.setItems(sortedList);

    scene = root.getScene();
    if (scene != null) {
        scene.addEventHandler(KeyEvent.KEY_RELEASED, keyEventEventHandler);

        //TODO: in what cases is it necessary to request focus?
        /*appFocusSubscription = EasyBind.subscribe(scene.getWindow().focusedProperty(), isFocused -> {
            if (isFocused && model.dataModel.selectedItemProperty.get() != null) {
                // Focus selectedItem from model
                int index = table.getItems().indexOf(model.dataModel.selectedItemProperty.get());
                UserThread.execute(() -> {
                    //TODO app wide focus
                    //table.requestFocus();
                    //UserThread.execute(() -> table.getFocusModel().focus(index));
                });
            }
        });*/
    }

    selectedItemSubscription = EasyBind.subscribe(model.dataModel.selectedItemProperty, selectedItem -> {
        if (selectedItem != null) {
            if (selectedSubView != null)
                selectedSubView.deactivate();

            if (selectedItem.getTrade() != null) {
                selectedSubView = model.dataModel.tradeManager.isBuyer(model.dataModel.getOffer()) ?
                        new BuyerSubView(model) : new SellerSubView(model);

                selectedSubView.setMinHeight(440);
                VBox.setVgrow(selectedSubView, Priority.ALWAYS);
                if (root.getChildren().size() == 1)
                    root.getChildren().add(selectedSubView);
                else if (root.getChildren().size() == 2)
                    root.getChildren().set(1, selectedSubView);

                // create and register a callback so we can be notified when the subview
                // wants to open the chat window
                ChatCallback chatCallback = this::openChat;
                selectedSubView.setChatCallback(chatCallback);
            }

            updateTableSelection();
        } else {
            removeSelectedSubView();
        }

        model.onSelectedItemChanged(selectedItem);

        if (selectedSubView != null && selectedItem != null)
            selectedSubView.activate();
    });

    selectedTableItemSubscription = EasyBind.subscribe(tableView.getSelectionModel().selectedItemProperty(),
            selectedItem -> {
                if (selectedItem != null && !selectedItem.equals(model.dataModel.selectedItemProperty.get()))
                    model.dataModel.onSelectItem(selectedItem);
            });

    updateTableSelection();

    model.dataModel.list.addListener(tradesListChangeListener);
    updateNewChatMessagesByTradeMap();
}
 
Example 13
Source File: SellerStep3View.java    From bisq with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void activate() {
    super.activate();

    if (timeoutTimer != null)
        timeoutTimer.stop();

    tradeStatePropertySubscription = EasyBind.subscribe(trade.stateProperty(), state -> {
        if (timeoutTimer != null)
            timeoutTimer.stop();

        if (trade.isFiatSent() && !trade.isFiatReceived()) {
            showPopup();
        } else if (trade.isFiatReceived()) {
            if (!trade.hasFailed()) {
                switch (state) {
                    case SELLER_CONFIRMED_IN_UI_FIAT_PAYMENT_RECEIPT:
                    case SELLER_PUBLISHED_PAYOUT_TX:
                    case SELLER_SENT_PAYOUT_TX_PUBLISHED_MSG:
                        busyAnimation.play();
                        // confirmButton.setDisable(true);
                        statusLabel.setText(Res.get("shared.sendingConfirmation"));

                        timeoutTimer = UserThread.runAfter(() -> {
                            busyAnimation.stop();
                            // confirmButton.setDisable(false);
                            statusLabel.setText(Res.get("shared.sendingConfirmationAgain"));
                        }, 10);
                        break;
                    case SELLER_SAW_ARRIVED_PAYOUT_TX_PUBLISHED_MSG:
                        busyAnimation.stop();
                        statusLabel.setText(Res.get("shared.messageArrived"));
                        break;
                    case SELLER_STORED_IN_MAILBOX_PAYOUT_TX_PUBLISHED_MSG:
                        busyAnimation.stop();
                        statusLabel.setText(Res.get("shared.messageStoredInMailbox"));
                        break;
                    case SELLER_SEND_FAILED_PAYOUT_TX_PUBLISHED_MSG:
                        // We get a popup and the trade closed, so we dont need to show anything here
                        busyAnimation.stop();
                        // confirmButton.setDisable(false);
                        statusLabel.setText("");
                        break;
                    default:
                        log.warn("Unexpected case: State={}, tradeId={} " + state.name(), trade.getId());
                        busyAnimation.stop();
                        // confirmButton.setDisable(false);
                        statusLabel.setText(Res.get("shared.sendingConfirmationAgain"));
                        break;
                }
            } else {
                log.warn("confirmButton gets disabled because trade contains error message {}", trade.getErrorMessage());
                // confirmButton.setDisable(true);
                statusLabel.setText("");
            }
        }
    });
}
 
Example 14
Source File: VoteResultView.java    From bisq with GNU Affero General Public License v3.0 4 votes vote down vote up
private void onResultsListItemSelected(CycleListItem item) {
    if (selectedProposalSubscription != null)
        selectedProposalSubscription.unsubscribe();

    GUIUtil.removeChildrenFromGridPaneRows(root, 3, gridRow);
    gridRow = 2;

    if (item != null) {
        resultsOfCycle = item.getResultsOfCycle();

        // Check if my vote is included in result
        isVoteIncludedInResult = false;
        resultsOfCycle.getEvaluatedProposals().forEach(evProposal -> resultsOfCycle.getDecryptedVotesForCycle()
                .forEach(decryptedBallotsWithMerits -> {
                    // Iterate through all included votes to see if any of those are ours
                    if (!isVoteIncludedInResult) {
                        isVoteIncludedInResult = bsqWalletService.isWalletTransaction(decryptedBallotsWithMerits
                                .getVoteRevealTxId()).isPresent();
                    }
                }));


        maybeShowVoteResultErrors(item.getResultsOfCycle().getCycle());
        createProposalsTable();

        selectedProposalSubscription = EasyBind.subscribe(proposalsTableView.getSelectionModel().selectedItemProperty(),
                this::onSelectProposalResultListItem);

        StringBuilder sb = new StringBuilder();
        voteResultService.getInvalidDecryptedBallotsWithMeritItems().stream()
                .filter(e -> periodService.isTxInCorrectCycle(e.getVoteRevealTxId(),
                        item.getResultsOfCycle().getCycle().getHeightOfFirstBlock()))
                .forEach(e -> {
                    sb.append("\n")
                            .append(Res.getWithCol("shared.blindVoteTxId")).append(" ")
                            .append(e.getBlindVoteTxId()).append("\n")
                            .append(Res.getWithCol("dao.results.votes.table.header.stake")).append(" ")
                            .append(bsqFormatter.formatCoinWithCode(Coin.valueOf(e.getStake()))).append("\n");
                    e.getBallotList().stream().forEach(ballot -> {
                        sb.append(Res.getWithCol("shared.proposal")).append("\n\t")
                                .append(Res.getWithCol("shared.name")).append(" ")
                                .append(ballot.getProposal().getName()).append("\n\t");
                        sb.append(Res.getWithCol("dao.bond.table.column.link")).append(" ")
                                .append(ballot.getProposal().getLink()).append("\n\t");
                        Vote vote = ballot.getVote();
                        String voteString = vote == null ? Res.get("dao.proposal.display.myVote.ignored") :
                                vote.isAccepted() ?
                                        Res.get("dao.proposal.display.myVote.accepted") :
                                        Res.get("dao.proposal.display.myVote.rejected");
                        sb.append(Res.getWithCol("dao.results.votes.table.header.vote")).append(" ")
                                .append(voteString).append("\n");

                    });
                });
        if (sb.length() != 0) {
            new Popup().information(Res.get("dao.results.invalidVotes", sb.toString())).show();
        }
    }
}
 
Example 15
Source File: BuyerStep2View.java    From bisq with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void activate() {
    super.activate();

    try {
        DelayedPayoutTxValidation.validatePayoutTx(trade,
                trade.getDelayedPayoutTx(),
                model.dataModel.daoFacade,
                model.dataModel.btcWalletService);
    } catch (DelayedPayoutTxValidation.DonationAddressException |
            DelayedPayoutTxValidation.InvalidTxException |
            DelayedPayoutTxValidation.AmountMismatchException |
            DelayedPayoutTxValidation.InvalidLockTimeException e) {
        if (!model.dataModel.tradeManager.isAllowFaultyDelayedTxs()) {
            new Popup().warning(Res.get("portfolio.pending.invalidDelayedPayoutTx", e.getMessage())).show();
        }
    } catch (DelayedPayoutTxValidation.MissingDelayedPayoutTxException ignore) {
        // We don't react on those errors as a failed trade might get listed initially but getting removed from the
        // trade manager after initPendingTrades which happens after activate might be called.
    }

    if (timeoutTimer != null)
        timeoutTimer.stop();

    //TODO we get called twice, check why
    if (tradeStatePropertySubscription == null) {
        tradeStatePropertySubscription = EasyBind.subscribe(trade.stateProperty(), state -> {
            if (timeoutTimer != null)
                timeoutTimer.stop();

            if (trade.isDepositConfirmed() && !trade.isFiatSent()) {
                showPopup();
            } else if (state.ordinal() <= Trade.State.BUYER_SEND_FAILED_FIAT_PAYMENT_INITIATED_MSG.ordinal()) {
                if (!trade.hasFailed()) {
                    switch (state) {
                        case BUYER_CONFIRMED_IN_UI_FIAT_PAYMENT_INITIATED:
                        case BUYER_SENT_FIAT_PAYMENT_INITIATED_MSG:
                            busyAnimation.play();
                            // confirmButton.setDisable(true);
                            statusLabel.setText(Res.get("shared.sendingConfirmation"));
                            model.setMessageStateProperty(MessageState.SENT);
                            timeoutTimer = UserThread.runAfter(() -> {
                                busyAnimation.stop();
                                // confirmButton.setDisable(false);
                                statusLabel.setText(Res.get("shared.sendingConfirmationAgain"));
                            }, 10);
                            break;
                        case BUYER_SAW_ARRIVED_FIAT_PAYMENT_INITIATED_MSG:
                            busyAnimation.stop();
                            statusLabel.setText(Res.get("shared.messageArrived"));
                            model.setMessageStateProperty(MessageState.ARRIVED);
                            break;
                        case BUYER_STORED_IN_MAILBOX_FIAT_PAYMENT_INITIATED_MSG:
                            busyAnimation.stop();
                            statusLabel.setText(Res.get("shared.messageStoredInMailbox"));
                            model.setMessageStateProperty(MessageState.STORED_IN_MAILBOX);
                            break;
                        case BUYER_SEND_FAILED_FIAT_PAYMENT_INITIATED_MSG:
                            // We get a popup and the trade closed, so we dont need to show anything here
                            busyAnimation.stop();
                            // confirmButton.setDisable(false);
                            statusLabel.setText("");
                            model.setMessageStateProperty(MessageState.FAILED);
                            break;
                        default:
                            log.warn("Unexpected case: State={}, tradeId={} " + state.name(), trade.getId());
                            busyAnimation.stop();
                            // confirmButton.setDisable(false);
                            statusLabel.setText(Res.get("shared.sendingConfirmationAgain"));
                            break;
                    }
                } else {
                    log.warn("confirmButton gets disabled because trade contains error message {}", trade.getErrorMessage());
                    // confirmButton.setDisable(true);
                    statusLabel.setText("");
                }
            }
        });
    }
}
 
Example 16
Source File: NetworkSettingsView.java    From bisq with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void activate() {
    bitcoinPeersToggleGroup.selectedToggleProperty().addListener(bitcoinPeersToggleGroupListener);

    if (filterManager.getFilter() != null)
        applyPreventPublicBtcNetwork();

    filterManager.filterProperty().addListener(filterPropertyListener);

    useTorForBtcJCheckBox.setSelected(preferences.getUseTorForBitcoinJ());
    useTorForBtcJCheckBox.setOnAction(event -> {
        boolean selected = useTorForBtcJCheckBox.isSelected();
        if (selected != preferences.getUseTorForBitcoinJ()) {
            new Popup().information(Res.get("settings.net.needRestart"))
                    .actionButtonText(Res.get("shared.applyAndShutDown"))
                    .onAction(() -> {
                        preferences.setUseTorForBitcoinJ(selected);
                        UserThread.runAfter(BisqApp.getShutDownHandler(), 500, TimeUnit.MILLISECONDS);
                    })
                    .closeButtonText(Res.get("shared.cancel"))
                    .onClose(() -> useTorForBtcJCheckBox.setSelected(!selected))
                    .show();
        }
    });

    reSyncSPVChainButton.setOnAction(event -> GUIUtil.reSyncSPVChain(preferences));

    bitcoinPeersSubscription = EasyBind.subscribe(walletsSetup.connectedPeersProperty(),
            connectedPeers -> updateBitcoinPeersTable());

    bitcoinBlocksDownloadedSubscription = EasyBind.subscribe(walletsSetup.blocksDownloadedFromPeerProperty(),
            peer -> updateBitcoinPeersTable());

    bitcoinBlockHeightSubscription = EasyBind.subscribe(walletsSetup.chainHeightProperty(),
            chainHeight -> updateBitcoinPeersTable());

    nodeAddressSubscription = EasyBind.subscribe(p2PService.getNetworkNode().nodeAddressProperty(),
            nodeAddress -> onionAddress.setText(nodeAddress == null ?
                    Res.get("settings.net.notKnownYet") :
                    nodeAddress.getFullAddress()));
    numP2PPeersSubscription = EasyBind.subscribe(p2PService.getNumConnectedPeers(), numPeers -> updateP2PTable());
    totalTrafficTextField.textProperty().bind(EasyBind.combine(Statistic.totalSentBytesProperty(),
            Statistic.totalReceivedBytesProperty(),
            (sent, received) -> Res.get("settings.net.sentReceived",
                    FormattingUtils.formatBytes((long) sent),
                    FormattingUtils.formatBytes((long) received))));

    bitcoinSortedList.comparatorProperty().bind(bitcoinPeersTableView.comparatorProperty());
    bitcoinPeersTableView.setItems(bitcoinSortedList);

    p2pSortedList.comparatorProperty().bind(p2pPeersTableView.comparatorProperty());
    p2pPeersTableView.setItems(p2pSortedList);

    btcNodesInputTextField.setText(preferences.getBitcoinNodes());

    btcNodesInputTextField.focusedProperty().addListener(btcNodesInputTextFieldFocusListener);

    openTorSettingsButton.setOnAction(e -> torNetworkSettingsWindow.show());
}
 
Example 17
Source File: TradeStepView.java    From bisq with GNU Affero General Public License v3.0 4 votes vote down vote up
public void activate() {
    if (txIdTextField != null) {
        if (txIdSubscription != null)
            txIdSubscription.unsubscribe();

        txIdSubscription = EasyBind.subscribe(model.dataModel.txId, id -> {
            if (!id.isEmpty())
                txIdTextField.setup(id);
            else
                txIdTextField.cleanup();
        });
    }
    trade.errorMessageProperty().addListener(errorMessageListener);

    if (!isMediationClosedState()) {
        tradeStepInfo.setOnAction(e -> {
            if (this.isTradePeriodOver()) {
                openSupportTicket();
            } else {
                openChat();
            }
        });
    }

    // We get mailbox messages processed after we have bootstrapped. This will influence the states we
    // handle in our disputeStateSubscription and mediationResultStateSubscriptions. To avoid that we show
    // popups from incorrect states we wait until we have bootstrapped and the mailbox messages processed.
    if (model.p2PService.isBootstrapped()) {
        registerSubscriptions();
    } else {
        bootstrapListener = new BootstrapListener() {
            @Override
            public void onUpdatedDataReceived() {
                registerSubscriptions();
            }
        };
        model.p2PService.addP2PServiceListener(bootstrapListener);
    }

    tradePeriodStateSubscription = EasyBind.subscribe(trade.tradePeriodStateProperty(), newValue -> {
        if (newValue != null)
            updateTradePeriodState(newValue);
    });

    model.clockWatcher.addListener(clockListener);

    if (infoLabel != null)
        infoLabel.setText(getInfoText());
}
 
Example 18
Source File: BuyerSubView.java    From bisq with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
protected void activate() {
    viewStateSubscription = EasyBind.subscribe(model.getBuyerState(), this::onViewStateChanged);
    super.activate();
}
 
Example 19
Source File: BuyerSetupDepositTxListener.java    From bisq with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
protected void run() {
    try {
        runInterceptHook();

        if (trade.getDepositTx() == null && processModel.getPreparedDepositTx() != null) {
            BtcWalletService walletService = processModel.getBtcWalletService();
            final NetworkParameters params = walletService.getParams();
            Transaction preparedDepositTx = new Transaction(params, processModel.getPreparedDepositTx());
            checkArgument(!preparedDepositTx.getOutputs().isEmpty(), "preparedDepositTx.getOutputs() must not be empty");
            Address depositTxAddress = preparedDepositTx.getOutput(0).getAddressFromP2SH(params);
            final TransactionConfidence confidence = walletService.getConfidenceForAddress(depositTxAddress);
            if (isInNetwork(confidence)) {
                applyConfidence(confidence);
            } else {
                confidenceListener = new AddressConfidenceListener(depositTxAddress) {
                    @Override
                    public void onTransactionConfidenceChanged(TransactionConfidence confidence) {
                        if (isInNetwork(confidence))
                            applyConfidence(confidence);
                    }
                };
                walletService.addAddressConfidenceListener(confidenceListener);

                tradeStateSubscription = EasyBind.subscribe(trade.stateProperty(), newValue -> {
                    if (trade.isDepositPublished()) {
                        swapReservedForTradeEntry();

                        // hack to remove tradeStateSubscription at callback
                        UserThread.execute(this::unSubscribe);
                    }
                });
            }
        }

        // we complete immediately, our object stays alive because the balanceListener is stored in the WalletService
        complete();
    } catch (Throwable t) {
        failed(t);
    }
}
 
Example 20
Source File: MakerSetupDepositTxListener.java    From bisq-core with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
protected void run() {
    try {
        runInterceptHook();

        if (trade.getDepositTx() == null && processModel.getPreparedDepositTx() != null) {
            BtcWalletService walletService = processModel.getBtcWalletService();
            final NetworkParameters params = walletService.getParams();
            Transaction preparedDepositTx = new Transaction(params, processModel.getPreparedDepositTx());
            checkArgument(!preparedDepositTx.getOutputs().isEmpty(), "preparedDepositTx.getOutputs() must not be empty");
            Address depositTxAddress = preparedDepositTx.getOutput(0).getAddressFromP2SH(params);
            final TransactionConfidence confidence = walletService.getConfidenceForAddress(depositTxAddress);
            if (isInNetwork(confidence)) {
                applyConfidence(confidence);
            } else {
                confidenceListener = new AddressConfidenceListener(depositTxAddress) {
                    @Override
                    public void onTransactionConfidenceChanged(TransactionConfidence confidence) {
                        if (isInNetwork(confidence))
                            applyConfidence(confidence);
                    }
                };
                walletService.addAddressConfidenceListener(confidenceListener);

                tradeStateSubscription = EasyBind.subscribe(trade.stateProperty(), newValue -> {
                    if (trade.isDepositPublished()) {
                        swapReservedForTradeEntry();

                        // hack to remove tradeStateSubscription at callback
                        UserThread.execute(this::unSubscribe);
                    }
                });
            }
        }

        // we complete immediately, our object stays alive because the balanceListener is stored in the WalletService
        complete();
    } catch (Throwable t) {
        failed(t);
    }
}