Search in sources :

Example 6 with AutoTooltipTableColumn

use of bisq.desktop.components.AutoTooltipTableColumn in project bisq-desktop by bisq-network.

the class OfferBookView method getPaymentMethodColumn.

private TableColumn<OfferBookListItem, OfferBookListItem> getPaymentMethodColumn() {
    TableColumn<OfferBookListItem, OfferBookListItem> column = new AutoTooltipTableColumn<OfferBookListItem, OfferBookListItem>(Res.get("shared.paymentMethod")) {

        {
            setMinWidth(80);
        }
    };
    column.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
    column.setCellFactory(new Callback<TableColumn<OfferBookListItem, OfferBookListItem>, TableCell<OfferBookListItem, OfferBookListItem>>() {

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

                private HyperlinkWithIcon field;

                @Override
                public void updateItem(final OfferBookListItem item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null && !empty) {
                        field = new HyperlinkWithIcon(model.getPaymentMethod(item));
                        field.setOnAction(event -> offerDetailsWindow.show(item.getOffer()));
                        field.setTooltip(new Tooltip(model.getPaymentMethodToolTip(item)));
                        setGraphic(field);
                    } else {
                        setGraphic(null);
                        if (field != null)
                            field.setOnAction(null);
                    }
                }
            };
        }
    });
    return column;
}
Also used : Button(javafx.scene.control.Button) HPos(javafx.geometry.HPos) HyperlinkWithIcon(bisq.desktop.components.HyperlinkWithIcon) ArbitratorSelectionView(bisq.desktop.main.account.content.arbitratorselection.ArbitratorSelectionView) Coin(org.bitcoinj.core.Coin) Layout(bisq.desktop.util.Layout) FiatAccountsView(bisq.desktop.main.account.content.fiataccounts.FiatAccountsView) BSFormatter(bisq.desktop.util.BSFormatter) FormBuilder.getIcon(bisq.desktop.util.FormBuilder.getIcon) ComboBox(javafx.scene.control.ComboBox) ReadOnlyObjectWrapper(javafx.beans.property.ReadOnlyObjectWrapper) ListChangeListener(javafx.collections.ListChangeListener) Res(bisq.core.locale.Res) MonadicBinding(org.fxmisc.easybind.monadic.MonadicBinding) TableView(javafx.scene.control.TableView) Navigation(bisq.desktop.Navigation) HBox(javafx.scene.layout.HBox) Popup(bisq.desktop.main.overlays.popups.Popup) Offer(bisq.core.offer.Offer) AutoTooltipTableColumn(bisq.desktop.components.AutoTooltipTableColumn) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) FormBuilder.addTitledGroupBg(bisq.desktop.util.FormBuilder.addTitledGroupBg) Canvas(javafx.scene.canvas.Canvas) Subscription(org.fxmisc.easybind.Subscription) PaymentMethod(bisq.core.payment.payload.PaymentMethod) Priority(javafx.scene.layout.Priority) PaymentAccount(bisq.core.payment.PaymentAccount) NodeAddress(bisq.network.p2p.NodeAddress) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) AppOptionKeys(bisq.core.app.AppOptionKeys) AccountSettingsView(bisq.desktop.main.account.settings.AccountSettingsView) Optional(java.util.Optional) MaterialDesignIcon(de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIcon) NotNull(org.jetbrains.annotations.NotNull) GUIUtil(bisq.desktop.util.GUIUtil) Scene(javafx.scene.Scene) TradeCurrency(bisq.core.locale.TradeCurrency) FormBuilder.addHBoxLabelComboBox(bisq.desktop.util.FormBuilder.addHBoxLabelComboBox) OfferDetailsWindow(bisq.desktop.main.overlays.windows.OfferDetailsWindow) FiatCurrency(bisq.core.locale.FiatCurrency) Volume(bisq.core.monetary.Volume) FxmlView(bisq.desktop.common.view.FxmlView) TableColumn(javafx.scene.control.TableColumn) InfoAutoTooltipLabel(bisq.desktop.components.InfoAutoTooltipLabel) Inject(javax.inject.Inject) TableCell(javafx.scene.control.TableCell) WithdrawalView(bisq.desktop.main.funds.withdrawal.WithdrawalView) OfferPayload(bisq.core.offer.OfferPayload) Tuple3(bisq.common.util.Tuple3) Insets(javafx.geometry.Insets) VPos(javafx.geometry.VPos) ColoredDecimalPlacesWithZerosText(bisq.desktop.components.ColoredDecimalPlacesWithZerosText) Callback(javafx.util.Callback) FundsView(bisq.desktop.main.funds.FundsView) Tooltip(javafx.scene.control.Tooltip) AccountView(bisq.desktop.main.account.AccountView) PrivateNotificationManager(bisq.core.alert.PrivateNotificationManager) GridPane(javafx.scene.layout.GridPane) Label(javafx.scene.control.Label) TableRow(javafx.scene.control.TableRow) DontShowAgainLookup(bisq.core.user.DontShowAgainLookup) OfferView(bisq.desktop.main.offer.OfferView) StringConverter(javafx.util.StringConverter) PeerInfoIcon(bisq.desktop.components.PeerInfoIcon) FormBuilder.addButton(bisq.desktop.util.FormBuilder.addButton) MainView(bisq.desktop.main.MainView) EasyBind(org.fxmisc.easybind.EasyBind) ImageView(javafx.scene.image.ImageView) Price(bisq.core.monetary.Price) ObservableValue(javafx.beans.value.ObservableValue) Named(com.google.inject.name.Named) ActivatableViewAndModel(bisq.desktop.common.view.ActivatableViewAndModel) ChangeListener(javafx.beans.value.ChangeListener) Comparator(java.util.Comparator) ContentDisplay(javafx.scene.control.ContentDisplay) Tooltip(javafx.scene.control.Tooltip) AutoTooltipTableColumn(bisq.desktop.components.AutoTooltipTableColumn) TableColumn(javafx.scene.control.TableColumn) TableCell(javafx.scene.control.TableCell) AutoTooltipTableColumn(bisq.desktop.components.AutoTooltipTableColumn) HyperlinkWithIcon(bisq.desktop.components.HyperlinkWithIcon)

Example 7 with AutoTooltipTableColumn

use of bisq.desktop.components.AutoTooltipTableColumn in project bisq-desktop by bisq-network.

the class OfferBookView method getActionColumn.

private TableColumn<OfferBookListItem, OfferBookListItem> getActionColumn() {
    TableColumn<OfferBookListItem, OfferBookListItem> column = new AutoTooltipTableColumn<OfferBookListItem, OfferBookListItem>("") {

        {
            setMinWidth(80);
            setSortable(false);
        }
    };
    column.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
    column.setCellFactory(new Callback<TableColumn<OfferBookListItem, OfferBookListItem>, TableCell<OfferBookListItem, OfferBookListItem>>() {

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

                final ImageView iconView = new ImageView();

                final Button button = new AutoTooltipButton();

                boolean isTradable, isPaymentAccountValidForOffer, hasMatchingArbitrator, hasSameProtocolVersion, isIgnored, isOfferBanned, isCurrencyBanned, isPaymentMethodBanned, isNodeAddressBanned, isInsufficientTradeLimit;

                {
                    button.setGraphic(iconView);
                    button.setMinWidth(130);
                    button.setMaxWidth(130);
                    button.setGraphicTextGap(10);
                }

                @Override
                public void updateItem(final OfferBookListItem newItem, boolean empty) {
                    super.updateItem(newItem, empty);
                    TableRow tableRow = getTableRow();
                    if (newItem != null && !empty) {
                        final Offer offer = newItem.getOffer();
                        boolean myOffer = model.isMyOffer(offer);
                        if (tableRow != null) {
                            isPaymentAccountValidForOffer = model.isAnyPaymentAccountValidForOffer(offer);
                            hasMatchingArbitrator = model.hasMatchingArbitrator(offer);
                            hasSameProtocolVersion = model.hasSameProtocolVersion(offer);
                            isIgnored = model.isIgnored(offer);
                            isOfferBanned = model.isOfferBanned(offer);
                            isCurrencyBanned = model.isCurrencyBanned(offer);
                            isPaymentMethodBanned = model.isPaymentMethodBanned(offer);
                            isNodeAddressBanned = model.isNodeAddressBanned(offer);
                            isInsufficientTradeLimit = model.isInsufficientTradeLimit(offer);
                            isTradable = isPaymentAccountValidForOffer && hasMatchingArbitrator && hasSameProtocolVersion && !isIgnored && !isOfferBanned && !isCurrencyBanned && !isPaymentMethodBanned && !isNodeAddressBanned && !isInsufficientTradeLimit;
                            tableRow.setOpacity(isTradable || myOffer ? 1 : 0.4);
                            if (isTradable) {
                                // set first row button as default
                                button.setDefaultButton(getIndex() == 0);
                                tableRow.setOnMousePressed(null);
                            } else {
                                button.setDefaultButton(false);
                                tableRow.setOnMousePressed(e -> {
                                    // ugly hack to get the icon clickable when deactivated
                                    if (!(e.getTarget() instanceof ImageView || e.getTarget() instanceof Canvas))
                                        onShowInfo(offer, isPaymentAccountValidForOffer, hasMatchingArbitrator, hasSameProtocolVersion, isIgnored, isOfferBanned, isCurrencyBanned, isPaymentMethodBanned, isNodeAddressBanned, isInsufficientTradeLimit);
                                });
                            }
                        }
                        String title;
                        if (myOffer) {
                            iconView.setId("image-remove");
                            title = Res.get("shared.remove");
                            button.setId("cancel-button");
                            // does not take the font colors sometimes from the style
                            button.setStyle("-fx-text-fill: #444;");
                            button.setOnAction(e -> onRemoveOpenOffer(offer));
                        } else {
                            boolean isSellOffer = offer.getDirection() == OfferPayload.Direction.SELL;
                            iconView.setId(isSellOffer ? "image-buy-white" : "image-sell-white");
                            button.setId(isSellOffer ? "buy-button" : "sell-button");
                            // does not take the font colors sometimes from the style
                            button.setStyle("-fx-text-fill: white;");
                            title = Res.get("offerbook.takeOffer");
                            button.setTooltip(new Tooltip(Res.get("offerbook.takeOfferButton.tooltip", model.getDirectionLabelTooltip(offer))));
                            button.setOnAction(e -> onTakeOffer(offer));
                        }
                        if (!myOffer && !isTradable)
                            button.setOnAction(e -> onShowInfo(offer, isPaymentAccountValidForOffer, hasMatchingArbitrator, hasSameProtocolVersion, isIgnored, isOfferBanned, isCurrencyBanned, isPaymentMethodBanned, isNodeAddressBanned, isInsufficientTradeLimit));
                        button.setText(title);
                        setGraphic(button);
                    } else {
                        setGraphic(null);
                        if (button != null)
                            button.setOnAction(null);
                        if (tableRow != null) {
                            tableRow.setOpacity(1);
                            tableRow.setOnMousePressed(null);
                        }
                    }
                }
            };
        }
    });
    return column;
}
Also used : Button(javafx.scene.control.Button) HPos(javafx.geometry.HPos) HyperlinkWithIcon(bisq.desktop.components.HyperlinkWithIcon) ArbitratorSelectionView(bisq.desktop.main.account.content.arbitratorselection.ArbitratorSelectionView) Coin(org.bitcoinj.core.Coin) Layout(bisq.desktop.util.Layout) FiatAccountsView(bisq.desktop.main.account.content.fiataccounts.FiatAccountsView) BSFormatter(bisq.desktop.util.BSFormatter) FormBuilder.getIcon(bisq.desktop.util.FormBuilder.getIcon) ComboBox(javafx.scene.control.ComboBox) ReadOnlyObjectWrapper(javafx.beans.property.ReadOnlyObjectWrapper) ListChangeListener(javafx.collections.ListChangeListener) Res(bisq.core.locale.Res) MonadicBinding(org.fxmisc.easybind.monadic.MonadicBinding) TableView(javafx.scene.control.TableView) Navigation(bisq.desktop.Navigation) HBox(javafx.scene.layout.HBox) Popup(bisq.desktop.main.overlays.popups.Popup) Offer(bisq.core.offer.Offer) AutoTooltipTableColumn(bisq.desktop.components.AutoTooltipTableColumn) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) FormBuilder.addTitledGroupBg(bisq.desktop.util.FormBuilder.addTitledGroupBg) Canvas(javafx.scene.canvas.Canvas) Subscription(org.fxmisc.easybind.Subscription) PaymentMethod(bisq.core.payment.payload.PaymentMethod) Priority(javafx.scene.layout.Priority) PaymentAccount(bisq.core.payment.PaymentAccount) NodeAddress(bisq.network.p2p.NodeAddress) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) AppOptionKeys(bisq.core.app.AppOptionKeys) AccountSettingsView(bisq.desktop.main.account.settings.AccountSettingsView) Optional(java.util.Optional) MaterialDesignIcon(de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIcon) NotNull(org.jetbrains.annotations.NotNull) GUIUtil(bisq.desktop.util.GUIUtil) Scene(javafx.scene.Scene) TradeCurrency(bisq.core.locale.TradeCurrency) FormBuilder.addHBoxLabelComboBox(bisq.desktop.util.FormBuilder.addHBoxLabelComboBox) OfferDetailsWindow(bisq.desktop.main.overlays.windows.OfferDetailsWindow) FiatCurrency(bisq.core.locale.FiatCurrency) Volume(bisq.core.monetary.Volume) FxmlView(bisq.desktop.common.view.FxmlView) TableColumn(javafx.scene.control.TableColumn) InfoAutoTooltipLabel(bisq.desktop.components.InfoAutoTooltipLabel) Inject(javax.inject.Inject) TableCell(javafx.scene.control.TableCell) WithdrawalView(bisq.desktop.main.funds.withdrawal.WithdrawalView) OfferPayload(bisq.core.offer.OfferPayload) Tuple3(bisq.common.util.Tuple3) Insets(javafx.geometry.Insets) VPos(javafx.geometry.VPos) ColoredDecimalPlacesWithZerosText(bisq.desktop.components.ColoredDecimalPlacesWithZerosText) Callback(javafx.util.Callback) FundsView(bisq.desktop.main.funds.FundsView) Tooltip(javafx.scene.control.Tooltip) AccountView(bisq.desktop.main.account.AccountView) PrivateNotificationManager(bisq.core.alert.PrivateNotificationManager) GridPane(javafx.scene.layout.GridPane) Label(javafx.scene.control.Label) TableRow(javafx.scene.control.TableRow) DontShowAgainLookup(bisq.core.user.DontShowAgainLookup) OfferView(bisq.desktop.main.offer.OfferView) StringConverter(javafx.util.StringConverter) PeerInfoIcon(bisq.desktop.components.PeerInfoIcon) FormBuilder.addButton(bisq.desktop.util.FormBuilder.addButton) MainView(bisq.desktop.main.MainView) EasyBind(org.fxmisc.easybind.EasyBind) ImageView(javafx.scene.image.ImageView) Price(bisq.core.monetary.Price) ObservableValue(javafx.beans.value.ObservableValue) Named(com.google.inject.name.Named) ActivatableViewAndModel(bisq.desktop.common.view.ActivatableViewAndModel) ChangeListener(javafx.beans.value.ChangeListener) Comparator(java.util.Comparator) ContentDisplay(javafx.scene.control.ContentDisplay) Canvas(javafx.scene.canvas.Canvas) Tooltip(javafx.scene.control.Tooltip) AutoTooltipTableColumn(bisq.desktop.components.AutoTooltipTableColumn) TableColumn(javafx.scene.control.TableColumn) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) TableCell(javafx.scene.control.TableCell) Button(javafx.scene.control.Button) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) FormBuilder.addButton(bisq.desktop.util.FormBuilder.addButton) Offer(bisq.core.offer.Offer) AutoTooltipTableColumn(bisq.desktop.components.AutoTooltipTableColumn) TableRow(javafx.scene.control.TableRow) ImageView(javafx.scene.image.ImageView)

Example 8 with AutoTooltipTableColumn

use of bisq.desktop.components.AutoTooltipTableColumn in project bisq-desktop by bisq-network.

the class OfferBookView method getVolumeColumn.

private AutoTooltipTableColumn<OfferBookListItem, OfferBookListItem> getVolumeColumn() {
    AutoTooltipTableColumn<OfferBookListItem, OfferBookListItem> column = new AutoTooltipTableColumn<OfferBookListItem, OfferBookListItem>("") {

        {
            setMinWidth(125);
        }
    };
    column.getStyleClass().add("number-column");
    column.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
    column.setCellFactory(new Callback<TableColumn<OfferBookListItem, OfferBookListItem>, TableCell<OfferBookListItem, OfferBookListItem>>() {

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

                private OfferBookListItem offerBookListItem;

                final ChangeListener<Number> listener = new ChangeListener<Number>() {

                    @Override
                    public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
                        if (offerBookListItem != null && offerBookListItem.getOffer().getVolume() != null) {
                            setGraphic(new ColoredDecimalPlacesWithZerosText(model.getVolume(offerBookListItem), model.getNumberOfDecimalsForVolume(offerBookListItem)));
                            model.priceFeedService.updateCounterProperty().removeListener(listener);
                        }
                    }
                };

                @Override
                public void updateItem(final OfferBookListItem item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null && !empty) {
                        if (item.getOffer().getPrice() == null) {
                            this.offerBookListItem = item;
                            model.priceFeedService.updateCounterProperty().addListener(listener);
                            setText(Res.get("shared.na"));
                            setGraphic(null);
                        } else {
                            setText("");
                            setGraphic(new ColoredDecimalPlacesWithZerosText(model.getVolume(item), model.getNumberOfDecimalsForVolume(item)));
                        }
                    } else {
                        if (listener != null)
                            model.priceFeedService.updateCounterProperty().removeListener(listener);
                        this.offerBookListItem = null;
                        setText("");
                        setGraphic(null);
                    }
                }
            };
        }
    });
    return column;
}
Also used : ObservableValue(javafx.beans.value.ObservableValue) AutoTooltipTableColumn(bisq.desktop.components.AutoTooltipTableColumn) TableColumn(javafx.scene.control.TableColumn) TableCell(javafx.scene.control.TableCell) AutoTooltipTableColumn(bisq.desktop.components.AutoTooltipTableColumn) ColoredDecimalPlacesWithZerosText(bisq.desktop.components.ColoredDecimalPlacesWithZerosText) ListChangeListener(javafx.collections.ListChangeListener) ChangeListener(javafx.beans.value.ChangeListener)

Example 9 with AutoTooltipTableColumn

use of bisq.desktop.components.AutoTooltipTableColumn in project bisq-desktop by bisq-network.

the class OfferBookView method getPriceColumn.

private AutoTooltipTableColumn<OfferBookListItem, OfferBookListItem> getPriceColumn() {
    AutoTooltipTableColumn<OfferBookListItem, OfferBookListItem> column = new AutoTooltipTableColumn<OfferBookListItem, OfferBookListItem>("") {

        {
            setMinWidth(100);
        }
    };
    column.getStyleClass().add("number-column");
    column.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
    column.setCellFactory(new Callback<TableColumn<OfferBookListItem, OfferBookListItem>, TableCell<OfferBookListItem, OfferBookListItem>>() {

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

                private OfferBookListItem offerBookListItem;

                private ChangeListener<Number> priceChangedListener;

                ChangeListener<Scene> sceneChangeListener;

                @Override
                public void updateItem(final OfferBookListItem item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null && !empty) {
                        if (getTableView().getScene() != null && sceneChangeListener == null) {
                            sceneChangeListener = (observable, oldValue, newValue) -> {
                                if (newValue == null) {
                                    if (priceChangedListener != null) {
                                        model.priceFeedService.updateCounterProperty().removeListener(priceChangedListener);
                                        priceChangedListener = null;
                                    }
                                    offerBookListItem = null;
                                    setGraphic(null);
                                    getTableView().sceneProperty().removeListener(sceneChangeListener);
                                    sceneChangeListener = null;
                                }
                            };
                            getTableView().sceneProperty().addListener(sceneChangeListener);
                        }
                        this.offerBookListItem = item;
                        if (priceChangedListener == null) {
                            priceChangedListener = (observable, oldValue, newValue) -> {
                                if (offerBookListItem != null && offerBookListItem.getOffer().getPrice() != null) {
                                    setGraphic(getPriceLabel(model.getPrice(offerBookListItem), offerBookListItem));
                                }
                            };
                            model.priceFeedService.updateCounterProperty().addListener(priceChangedListener);
                        }
                        setGraphic(getPriceLabel(item.getOffer().getPrice() == null ? Res.get("shared.na") : model.getPrice(item), item));
                    } else {
                        if (priceChangedListener != null) {
                            model.priceFeedService.updateCounterProperty().removeListener(priceChangedListener);
                            priceChangedListener = null;
                        }
                        if (sceneChangeListener != null) {
                            getTableView().sceneProperty().removeListener(sceneChangeListener);
                            sceneChangeListener = null;
                        }
                        this.offerBookListItem = null;
                        setGraphic(null);
                    }
                }

                @NotNull
                private AutoTooltipLabel getPriceLabel(String priceString, OfferBookListItem item) {
                    final Offer offer = item.getOffer();
                    final MaterialDesignIcon icon = offer.isUseMarketBasedPrice() ? MaterialDesignIcon.CHART_LINE : MaterialDesignIcon.LOCK;
                    String info;
                    if (offer.isUseMarketBasedPrice()) {
                        if (offer.getMarketPriceMargin() == 0) {
                            if (offer.isBuyOffer()) {
                                info = Res.get("offerbook.info.sellAtMarketPrice");
                            } else {
                                info = Res.get("offerbook.info.buyAtMarketPrice");
                            }
                        } else if (offer.getMarketPriceMargin() > 0) {
                            if (offer.isBuyOffer()) {
                                info = Res.get("offerbook.info.sellBelowMarketPrice", model.getAbsolutePriceMargin(offer));
                            } else {
                                info = Res.get("offerbook.info.buyAboveMarketPrice", model.getAbsolutePriceMargin(offer));
                            }
                        } else {
                            if (offer.isBuyOffer()) {
                                info = Res.get("offerbook.info.sellAboveMarketPrice", model.getAbsolutePriceMargin(offer));
                            } else {
                                info = Res.get("offerbook.info.buyBelowMarketPrice", model.getAbsolutePriceMargin(offer));
                            }
                        }
                    } else {
                        if (offer.isBuyOffer()) {
                            info = Res.get("offerbook.info.sellAtFixedPrice");
                        } else {
                            info = Res.get("offerbook.info.buyAtFixedPrice");
                        }
                    }
                    return new InfoAutoTooltipLabel(priceString, icon, ContentDisplay.RIGHT, info);
                }
            };
        }
    });
    return column;
}
Also used : Button(javafx.scene.control.Button) HPos(javafx.geometry.HPos) HyperlinkWithIcon(bisq.desktop.components.HyperlinkWithIcon) ArbitratorSelectionView(bisq.desktop.main.account.content.arbitratorselection.ArbitratorSelectionView) Coin(org.bitcoinj.core.Coin) Layout(bisq.desktop.util.Layout) FiatAccountsView(bisq.desktop.main.account.content.fiataccounts.FiatAccountsView) BSFormatter(bisq.desktop.util.BSFormatter) FormBuilder.getIcon(bisq.desktop.util.FormBuilder.getIcon) ComboBox(javafx.scene.control.ComboBox) ReadOnlyObjectWrapper(javafx.beans.property.ReadOnlyObjectWrapper) ListChangeListener(javafx.collections.ListChangeListener) Res(bisq.core.locale.Res) MonadicBinding(org.fxmisc.easybind.monadic.MonadicBinding) TableView(javafx.scene.control.TableView) Navigation(bisq.desktop.Navigation) HBox(javafx.scene.layout.HBox) Popup(bisq.desktop.main.overlays.popups.Popup) Offer(bisq.core.offer.Offer) AutoTooltipTableColumn(bisq.desktop.components.AutoTooltipTableColumn) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) FormBuilder.addTitledGroupBg(bisq.desktop.util.FormBuilder.addTitledGroupBg) Canvas(javafx.scene.canvas.Canvas) Subscription(org.fxmisc.easybind.Subscription) PaymentMethod(bisq.core.payment.payload.PaymentMethod) Priority(javafx.scene.layout.Priority) PaymentAccount(bisq.core.payment.PaymentAccount) NodeAddress(bisq.network.p2p.NodeAddress) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) AppOptionKeys(bisq.core.app.AppOptionKeys) AccountSettingsView(bisq.desktop.main.account.settings.AccountSettingsView) Optional(java.util.Optional) MaterialDesignIcon(de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIcon) NotNull(org.jetbrains.annotations.NotNull) GUIUtil(bisq.desktop.util.GUIUtil) Scene(javafx.scene.Scene) TradeCurrency(bisq.core.locale.TradeCurrency) FormBuilder.addHBoxLabelComboBox(bisq.desktop.util.FormBuilder.addHBoxLabelComboBox) OfferDetailsWindow(bisq.desktop.main.overlays.windows.OfferDetailsWindow) FiatCurrency(bisq.core.locale.FiatCurrency) Volume(bisq.core.monetary.Volume) FxmlView(bisq.desktop.common.view.FxmlView) TableColumn(javafx.scene.control.TableColumn) InfoAutoTooltipLabel(bisq.desktop.components.InfoAutoTooltipLabel) Inject(javax.inject.Inject) TableCell(javafx.scene.control.TableCell) WithdrawalView(bisq.desktop.main.funds.withdrawal.WithdrawalView) OfferPayload(bisq.core.offer.OfferPayload) Tuple3(bisq.common.util.Tuple3) Insets(javafx.geometry.Insets) VPos(javafx.geometry.VPos) ColoredDecimalPlacesWithZerosText(bisq.desktop.components.ColoredDecimalPlacesWithZerosText) Callback(javafx.util.Callback) FundsView(bisq.desktop.main.funds.FundsView) Tooltip(javafx.scene.control.Tooltip) AccountView(bisq.desktop.main.account.AccountView) PrivateNotificationManager(bisq.core.alert.PrivateNotificationManager) GridPane(javafx.scene.layout.GridPane) Label(javafx.scene.control.Label) TableRow(javafx.scene.control.TableRow) DontShowAgainLookup(bisq.core.user.DontShowAgainLookup) OfferView(bisq.desktop.main.offer.OfferView) StringConverter(javafx.util.StringConverter) PeerInfoIcon(bisq.desktop.components.PeerInfoIcon) FormBuilder.addButton(bisq.desktop.util.FormBuilder.addButton) MainView(bisq.desktop.main.MainView) EasyBind(org.fxmisc.easybind.EasyBind) ImageView(javafx.scene.image.ImageView) Price(bisq.core.monetary.Price) ObservableValue(javafx.beans.value.ObservableValue) Named(com.google.inject.name.Named) ActivatableViewAndModel(bisq.desktop.common.view.ActivatableViewAndModel) ChangeListener(javafx.beans.value.ChangeListener) Comparator(java.util.Comparator) ContentDisplay(javafx.scene.control.ContentDisplay) MaterialDesignIcon(de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIcon) Scene(javafx.scene.Scene) AutoTooltipTableColumn(bisq.desktop.components.AutoTooltipTableColumn) TableColumn(javafx.scene.control.TableColumn) NotNull(org.jetbrains.annotations.NotNull) InfoAutoTooltipLabel(bisq.desktop.components.InfoAutoTooltipLabel) TableCell(javafx.scene.control.TableCell) Offer(bisq.core.offer.Offer) AutoTooltipTableColumn(bisq.desktop.components.AutoTooltipTableColumn) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) InfoAutoTooltipLabel(bisq.desktop.components.InfoAutoTooltipLabel)

Example 10 with AutoTooltipTableColumn

use of bisq.desktop.components.AutoTooltipTableColumn in project bisq-desktop by bisq-network.

the class OfferBookChartView method getOfferTable.

private Tuple4<TableView<OfferListItem>, VBox, Button, Label> getOfferTable(OfferPayload.Direction direction) {
    TableView<OfferListItem> tableView = new TableView<>();
    tableView.setMinHeight(initialOfferTableViewHeight);
    tableView.setPrefHeight(121);
    tableView.setMinWidth(480);
    tableView.getStyleClass().add("offer-table");
    // price
    TableColumn<OfferListItem, OfferListItem> priceColumn = new TableColumn<>();
    priceColumn.textProperty().bind(priceColumnLabel);
    priceColumn.setMinWidth(115);
    priceColumn.setMaxWidth(115);
    priceColumn.setSortable(false);
    priceColumn.getStyleClass().add("number-column");
    priceColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
    priceColumn.setCellFactory(new Callback<TableColumn<OfferListItem, OfferListItem>, TableCell<OfferListItem, OfferListItem>>() {

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

                private Offer offer;

                final ChangeListener<Number> listener = new ChangeListener<Number>() {

                    @Override
                    public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
                        if (offer != null && offer.getPrice() != null) {
                            setText("");
                            setGraphic(new ColoredDecimalPlacesWithZerosText(model.getPrice(offer), model.getZeroDecimalsForPrice(offer)));
                            model.priceFeedService.updateCounterProperty().removeListener(listener);
                        }
                    }
                };

                @Override
                public void updateItem(final OfferListItem offerListItem, boolean empty) {
                    super.updateItem(offerListItem, empty);
                    if (offerListItem != null && !empty) {
                        final Offer offer = offerListItem.offer;
                        if (offer.getPrice() == null) {
                            this.offer = offer;
                            model.priceFeedService.updateCounterProperty().addListener(listener);
                            setText(Res.get("shared.na"));
                        } else {
                            setGraphic(new ColoredDecimalPlacesWithZerosText(model.getPrice(offer), model.getZeroDecimalsForPrice(offer)));
                        }
                    } else {
                        if (listener != null)
                            model.priceFeedService.updateCounterProperty().removeListener(listener);
                        this.offer = null;
                        setText("");
                        setGraphic(null);
                    }
                }
            };
        }
    });
    // volume
    TableColumn<OfferListItem, OfferListItem> volumeColumn = new TableColumn<>();
    volumeColumn.setMinWidth(115);
    volumeColumn.setSortable(false);
    volumeColumn.textProperty().bind(volumeColumnLabel);
    volumeColumn.getStyleClass().add("number-column");
    volumeColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
    volumeColumn.setCellFactory(new Callback<TableColumn<OfferListItem, OfferListItem>, TableCell<OfferListItem, OfferListItem>>() {

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

                private Offer offer;

                final ChangeListener<Number> listener = new ChangeListener<Number>() {

                    @Override
                    public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
                        if (offer != null && offer.getPrice() != null) {
                            setText("");
                            setGraphic(new ColoredDecimalPlacesWithZerosText(model.getVolume(offer), model.getMaxNumberOfPriceZeroDecimalsToColorize(offer)));
                            model.priceFeedService.updateCounterProperty().removeListener(listener);
                        }
                    }
                };

                @Override
                public void updateItem(final OfferListItem offerListItem, boolean empty) {
                    super.updateItem(offerListItem, empty);
                    if (offerListItem != null && !empty) {
                        this.offer = offerListItem.offer;
                        if (offer.getPrice() == null) {
                            this.offer = offerListItem.offer;
                            model.priceFeedService.updateCounterProperty().addListener(listener);
                            setText(Res.get("shared.na"));
                        } else {
                            setText("");
                            setGraphic(new ColoredDecimalPlacesWithZerosText(model.getVolume(offer), model.getMaxNumberOfPriceZeroDecimalsToColorize(offer)));
                        }
                    } else {
                        if (listener != null)
                            model.priceFeedService.updateCounterProperty().removeListener(listener);
                        this.offer = null;
                        setText("");
                        setGraphic(null);
                    }
                }
            };
        }
    });
    // amount
    TableColumn<OfferListItem, OfferListItem> amountColumn = new AutoTooltipTableColumn<>(Res.get("shared.amountWithCur", Res.getBaseCurrencyCode()));
    amountColumn.setMinWidth(115);
    amountColumn.setSortable(false);
    amountColumn.getStyleClass().add("number-column");
    amountColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
    amountColumn.setCellFactory(new Callback<TableColumn<OfferListItem, OfferListItem>, TableCell<OfferListItem, OfferListItem>>() {

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

                @Override
                public void updateItem(final OfferListItem offerListItem, boolean empty) {
                    super.updateItem(offerListItem, empty);
                    if (offerListItem != null && !empty) {
                        setGraphic(new ColoredDecimalPlacesWithZerosText(formatter.formatCoin(offerListItem.offer.getAmount(), 4), GUIUtil.AMOUNT_DECIMALS_WITH_ZEROS));
                    } else {
                        setGraphic(null);
                    }
                }
            };
        }
    });
    tableView.getColumns().add(volumeColumn);
    tableView.getColumns().add(amountColumn);
    tableView.getColumns().add(priceColumn);
    tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    Label placeholder = new AutoTooltipLabel(Res.get("table.placeholder.noItems", Res.get("shared.multipleOffers")));
    placeholder.setWrapText(true);
    tableView.setPlaceholder(placeholder);
    Label titleLabel = new AutoTooltipLabel();
    titleLabel.getStyleClass().add("table-title");
    UserThread.execute(() -> titleLabel.prefWidthProperty().bind(tableView.widthProperty()));
    boolean isSellOffer = direction == OfferPayload.Direction.SELL;
    Button button = new AutoTooltipButton();
    ImageView iconView = new ImageView();
    iconView.setId(isSellOffer ? "image-buy-white" : "image-sell-white");
    button.setGraphic(iconView);
    button.setGraphicTextGap(10);
    button.setText(isSellOffer ? Res.get("market.offerBook.buy") : Res.get("market.offerBook.sell"));
    button.setMinHeight(40);
    button.setId(isSellOffer ? "buy-button-big" : "sell-button-big");
    button.setOnAction(e -> {
        if (isSellOffer) {
            model.preferences.setBuyScreenCurrencyCode(model.getCurrencyCode());
            // noinspection unchecked
            navigation.navigateTo(MainView.class, BuyOfferView.class);
        } else {
            model.preferences.setSellScreenCurrencyCode(model.getCurrencyCode());
            // noinspection unchecked
            navigation.navigateTo(MainView.class, SellOfferView.class);
        }
    });
    VBox vBox = new VBox();
    vBox.setSpacing(10);
    vBox.setFillWidth(true);
    vBox.setMinHeight(190);
    vBox.setVgrow(tableView, Priority.ALWAYS);
    vBox.getChildren().addAll(titleLabel, tableView, button);
    button.prefWidthProperty().bind(vBox.widthProperty());
    return new Tuple4<>(tableView, vBox, button, titleLabel);
}
Also used : ObservableValue(javafx.beans.value.ObservableValue) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) Label(javafx.scene.control.Label) TableCell(javafx.scene.control.TableCell) Button(javafx.scene.control.Button) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) AutoTooltipTableColumn(bisq.desktop.components.AutoTooltipTableColumn) ListChangeListener(javafx.collections.ListChangeListener) ChangeListener(javafx.beans.value.ChangeListener) ImageView(javafx.scene.image.ImageView) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) TableView(javafx.scene.control.TableView) AutoTooltipTableColumn(bisq.desktop.components.AutoTooltipTableColumn) TableColumn(javafx.scene.control.TableColumn) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) Tuple4(bisq.common.util.Tuple4) Offer(bisq.core.offer.Offer) ColoredDecimalPlacesWithZerosText(bisq.desktop.components.ColoredDecimalPlacesWithZerosText) VBox(javafx.scene.layout.VBox)

Aggregations

AutoTooltipTableColumn (bisq.desktop.components.AutoTooltipTableColumn)17 TableCell (javafx.scene.control.TableCell)17 TableColumn (javafx.scene.control.TableColumn)17 AutoTooltipLabel (bisq.desktop.components.AutoTooltipLabel)14 ChangeListener (javafx.beans.value.ChangeListener)13 ListChangeListener (javafx.collections.ListChangeListener)13 TableView (javafx.scene.control.TableView)13 Res (bisq.core.locale.Res)12 FxmlView (bisq.desktop.common.view.FxmlView)12 ReadOnlyObjectWrapper (javafx.beans.property.ReadOnlyObjectWrapper)12 Insets (javafx.geometry.Insets)12 Label (javafx.scene.control.Label)12 Tooltip (javafx.scene.control.Tooltip)12 Callback (javafx.util.Callback)12 Inject (javax.inject.Inject)12 HyperlinkWithIcon (bisq.desktop.components.HyperlinkWithIcon)11 GUIUtil (bisq.desktop.util.GUIUtil)10 ImageView (javafx.scene.image.ImageView)10 AutoTooltipButton (bisq.desktop.components.AutoTooltipButton)9 Optional (java.util.Optional)9