diff --git a/core/src/main/resources/i18n/displayStrings.properties b/core/src/main/resources/i18n/displayStrings.properties index 84632a32a56..30e09d62146 100644 --- a/core/src/main/resources/i18n/displayStrings.properties +++ b/core/src/main/resources/i18n/displayStrings.properties @@ -1613,10 +1613,12 @@ dao.results.cycles.table.header.issuance=Issuance dao.results.results.table.item.cycle=Cycle {0} started: {1} dao.results.proposals.header=Proposals of selected cycle -dao.results.proposals.table.header.proposalOwnerName=Name +dao.results.proposals.table.header.nameLink=Name/link dao.results.proposals.table.header.details=Details dao.results.proposals.table.header.myVote=My vote dao.results.proposals.table.header.result=Vote result +dao.results.proposals.table.header.threshold=Threshold +dao.results.proposals.table.header.quorum=Quorum dao.results.proposals.voting.detail.header=Vote results for selected proposal diff --git a/desktop/src/main/java/bisq/desktop/main/dao/governance/result/ProposalListItem.java b/desktop/src/main/java/bisq/desktop/main/dao/governance/result/ProposalListItem.java index d90af7def03..ac7bf0bcb72 100644 --- a/desktop/src/main/java/bisq/desktop/main/dao/governance/result/ProposalListItem.java +++ b/desktop/src/main/java/bisq/desktop/main/dao/governance/result/ProposalListItem.java @@ -19,6 +19,7 @@ import bisq.desktop.util.FormBuilder; +import bisq.core.dao.governance.proposal.ProposalType; import bisq.core.dao.state.model.governance.Ballot; import bisq.core.dao.state.model.governance.ChangeParamProposal; import bisq.core.dao.state.model.governance.CompensationProposal; @@ -122,6 +123,10 @@ public AwesomeIcon getIcon() { return evaluatedProposal.isAccepted() ? AwesomeIcon.OK_SIGN : AwesomeIcon.BAN_CIRCLE; } + public boolean isAccepted() { + return evaluatedProposal.isAccepted(); + } + public String getColorStyleClass() { return evaluatedProposal.isAccepted() ? "dao-accepted-icon" : "dao-rejected-icon"; } @@ -130,11 +135,38 @@ public String getDetails() { return ProposalListItem.getProposalDetails(evaluatedProposal, bsqFormatter); } + public long getIssuedAmount() { + if (evaluatedProposal.getProposal().getType() == ProposalType.COMPENSATION_REQUEST) { + CompensationProposal compensationProposal = (CompensationProposal) proposal; + Coin requestedBsq = evaluatedProposal.isAccepted() ? compensationProposal.getRequestedBsq() : Coin.ZERO; + return requestedBsq.value; + } + return 0; + } + + public String getThresholdAsString() { + return (evaluatedProposal.getProposalVoteResult().getThreshold() / 100D) + "%"; + } + + public long getThreshold() { + return evaluatedProposal.getProposalVoteResult().getThreshold(); + } + + public String getQuorumAsString() { + return bsqFormatter.formatCoinWithCode(Coin.valueOf(evaluatedProposal.getProposalVoteResult().getQuorum())); + } + + public long getQuorum() { + return evaluatedProposal.getProposalVoteResult().getQuorum(); + } + private static String getProposalDetails(EvaluatedProposal evaluatedProposal, BsqFormatter bsqFormatter) { return getProposalDetails(evaluatedProposal, bsqFormatter, true); } - private static String getProposalDetails(EvaluatedProposal evaluatedProposal, BsqFormatter bsqFormatter, boolean useDisplayString) { + private static String getProposalDetails(EvaluatedProposal evaluatedProposal, + BsqFormatter bsqFormatter, + boolean useDisplayString) { Proposal proposal = evaluatedProposal.getProposal(); switch (proposal.getType()) { case COMPENSATION_REQUEST: diff --git a/desktop/src/main/java/bisq/desktop/main/dao/governance/result/VoteResultView.java b/desktop/src/main/java/bisq/desktop/main/dao/governance/result/VoteResultView.java index 321cc95d116..c7a3eaf7f26 100644 --- a/desktop/src/main/java/bisq/desktop/main/dao/governance/result/VoteResultView.java +++ b/desktop/src/main/java/bisq/desktop/main/dao/governance/result/VoteResultView.java @@ -651,8 +651,7 @@ private void createProposalsColumns(TableView votesTableView) TableColumn column; column = new AutoTooltipTableColumn<>(Res.get("shared.dateTime")); - column.setMinWidth(190); - column.setMaxWidth(column.getMinWidth()); + column.setMinWidth(160); column.getStyleClass().add("first-column"); column.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue())); column.setCellFactory( @@ -678,36 +677,8 @@ public void updateItem(final ProposalListItem item, boolean empty) { votesTableView.getSortOrder().add(column); - column = new AutoTooltipTableColumn<>(Res.get("dao.results.proposals.table.header.proposalOwnerName")); - column.setMinWidth(80); - column.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue())); - column.setCellFactory( - new Callback<>() { - @Override - public TableCell call( - TableColumn column) { - return new TableCell<>() { - - @Override - public void updateItem(final ProposalListItem item, boolean empty) { - super.updateItem(item, empty); - if (item != null) { - item.setTableRow(getTableRow()); - setText(item.getProposalOwnerName()); - } else { - setText(""); - } - } - }; - } - }); - column.setComparator(Comparator.comparing(ProposalListItem::getProposalOwnerName)); - votesTableView.getColumns().add(column); - - - column = new AutoTooltipTableColumn<>(Res.get("dao.proposal.table.header.link")); - column.setMinWidth(100); - column.setMaxWidth(column.getMinWidth()); + column = new AutoTooltipTableColumn<>(Res.get("dao.results.proposals.table.header.nameLink")); + column.setMinWidth(130); column.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue())); column.setCellFactory( new Callback<>() { @@ -722,10 +693,19 @@ public TableCell call(TableColumn GUIUtil.openWebPage(proposal.getLink())); - field.setTooltip(new Tooltip(proposal.getLink())); + Proposal proposal = item.getProposal(); + String link = proposal.getLink(); + String proposalOwnerName = item.getProposalOwnerName(); + String[] tokens = link.split("/"); + String nameLink = proposalOwnerName; + if (tokens.length > 0) { + String proposalNr = tokens[tokens.length - 1]; + nameLink += " (#" + proposalNr + ")"; + } + + field = new ExternalHyperlink(nameLink); + field.setOnAction(event -> GUIUtil.openWebPage(link)); + field.setTooltip(new Tooltip(proposalOwnerName + " (" + link + ")")); setGraphic(field); } else { setGraphic(null); @@ -736,7 +716,7 @@ public void updateItem(final ProposalListItem item, boolean empty) { }; } }); - column.setComparator(Comparator.comparing(o -> o.getProposal().getTxId())); + column.setComparator(Comparator.comparing((evaluatedProposal -> evaluatedProposal.getProposal().getName().toLowerCase()))); votesTableView.getColumns().add(column); @@ -760,12 +740,12 @@ public void updateItem(final ProposalListItem item, boolean empty) { }; } }); - column.setComparator(Comparator.comparing(o2 -> o2.getProposal().getName())); + column.setComparator(Comparator.comparing(o2 -> o2.getProposal().getType().getDisplayName())); votesTableView.getColumns().add(column); column = new AutoTooltipTableColumn<>(Res.get("dao.results.proposals.table.header.details")); - column.setMinWidth(180); + column.setMinWidth(100); column.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue())); column.setCellFactory( new Callback<>() { @@ -784,12 +764,13 @@ public void updateItem(final ProposalListItem item, boolean empty) { }; } }); - column.setComparator(Comparator.comparing(ProposalListItem::getDetails)); + // We sort by issued amount + column.setComparator(Comparator.comparing(ProposalListItem::getIssuedAmount)); votesTableView.getColumns().add(column); column = new AutoTooltipTableColumn<>(Res.get("dao.results.proposals.table.header.myVote")); - column.setMinWidth(70); + column.setMinWidth(60); column.setMaxWidth(column.getMinWidth()); column.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue())); column.setCellFactory(new Callback<>() { @@ -811,11 +792,60 @@ public void updateItem(final ProposalListItem item, boolean empty) { }; } }); + column.setSortable(false); votesTableView.getColumns().add(column); - column = new AutoTooltipTableColumn<>(Res.get("dao.results.proposals.table.header.result")); + column = new AutoTooltipTableColumn<>(Res.get("dao.results.proposals.table.header.threshold")); + column.setMinWidth(80); + column.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue())); + column.setCellFactory( + new Callback<>() { + @Override + public TableCell call( + TableColumn column) { + return new TableCell<>() { + @Override + public void updateItem(final ProposalListItem item, boolean empty) { + super.updateItem(item, empty); + if (item != null) + setText(item.getThresholdAsString()); + else + setText(""); + } + }; + } + }); + column.setComparator(Comparator.comparing(ProposalListItem::getThreshold)); + votesTableView.getColumns().add(column); + + + column = new AutoTooltipTableColumn<>(Res.get("dao.results.proposals.table.header.quorum")); column.setMinWidth(90); + column.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue())); + column.setCellFactory( + new Callback<>() { + @Override + public TableCell call( + TableColumn column) { + return new TableCell<>() { + @Override + public void updateItem(final ProposalListItem item, boolean empty) { + super.updateItem(item, empty); + if (item != null) + setText(item.getQuorumAsString()); + else + setText(""); + } + }; + } + }); + column.setComparator(Comparator.comparing(ProposalListItem::getQuorum)); + votesTableView.getColumns().add(column); + + + column = new AutoTooltipTableColumn<>(Res.get("dao.results.proposals.table.header.result")); + column.setMinWidth(80); column.setMaxWidth(column.getMinWidth()); column.getStyleClass().add("last-column"); column.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue())); @@ -840,6 +870,7 @@ public void updateItem(final ProposalListItem item, boolean empty) { }; } }); + column.setComparator(Comparator.comparing(ProposalListItem::isAccepted)); votesTableView.getColumns().add(column); }