Search in sources :

Example 1 with VoteResult

use of bisq.core.dao.vote.VoteResult 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)

Aggregations

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