Search in sources :

Example 41 with Popup

use of bisq.desktop.main.overlays.popups.Popup in project bisq-desktop by bisq-network.

the class MainViewModel method updateTradePeriodState.

private void updateTradePeriodState() {
    tradeManager.getTradableList().forEach(trade -> {
        if (!trade.isPayoutPublished()) {
            Date maxTradePeriodDate = trade.getMaxTradePeriodDate();
            Date halfTradePeriodDate = trade.getHalfTradePeriodDate();
            if (maxTradePeriodDate != null && halfTradePeriodDate != null) {
                Date now = new Date();
                if (now.after(maxTradePeriodDate))
                    trade.setTradePeriodState(Trade.TradePeriodState.TRADE_PERIOD_OVER);
                else if (now.after(halfTradePeriodDate))
                    trade.setTradePeriodState(Trade.TradePeriodState.SECOND_HALF);
                String key;
                switch(trade.getTradePeriodState()) {
                    case FIRST_HALF:
                        break;
                    case SECOND_HALF:
                        key = "displayHalfTradePeriodOver" + trade.getId();
                        if (DontShowAgainLookup.showAgain(key)) {
                            DontShowAgainLookup.dontShowAgain(key, true);
                            new Popup<>().warning(Res.get("popup.warning.tradePeriod.halfReached", trade.getShortId(), formatter.formatDateTime(maxTradePeriodDate))).show();
                        }
                        break;
                    case TRADE_PERIOD_OVER:
                        key = "displayTradePeriodOver" + trade.getId();
                        if (DontShowAgainLookup.showAgain(key)) {
                            DontShowAgainLookup.dontShowAgain(key, true);
                            new Popup<>().warning(Res.get("popup.warning.tradePeriod.ended", trade.getShortId(), formatter.formatDateTime(maxTradePeriodDate))).show();
                        }
                        break;
                }
            }
        }
    });
}
Also used : Popup(bisq.desktop.main.overlays.popups.Popup) Date(java.util.Date)

Example 42 with Popup

use of bisq.desktop.main.overlays.popups.Popup in project bisq-desktop by bisq-network.

the class MainViewModel method onBasicServicesInitialized.

private void onBasicServicesInitialized() {
    log.info("onBasicServicesInitialized");
    clock.start();
    PaymentMethod.onAllServicesInitialized();
    // disputeManager
    disputeManager.onAllServicesInitialized();
    disputeManager.getDisputesAsObservableList().addListener((ListChangeListener<Dispute>) change -> {
        change.next();
        onDisputesChangeListener(change.getAddedSubList(), change.getRemoved());
    });
    onDisputesChangeListener(disputeManager.getDisputesAsObservableList(), null);
    // tradeManager
    tradeManager.onAllServicesInitialized();
    tradeManager.getTradableList().addListener((ListChangeListener<Trade>) c -> updateBalance());
    tradeManager.getTradableList().addListener((ListChangeListener<Trade>) change -> onTradesChanged());
    onTradesChanged();
    // We handle the trade period here as we display a global popup if we reached dispute time
    tradesAndUIReady = EasyBind.combine(isSplashScreenRemoved, tradeManager.pendingTradesInitializedProperty(), (a, b) -> a && b);
    tradesAndUIReady.subscribe((observable, oldValue, newValue) -> {
        if (newValue)
            applyTradePeriodState();
    });
    tradeManager.setTakeOfferRequestErrorMessageHandler(errorMessage -> new Popup<>().warning(Res.get("popup.error.takeOfferRequestFailed", errorMessage)).show());
    // walletService
    btcWalletService.addBalanceListener(new BalanceListener() {

        @Override
        public void onBalanceChanged(Coin balance, Transaction tx) {
            updateBalance();
        }
    });
    openOfferManager.getObservableList().addListener((ListChangeListener<OpenOffer>) c -> updateBalance());
    tradeManager.getTradableList().addListener((ListChangeListener<Trade>) c -> updateBalance());
    openOfferManager.onAllServicesInitialized();
    removeOffersWithoutAccountAgeWitness();
    arbitratorManager.onAllServicesInitialized();
    alertManager.alertMessageProperty().addListener((observable, oldValue, newValue) -> displayAlertIfPresent(newValue, false));
    privateNotificationManager.privateNotificationProperty().addListener((observable, oldValue, newValue) -> displayPrivateNotification(newValue));
    displayAlertIfPresent(alertManager.alertMessageProperty().get(), false);
    p2PService.onAllServicesInitialized();
    feeService.onAllServicesInitialized();
    GUIUtil.setFeeService(feeService);
    daoManager.onAllServicesInitialized(errorMessage -> new Popup<>().error(errorMessage).show());
    tradeStatisticsManager.onAllServicesInitialized();
    accountAgeWitnessService.onAllServicesInitialized();
    priceFeedService.setCurrencyCodeOnInit();
    filterManager.onAllServicesInitialized();
    filterManager.addListener(filter -> {
        if (filter != null) {
            if (filter.getSeedNodes() != null && !filter.getSeedNodes().isEmpty())
                new Popup<>().warning(Res.get("popup.warning.nodeBanned", Res.get("popup.warning.seed"))).show();
            if (filter.getPriceRelayNodes() != null && !filter.getPriceRelayNodes().isEmpty())
                new Popup<>().warning(Res.get("popup.warning.nodeBanned", Res.get("popup.warning.priceRelay"))).show();
        }
    });
    setupBtcNumPeersWatcher();
    setupP2PNumPeersWatcher();
    updateBalance();
    if (DevEnv.isDevMode()) {
        preferences.setShowOwnOffersInOfferBook(true);
        setupDevDummyPaymentAccounts();
    }
    fillPriceFeedComboBoxItems();
    setupMarketPriceFeed();
    swapPendingOfferFundingEntries();
    showAppScreen.set(true);
    String key = "remindPasswordAndBackup";
    user.getPaymentAccountsAsObservable().addListener((SetChangeListener<PaymentAccount>) change -> {
        if (!walletsManager.areWalletsEncrypted() && preferences.showAgain(key) && change.wasAdded()) {
            new Popup<>().headLine(Res.get("popup.securityRecommendation.headline")).information(Res.get("popup.securityRecommendation.msg")).dontShowAgainId(key).show();
        }
    });
    checkIfOpenOffersMatchTradeProtocolVersion();
    if (walletsSetup.downloadPercentageProperty().get() == 1)
        checkForLockedUpFunds();
    allBasicServicesInitialized = true;
}
Also used : OpenOffer(bisq.core.offer.OpenOffer) User(bisq.core.user.User) ChainFileLockedException(org.bitcoinj.store.ChainFileLockedException) ListChangeListener(javafx.collections.ListChangeListener) BootstrapListener(bisq.network.p2p.BootstrapListener) SimpleIntegerProperty(javafx.beans.property.SimpleIntegerProperty) Map(java.util.Map) BlockStoreException(org.bitcoinj.store.BlockStoreException) MonadicBinding(org.fxmisc.easybind.monadic.MonadicBinding) P2PServiceListener(bisq.network.p2p.P2PServiceListener) ClosedTradableManager(bisq.core.trade.closed.ClosedTradableManager) FilterManager(bisq.core.filter.FilterManager) Set(java.util.Set) PaymentMethod(bisq.core.payment.payload.PaymentMethod) BooleanProperty(javafx.beans.property.BooleanProperty) Slf4j(lombok.extern.slf4j.Slf4j) TxIdTextField(bisq.desktop.components.TxIdTextField) Stream(java.util.stream.Stream) TorNetworkSettingsWindow(bisq.desktop.main.overlays.windows.TorNetworkSettingsWindow) AddressEntry(bisq.core.btc.AddressEntry) WalletsSetup(bisq.core.btc.wallet.WalletsSetup) TradeManager(bisq.core.trade.TradeManager) UserThread(bisq.common.UserThread) SimpleDoubleProperty(javafx.beans.property.SimpleDoubleProperty) FeeService(bisq.core.provider.fee.FeeService) ObservableList(javafx.collections.ObservableList) StringProperty(javafx.beans.property.StringProperty) CryptoException(bisq.common.crypto.CryptoException) AlertManager(bisq.core.alert.AlertManager) SetupUtils(bisq.core.app.SetupUtils) FXCollections(javafx.collections.FXCollections) Dispute(bisq.core.arbitration.Dispute) NotificationCenter(bisq.desktop.main.overlays.notifications.NotificationCenter) IntegerProperty(javafx.beans.property.IntegerProperty) ConnectionListener(bisq.network.p2p.network.ConnectionListener) Nullable(javax.annotation.Nullable) EncryptionService(bisq.network.crypto.EncryptionService) DontShowAgainLookup(bisq.core.user.DontShowAgainLookup) GlobalSettings(bisq.core.locale.GlobalSettings) IOException(java.io.IOException) BisqEnvironment(bisq.core.app.BisqEnvironment) OpenOfferManager(bisq.core.offer.OpenOfferManager) PriceFeedService(bisq.core.provider.price.PriceFeedService) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) CloseConnectionReason(bisq.network.p2p.network.CloseConnectionReason) KeyRing(bisq.common.crypto.KeyRing) InetAddresses(com.google.common.net.InetAddresses) SealedAndSigned(bisq.common.crypto.SealedAndSigned) Transaction(org.bitcoinj.core.Transaction) DisplayAlertMessageWindow(bisq.desktop.main.overlays.windows.DisplayAlertMessageWindow) Coin(org.bitcoinj.core.Coin) Date(java.util.Date) DaoManager(bisq.core.dao.DaoManager) Clock(bisq.common.Clock) Inject(com.google.inject.Inject) PerfectMoneyAccount(bisq.core.payment.PerfectMoneyAccount) Security(java.security.Security) TimeoutException(java.util.concurrent.TimeoutException) Random(java.util.Random) DisputeManager(bisq.core.arbitration.DisputeManager) BSFormatter(bisq.desktop.util.BSFormatter) Alert(bisq.core.alert.Alert) Res(bisq.core.locale.Res) Popup(bisq.desktop.main.overlays.popups.Popup) WalletPasswordWindow(bisq.desktop.main.overlays.windows.WalletPasswordWindow) P2PService(bisq.network.p2p.P2PService) ArbitratorManager(bisq.core.arbitration.ArbitratorManager) Subscription(org.fxmisc.easybind.Subscription) InetSocketAddress(java.net.InetSocketAddress) Collectors(java.util.stream.Collectors) AccountAgeWitnessService(bisq.core.payment.AccountAgeWitnessService) PaymentAccount(bisq.core.payment.PaymentAccount) List(java.util.List) TacWindow(bisq.desktop.main.overlays.windows.TacWindow) DevEnv(bisq.common.app.DevEnv) AppOptionKeys(bisq.core.app.AppOptionKeys) Preferences(bisq.core.user.Preferences) Optional(java.util.Optional) Address(org.bitcoinj.core.Address) BalanceWithConfirmationTextField(bisq.desktop.components.BalanceWithConfirmationTextField) Ping(bisq.network.p2p.peers.keepalive.messages.Ping) MarketPrice(bisq.core.provider.price.MarketPrice) DisplayUpdateDownloadWindow(bisq.desktop.main.overlays.windows.downloadupdate.DisplayUpdateDownloadWindow) GUIUtil(bisq.desktop.util.GUIUtil) BtcWalletService(bisq.core.btc.wallet.BtcWalletService) Socket(java.net.Socket) TradeCurrency(bisq.core.locale.TradeCurrency) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) SetChangeListener(javafx.collections.SetChangeListener) Timer(bisq.common.Timer) DoubleProperty(javafx.beans.property.DoubleProperty) HashMap(java.util.HashMap) TradeStatisticsManager(bisq.core.trade.statistics.TradeStatisticsManager) BalanceListener(bisq.core.btc.listeners.BalanceListener) WalletsManager(bisq.core.btc.wallet.WalletsManager) CurrencyUtil(bisq.core.locale.CurrencyUtil) Connection(bisq.network.p2p.network.Connection) PrivateNotificationManager(bisq.core.alert.PrivateNotificationManager) Version(bisq.common.app.Version) ObjectProperty(javafx.beans.property.ObjectProperty) CryptoCurrencyAccount(bisq.core.payment.CryptoCurrencyAccount) PrivateNotificationPayload(bisq.core.alert.PrivateNotificationPayload) Trade(bisq.core.trade.Trade) FailedTradesManager(bisq.core.trade.failed.FailedTradesManager) ViewModel(bisq.desktop.common.model.ViewModel) TimeUnit(java.util.concurrent.TimeUnit) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) EasyBind(org.fxmisc.easybind.EasyBind) DecryptedDataTuple(bisq.network.crypto.DecryptedDataTuple) ChangeListener(javafx.beans.value.ChangeListener) Trade(bisq.core.trade.Trade) Coin(org.bitcoinj.core.Coin) BalanceListener(bisq.core.btc.listeners.BalanceListener) Transaction(org.bitcoinj.core.Transaction) PaymentAccount(bisq.core.payment.PaymentAccount) OpenOffer(bisq.core.offer.OpenOffer) Dispute(bisq.core.arbitration.Dispute)

Example 43 with Popup

use of bisq.desktop.main.overlays.popups.Popup in project bisq-desktop by bisq-network.

the class PasswordView method initialize.

@Override
public void initialize() {
    headline = FormBuilder.addTitledGroupBg(root, gridRow, 2, "");
    passwordField = FormBuilder.addLabelPasswordTextField(root, gridRow, Res.get("password.enterPassword"), Layout.FIRST_ROW_DISTANCE).second;
    passwordField.setValidator(passwordValidator);
    passwordFieldChangeListener = (observable, oldValue, newValue) -> validatePasswords();
    Tuple2<Label, PasswordTextField> tuple2 = FormBuilder.addLabelPasswordTextField(root, ++gridRow, Res.get("password.confirmPassword"));
    repeatedPasswordLabel = tuple2.first;
    repeatedPasswordField = tuple2.second;
    repeatedPasswordField.setValidator(passwordValidator);
    repeatedPasswordFieldChangeListener = (observable, oldValue, newValue) -> validatePasswords();
    Tuple3<Button, BusyAnimation, Label> tuple = FormBuilder.addButtonBusyAnimationLabel(root, ++gridRow, "", 15);
    pwButton = tuple.first;
    BusyAnimation busyAnimation = tuple.second;
    Label deriveStatusLabel = tuple.third;
    pwButton.setDisable(true);
    setText();
    pwButton.setOnAction(e -> {
        if (!walletsManager.areWalletsEncrypted()) {
            new Popup<>().backgroundInfo(Res.get("password.backupReminder")).closeButtonText(Res.get("password.backupWasDone")).onClose(() -> onApplyPassword(busyAnimation, deriveStatusLabel)).actionButtonTextWithGoTo("navigation.account.walletSeed").onAction(() -> {
                navigation.setReturnPath(navigation.getCurrentPath());
                // noinspection unchecked
                navigation.navigateTo(MainView.class, AccountView.class, AccountSettingsView.class, SeedWordsView.class);
            }).show();
        } else {
            onApplyPassword(busyAnimation, deriveStatusLabel);
        }
    });
    FormBuilder.addTitledGroupBg(root, ++gridRow, 1, Res.get("shared.information"), Layout.GROUP_DISTANCE);
    FormBuilder.addMultilineLabel(root, gridRow, Res.get("account.password.info"), Layout.FIRST_ROW_AND_GROUP_DISTANCE);
}
Also used : BusyAnimation(bisq.desktop.components.BusyAnimation) AccountSettingsView(bisq.desktop.main.account.settings.AccountSettingsView) MainView(bisq.desktop.main.MainView) Button(javafx.scene.control.Button) SeedWordsView(bisq.desktop.main.account.content.seedwords.SeedWordsView) Popup(bisq.desktop.main.overlays.popups.Popup) Label(javafx.scene.control.Label) AccountView(bisq.desktop.main.account.AccountView) PasswordTextField(bisq.desktop.components.PasswordTextField)

Example 44 with Popup

use of bisq.desktop.main.overlays.popups.Popup in project bisq-desktop by bisq-network.

the class AltCoinAccountsView method onSaveNewAccount.

// /////////////////////////////////////////////////////////////////////////////////////////
// UI actions
// /////////////////////////////////////////////////////////////////////////////////////////
private void onSaveNewAccount(PaymentAccount paymentAccount) {
    TradeCurrency selectedTradeCurrency = paymentAccount.getSelectedTradeCurrency();
    if (selectedTradeCurrency != null) {
        String code = selectedTradeCurrency.getCode();
        if (selectedTradeCurrency instanceof CryptoCurrency && ((CryptoCurrency) selectedTradeCurrency).isAsset()) {
            String name = selectedTradeCurrency.getName();
            new Popup<>().information(Res.get("account.altcoin.popup.wallet.msg", selectedTradeCurrency.getCodeAndName(), name, name)).closeButtonText(Res.get("account.altcoin.popup.wallet.confirm")).show();
        }
        switch(code) {
            case "XMR":
                new Popup<>().information(Res.get("account.altcoin.popup.xmr.msg")).useIUnderstandButton().show();
                break;
            case "ZEC":
                new Popup<>().information(Res.get("account.altcoin.popup.ZEC.msg", "ZEC")).useIUnderstandButton().show();
                break;
            case "XZC":
                new Popup<>().information(Res.get("account.altcoin.popup.XZC.msg", "XZC")).useIUnderstandButton().show();
                break;
            case "BCH":
            case "BCHC":
                new Popup<>().information(Res.get("account.altcoin.popup.bch")).useIUnderstandButton().show();
                break;
            case "BTG":
                new Popup<>().information(Res.get("account.altcoin.popup.btg")).useIUnderstandButton().show();
                break;
        }
        if (!model.getPaymentAccounts().stream().filter(e -> e.getAccountName() != null && e.getAccountName().equals(paymentAccount.getAccountName())).findAny().isPresent()) {
            model.onSaveNewAccount(paymentAccount);
            removeNewAccountForm();
        } else {
            new Popup<>().warning(Res.get("shared.accountNameAlreadyUsed")).show();
        }
    }
}
Also used : Button(javafx.scene.control.Button) TradeCurrency(bisq.core.locale.TradeCurrency) ListView(javafx.scene.control.ListView) ListCell(javafx.scene.control.ListCell) Layout(bisq.desktop.util.Layout) FxmlView(bisq.desktop.common.view.FxmlView) BSFormatter(bisq.desktop.util.BSFormatter) AltCoinAddressValidator(bisq.core.payment.validation.AltCoinAddressValidator) Inject(javax.inject.Inject) PaymentAccountFactory(bisq.core.payment.PaymentAccountFactory) Tuple2(bisq.common.util.Tuple2) CryptoCurrencyForm(bisq.desktop.components.paymentmethods.CryptoCurrencyForm) Tuple3(bisq.common.util.Tuple3) VPos(javafx.geometry.VPos) Res(bisq.core.locale.Res) Callback(javafx.util.Callback) TitledGroupBg(bisq.desktop.components.TitledGroupBg) GridPane(javafx.scene.layout.GridPane) FormBuilder.addLabelListView(bisq.desktop.util.FormBuilder.addLabelListView) FormBuilder.add3ButtonsAfterGroup(bisq.desktop.util.FormBuilder.add3ButtonsAfterGroup) Popup(bisq.desktop.main.overlays.popups.Popup) Label(javafx.scene.control.Label) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) FormBuilder.addTitledGroupBg(bisq.desktop.util.FormBuilder.addTitledGroupBg) FormBuilder(bisq.desktop.util.FormBuilder) PaymentMethod(bisq.core.payment.payload.PaymentMethod) AccountAgeWitnessService(bisq.core.payment.AccountAgeWitnessService) TimeUnit(java.util.concurrent.TimeUnit) PaymentMethodForm(bisq.desktop.components.paymentmethods.PaymentMethodForm) PaymentAccount(bisq.core.payment.PaymentAccount) InputValidator(bisq.core.util.validation.InputValidator) FormBuilder.add2ButtonsAfterGroup(bisq.desktop.util.FormBuilder.add2ButtonsAfterGroup) CryptoCurrency(bisq.core.locale.CryptoCurrency) ImageUtil(bisq.desktop.util.ImageUtil) AnchorPane(javafx.scene.layout.AnchorPane) ImageView(javafx.scene.image.ImageView) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) UserThread(bisq.common.UserThread) ActivatableViewAndModel(bisq.desktop.common.view.ActivatableViewAndModel) ChangeListener(javafx.beans.value.ChangeListener) CryptoCurrency(bisq.core.locale.CryptoCurrency) TradeCurrency(bisq.core.locale.TradeCurrency) Popup(bisq.desktop.main.overlays.popups.Popup)

Example 45 with Popup

use of bisq.desktop.main.overlays.popups.Popup in project bisq-desktop by bisq-network.

the class ArbitratorSelectionView method addArbitratorsGroup.

private void addArbitratorsGroup() {
    TableGroupHeadline tableGroupHeadline = new TableGroupHeadline(Res.get("account.arbitratorSelection.whichDoYouAccept"));
    GridPane.setRowIndex(tableGroupHeadline, ++gridRow);
    GridPane.setColumnSpan(tableGroupHeadline, 2);
    GridPane.setMargin(tableGroupHeadline, new Insets(40, -10, -10, -10));
    root.getChildren().add(tableGroupHeadline);
    tableView = new TableView<>();
    GridPane.setRowIndex(tableView, gridRow);
    GridPane.setColumnSpan(tableView, 2);
    GridPane.setMargin(tableView, new Insets(60, -10, 5, -10));
    root.getChildren().add(tableView);
    autoSelectAllMatchingCheckBox = addCheckBox(root, ++gridRow, Res.get("account.arbitratorSelection.autoSelect"));
    GridPane.setColumnSpan(autoSelectAllMatchingCheckBox, 2);
    GridPane.setHalignment(autoSelectAllMatchingCheckBox, HPos.LEFT);
    GridPane.setColumnIndex(autoSelectAllMatchingCheckBox, 0);
    GridPane.setMargin(autoSelectAllMatchingCheckBox, new Insets(0, -10, 0, -10));
    autoSelectAllMatchingCheckBox.setOnAction(event -> model.setAutoSelectArbitrators(autoSelectAllMatchingCheckBox.isSelected()));
    TableColumn<ArbitratorListItem, String> dateColumn = new AutoTooltipTableColumn<>(Res.get("account.arbitratorSelection.regDate"));
    dateColumn.setSortable(false);
    dateColumn.setCellValueFactory(param -> new ReadOnlyObjectWrapper<>(param.getValue().getRegistrationDate()));
    dateColumn.setMinWidth(140);
    dateColumn.setMaxWidth(140);
    TableColumn<ArbitratorListItem, String> nameColumn = new AutoTooltipTableColumn<>(Res.get("shared.onionAddress"));
    nameColumn.setSortable(false);
    nameColumn.setCellValueFactory(param -> new ReadOnlyObjectWrapper<>(param.getValue().getAddressString()));
    nameColumn.setMinWidth(90);
    TableColumn<ArbitratorListItem, String> languagesColumn = new AutoTooltipTableColumn<>(Res.get("account.arbitratorSelection.languages"));
    languagesColumn.setSortable(false);
    languagesColumn.setCellValueFactory(param -> new ReadOnlyObjectWrapper<>(param.getValue().getLanguageCodes()));
    languagesColumn.setMinWidth(130);
    TableColumn<ArbitratorListItem, ArbitratorListItem> selectionColumn = new AutoTooltipTableColumn<ArbitratorListItem, ArbitratorListItem>(Res.get("shared.accept")) {

        {
            setMinWidth(60);
            setMaxWidth(60);
            setSortable(false);
        }
    };
    selectionColumn.setCellValueFactory((arbitrator) -> new ReadOnlyObjectWrapper<>(arbitrator.getValue()));
    selectionColumn.setCellFactory(new Callback<TableColumn<ArbitratorListItem, ArbitratorListItem>, TableCell<ArbitratorListItem, ArbitratorListItem>>() {

        @Override
        public TableCell<ArbitratorListItem, ArbitratorListItem> call(TableColumn<ArbitratorListItem, ArbitratorListItem> column) {
            return new TableCell<ArbitratorListItem, ArbitratorListItem>() {

                private final CheckBox checkBox = new AutoTooltipCheckBox();

                private TableRow tableRow;

                private BooleanProperty selectedProperty;

                private void updateDisableState(final ArbitratorListItem item) {
                    boolean selected = model.isAcceptedArbitrator(item.arbitrator);
                    item.setIsSelected(selected);
                    boolean hasMatchingLanguage = model.hasMatchingLanguage(item.arbitrator);
                    if (!hasMatchingLanguage) {
                        model.onRemoveArbitrator(item.arbitrator);
                        if (selected)
                            item.setIsSelected(false);
                    }
                    boolean isMyOwnRegisteredArbitrator = model.isMyOwnRegisteredArbitrator(item.arbitrator);
                    checkBox.setDisable(!hasMatchingLanguage || isMyOwnRegisteredArbitrator);
                    tableRow = getTableRow();
                    if (tableRow != null) {
                        tableRow.setOpacity(hasMatchingLanguage && !isMyOwnRegisteredArbitrator ? 1 : 0.4);
                        if (isMyOwnRegisteredArbitrator) {
                            String text = Res.get("account.arbitratorSelection.cannotSelectHimself");
                            tableRow.setTooltip(new Tooltip(text));
                            tableRow.setOnMouseClicked(e -> new Popup<>().warning(text).show());
                        } else if (!hasMatchingLanguage) {
                            tableRow.setTooltip(new Tooltip(Res.get("account.arbitratorSelection.noMatchingLang")));
                            tableRow.setOnMouseClicked(e -> new Popup<>().warning(Res.get("account.arbitratorSelection.noLang")).show());
                        } else {
                            tableRow.setOnMouseClicked(null);
                            tableRow.setTooltip(null);
                        }
                    }
                }

                @Override
                public void updateItem(final ArbitratorListItem item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null && !empty) {
                        selectedProperty = item.isSelectedProperty();
                        languageCodesListChangeListener = c -> updateDisableState(item);
                        model.languageCodes.addListener(languageCodesListChangeListener);
                        isSelectedChangeListener = (observable, oldValue, newValue) -> checkBox.setSelected(newValue);
                        selectedProperty.addListener(isSelectedChangeListener);
                        checkBox.setSelected(model.isAcceptedArbitrator(item.arbitrator));
                        checkBox.setOnAction(e -> {
                            if (checkBox.isSelected()) {
                                onAddArbitrator(item);
                            } else if (model.isDeselectAllowed(item)) {
                                onRemoveArbitrator(item);
                            } else {
                                new Popup<>().warning(Res.get("account.arbitratorSelection.minOne")).show();
                                checkBox.setSelected(true);
                            }
                            item.setIsSelected(checkBox.isSelected());
                        });
                        updateDisableState(item);
                        setGraphic(checkBox);
                    } else {
                        model.languageCodes.removeListener(languageCodesListChangeListener);
                        if (selectedProperty != null)
                            selectedProperty.removeListener(isSelectedChangeListener);
                        setGraphic(null);
                        if (checkBox != null)
                            checkBox.setOnAction(null);
                        if (tableRow != null)
                            tableRow.setOnMouseClicked(null);
                    }
                }
            };
        }
    });
    // noinspection unchecked
    tableView.getColumns().addAll(dateColumn, nameColumn, languagesColumn, selectionColumn);
    tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
}
Also used : AutoTooltipCheckBox(bisq.desktop.components.AutoTooltipCheckBox) TableGroupHeadline(bisq.desktop.components.TableGroupHeadline) Button(javafx.scene.control.Button) HPos(javafx.geometry.HPos) ListView(javafx.scene.control.ListView) ListCell(javafx.scene.control.ListCell) Layout(bisq.desktop.util.Layout) FxmlView(bisq.desktop.common.view.FxmlView) TableColumn(javafx.scene.control.TableColumn) Inject(javax.inject.Inject) Tuple2(bisq.common.util.Tuple2) TableCell(javafx.scene.control.TableCell) FormBuilder.addLabelComboBox(bisq.desktop.util.FormBuilder.addLabelComboBox) Insets(javafx.geometry.Insets) ComboBox(javafx.scene.control.ComboBox) ReadOnlyObjectWrapper(javafx.beans.property.ReadOnlyObjectWrapper) ListChangeListener(javafx.collections.ListChangeListener) VPos(javafx.geometry.VPos) Res(bisq.core.locale.Res) TableView(javafx.scene.control.TableView) Callback(javafx.util.Callback) Tooltip(javafx.scene.control.Tooltip) GridPane(javafx.scene.layout.GridPane) FormBuilder.addLabelListView(bisq.desktop.util.FormBuilder.addLabelListView) Popup(bisq.desktop.main.overlays.popups.Popup) Label(javafx.scene.control.Label) AutoTooltipTableColumn(bisq.desktop.components.AutoTooltipTableColumn) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) TableRow(javafx.scene.control.TableRow) FormBuilder.addTitledGroupBg(bisq.desktop.util.FormBuilder.addTitledGroupBg) CheckBox(javafx.scene.control.CheckBox) StringConverter(javafx.util.StringConverter) FormBuilder.addCheckBox(bisq.desktop.util.FormBuilder.addCheckBox) BooleanProperty(javafx.beans.property.BooleanProperty) ImageUtil(bisq.desktop.util.ImageUtil) AnchorPane(javafx.scene.layout.AnchorPane) ImageView(javafx.scene.image.ImageView) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) LanguageUtil(bisq.core.locale.LanguageUtil) UserThread(bisq.common.UserThread) ActivatableViewAndModel(bisq.desktop.common.view.ActivatableViewAndModel) AutoTooltipCheckBox(bisq.desktop.components.AutoTooltipCheckBox) ChangeListener(javafx.beans.value.ChangeListener) TableGroupHeadline(bisq.desktop.components.TableGroupHeadline) Insets(javafx.geometry.Insets) BooleanProperty(javafx.beans.property.BooleanProperty) Tooltip(javafx.scene.control.Tooltip) TableColumn(javafx.scene.control.TableColumn) AutoTooltipTableColumn(bisq.desktop.components.AutoTooltipTableColumn) TableCell(javafx.scene.control.TableCell) AutoTooltipTableColumn(bisq.desktop.components.AutoTooltipTableColumn) CheckBox(javafx.scene.control.CheckBox) FormBuilder.addCheckBox(bisq.desktop.util.FormBuilder.addCheckBox) AutoTooltipCheckBox(bisq.desktop.components.AutoTooltipCheckBox) TableRow(javafx.scene.control.TableRow) Popup(bisq.desktop.main.overlays.popups.Popup)

Aggregations

Popup (bisq.desktop.main.overlays.popups.Popup)57 Label (javafx.scene.control.Label)22 Coin (org.bitcoinj.core.Coin)17 AutoTooltipLabel (bisq.desktop.components.AutoTooltipLabel)16 Button (javafx.scene.control.Button)16 Res (bisq.core.locale.Res)13 AutoTooltipButton (bisq.desktop.components.AutoTooltipButton)13 Insets (javafx.geometry.Insets)13 InputTextField (bisq.desktop.components.InputTextField)12 BSFormatter (bisq.desktop.util.BSFormatter)12 Transaction (org.bitcoinj.core.Transaction)12 List (java.util.List)11 UserThread (bisq.common.UserThread)10 ChangeListener (javafx.beans.value.ChangeListener)9 BusyAnimation (bisq.desktop.components.BusyAnimation)8 ObservableList (javafx.collections.ObservableList)8 HBox (javafx.scene.layout.HBox)8 Tuple2 (bisq.common.util.Tuple2)7 FxmlView (bisq.desktop.common.view.FxmlView)7 TradeCurrency (bisq.core.locale.TradeCurrency)6