Search in sources :

Example 1 with AutoTooltipTableColumn

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

the class BaseProposalView method createProposalColumns.

// /////////////////////////////////////////////////////////////////////////////////////////
// TableColumns
// /////////////////////////////////////////////////////////////////////////////////////////
protected void createProposalColumns(TableView<ProposalListItem> tableView) {
    TableColumn<ProposalListItem, ProposalListItem> dateColumn = new AutoTooltipTableColumn<ProposalListItem, ProposalListItem>(Res.get("shared.dateTime")) {

        {
            setMinWidth(190);
            setMaxWidth(190);
        }
    };
    dateColumn.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
    dateColumn.setCellFactory(new Callback<TableColumn<ProposalListItem, ProposalListItem>, TableCell<ProposalListItem, ProposalListItem>>() {

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

                @Override
                public void updateItem(final ProposalListItem item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null)
                        setText(bsqFormatter.formatDateTime(item.getProposal().getProposalPayload().getCreationDate()));
                    else
                        setText("");
                }
            };
        }
    });
    dateColumn.setComparator(Comparator.comparing(o3 -> o3.getProposal().getProposalPayload().getCreationDate()));
    dateColumn.setSortType(TableColumn.SortType.DESCENDING);
    tableView.getColumns().add(dateColumn);
    tableView.getSortOrder().add(dateColumn);
    TableColumn<ProposalListItem, ProposalListItem> nameColumn = new AutoTooltipTableColumn<>(Res.get("shared.name"));
    nameColumn.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
    nameColumn.setCellFactory(new Callback<TableColumn<ProposalListItem, ProposalListItem>, TableCell<ProposalListItem, ProposalListItem>>() {

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

                @Override
                public void updateItem(final ProposalListItem item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null)
                        setText(item.getProposal().getProposalPayload().getName());
                    else
                        setText("");
                }
            };
        }
    });
    nameColumn.setComparator(Comparator.comparing(o2 -> o2.getProposal().getProposalPayload().getName()));
    tableView.getColumns().add(nameColumn);
    TableColumn<ProposalListItem, ProposalListItem> titleColumn = new AutoTooltipTableColumn<>(Res.get("dao.proposal.title"));
    titleColumn.setPrefWidth(100);
    titleColumn.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
    titleColumn.setCellFactory(new Callback<TableColumn<ProposalListItem, ProposalListItem>, TableCell<ProposalListItem, ProposalListItem>>() {

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

                @Override
                public void updateItem(final ProposalListItem item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null)
                        setText(item.getProposal().getProposalPayload().getTitle());
                    else
                        setText("");
                }
            };
        }
    });
    titleColumn.setComparator(Comparator.comparing(o2 -> o2.getProposal().getProposalPayload().getTitle()));
    tableView.getColumns().add(titleColumn);
    TableColumn<ProposalListItem, ProposalListItem> uidColumn = new AutoTooltipTableColumn<>(Res.get("shared.id"));
    uidColumn.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
    uidColumn.setCellFactory(new Callback<TableColumn<ProposalListItem, ProposalListItem>, TableCell<ProposalListItem, ProposalListItem>>() {

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

                private HyperlinkWithIcon field;

                @Override
                public void updateItem(final ProposalListItem item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null && !empty) {
                        final Proposal proposal = item.getProposal();
                        final ProposalPayload proposalPayload = proposal.getProposalPayload();
                        field = new HyperlinkWithIcon(proposalPayload.getShortId());
                        field.setOnAction(event -> {
                            new ProposalDetailsWindow(bsqFormatter, bsqWalletService, proposalPayload).show();
                        });
                        field.setTooltip(new Tooltip(Res.get("tooltip.openPopupForDetails")));
                        setGraphic(field);
                    } else {
                        setGraphic(null);
                        if (field != null)
                            field.setOnAction(null);
                    }
                }
            };
        }
    });
    uidColumn.setComparator(Comparator.comparing(o -> o.getProposal().getProposalPayload().getUid()));
    tableView.getColumns().add(uidColumn);
}
Also used : TableGroupHeadline(bisq.desktop.components.TableGroupHeadline) ActivatableView(bisq.desktop.common.view.ActivatableView) BsqBlockChainChangeDispatcher(bisq.core.dao.blockchain.BsqBlockChainChangeDispatcher) HyperlinkWithIcon(bisq.desktop.components.HyperlinkWithIcon) FXCollections(javafx.collections.FXCollections) BsqNode(bisq.core.dao.node.BsqNode) Proposal(bisq.core.dao.proposal.Proposal) FxmlView(bisq.desktop.common.view.FxmlView) TableColumn(javafx.scene.control.TableColumn) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) TableCell(javafx.scene.control.TableCell) ScrollPane(javafx.scene.control.ScrollPane) Insets(javafx.geometry.Insets) ReadOnlyObjectWrapper(javafx.beans.property.ReadOnlyObjectWrapper) ListChangeListener(javafx.collections.ListChangeListener) Res(bisq.core.locale.Res) TableView(javafx.scene.control.TableView) Callback(javafx.util.Callback) Tooltip(javafx.scene.control.Tooltip) BsqBlockChain(bisq.core.dao.blockchain.BsqBlockChain) GridPane(javafx.scene.layout.GridPane) SortedList(javafx.collections.transformation.SortedList) AutoTooltipTableColumn(bisq.desktop.components.AutoTooltipTableColumn) DaoPeriodService(bisq.core.dao.DaoPeriodService) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) Node(javafx.scene.Node) Subscription(org.fxmisc.easybind.Subscription) Collectors(java.util.stream.Collectors) BsqFormatter(bisq.desktop.util.BsqFormatter) BsqWalletService(bisq.core.btc.wallet.BsqWalletService) Priority(javafx.scene.layout.Priority) ProposalPayload(bisq.core.dao.proposal.ProposalPayload) List(java.util.List) EasyBind(org.fxmisc.easybind.EasyBind) ObservableList(javafx.collections.ObservableList) ChangeListener(javafx.beans.value.ChangeListener) Comparator(java.util.Comparator) ProposalCollectionsService(bisq.core.dao.proposal.ProposalCollectionsService) 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) ProposalPayload(bisq.core.dao.proposal.ProposalPayload) HyperlinkWithIcon(bisq.desktop.components.HyperlinkWithIcon) Proposal(bisq.core.dao.proposal.Proposal)

Example 2 with AutoTooltipTableColumn

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

the class TraderDisputeView method getContractColumn.

private TableColumn<Dispute, Dispute> getContractColumn() {
    TableColumn<Dispute, Dispute> column = new AutoTooltipTableColumn<Dispute, Dispute>(Res.get("shared.details")) {

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

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

                Button button;

                @Override
                public void updateItem(final Dispute item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null && !empty) {
                        if (button == null) {
                            button = new AutoTooltipButton(Res.get("shared.details"));
                            setGraphic(button);
                        }
                        button.setOnAction(e -> onOpenContract(item));
                    } else {
                        setGraphic(null);
                        if (button != null) {
                            button.setOnAction(null);
                            button = null;
                        }
                    }
                }
            };
        }
    });
    return column;
}
Also used : Button(javafx.scene.control.Button) EventHandler(javafx.event.EventHandler) PubKeyRing(bisq.common.crypto.PubKeyRing) BusyAnimation(bisq.desktop.components.BusyAnimation) Utilities(bisq.common.util.Utilities) HyperlinkWithIcon(bisq.desktop.components.HyperlinkWithIcon) ListCell(javafx.scene.control.ListCell) URL(java.net.URL) Date(java.util.Date) ReadOnlyBooleanProperty(javafx.beans.property.ReadOnlyBooleanProperty) DisputeManager(bisq.core.arbitration.DisputeManager) VBox(javafx.scene.layout.VBox) BSFormatter(bisq.desktop.util.BSFormatter) Contract(bisq.core.trade.Contract) InputTextField(bisq.desktop.components.InputTextField) ReadOnlyObjectWrapper(javafx.beans.property.ReadOnlyObjectWrapper) ListChangeListener(javafx.collections.ListChangeListener) Res(bisq.core.locale.Res) Map(java.util.Map) TableView(javafx.scene.control.TableView) ParseException(java.text.ParseException) DateFormat(java.text.DateFormat) Pane(javafx.scene.layout.Pane) SortedList(javafx.collections.transformation.SortedList) HBox(javafx.scene.layout.HBox) Popup(bisq.desktop.main.overlays.popups.Popup) AutoTooltipTableColumn(bisq.desktop.components.AutoTooltipTableColumn) P2PService(bisq.network.p2p.P2PService) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) FilteredList(javafx.collections.transformation.FilteredList) KeyEvent(javafx.scene.input.KeyEvent) Subscription(org.fxmisc.easybind.Subscription) SendPrivateNotificationWindow(bisq.desktop.main.overlays.windows.SendPrivateNotificationWindow) Priority(javafx.scene.layout.Priority) List(java.util.List) TradeManager(bisq.core.trade.TradeManager) AnchorPane(javafx.scene.layout.AnchorPane) Paint(javafx.scene.paint.Paint) NodeAddress(bisq.network.p2p.NodeAddress) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) AppOptionKeys(bisq.core.app.AppOptionKeys) UserThread(bisq.common.UserThread) ByteStreams(com.google.common.io.ByteStreams) Optional(java.util.Optional) Attachment(bisq.core.arbitration.Attachment) ObservableList(javafx.collections.ObservableList) AwesomeIcon(de.jensd.fx.fontawesome.AwesomeIcon) TableGroupHeadline(bisq.desktop.components.TableGroupHeadline) GUIUtil(bisq.desktop.util.GUIUtil) Scene(javafx.scene.Scene) ActivatableView(bisq.desktop.common.view.ActivatableView) ListView(javafx.scene.control.ListView) DisputeSummaryWindow(bisq.desktop.main.overlays.windows.DisputeSummaryWindow) TextArea(javafx.scene.control.TextArea) SimpleDateFormat(java.text.SimpleDateFormat) Timer(bisq.common.Timer) HashMap(java.util.HashMap) Dispute(bisq.core.arbitration.Dispute) ContractWindow(bisq.desktop.main.overlays.windows.ContractWindow) FxmlView(bisq.desktop.common.view.FxmlView) TableColumn(javafx.scene.control.TableColumn) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) TableCell(javafx.scene.control.TableCell) Lists(com.google.common.collect.Lists) Insets(javafx.geometry.Insets) Connection(bisq.network.p2p.network.Connection) TextAlignment(javafx.scene.text.TextAlignment) Callback(javafx.util.Callback) Tooltip(javafx.scene.control.Tooltip) PrivateNotificationManager(bisq.core.alert.PrivateNotificationManager) Nullable(javax.annotation.Nullable) KeyCode(javafx.scene.input.KeyCode) Version(bisq.common.app.Version) Label(javafx.scene.control.Label) TradeDetailsWindow(bisq.desktop.main.overlays.windows.TradeDetailsWindow) MalformedURLException(java.net.MalformedURLException) Trade(bisq.core.trade.Trade) AwesomeDude(de.jensd.fx.fontawesome.AwesomeDude) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) File(java.io.File) TimeUnit(java.util.concurrent.TimeUnit) FileChooser(javafx.stage.FileChooser) DisputeCommunicationMessage(bisq.core.arbitration.messages.DisputeCommunicationMessage) Stage(javafx.stage.Stage) EasyBind(org.fxmisc.easybind.EasyBind) ImageView(javafx.scene.image.ImageView) ArbitratorDisputeView(bisq.desktop.main.disputes.arbitrator.ArbitratorDisputeView) Named(com.google.inject.name.Named) KeyRing(bisq.common.crypto.KeyRing) ChangeListener(javafx.beans.value.ChangeListener) InputStream(java.io.InputStream) 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) AutoTooltipTableColumn(bisq.desktop.components.AutoTooltipTableColumn) Dispute(bisq.core.arbitration.Dispute)

Example 3 with AutoTooltipTableColumn

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

the class TraderDisputeView method getTradeIdColumn.

private TableColumn<Dispute, Dispute> getTradeIdColumn() {
    TableColumn<Dispute, Dispute> column = new AutoTooltipTableColumn<Dispute, Dispute>(Res.get("shared.tradeId")) {

        {
            setMinWidth(110);
        }
    };
    column.setCellValueFactory((dispute) -> new ReadOnlyObjectWrapper<>(dispute.getValue()));
    column.setCellFactory(new Callback<TableColumn<Dispute, Dispute>, TableCell<Dispute, Dispute>>() {

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

                private HyperlinkWithIcon field;

                @Override
                public void updateItem(final Dispute item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null && !empty) {
                        field = new HyperlinkWithIcon(item.getShortTradeId());
                        Optional<Trade> tradeOptional = tradeManager.getTradeById(item.getTradeId());
                        if (tradeOptional.isPresent()) {
                            field.setMouseTransparent(false);
                            field.setTooltip(new Tooltip(Res.get("tooltip.openPopupForDetails")));
                            field.setOnAction(event -> tradeDetailsWindow.show(tradeOptional.get()));
                        } else {
                            field.setMouseTransparent(true);
                        }
                        setGraphic(field);
                    } else {
                        setGraphic(null);
                        if (field != null)
                            field.setOnAction(null);
                    }
                }
            };
        }
    });
    return column;
}
Also used : Button(javafx.scene.control.Button) EventHandler(javafx.event.EventHandler) PubKeyRing(bisq.common.crypto.PubKeyRing) BusyAnimation(bisq.desktop.components.BusyAnimation) Utilities(bisq.common.util.Utilities) HyperlinkWithIcon(bisq.desktop.components.HyperlinkWithIcon) ListCell(javafx.scene.control.ListCell) URL(java.net.URL) Date(java.util.Date) ReadOnlyBooleanProperty(javafx.beans.property.ReadOnlyBooleanProperty) DisputeManager(bisq.core.arbitration.DisputeManager) VBox(javafx.scene.layout.VBox) BSFormatter(bisq.desktop.util.BSFormatter) Contract(bisq.core.trade.Contract) InputTextField(bisq.desktop.components.InputTextField) ReadOnlyObjectWrapper(javafx.beans.property.ReadOnlyObjectWrapper) ListChangeListener(javafx.collections.ListChangeListener) Res(bisq.core.locale.Res) Map(java.util.Map) TableView(javafx.scene.control.TableView) ParseException(java.text.ParseException) DateFormat(java.text.DateFormat) Pane(javafx.scene.layout.Pane) SortedList(javafx.collections.transformation.SortedList) HBox(javafx.scene.layout.HBox) Popup(bisq.desktop.main.overlays.popups.Popup) AutoTooltipTableColumn(bisq.desktop.components.AutoTooltipTableColumn) P2PService(bisq.network.p2p.P2PService) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) FilteredList(javafx.collections.transformation.FilteredList) KeyEvent(javafx.scene.input.KeyEvent) Subscription(org.fxmisc.easybind.Subscription) SendPrivateNotificationWindow(bisq.desktop.main.overlays.windows.SendPrivateNotificationWindow) Priority(javafx.scene.layout.Priority) List(java.util.List) TradeManager(bisq.core.trade.TradeManager) AnchorPane(javafx.scene.layout.AnchorPane) Paint(javafx.scene.paint.Paint) NodeAddress(bisq.network.p2p.NodeAddress) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) AppOptionKeys(bisq.core.app.AppOptionKeys) UserThread(bisq.common.UserThread) ByteStreams(com.google.common.io.ByteStreams) Optional(java.util.Optional) Attachment(bisq.core.arbitration.Attachment) ObservableList(javafx.collections.ObservableList) AwesomeIcon(de.jensd.fx.fontawesome.AwesomeIcon) TableGroupHeadline(bisq.desktop.components.TableGroupHeadline) GUIUtil(bisq.desktop.util.GUIUtil) Scene(javafx.scene.Scene) ActivatableView(bisq.desktop.common.view.ActivatableView) ListView(javafx.scene.control.ListView) DisputeSummaryWindow(bisq.desktop.main.overlays.windows.DisputeSummaryWindow) TextArea(javafx.scene.control.TextArea) SimpleDateFormat(java.text.SimpleDateFormat) Timer(bisq.common.Timer) HashMap(java.util.HashMap) Dispute(bisq.core.arbitration.Dispute) ContractWindow(bisq.desktop.main.overlays.windows.ContractWindow) FxmlView(bisq.desktop.common.view.FxmlView) TableColumn(javafx.scene.control.TableColumn) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) TableCell(javafx.scene.control.TableCell) Lists(com.google.common.collect.Lists) Insets(javafx.geometry.Insets) Connection(bisq.network.p2p.network.Connection) TextAlignment(javafx.scene.text.TextAlignment) Callback(javafx.util.Callback) Tooltip(javafx.scene.control.Tooltip) PrivateNotificationManager(bisq.core.alert.PrivateNotificationManager) Nullable(javax.annotation.Nullable) KeyCode(javafx.scene.input.KeyCode) Version(bisq.common.app.Version) Label(javafx.scene.control.Label) TradeDetailsWindow(bisq.desktop.main.overlays.windows.TradeDetailsWindow) MalformedURLException(java.net.MalformedURLException) Trade(bisq.core.trade.Trade) AwesomeDude(de.jensd.fx.fontawesome.AwesomeDude) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) File(java.io.File) TimeUnit(java.util.concurrent.TimeUnit) FileChooser(javafx.stage.FileChooser) DisputeCommunicationMessage(bisq.core.arbitration.messages.DisputeCommunicationMessage) Stage(javafx.stage.Stage) EasyBind(org.fxmisc.easybind.EasyBind) ImageView(javafx.scene.image.ImageView) ArbitratorDisputeView(bisq.desktop.main.disputes.arbitrator.ArbitratorDisputeView) Named(com.google.inject.name.Named) KeyRing(bisq.common.crypto.KeyRing) ChangeListener(javafx.beans.value.ChangeListener) InputStream(java.io.InputStream) Optional(java.util.Optional) 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) Dispute(bisq.core.arbitration.Dispute) HyperlinkWithIcon(bisq.desktop.components.HyperlinkWithIcon)

Example 4 with AutoTooltipTableColumn

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

the class MyVotesView method createVoteColumns.

// /////////////////////////////////////////////////////////////////////////////////////////
// TableColumns
// /////////////////////////////////////////////////////////////////////////////////////////
private void createVoteColumns(TableView<VoteListItem> tableView) {
    TableColumn<VoteListItem, VoteListItem> dateColumn = new AutoTooltipTableColumn<VoteListItem, VoteListItem>(Res.get("shared.dateTime")) {

        {
            setMinWidth(190);
            setMaxWidth(190);
        }
    };
    dateColumn.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
    dateColumn.setCellFactory(new Callback<TableColumn<VoteListItem, VoteListItem>, TableCell<VoteListItem, VoteListItem>>() {

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

                @Override
                public void updateItem(final VoteListItem item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null)
                        setText(bsqFormatter.formatDateTime(new Date(item.getMyVote().getDate())));
                    else
                        setText("");
                }
            };
        }
    });
    dateColumn.setComparator(Comparator.comparing(o3 -> o3.getMyVote().getDate()));
    dateColumn.setSortType(TableColumn.SortType.DESCENDING);
    tableView.getColumns().add(dateColumn);
    tableView.getSortOrder().add(dateColumn);
    TableColumn<VoteListItem, VoteListItem> proposalListColumn = new AutoTooltipTableColumn<>(Res.get("dao.proposal.myVotes.proposalList"));
    proposalListColumn.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
    proposalListColumn.setCellFactory(new Callback<TableColumn<VoteListItem, VoteListItem>, TableCell<VoteListItem, VoteListItem>>() {

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

                @Override
                public void updateItem(final VoteListItem item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null && !empty) {
                        ProposalList proposalList = item.getMyVote().getProposalList();
                        HyperlinkWithIcon field = new HyperlinkWithIcon(Res.get("dao.proposal.myVotes.showProposalList"), AwesomeIcon.INFO_SIGN);
                        field.setOnAction(event -> onShowProposalList(proposalList));
                        field.setTooltip(new Tooltip(Res.get("dao.proposal.myVotes.tooltip.showProposalList")));
                        setGraphic(field);
                    } else {
                        setGraphic(null);
                    }
                }
            };
        }
    });
    proposalListColumn.setSortable(false);
    tableView.getColumns().add(proposalListColumn);
    TableColumn<VoteListItem, VoteListItem> stakeColumn = new AutoTooltipTableColumn<>(Res.get("dao.proposal.votes.stake"));
    stakeColumn.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
    stakeColumn.setCellFactory(new Callback<TableColumn<VoteListItem, VoteListItem>, TableCell<VoteListItem, VoteListItem>>() {

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

                @Override
                public void updateItem(final VoteListItem item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null && !empty) {
                        textProperty().bind(item.getStakeAsStringProperty());
                    } else {
                        textProperty().unbind();
                        setText("");
                    }
                }
            };
        }
    });
    stakeColumn.setComparator(Comparator.comparing(VoteListItem::getStake));
    tableView.getColumns().add(stakeColumn);
    TableColumn<VoteListItem, VoteListItem> txColumn = new AutoTooltipTableColumn<>(Res.get("dao.proposal.myVotes.tx"));
    txColumn.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
    txColumn.setCellFactory(new Callback<TableColumn<VoteListItem, VoteListItem>, TableCell<VoteListItem, VoteListItem>>() {

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

                @Override
                public void updateItem(final VoteListItem item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null && !empty) {
                        String txId = item.getMyVote().getTxId();
                        HyperlinkWithIcon hyperlinkWithIcon = new HyperlinkWithIcon(txId, AwesomeIcon.EXTERNAL_LINK);
                        hyperlinkWithIcon.setOnAction(event -> {
                            if (txId != null)
                                GUIUtil.openWebPage(preferences.getBlockChainExplorer().txUrl + txId);
                        });
                        hyperlinkWithIcon.setTooltip(new Tooltip(Res.get("tooltip.openBlockchainForTx", txId)));
                        setGraphic(hyperlinkWithIcon);
                    } else {
                        setGraphic(null);
                    }
                }
            };
        }
    });
    txColumn.setComparator(Comparator.comparing(o2 -> o2.getMyVote().getBlindVote().getTxId()));
    tableView.getColumns().add(txColumn);
    TableColumn<VoteListItem, VoteListItem> confidenceColumn = new TableColumn<>(Res.get("shared.confirmations"));
    confidenceColumn.setMinWidth(130);
    confidenceColumn.setMaxWidth(confidenceColumn.getMinWidth());
    confidenceColumn.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
    confidenceColumn.setCellFactory(new Callback<TableColumn<VoteListItem, VoteListItem>, TableCell<VoteListItem, VoteListItem>>() {

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

                @Override
                public void updateItem(final VoteListItem item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null && !empty) {
                        setGraphic(item.getTxConfidenceIndicator());
                    } else {
                        setGraphic(null);
                    }
                }
            };
        }
    });
    confidenceColumn.setComparator(Comparator.comparing(VoteListItem::getConfirmations));
    tableView.getColumns().add(confidenceColumn);
}
Also used : TableGroupHeadline(bisq.desktop.components.TableGroupHeadline) GUIUtil(bisq.desktop.util.GUIUtil) BsqBlockChainChangeDispatcher(bisq.core.dao.blockchain.BsqBlockChainChangeDispatcher) HyperlinkWithIcon(bisq.desktop.components.HyperlinkWithIcon) Date(java.util.Date) ReadableBsqBlockChain(bisq.core.dao.blockchain.ReadableBsqBlockChain) FXCollections(javafx.collections.FXCollections) Layout(bisq.desktop.util.Layout) BsqNodeProvider(bisq.core.dao.node.BsqNodeProvider) FxmlView(bisq.desktop.common.view.FxmlView) TableColumn(javafx.scene.control.TableColumn) Inject(javax.inject.Inject) TableCell(javafx.scene.control.TableCell) Insets(javafx.geometry.Insets) ReadOnlyObjectWrapper(javafx.beans.property.ReadOnlyObjectWrapper) ProposalListItem(bisq.desktop.main.dao.proposal.ProposalListItem) Res(bisq.core.locale.Res) TableView(javafx.scene.control.TableView) Callback(javafx.util.Callback) VoteService(bisq.core.dao.vote.VoteService) Tooltip(javafx.scene.control.Tooltip) BsqBlockChain(bisq.core.dao.blockchain.BsqBlockChain) GridPane(javafx.scene.layout.GridPane) SortedList(javafx.collections.transformation.SortedList) AutoTooltipTableColumn(bisq.desktop.components.AutoTooltipTableColumn) DaoPeriodService(bisq.core.dao.DaoPeriodService) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) VoteResult(bisq.core.dao.vote.VoteResult) Subscription(org.fxmisc.easybind.Subscription) Collectors(java.util.stream.Collectors) BsqFormatter(bisq.desktop.util.BsqFormatter) BsqWalletService(bisq.core.btc.wallet.BsqWalletService) Priority(javafx.scene.layout.Priority) BaseProposalView(bisq.desktop.main.dao.proposal.BaseProposalView) List(java.util.List) EasyBind(org.fxmisc.easybind.EasyBind) ImageView(javafx.scene.image.ImageView) ProposalList(bisq.core.dao.proposal.ProposalList) Preferences(bisq.core.user.Preferences) BooleanVoteResult(bisq.core.dao.vote.BooleanVoteResult) ObservableList(javafx.collections.ObservableList) AwesomeIcon(de.jensd.fx.fontawesome.AwesomeIcon) Comparator(java.util.Comparator) ProposalCollectionsService(bisq.core.dao.proposal.ProposalCollectionsService) Tooltip(javafx.scene.control.Tooltip) TableColumn(javafx.scene.control.TableColumn) AutoTooltipTableColumn(bisq.desktop.components.AutoTooltipTableColumn) Date(java.util.Date) TableCell(javafx.scene.control.TableCell) AutoTooltipTableColumn(bisq.desktop.components.AutoTooltipTableColumn) HyperlinkWithIcon(bisq.desktop.components.HyperlinkWithIcon) ProposalList(bisq.core.dao.proposal.ProposalList)

Example 5 with AutoTooltipTableColumn

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

the class OfferBookView method getAmountColumn.

// /////////////////////////////////////////////////////////////////////////////////////////
// Table
// /////////////////////////////////////////////////////////////////////////////////////////
private AutoTooltipTableColumn<OfferBookListItem, OfferBookListItem> getAmountColumn() {
    AutoTooltipTableColumn<OfferBookListItem, OfferBookListItem> column = new AutoTooltipTableColumn<>(Res.get("shared.BTCMinMax"), Res.get("shared.amountHelp"));
    column.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>() {

                @Override
                public void updateItem(final OfferBookListItem item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null && !empty)
                        setGraphic(new ColoredDecimalPlacesWithZerosText(model.getAmount(item), GUIUtil.AMOUNT_DECIMALS_WITH_ZEROS));
                    else
                        setGraphic(null);
                }
            };
        }
    });
    return column;
}
Also used : TableCell(javafx.scene.control.TableCell) AutoTooltipTableColumn(bisq.desktop.components.AutoTooltipTableColumn) ColoredDecimalPlacesWithZerosText(bisq.desktop.components.ColoredDecimalPlacesWithZerosText) AutoTooltipTableColumn(bisq.desktop.components.AutoTooltipTableColumn) TableColumn(javafx.scene.control.TableColumn)

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