Search in sources :

Example 1 with ProposalListItem

use of bisq.desktop.main.dao.proposal.ProposalListItem in project bisq-desktop by bisq-network.

the class MyVotesView method createProposalColumns.

@Override
protected void createProposalColumns(TableView<ProposalListItem> tableView) {
    super.createProposalColumns(tableView);
    TableColumn<ProposalListItem, ProposalListItem> actionColumn = new TableColumn<>(Res.get("dao.proposal.votes.header"));
    actionColumn.setMinWidth(50);
    actionColumn.setMaxWidth(actionColumn.getMinWidth());
    actionColumn.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
    actionColumn.setCellFactory(new Callback<TableColumn<ProposalListItem, ProposalListItem>, TableCell<ProposalListItem, ProposalListItem>>() {

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

                ImageView actionButtonIconView;

                @Override
                public void updateItem(final ProposalListItem item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null && !empty) {
                        actionButtonIconView = new ImageView();
                        VoteResult voteResult = item.getProposal().getVoteResult();
                        if (voteResult instanceof BooleanVoteResult) {
                            if (((BooleanVoteResult) voteResult).isAccepted()) {
                                actionButtonIconView.setId("accepted");
                            } else {
                                actionButtonIconView.setId("rejected");
                            }
                        } else {
                        // TODO
                        }
                        setGraphic(actionButtonIconView);
                    } else {
                        setGraphic(null);
                    }
                }
            };
        }
    });
    actionColumn.setComparator(Comparator.comparing(ProposalListItem::getConfirmations));
    tableView.getColumns().add(actionColumn);
}
Also used : BooleanVoteResult(bisq.core.dao.vote.BooleanVoteResult) TableCell(javafx.scene.control.TableCell) ProposalListItem(bisq.desktop.main.dao.proposal.ProposalListItem) ImageView(javafx.scene.image.ImageView) TableColumn(javafx.scene.control.TableColumn) AutoTooltipTableColumn(bisq.desktop.components.AutoTooltipTableColumn) VoteResult(bisq.core.dao.vote.VoteResult) BooleanVoteResult(bisq.core.dao.vote.BooleanVoteResult)

Example 2 with ProposalListItem

use of bisq.desktop.main.dao.proposal.ProposalListItem in project bisq-desktop by bisq-network.

the class ActiveProposalsView method createProposalColumns.

// /////////////////////////////////////////////////////////////////////////////////////////
// TableColumns
// /////////////////////////////////////////////////////////////////////////////////////////
@Override
protected void createProposalColumns(TableView<ProposalListItem> tableView) {
    super.createProposalColumns(tableView);
    createConfidenceColumn(tableView);
    TableColumn<ProposalListItem, ProposalListItem> actionColumn = new TableColumn<>();
    actionColumn.setMinWidth(130);
    actionColumn.setMaxWidth(actionColumn.getMinWidth());
    actionColumn.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
    actionColumn.setCellFactory(new Callback<TableColumn<ProposalListItem, ProposalListItem>, TableCell<ProposalListItem, ProposalListItem>>() {

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

                Node node;

                @Override
                public void updateItem(final ProposalListItem item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null && !empty) {
                        if (node == null) {
                            node = item.getActionNode();
                            setGraphic(node);
                            item.setOnRemoveHandler(() -> {
                                ActiveProposalsView.this.selectedProposalListItem = item;
                                ActiveProposalsView.this.onRemove();
                            });
                            item.applyState(currentPhase, item.getProposal().getVoteResultProperty().get());
                        }
                    } else {
                        setGraphic(null);
                        if (node != null) {
                            if (node instanceof Button)
                                ((Button) node).setOnAction(null);
                            node = null;
                        }
                    }
                }
            };
        }
    });
    actionColumn.setComparator(Comparator.comparing(ProposalListItem::getConfirmations));
    tableView.getColumns().add(actionColumn);
}
Also used : TableCell(javafx.scene.control.TableCell) Button(javafx.scene.control.Button) Node(javafx.scene.Node) ProposalListItem(bisq.desktop.main.dao.proposal.ProposalListItem) TableColumn(javafx.scene.control.TableColumn)

Aggregations

ProposalListItem (bisq.desktop.main.dao.proposal.ProposalListItem)2 TableCell (javafx.scene.control.TableCell)2 TableColumn (javafx.scene.control.TableColumn)2 BooleanVoteResult (bisq.core.dao.vote.BooleanVoteResult)1 VoteResult (bisq.core.dao.vote.VoteResult)1 AutoTooltipTableColumn (bisq.desktop.components.AutoTooltipTableColumn)1 Node (javafx.scene.Node)1 Button (javafx.scene.control.Button)1 ImageView (javafx.scene.image.ImageView)1