mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-23 23:06:39 +01:00
Remove views
This commit is contained in:
parent
1b4572a898
commit
242fe68df8
28 changed files with 0 additions and 3639 deletions
|
@ -1,104 +0,0 @@
|
|||
/*
|
||||
* This file is part of Bisq.
|
||||
*
|
||||
* Bisq is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Bisq is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package bisq.desktop.main.dao.results;
|
||||
|
||||
import bisq.desktop.components.AutoTooltipLabel;
|
||||
import bisq.desktop.components.TableGroupHeadline;
|
||||
import bisq.desktop.main.dao.results.model.ResultsOfCycle;
|
||||
|
||||
import bisq.core.btc.wallet.BsqWalletService;
|
||||
import bisq.core.dao.DaoFacade;
|
||||
import bisq.core.locale.Res;
|
||||
import bisq.core.util.BsqFormatter;
|
||||
|
||||
import javafx.scene.control.TableView;
|
||||
import javafx.scene.layout.GridPane;
|
||||
import javafx.scene.layout.Priority;
|
||||
|
||||
import javafx.geometry.Insets;
|
||||
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.collections.transformation.SortedList;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public abstract class BaseResultsGridPane<R> extends GridPane {
|
||||
@Getter
|
||||
protected final BsqWalletService bsqWalletService;
|
||||
protected final DaoFacade daoFacade;
|
||||
protected final BsqFormatter bsqFormatter;
|
||||
|
||||
protected final ObservableList<R> itemList = FXCollections.observableArrayList();
|
||||
private final SortedList<R> sortedList = new SortedList<>(itemList);
|
||||
protected ResultsOfCycle resultsOfCycle;
|
||||
protected TableView<R> tableView;
|
||||
private TableGroupHeadline headline;
|
||||
|
||||
protected abstract String getTitle();
|
||||
|
||||
protected abstract void fillList();
|
||||
|
||||
protected abstract void createColumns(TableView<R> tableView);
|
||||
|
||||
public BaseResultsGridPane(BsqWalletService bsqWalletService, DaoFacade daoFacade,
|
||||
BsqFormatter bsqFormatter, int columnIndex) {
|
||||
this.bsqWalletService = bsqWalletService;
|
||||
this.daoFacade = daoFacade;
|
||||
this.bsqFormatter = bsqFormatter;
|
||||
|
||||
headline = new TableGroupHeadline(getTitle());
|
||||
GridPane.setMargin(headline, new Insets(15, -10, -10, -10));
|
||||
GridPane.setColumnIndex(headline, columnIndex);
|
||||
getChildren().add(headline);
|
||||
|
||||
tableView = new TableView<>();
|
||||
tableView.setPlaceholder(new AutoTooltipLabel(Res.get("table.placeholder.noData")));
|
||||
tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
|
||||
|
||||
createColumns(tableView);
|
||||
GridPane.setMargin(tableView, new Insets(35, -10, 5, -10));
|
||||
GridPane.setColumnIndex(tableView, columnIndex);
|
||||
getChildren().add(tableView);
|
||||
|
||||
GridPane.setHgrow(headline, Priority.ALWAYS);
|
||||
GridPane.setHgrow(tableView, Priority.ALWAYS);
|
||||
|
||||
tableView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<R>() {
|
||||
@Override
|
||||
public void changed(ObservableValue<? extends R> observable, R oldValue, R newValue) {
|
||||
onSelected(newValue);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected abstract void onSelected(R item);
|
||||
|
||||
public void createAllFields(ResultsOfCycle resultsOfCycle) {
|
||||
this.resultsOfCycle = resultsOfCycle;
|
||||
|
||||
tableView.setItems(sortedList);
|
||||
sortedList.comparatorProperty().bind(tableView.comparatorProperty());
|
||||
fillList();
|
||||
}
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
/*
|
||||
* This file is part of Bisq.
|
||||
*
|
||||
* Bisq is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Bisq is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package bisq.desktop.main.dao.results;
|
||||
|
||||
import bisq.core.dao.voting.voteresult.DecryptedVote;
|
||||
import bisq.core.dao.voting.voteresult.EvaluatedProposal;
|
||||
|
||||
import javafx.scene.control.TableRow;
|
||||
|
||||
public class BaseResultsListItem {
|
||||
private TableRow tableRow;
|
||||
|
||||
public void setTableRow(TableRow tableRow) {
|
||||
this.tableRow = tableRow;
|
||||
}
|
||||
|
||||
public void resetTableRow() {
|
||||
if (tableRow != null) {
|
||||
tableRow.setStyle(null);
|
||||
tableRow.requestLayout();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void applyVoteAndProposal(DecryptedVote decryptedVote, EvaluatedProposal evaluatedProposal) {
|
||||
String rowBgColor = decryptedVote.getVote(evaluatedProposal.getProposalTxId())
|
||||
.map(booleanVote -> booleanVote.isAccepted() ?
|
||||
"-fx-background-color: rgba(0, 255, 0, 0.4)" :
|
||||
"-fx-background-color: rgba(255, 0, 0, 0.23)")
|
||||
.orElse("-fx-background-color: rgba(182, 182, 182, 0.4)");
|
||||
tableRow.setStyle(rowBgColor);
|
||||
}
|
||||
}
|
|
@ -1,110 +0,0 @@
|
|||
/*
|
||||
* This file is part of Bisq.
|
||||
*
|
||||
* Bisq is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Bisq is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package bisq.desktop.main.dao.results;
|
||||
|
||||
import bisq.desktop.components.AutoTooltipLabel;
|
||||
import bisq.desktop.components.TableGroupHeadline;
|
||||
import bisq.desktop.main.dao.results.model.ResultsOfCycle;
|
||||
import bisq.desktop.util.GUIUtil;
|
||||
|
||||
import bisq.core.btc.wallet.BsqWalletService;
|
||||
import bisq.core.dao.DaoFacade;
|
||||
import bisq.core.locale.Res;
|
||||
import bisq.core.util.BsqFormatter;
|
||||
|
||||
import javafx.scene.control.TableView;
|
||||
import javafx.scene.layout.GridPane;
|
||||
import javafx.scene.layout.Priority;
|
||||
|
||||
import javafx.geometry.Insets;
|
||||
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.collections.transformation.SortedList;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public abstract class BaseResultsTableView<R> {
|
||||
protected final GridPane gridPane;
|
||||
protected final BsqWalletService bsqWalletService;
|
||||
protected final DaoFacade daoFacade;
|
||||
protected final BsqFormatter bsqFormatter;
|
||||
|
||||
protected int gridRow;
|
||||
protected int gridRowStartIndex;
|
||||
|
||||
|
||||
protected final ObservableList<R> itemList = FXCollections.observableArrayList();
|
||||
private final SortedList<R> sortedList = new SortedList<>(itemList);
|
||||
protected ResultsOfCycle resultsOfCycle;
|
||||
protected TableView<R> tableView;
|
||||
|
||||
protected abstract String getTitle();
|
||||
|
||||
protected abstract void fillList();
|
||||
|
||||
protected abstract void createColumns(TableView<R> tableView);
|
||||
|
||||
public BaseResultsTableView(GridPane gridPane, BsqWalletService bsqWalletService, DaoFacade daoFacade, BsqFormatter bsqFormatter) {
|
||||
this.gridPane = gridPane;
|
||||
this.bsqWalletService = bsqWalletService;
|
||||
this.daoFacade = daoFacade;
|
||||
this.bsqFormatter = bsqFormatter;
|
||||
}
|
||||
|
||||
public int createAllFields(int gridRowStartIndex, ResultsOfCycle resultsOfCycle) {
|
||||
this.resultsOfCycle = resultsOfCycle;
|
||||
this.gridRowStartIndex = gridRowStartIndex;
|
||||
this.gridRow = gridRowStartIndex;
|
||||
|
||||
removeAllFields();
|
||||
createTableView();
|
||||
fillList();
|
||||
GUIUtil.setFitToRowsForTableView(tableView, 33, 28, 80);
|
||||
|
||||
return gridRow;
|
||||
}
|
||||
|
||||
private void createTableView() {
|
||||
TableGroupHeadline headline = new TableGroupHeadline(getTitle());
|
||||
GridPane.setRowIndex(headline, gridRow);
|
||||
GridPane.setMargin(headline, new Insets(15, -10, -10, -10));
|
||||
GridPane.setColumnSpan(headline, 2);
|
||||
gridPane.getChildren().add(headline);
|
||||
|
||||
tableView = new TableView<>();
|
||||
tableView.setPlaceholder(new AutoTooltipLabel(Res.get("table.placeholder.noData")));
|
||||
tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
|
||||
|
||||
createColumns(tableView);
|
||||
GridPane.setRowIndex(tableView, gridRow);
|
||||
GridPane.setMargin(tableView, new Insets(35, -10, 5, -10));
|
||||
GridPane.setColumnSpan(tableView, 2);
|
||||
GridPane.setHgrow(tableView, Priority.SOMETIMES);
|
||||
gridPane.getChildren().add(tableView);
|
||||
|
||||
tableView.setItems(sortedList);
|
||||
sortedList.comparatorProperty().bind(tableView.comparatorProperty());
|
||||
}
|
||||
|
||||
private void removeAllFields() {
|
||||
GUIUtil.removeChildrenFromGridPaneRows(gridPane, gridRowStartIndex, gridRow);
|
||||
gridRow = gridRowStartIndex;
|
||||
}
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
~ This file is part of Bisq.
|
||||
~
|
||||
~ Bisq is free software: you can redistribute it and/or modify it
|
||||
~ under the terms of the GNU Affero General Public License as published by
|
||||
~ the Free Software Foundation, either version 3 of the License, or (at
|
||||
~ your option) any later version.
|
||||
~
|
||||
~ Bisq is distributed in the hope that it will be useful, but WITHOUT
|
||||
~ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
~ FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
~ License for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU Affero General Public License
|
||||
~ along with Bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<!--<GridPane fx:id="root" fx:controller="bisq.desktop.main.dao.results.ResultsView"
|
||||
hgap="5.0" vgap="5.0"
|
||||
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
|
||||
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"
|
||||
xmlns:fx="http://javafx.com/fxml">
|
||||
<padding>
|
||||
<Insets bottom="10.0" left="25.0" top="15.0" right="25"/>
|
||||
</padding>
|
||||
|
||||
<columnConstraints>
|
||||
<ColumnConstraints hgrow="SOMETIMES" halignment="RIGHT" minWidth="140.0"/>
|
||||
<ColumnConstraints hgrow="ALWAYS" minWidth="300.0"/>
|
||||
</columnConstraints>
|
||||
</GridPane>-->
|
||||
|
||||
<?import javafx.scene.control.ScrollPane?>
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
<AnchorPane fx:id="root" fx:controller="bisq.desktop.main.dao.results.ResultsView"
|
||||
xmlns:fx="http://javafx.com/fxml">
|
||||
|
||||
<ScrollPane fx:id="scrollPane" fitToWidth="true" fitToHeight="true"
|
||||
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
|
||||
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
</ScrollPane>
|
||||
|
||||
</AnchorPane>
|
|
@ -1,542 +0,0 @@
|
|||
/*
|
||||
* This file is part of Bisq.
|
||||
*
|
||||
* Bisq is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Bisq is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package bisq.desktop.main.dao.results;
|
||||
|
||||
|
||||
import bisq.desktop.common.model.Activatable;
|
||||
import bisq.desktop.common.view.ActivatableViewAndModel;
|
||||
import bisq.desktop.common.view.FxmlView;
|
||||
import bisq.desktop.components.AutoTooltipLabel;
|
||||
import bisq.desktop.components.AutoTooltipTableColumn;
|
||||
import bisq.desktop.components.TableGroupHeadline;
|
||||
import bisq.desktop.components.TitledGroupBg;
|
||||
import bisq.desktop.main.dao.results.model.ResultsOfCycle;
|
||||
import bisq.desktop.main.dao.results.proposals.ProposalResultsGridPane;
|
||||
import bisq.desktop.main.dao.results.votes.VoteResultsGridPane;
|
||||
import bisq.desktop.util.FormBuilder;
|
||||
import bisq.desktop.util.GUIUtil;
|
||||
|
||||
import bisq.core.btc.wallet.BsqWalletService;
|
||||
import bisq.core.dao.DaoFacade;
|
||||
import bisq.core.dao.state.BsqStateListener;
|
||||
import bisq.core.dao.state.BsqStateService;
|
||||
import bisq.core.dao.state.blockchain.Block;
|
||||
import bisq.core.dao.state.ext.Param;
|
||||
import bisq.core.dao.state.period.Cycle;
|
||||
import bisq.core.dao.state.period.CycleService;
|
||||
import bisq.core.dao.voting.blindvote.BlindVoteConsensus;
|
||||
import bisq.core.dao.voting.proposal.Proposal;
|
||||
import bisq.core.dao.voting.proposal.ProposalConsensus;
|
||||
import bisq.core.dao.voting.proposal.ProposalService;
|
||||
import bisq.core.dao.voting.proposal.storage.appendonly.ProposalPayload;
|
||||
import bisq.core.dao.voting.voteresult.DecryptedVote;
|
||||
import bisq.core.dao.voting.voteresult.EvaluatedProposal;
|
||||
import bisq.core.dao.voting.voteresult.VoteResultService;
|
||||
import bisq.core.locale.Res;
|
||||
import bisq.core.user.Preferences;
|
||||
import bisq.core.util.BsqFormatter;
|
||||
|
||||
import org.bitcoinj.core.Coin;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import javafx.fxml.FXML;
|
||||
|
||||
import javafx.scene.control.ScrollPane;
|
||||
import javafx.scene.control.TableCell;
|
||||
import javafx.scene.control.TableColumn;
|
||||
import javafx.scene.control.TableView;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.layout.ColumnConstraints;
|
||||
import javafx.scene.layout.GridPane;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.Priority;
|
||||
|
||||
import javafx.geometry.HPos;
|
||||
import javafx.geometry.Insets;
|
||||
|
||||
import javafx.beans.property.ReadOnlyObjectWrapper;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.collections.transformation.SortedList;
|
||||
|
||||
import javafx.util.Callback;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static bisq.desktop.util.FormBuilder.addLabelTextField;
|
||||
|
||||
@FxmlView
|
||||
public class ResultsView extends ActivatableViewAndModel<AnchorPane, Activatable> implements BsqStateListener, SelectionListener {
|
||||
@FXML
|
||||
private ScrollPane scrollPane;
|
||||
|
||||
private final DaoFacade daoFacade;
|
||||
// TODO use daoFacade once dev work completed
|
||||
private final BsqStateService bsqStateService;
|
||||
private final CycleService cycleService;
|
||||
private final VoteResultService voteResultService;
|
||||
private final ProposalService proposalService;
|
||||
private final BsqWalletService bsqWalletService;
|
||||
private final Preferences preferences;
|
||||
private final BsqFormatter bsqFormatter;
|
||||
|
||||
private int gridRow = 0;
|
||||
private TableView<ResultsListItem> tableView;
|
||||
private final ObservableList<ResultsListItem> itemList = FXCollections.observableArrayList();
|
||||
private final SortedList<ResultsListItem> sortedList = new SortedList<>(itemList);
|
||||
private ChangeListener<ResultsListItem> selectedItemListener;
|
||||
private ProposalResultsGridPane proposalResultsGridPane;
|
||||
private VoteResultsGridPane voteResultsGridPane;
|
||||
private GridPane gridPane;
|
||||
private HBox hBox;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Constructor, lifecycle
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
private ResultsView(DaoFacade daoFacade,
|
||||
BsqStateService bsqStateService,
|
||||
CycleService cycleService,
|
||||
VoteResultService voteResultService,
|
||||
ProposalService proposalService,
|
||||
BsqWalletService bsqWalletService,
|
||||
Preferences preferences,
|
||||
BsqFormatter bsqFormatter) {
|
||||
this.daoFacade = daoFacade;
|
||||
this.bsqStateService = bsqStateService;
|
||||
this.cycleService = cycleService;
|
||||
this.voteResultService = voteResultService;
|
||||
this.proposalService = proposalService;
|
||||
this.bsqWalletService = bsqWalletService;
|
||||
this.preferences = preferences;
|
||||
this.bsqFormatter = bsqFormatter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
daoFacade.addBsqStateListener(this);
|
||||
|
||||
createCyclesTable();
|
||||
|
||||
hBox = new HBox();
|
||||
hBox.setSpacing(30);
|
||||
hBox.setFillHeight(true);
|
||||
|
||||
proposalResultsGridPane = new ProposalResultsGridPane(this, bsqWalletService, daoFacade, bsqFormatter,
|
||||
bsqStateService);
|
||||
hBox.getChildren().add(proposalResultsGridPane);
|
||||
|
||||
voteResultsGridPane = new VoteResultsGridPane(this, bsqWalletService, daoFacade, bsqStateService, preferences, bsqFormatter);
|
||||
hBox.getChildren().add(voteResultsGridPane);
|
||||
|
||||
HBox.setHgrow(proposalResultsGridPane, Priority.ALWAYS);
|
||||
HBox.setHgrow(voteResultsGridPane, Priority.ALWAYS);
|
||||
|
||||
selectedItemListener = (observable, oldValue, newValue) -> onResultsListItemSelected(newValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void activate() {
|
||||
tableView.getSelectionModel().selectedItemProperty().addListener(selectedItemListener);
|
||||
fillCycleList();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void deactivate() {
|
||||
tableView.getSelectionModel().selectedItemProperty().removeListener(selectedItemListener);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// SelectionListener
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void onSelectedEvaluatedProposal(EvaluatedProposal evaluatedProposal) {
|
||||
voteResultsGridPane.onSelectedEvaluatedProposal(evaluatedProposal);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSelectedDecryptedVote(DecryptedVote decryptedVote) {
|
||||
proposalResultsGridPane.onSelectedDecryptedVote(decryptedVote);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// BsqStateListener
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void onNewBlockHeight(int blockHeight) {
|
||||
fillCycleList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEmptyBlockAdded(Block block) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onParseTxsComplete(Block block) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onParseBlockChainComplete() {
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// UI handlers
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private void onResultsListItemSelected(ResultsListItem item) {
|
||||
//removeDetailsViews();
|
||||
if (item != null) {
|
||||
ResultsOfCycle resultsOfCycle = item.getResultsOfCycle();
|
||||
|
||||
GUIUtil.removeChildrenFromGridPaneRows(gridPane, 1, gridRow);
|
||||
gridRow = 1;
|
||||
|
||||
// gridRow = votesPerProposalTableView.createAllFields(++gridRow, resultsOfCycle);
|
||||
proposalResultsGridPane.createAllFields(resultsOfCycle);
|
||||
voteResultsGridPane.createAllFields(resultsOfCycle);
|
||||
|
||||
gridPane.getChildren().add(hBox);
|
||||
|
||||
GridPane.setRowIndex(hBox, gridRow);
|
||||
GridPane.setMargin(hBox, new Insets(0, 0, 0, 0));
|
||||
GridPane.setColumnSpan(hBox, 2);
|
||||
|
||||
// addParams(resultsOfCycle);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Create views
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private void createCyclesTable() {
|
||||
gridPane = new GridPane();
|
||||
|
||||
gridPane.setHgap(5);
|
||||
gridPane.setVgap(5);
|
||||
|
||||
gridPane.setPadding(new Insets(15, 25, 10, 25));
|
||||
|
||||
ColumnConstraints columnConstraints1 = new ColumnConstraints();
|
||||
columnConstraints1.setHalignment(HPos.RIGHT);
|
||||
columnConstraints1.setHgrow(Priority.SOMETIMES);
|
||||
|
||||
columnConstraints1.setMinWidth(140);
|
||||
|
||||
ColumnConstraints columnConstraints2 = new ColumnConstraints();
|
||||
columnConstraints2.setHgrow(Priority.ALWAYS);
|
||||
columnConstraints1.setMinWidth(300);
|
||||
|
||||
gridPane.getColumnConstraints().addAll(columnConstraints1, columnConstraints2);
|
||||
scrollPane.setContent(gridPane);
|
||||
|
||||
TableGroupHeadline headline = new TableGroupHeadline(Res.get("dao.results.cycles.header"));
|
||||
GridPane.setRowIndex(headline, gridRow);
|
||||
GridPane.setMargin(headline, new Insets(0, -10, -10, -10));
|
||||
GridPane.setColumnSpan(headline, 2);
|
||||
gridPane.getChildren().add(headline);
|
||||
|
||||
tableView = new TableView<>();
|
||||
tableView.setPlaceholder(new AutoTooltipLabel(Res.get("table.placeholder.noData")));
|
||||
tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
|
||||
|
||||
createColumns(tableView);
|
||||
|
||||
GridPane.setRowIndex(tableView, gridRow);
|
||||
GridPane.setMargin(tableView, new Insets(20, -10, 5, -10));
|
||||
GridPane.setColumnSpan(tableView, 2);
|
||||
gridPane.getChildren().add(tableView);
|
||||
|
||||
tableView.setItems(sortedList);
|
||||
sortedList.comparatorProperty().bind(tableView.comparatorProperty());
|
||||
}
|
||||
|
||||
private void addParams(ResultsOfCycle resultsOfCycle) {
|
||||
//TODO
|
||||
AtomicInteger rowSpan = new AtomicInteger(2);
|
||||
TitledGroupBg header = FormBuilder.addTitledGroupBg(gridPane, ++gridRow, rowSpan.get(), Res.get("dao.results.cycle.header"), 20);
|
||||
|
||||
int height = resultsOfCycle.getCycle().getHeightOfFirstBlock();
|
||||
gridRow--; // first item use same gridRow as header. as we use a ++ in the loop adjust by --.
|
||||
Arrays.stream(Param.values()).forEach(param -> {
|
||||
String label = null;
|
||||
long paramValue = bsqStateService.getParamValue(param, height);
|
||||
boolean isDefaultValue = param.getDefaultValue() == paramValue;
|
||||
String value = null;
|
||||
int top = (param == Param.BSQ_MAKER_FEE_IN_PERCENT) ? 40 : 0;
|
||||
switch (param) {
|
||||
case UNDEFINED:
|
||||
// ignore
|
||||
break;
|
||||
|
||||
case BSQ_MAKER_FEE_IN_PERCENT:
|
||||
case BSQ_TAKER_FEE_IN_PERCENT:
|
||||
case BTC_MAKER_FEE_IN_PERCENT:
|
||||
case BTC_TAKER_FEE_IN_PERCENT:
|
||||
label = Res.getWithCol("dao.param." + param.name());
|
||||
value = bsqFormatter.formatToPercentWithSymbol(paramValue / 10000d);
|
||||
break;
|
||||
|
||||
case PROPOSAL_FEE:
|
||||
label = Res.getWithCol("dao.param." + param.name());
|
||||
value = bsqFormatter.formatCoinWithCode(ProposalConsensus.getFee(bsqStateService, height));
|
||||
break;
|
||||
case BLIND_VOTE_FEE:
|
||||
label = Res.getWithCol("dao.param." + param.name());
|
||||
value = bsqFormatter.formatCoinWithCode(BlindVoteConsensus.getFee(bsqStateService, height));
|
||||
break;
|
||||
|
||||
case QUORUM_PROPOSAL:
|
||||
case QUORUM_COMP_REQUEST:
|
||||
case QUORUM_CHANGE_PARAM:
|
||||
case QUORUM_REMOVE_ASSET:
|
||||
case QUORUM_CONFISCATION:
|
||||
label = Res.getWithCol("dao.param." + param.name());
|
||||
value = bsqFormatter.formatCoinWithCode(Coin.valueOf(paramValue));
|
||||
break;
|
||||
case THRESHOLD_PROPOSAL:
|
||||
|
||||
case THRESHOLD_COMP_REQUEST:
|
||||
case THRESHOLD_CHANGE_PARAM:
|
||||
case THRESHOLD_REMOVE_ASSET:
|
||||
case THRESHOLD_CONFISCATION:
|
||||
label = Res.getWithCol("dao.param." + param.name());
|
||||
value = bsqFormatter.formatToPercentWithSymbol(paramValue / 10000d);
|
||||
break;
|
||||
|
||||
case PHASE_UNDEFINED:
|
||||
// ignore
|
||||
break;
|
||||
|
||||
case PHASE_PROPOSAL:
|
||||
case PHASE_BREAK1:
|
||||
case PHASE_BLIND_VOTE:
|
||||
case PHASE_BREAK2:
|
||||
case PHASE_VOTE_REVEAL:
|
||||
case PHASE_BREAK3:
|
||||
case PHASE_RESULT:
|
||||
case PHASE_BREAK4:
|
||||
String phase = Res.get("dao.phase." + param.name());
|
||||
label = Res.getWithCol("dao.results.cycle.duration.label", phase);
|
||||
value = Res.get("dao.results.cycle.duration.value", paramValue);
|
||||
break;
|
||||
}
|
||||
if (value != null) {
|
||||
String postFix = isDefaultValue ?
|
||||
Res.get("dao.results.cycle.value.postFix.isDefaultValue") :
|
||||
Res.get("dao.results.cycle.value.postFix.hasChanged");
|
||||
value += " " + postFix;
|
||||
addLabelTextField(gridPane, ++gridRow, label, value, top);
|
||||
rowSpan.getAndIncrement();
|
||||
}
|
||||
});
|
||||
|
||||
GridPane.setRowSpan(header, rowSpan.get());
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Private
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private void fillCycleList() {
|
||||
itemList.clear();
|
||||
bsqStateService.getCycles().forEach(this::addCycleListItem);
|
||||
Collections.reverse(itemList);
|
||||
GUIUtil.setFitToRowsForTableView(tableView, 24, 28, 80);
|
||||
}
|
||||
|
||||
private void addCycleListItem(Cycle cycle) {
|
||||
List<Proposal> proposalsForCycle = proposalService.getAppendOnlyStoreList().stream()
|
||||
.filter(proposalPayload -> cycleService.isTxInCycle(cycle, proposalPayload.getProposal().getTxId()))
|
||||
.map(ProposalPayload::getProposal)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<EvaluatedProposal> evaluatedProposalsForCycle = voteResultService.getAllEvaluatedProposals().stream()
|
||||
.filter(evaluatedProposal -> cycleService.isTxInCycle(cycle, evaluatedProposal.getProposal().getTxId()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<DecryptedVote> decryptedVotesForCycle = voteResultService.getAllDecryptedVotes().stream()
|
||||
.filter(decryptedVote -> cycleService.isTxInCycle(cycle, decryptedVote.getBlindVoteTxId()))
|
||||
.filter(decryptedVote -> cycleService.isTxInCycle(cycle, decryptedVote.getVoteRevealTxId()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
long cycleStartTime = bsqStateService.getBlockAtHeight(cycle.getHeightOfFirstBlock())
|
||||
.map(e -> e.getTime() * 1000)
|
||||
.orElse(0L);
|
||||
int cycleIndex = cycleService.getCycleIndex(cycle);
|
||||
ResultsOfCycle resultsOfCycle = new ResultsOfCycle(cycle,
|
||||
cycleIndex,
|
||||
cycleStartTime,
|
||||
proposalsForCycle,
|
||||
evaluatedProposalsForCycle,
|
||||
decryptedVotesForCycle);
|
||||
ResultsListItem resultsListItem = new ResultsListItem(resultsOfCycle, bsqStateService, bsqFormatter);
|
||||
itemList.add(resultsListItem);
|
||||
}
|
||||
|
||||
private void removeDetailsViews() {
|
||||
GUIUtil.removeChildrenFromGridPaneRows(gridPane, 1, gridRow);
|
||||
gridRow = 0;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// TableColumns
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private void createColumns(TableView<ResultsListItem> tableView) {
|
||||
TableColumn<ResultsListItem, ResultsListItem> cycleColumn = new AutoTooltipTableColumn<>(Res.get("dao.results.cycles.table.header.cycle"));
|
||||
cycleColumn.setMinWidth(160);
|
||||
cycleColumn.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
|
||||
cycleColumn.setCellFactory(
|
||||
new Callback<TableColumn<ResultsListItem, ResultsListItem>, TableCell<ResultsListItem,
|
||||
ResultsListItem>>() {
|
||||
@Override
|
||||
public TableCell<ResultsListItem, ResultsListItem> call(
|
||||
TableColumn<ResultsListItem, ResultsListItem> column) {
|
||||
return new TableCell<ResultsListItem, ResultsListItem>() {
|
||||
@Override
|
||||
public void updateItem(final ResultsListItem item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (item != null)
|
||||
setText(item.getCycle());
|
||||
else
|
||||
setText("");
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
cycleColumn.setComparator(Comparator.comparing(ResultsListItem::getCycleStartTime));
|
||||
tableView.getColumns().add(cycleColumn);
|
||||
|
||||
TableColumn<ResultsListItem, ResultsListItem> proposalsColumn = new AutoTooltipTableColumn<>(Res.get("dao.results.cycles.table.header.numProposals"));
|
||||
proposalsColumn.setMinWidth(90);
|
||||
proposalsColumn.setMaxWidth(90);
|
||||
proposalsColumn.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
|
||||
proposalsColumn.setCellFactory(
|
||||
new Callback<TableColumn<ResultsListItem, ResultsListItem>, TableCell<ResultsListItem,
|
||||
ResultsListItem>>() {
|
||||
@Override
|
||||
public TableCell<ResultsListItem, ResultsListItem> call(
|
||||
TableColumn<ResultsListItem, ResultsListItem> column) {
|
||||
return new TableCell<ResultsListItem, ResultsListItem>() {
|
||||
@Override
|
||||
public void updateItem(final ResultsListItem item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (item != null)
|
||||
setText(item.getNumProposals());
|
||||
else
|
||||
setText("");
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
proposalsColumn.setComparator(Comparator.comparing(ResultsListItem::getNumProposals));
|
||||
tableView.getColumns().add(proposalsColumn);
|
||||
|
||||
TableColumn<ResultsListItem, ResultsListItem> votesColumn = new AutoTooltipTableColumn<>(Res.get("dao.results.cycles.table.header.numVotes"));
|
||||
votesColumn.setMinWidth(70);
|
||||
votesColumn.setMaxWidth(70);
|
||||
votesColumn.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
|
||||
votesColumn.setCellFactory(
|
||||
new Callback<TableColumn<ResultsListItem, ResultsListItem>, TableCell<ResultsListItem,
|
||||
ResultsListItem>>() {
|
||||
@Override
|
||||
public TableCell<ResultsListItem, ResultsListItem> call(
|
||||
TableColumn<ResultsListItem, ResultsListItem> column) {
|
||||
return new TableCell<ResultsListItem, ResultsListItem>() {
|
||||
@Override
|
||||
public void updateItem(final ResultsListItem item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (item != null)
|
||||
setText(item.getNumVotesAsString());
|
||||
else
|
||||
setText("");
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
votesColumn.setComparator(Comparator.comparing(ResultsListItem::getNumProposals));
|
||||
tableView.getColumns().add(votesColumn);
|
||||
|
||||
TableColumn<ResultsListItem, ResultsListItem> stakeColumn = new AutoTooltipTableColumn<>(Res.get("dao.results.cycles.table.header.stake"));
|
||||
stakeColumn.setMinWidth(70);
|
||||
stakeColumn.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
|
||||
stakeColumn.setCellFactory(
|
||||
new Callback<TableColumn<ResultsListItem, ResultsListItem>, TableCell<ResultsListItem,
|
||||
ResultsListItem>>() {
|
||||
@Override
|
||||
public TableCell<ResultsListItem, ResultsListItem> call(
|
||||
TableColumn<ResultsListItem, ResultsListItem> column) {
|
||||
return new TableCell<ResultsListItem, ResultsListItem>() {
|
||||
@Override
|
||||
public void updateItem(final ResultsListItem item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (item != null)
|
||||
setText(item.getStake());
|
||||
else
|
||||
setText("");
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
stakeColumn.setComparator(Comparator.comparing(ResultsListItem::getNumProposals));
|
||||
tableView.getColumns().add(stakeColumn);
|
||||
|
||||
TableColumn<ResultsListItem, ResultsListItem> issuanceColumn = new AutoTooltipTableColumn<>(Res.get("dao.results.cycles.table.header.issuance"));
|
||||
issuanceColumn.setMinWidth(70);
|
||||
issuanceColumn.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
|
||||
issuanceColumn.setCellFactory(
|
||||
new Callback<TableColumn<ResultsListItem, ResultsListItem>, TableCell<ResultsListItem,
|
||||
ResultsListItem>>() {
|
||||
@Override
|
||||
public TableCell<ResultsListItem, ResultsListItem> call(
|
||||
TableColumn<ResultsListItem, ResultsListItem> column) {
|
||||
return new TableCell<ResultsListItem, ResultsListItem>() {
|
||||
@Override
|
||||
public void updateItem(final ResultsListItem item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (item != null)
|
||||
setText(item.getIssuance());
|
||||
else
|
||||
setText("");
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
issuanceColumn.setComparator(Comparator.comparing(ResultsListItem::getNumProposals));
|
||||
tableView.getColumns().add(issuanceColumn);
|
||||
}
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
/*
|
||||
* This file is part of Bisq.
|
||||
*
|
||||
* Bisq is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Bisq is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package bisq.desktop.main.dao.results;
|
||||
|
||||
import bisq.core.dao.voting.voteresult.DecryptedVote;
|
||||
import bisq.core.dao.voting.voteresult.EvaluatedProposal;
|
||||
|
||||
public interface SelectionListener {
|
||||
|
||||
void onSelectedEvaluatedProposal(EvaluatedProposal evaluatedProposal);
|
||||
|
||||
void onSelectedDecryptedVote(DecryptedVote decryptedVote);
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
/*
|
||||
* This file is part of Bisq.
|
||||
*
|
||||
* Bisq is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Bisq is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package bisq.desktop.main.dao.results.combo;
|
||||
|
||||
import bisq.core.dao.voting.voteresult.DecryptedVote;
|
||||
import bisq.core.dao.voting.voteresult.EvaluatedProposal;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class EvaluatedProposalWithDecryptedVotes {
|
||||
private final EvaluatedProposal evaluatedProposal;
|
||||
private Map<String, DecryptedVote> decryptedVotesByBlindVoteTxId = new HashMap<>();
|
||||
|
||||
public EvaluatedProposalWithDecryptedVotes(EvaluatedProposal evaluatedProposal) {
|
||||
this.evaluatedProposal = evaluatedProposal;
|
||||
}
|
||||
|
||||
public void addDecryptedVote(DecryptedVote decryptedVote) {
|
||||
decryptedVotesByBlindVoteTxId.put(decryptedVote.getBlindVoteTxId(), decryptedVote);
|
||||
}
|
||||
}
|
|
@ -1,75 +0,0 @@
|
|||
/*
|
||||
* This file is part of Bisq.
|
||||
*
|
||||
* Bisq is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Bisq is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package bisq.desktop.main.dao.results.combo;
|
||||
|
||||
import bisq.core.dao.voting.ballot.Ballot;
|
||||
import bisq.core.dao.voting.ballot.vote.BooleanVote;
|
||||
import bisq.core.dao.voting.proposal.Proposal;
|
||||
import bisq.core.dao.voting.voteresult.DecryptedVote;
|
||||
|
||||
import bisq.common.util.Tuple2;
|
||||
|
||||
import de.jensd.fx.fontawesome.AwesomeIcon;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class VotesPerProposalListItem {
|
||||
@Getter
|
||||
private final EvaluatedProposalWithDecryptedVotes evaluatedProposalWithDecryptedVotes;
|
||||
@Getter
|
||||
private final Proposal proposal;
|
||||
private final String proposalTxId;
|
||||
|
||||
public VotesPerProposalListItem(EvaluatedProposalWithDecryptedVotes evaluatedProposalWithDecryptedVotes) {
|
||||
this.evaluatedProposalWithDecryptedVotes = evaluatedProposalWithDecryptedVotes;
|
||||
proposal = evaluatedProposalWithDecryptedVotes.getEvaluatedProposal().getProposal();
|
||||
proposalTxId = proposal.getTxId();
|
||||
}
|
||||
|
||||
public String getProposalInfo() {
|
||||
return proposal.getName();
|
||||
}
|
||||
|
||||
public Tuple2<AwesomeIcon, String> getIconStyleTuple(String blindVoteTxId) {
|
||||
Optional<Boolean> isAccepted = Optional.empty();
|
||||
Map<String, DecryptedVote> map = evaluatedProposalWithDecryptedVotes.getDecryptedVotesByBlindVoteTxId();
|
||||
if (map.containsKey(blindVoteTxId)) {
|
||||
DecryptedVote decryptedVote = map.get(blindVoteTxId);
|
||||
isAccepted = decryptedVote.getBallotList().stream()
|
||||
.filter(ballot -> ballot.getProposalTxId().equals(proposalTxId))
|
||||
.map(Ballot::getVote)
|
||||
.filter(vote -> vote instanceof BooleanVote)
|
||||
.map(vote -> (BooleanVote) vote)
|
||||
.map(BooleanVote::isAccepted)
|
||||
.findAny();
|
||||
}
|
||||
if (isAccepted.isPresent()) {
|
||||
if (isAccepted.get())
|
||||
return new Tuple2<>(AwesomeIcon.THUMBS_UP, "dao-accepted-icon");
|
||||
else
|
||||
return new Tuple2<>(AwesomeIcon.THUMBS_DOWN, "dao-rejected-icon");
|
||||
} else {
|
||||
return new Tuple2<>(AwesomeIcon.MINUS, "dao-ignored-icon");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,197 +0,0 @@
|
|||
/*
|
||||
* This file is part of Bisq.
|
||||
*
|
||||
* Bisq is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Bisq is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package bisq.desktop.main.dao.results.combo;
|
||||
|
||||
import bisq.desktop.components.AutoTooltipTableColumn;
|
||||
import bisq.desktop.main.dao.proposal.ProposalWindow;
|
||||
import bisq.desktop.main.dao.results.BaseResultsTableView;
|
||||
import bisq.desktop.main.dao.results.model.ResultsOfCycle;
|
||||
import bisq.desktop.util.GUIUtil;
|
||||
|
||||
import bisq.core.btc.wallet.BsqWalletService;
|
||||
import bisq.core.dao.DaoFacade;
|
||||
import bisq.core.dao.state.BsqStateService;
|
||||
import bisq.core.dao.voting.voteresult.DecryptedVote;
|
||||
import bisq.core.dao.voting.voteresult.EvaluatedProposal;
|
||||
import bisq.core.locale.Res;
|
||||
import bisq.core.util.BsqFormatter;
|
||||
|
||||
import bisq.common.util.Tuple2;
|
||||
|
||||
import org.bitcoinj.core.Coin;
|
||||
|
||||
import de.jensd.fx.fontawesome.AwesomeDude;
|
||||
import de.jensd.fx.fontawesome.AwesomeIcon;
|
||||
|
||||
import javafx.scene.control.Hyperlink;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.TableCell;
|
||||
import javafx.scene.control.TableColumn;
|
||||
import javafx.scene.control.TableView;
|
||||
import javafx.scene.control.Tooltip;
|
||||
import javafx.scene.layout.GridPane;
|
||||
|
||||
import javafx.beans.property.ReadOnlyObjectWrapper;
|
||||
|
||||
import javafx.util.Callback;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class VotesPerProposalTableView extends BaseResultsTableView<VotesPerProposalListItem> {
|
||||
|
||||
private final BsqStateService bsqStateService;
|
||||
|
||||
public VotesPerProposalTableView(GridPane gridPane, BsqWalletService bsqWalletService, DaoFacade daoFacade,
|
||||
BsqStateService bsqStateService, BsqFormatter bsqFormatter) {
|
||||
super(gridPane, bsqWalletService, daoFacade, bsqFormatter);
|
||||
this.bsqStateService = bsqStateService;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTitle() {
|
||||
return Res.get("dao.results.combo.header");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillList() {
|
||||
//TODO move to domain
|
||||
Map<String, EvaluatedProposalWithDecryptedVotes> map = resultsOfCycle.getEvaluatedProposals().stream()
|
||||
.collect(Collectors.toMap(EvaluatedProposal::getProposalTxId,
|
||||
EvaluatedProposalWithDecryptedVotes::new));
|
||||
|
||||
resultsOfCycle.getDecryptedVotesForCycle()
|
||||
.forEach(decryptedVote -> {
|
||||
decryptedVote.getBallotList().stream().forEach(ballot -> {
|
||||
EvaluatedProposalWithDecryptedVotes evaluatedProposalWithDecryptedVotes = map.get(ballot.getProposalTxId());
|
||||
evaluatedProposalWithDecryptedVotes.addDecryptedVote(decryptedVote);
|
||||
});
|
||||
});
|
||||
|
||||
itemList.setAll(map.values().stream()
|
||||
.map(VotesPerProposalListItem::new)
|
||||
.collect(Collectors.toList()));
|
||||
|
||||
itemList.sort(Comparator.comparing(votesPerProposalListItem -> votesPerProposalListItem.getProposal().getCreationDate()));
|
||||
}
|
||||
|
||||
|
||||
public int createAllFields(int gridRowStartIndex, ResultsOfCycle resultsOfCycle) {
|
||||
super.createAllFields(gridRowStartIndex, resultsOfCycle);
|
||||
|
||||
createColumnsFromData(tableView);
|
||||
|
||||
GUIUtil.setFitToRowsForTableView(tableView, 30, 28, 80);
|
||||
|
||||
return gridRow;
|
||||
}
|
||||
|
||||
private void createColumnsFromData(TableView<VotesPerProposalListItem> tableView) {
|
||||
TableColumn<VotesPerProposalListItem, VotesPerProposalListItem> votesColumn = new AutoTooltipTableColumn<>(Res.get("dao.results.combo.table.proposals"));
|
||||
votesColumn.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
|
||||
votesColumn.setSortable(false);
|
||||
votesColumn.setMinWidth(150);
|
||||
votesColumn.setCellFactory(
|
||||
new Callback<TableColumn<VotesPerProposalListItem, VotesPerProposalListItem>, TableCell<VotesPerProposalListItem,
|
||||
VotesPerProposalListItem>>() {
|
||||
|
||||
@Override
|
||||
public TableCell<VotesPerProposalListItem, VotesPerProposalListItem> call(
|
||||
TableColumn<VotesPerProposalListItem, VotesPerProposalListItem> column) {
|
||||
return new TableCell<VotesPerProposalListItem, VotesPerProposalListItem>() {
|
||||
private Hyperlink hyperlinkWithIcon;
|
||||
|
||||
@Override
|
||||
public void updateItem(final VotesPerProposalListItem item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (item != null && !empty) {
|
||||
hyperlinkWithIcon = new Hyperlink(item.getProposalInfo());
|
||||
hyperlinkWithIcon.setOnAction(event -> new ProposalWindow(bsqFormatter,
|
||||
bsqWalletService,
|
||||
item.getEvaluatedProposalWithDecryptedVotes().getEvaluatedProposal().getProposal(),
|
||||
daoFacade)
|
||||
.show());
|
||||
hyperlinkWithIcon.setTooltip(new Tooltip(Res.get("tooltip.openPopupForDetails")));
|
||||
|
||||
setGraphic(hyperlinkWithIcon);
|
||||
} else {
|
||||
setGraphic(null);
|
||||
if (hyperlinkWithIcon != null)
|
||||
hyperlinkWithIcon.setOnAction(null);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
tableView.getColumns().add(votesColumn);
|
||||
|
||||
List<DecryptedVote> list = new ArrayList<>(resultsOfCycle.getDecryptedVotesForCycle());
|
||||
list.sort(Comparator.comparing(DecryptedVote::getBlindVoteTxId));
|
||||
AtomicInteger index = new AtomicInteger();
|
||||
list.forEach(decryptedVote -> {
|
||||
index.getAndIncrement();
|
||||
String stake = bsqFormatter.formatCoinWithCode(Coin.valueOf(decryptedVote.getStake() + decryptedVote.getMerit(bsqStateService)));
|
||||
String header = "Vote " + index.get() + " (" + stake + ")";
|
||||
TableColumn<VotesPerProposalListItem, VotesPerProposalListItem> column = new AutoTooltipTableColumn<>(header);
|
||||
column.setSortable(false);
|
||||
column.setMinWidth(150);
|
||||
column.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
|
||||
column.setCellFactory(
|
||||
new Callback<TableColumn<VotesPerProposalListItem, VotesPerProposalListItem>, TableCell<VotesPerProposalListItem,
|
||||
VotesPerProposalListItem>>() {
|
||||
|
||||
@Override
|
||||
public TableCell<VotesPerProposalListItem, VotesPerProposalListItem> call(
|
||||
TableColumn<VotesPerProposalListItem, VotesPerProposalListItem> column) {
|
||||
return new TableCell<VotesPerProposalListItem, VotesPerProposalListItem>() {
|
||||
private Label icon;
|
||||
|
||||
@Override
|
||||
public void updateItem(final VotesPerProposalListItem item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
|
||||
if (item != null && !empty) {
|
||||
String blindVoteTxId = decryptedVote.getBlindVoteTxId();
|
||||
Tuple2<AwesomeIcon, String> iconStyleTuple = item.getIconStyleTuple(blindVoteTxId);
|
||||
icon = new Label();
|
||||
AwesomeDude.setIcon(icon, iconStyleTuple.first);
|
||||
icon.getStyleClass().add(iconStyleTuple.second);
|
||||
setGraphic(icon);
|
||||
} else {
|
||||
setGraphic(null);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
tableView.getColumns().add(column);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createColumns(TableView<VotesPerProposalListItem> tableView) {
|
||||
// do nothing as we create the columns dynamically
|
||||
}
|
||||
}
|
|
@ -1,398 +0,0 @@
|
|||
/*
|
||||
* This file is part of Bisq.
|
||||
*
|
||||
* Bisq is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Bisq is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package bisq.desktop.main.dao.results.proposals;
|
||||
|
||||
import bisq.desktop.components.AutoTooltipTableColumn;
|
||||
import bisq.desktop.main.dao.results.BaseResultsGridPane;
|
||||
import bisq.desktop.main.dao.results.SelectionListener;
|
||||
|
||||
import bisq.core.btc.wallet.BsqWalletService;
|
||||
import bisq.core.dao.DaoFacade;
|
||||
import bisq.core.dao.state.BsqStateService;
|
||||
import bisq.core.dao.voting.voteresult.DecryptedVote;
|
||||
import bisq.core.locale.Res;
|
||||
import bisq.core.util.BsqFormatter;
|
||||
|
||||
import de.jensd.fx.fontawesome.AwesomeDude;
|
||||
import de.jensd.fx.fontawesome.AwesomeIcon;
|
||||
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.TableCell;
|
||||
import javafx.scene.control.TableColumn;
|
||||
import javafx.scene.control.TableView;
|
||||
import javafx.scene.control.Tooltip;
|
||||
|
||||
import javafx.beans.property.ReadOnlyObjectWrapper;
|
||||
|
||||
import javafx.util.Callback;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class ProposalResultsGridPane extends BaseResultsGridPane<ProposalResultsListItem> {
|
||||
|
||||
private SelectionListener selectionListener;
|
||||
private final BsqStateService bsqStateService;
|
||||
|
||||
public ProposalResultsGridPane(SelectionListener selectionListener,
|
||||
BsqWalletService bsqWalletService, DaoFacade daoFacade, BsqFormatter bsqFormatter,
|
||||
BsqStateService bsqStateService) {
|
||||
super(bsqWalletService, daoFacade, bsqFormatter, 0);
|
||||
this.selectionListener = selectionListener;
|
||||
this.bsqStateService = bsqStateService;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSelected(ProposalResultsListItem item) {
|
||||
itemList.forEach(ProposalResultsListItem::resetTableRow);
|
||||
|
||||
if (item != null)
|
||||
selectionListener.onSelectedEvaluatedProposal(item.getEvaluatedProposal());
|
||||
}
|
||||
|
||||
public void onSelectedDecryptedVote(DecryptedVote decryptedVote) {
|
||||
itemList.forEach(item -> item.applyVoteAndProposal(decryptedVote, item.getEvaluatedProposal()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillList() {
|
||||
itemList.forEach(ProposalResultsListItem::resetTableRow);
|
||||
|
||||
itemList.setAll(resultsOfCycle.getEvaluatedProposals().stream()
|
||||
.map(e -> new ProposalResultsListItem(e, bsqFormatter))
|
||||
.collect(Collectors.toList()));
|
||||
|
||||
itemList.sort(Comparator.comparing(proposalResultsListItem -> proposalResultsListItem.getEvaluatedProposal().getProposal().getCreationDate()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTitle() {
|
||||
return Res.get("dao.results.proposals.header");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createColumns(TableView<ProposalResultsListItem> tableView) {
|
||||
TableColumn<ProposalResultsListItem, ProposalResultsListItem> nameColumn = new AutoTooltipTableColumn<>(Res.get("dao.results.proposals.table.header.proposalOwnerName"));
|
||||
nameColumn.setMinWidth(110);
|
||||
nameColumn.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
|
||||
nameColumn.setCellFactory(
|
||||
new Callback<TableColumn<ProposalResultsListItem, ProposalResultsListItem>, TableCell<ProposalResultsListItem,
|
||||
ProposalResultsListItem>>() {
|
||||
@Override
|
||||
public TableCell<ProposalResultsListItem, ProposalResultsListItem> call(
|
||||
TableColumn<ProposalResultsListItem, ProposalResultsListItem> column) {
|
||||
return new TableCell<ProposalResultsListItem, ProposalResultsListItem>() {
|
||||
|
||||
@Override
|
||||
public void updateItem(final ProposalResultsListItem item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (item != null) {
|
||||
item.setTableRow(getTableRow());
|
||||
setText(item.getProposalOwnerName());
|
||||
} else {
|
||||
setText("");
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
nameColumn.setComparator(Comparator.comparing(ProposalResultsListItem::getProposalOwnerName));
|
||||
tableView.getColumns().add(nameColumn);
|
||||
|
||||
|
||||
TableColumn<ProposalResultsListItem, ProposalResultsListItem> issuanceColumn = new AutoTooltipTableColumn<>(Res.get("dao.results.proposals.table.header.issuance"));
|
||||
issuanceColumn.setMinWidth(100);
|
||||
issuanceColumn.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
|
||||
issuanceColumn.setCellFactory(
|
||||
new Callback<TableColumn<ProposalResultsListItem, ProposalResultsListItem>, TableCell<ProposalResultsListItem,
|
||||
ProposalResultsListItem>>() {
|
||||
@Override
|
||||
public TableCell<ProposalResultsListItem, ProposalResultsListItem> call(
|
||||
TableColumn<ProposalResultsListItem, ProposalResultsListItem> column) {
|
||||
return new TableCell<ProposalResultsListItem, ProposalResultsListItem>() {
|
||||
@Override
|
||||
public void updateItem(final ProposalResultsListItem item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (item != null)
|
||||
setText(item.getIssuance());
|
||||
else
|
||||
setText("");
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
issuanceColumn.setComparator(Comparator.comparing(ProposalResultsListItem::getThreshold));
|
||||
tableView.getColumns().add(issuanceColumn);
|
||||
|
||||
TableColumn<ProposalResultsListItem, ProposalResultsListItem> resultColumn = new AutoTooltipTableColumn<>(Res.get("dao.results.proposals.table.header.result"));
|
||||
resultColumn.setMinWidth(60);
|
||||
resultColumn.setMaxWidth(60);
|
||||
resultColumn.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
|
||||
resultColumn.setCellFactory(new Callback<TableColumn<ProposalResultsListItem, ProposalResultsListItem>,
|
||||
TableCell<ProposalResultsListItem, ProposalResultsListItem>>() {
|
||||
@Override
|
||||
public TableCell<ProposalResultsListItem, ProposalResultsListItem> call(TableColumn<ProposalResultsListItem,
|
||||
ProposalResultsListItem> column) {
|
||||
return new TableCell<ProposalResultsListItem, ProposalResultsListItem>() {
|
||||
Label icon;
|
||||
|
||||
@Override
|
||||
public void updateItem(final ProposalResultsListItem item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
|
||||
if (item != null && !empty) {
|
||||
icon = new Label();
|
||||
AwesomeDude.setIcon(icon, item.getIcon());
|
||||
icon.getStyleClass().add(item.getColorStyleClass());
|
||||
setGraphic(icon);
|
||||
} else {
|
||||
setGraphic(null);
|
||||
if (icon != null)
|
||||
icon = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
tableView.getColumns().add(resultColumn);
|
||||
|
||||
|
||||
TableColumn<ProposalResultsListItem, ProposalResultsListItem> detailsColumn = new TableColumn<>();
|
||||
detailsColumn.setMinWidth(60);
|
||||
detailsColumn.setMaxWidth(60);
|
||||
detailsColumn.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
|
||||
detailsColumn.setCellFactory(new Callback<TableColumn<ProposalResultsListItem, ProposalResultsListItem>,
|
||||
TableCell<ProposalResultsListItem, ProposalResultsListItem>>() {
|
||||
@Override
|
||||
public TableCell<ProposalResultsListItem, ProposalResultsListItem> call(TableColumn<ProposalResultsListItem,
|
||||
ProposalResultsListItem> column) {
|
||||
return new TableCell<ProposalResultsListItem, ProposalResultsListItem>() {
|
||||
Label icon;
|
||||
Button button;
|
||||
|
||||
@Override
|
||||
public void updateItem(final ProposalResultsListItem item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
|
||||
if (item != null && !empty) {
|
||||
icon = new Label();
|
||||
AwesomeDude.setIcon(icon, AwesomeIcon.INFO_SIGN);
|
||||
icon.setTooltip(new Tooltip(Res.get("tooltip.openPopupForDetails")));
|
||||
icon.getStyleClass().add("info-icon");
|
||||
|
||||
button = new Button("", icon);
|
||||
button.getStyleClass().add("info-icon-button");
|
||||
button.setOnAction(e -> {
|
||||
new VoteResultsForProposalWindow(resultsOfCycle,
|
||||
item.getEvaluatedProposal().getProposal(),
|
||||
bsqStateService,
|
||||
bsqFormatter)
|
||||
.show();
|
||||
});
|
||||
setGraphic(button);
|
||||
} else {
|
||||
setGraphic(null);
|
||||
if (icon != null)
|
||||
icon = null;
|
||||
if (button != null)
|
||||
button = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
tableView.getColumns().add(detailsColumn);
|
||||
|
||||
|
||||
|
||||
|
||||
/* TableColumn<ProposalResultsListItem, ProposalResultsListItem> idColumn = new AutoTooltipTableColumn<>(Res.get("dao.results.proposals.table.header.proposalId"));
|
||||
idColumn.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
|
||||
idColumn.setMinWidth(100);
|
||||
idColumn.setCellFactory(
|
||||
new Callback<TableColumn<ProposalResultsListItem, ProposalResultsListItem>, TableCell<ProposalResultsListItem, ProposalResultsListItem>>() {
|
||||
|
||||
@Override
|
||||
public TableCell<ProposalResultsListItem, ProposalResultsListItem> call(TableColumn<ProposalResultsListItem,
|
||||
ProposalResultsListItem> column) {
|
||||
return new TableCell<ProposalResultsListItem, ProposalResultsListItem>() {
|
||||
private Hyperlink field;
|
||||
|
||||
@Override
|
||||
public void updateItem(final ProposalResultsListItem item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
|
||||
// cycleDetailsWindow.show(item.getEvaluatedProposal())
|
||||
if (item != null && !empty) {
|
||||
field = new Hyperlink(item.getProposalId());
|
||||
|
||||
//TODO setId or getStyleClass.add does not apply color...
|
||||
//field.getStyleClass().add(item.getColorStyleClass());
|
||||
//field.setId(item.getColorStyleClass());
|
||||
field.setStyle(item.getColorStyle());
|
||||
field.setOnAction(event -> new ProposalWindow(bsqFormatter,
|
||||
bsqWalletService,
|
||||
item.getEvaluatedProposal().getProposal(),
|
||||
daoFacade)
|
||||
.show());
|
||||
field.setTooltip(new Tooltip(Res.get("tooltip.openPopupForDetails")));
|
||||
setGraphic(field);
|
||||
} else {
|
||||
setGraphic(null);
|
||||
if (field != null)
|
||||
field.setOnAction(null);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
idColumn.setComparator(Comparator.comparing(ProposalResultsListItem::getProposalOwnerName));
|
||||
tableView.getColumns().add(idColumn);*/
|
||||
|
||||
/* TableColumn<ProposalResultsListItem, ProposalResultsListItem> acceptedColumn = new AutoTooltipTableColumn<>(Res.get("dao.results.proposals.table.header.accepted"));
|
||||
acceptedColumn.setMinWidth(80);
|
||||
acceptedColumn.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
|
||||
acceptedColumn.setCellFactory(
|
||||
new Callback<TableColumn<ProposalResultsListItem, ProposalResultsListItem>, TableCell<ProposalResultsListItem,
|
||||
ProposalResultsListItem>>() {
|
||||
private Hyperlink field;
|
||||
|
||||
@Override
|
||||
public TableCell<ProposalResultsListItem, ProposalResultsListItem> call(
|
||||
TableColumn<ProposalResultsListItem, ProposalResultsListItem> column) {
|
||||
return new TableCell<ProposalResultsListItem, ProposalResultsListItem>() {
|
||||
@Override
|
||||
public void updateItem(final ProposalResultsListItem item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (item != null && !empty) {
|
||||
field = new Hyperlink(item.getAccepted());
|
||||
field.setStyle(item.getColorStyle());
|
||||
field.setOnAction(event -> new VoteResultsForProposalWindow(resultsOfCycle,
|
||||
item.getEvaluatedProposal().getProposal(),
|
||||
bsqStateService,
|
||||
bsqFormatter)
|
||||
.show());
|
||||
field.setTooltip(new Tooltip(Res.get("tooltip.openPopupForDetails")));
|
||||
setGraphic(field);
|
||||
} else {
|
||||
setGraphic(null);
|
||||
|
||||
//TODO does get called on active items somehow...
|
||||
//if (field != null)
|
||||
// field.setOnAction(null);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
acceptedColumn.setComparator(Comparator.comparing(ProposalResultsListItem::getAccepted));
|
||||
tableView.getColumns().add(acceptedColumn);
|
||||
|
||||
TableColumn<ProposalResultsListItem, ProposalResultsListItem> rejectedColumn = new AutoTooltipTableColumn<>(Res.get("dao.results.proposals.table.header.rejected"));
|
||||
rejectedColumn.setMinWidth(80);
|
||||
rejectedColumn.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
|
||||
rejectedColumn.setCellFactory(
|
||||
new Callback<TableColumn<ProposalResultsListItem, ProposalResultsListItem>, TableCell<ProposalResultsListItem,
|
||||
ProposalResultsListItem>>() {
|
||||
private Hyperlink field;
|
||||
|
||||
@Override
|
||||
public TableCell<ProposalResultsListItem, ProposalResultsListItem> call(
|
||||
TableColumn<ProposalResultsListItem, ProposalResultsListItem> column) {
|
||||
return new TableCell<ProposalResultsListItem, ProposalResultsListItem>() {
|
||||
@Override
|
||||
public void updateItem(final ProposalResultsListItem item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (item != null && !empty) {
|
||||
field = new Hyperlink(item.getRejected());
|
||||
field.setStyle(item.getColorStyle());
|
||||
field.setOnAction(event -> new VoteResultsForProposalWindow(resultsOfCycle,
|
||||
item.getEvaluatedProposal().getProposal(),
|
||||
bsqStateService,
|
||||
bsqFormatter)
|
||||
.show());
|
||||
field.setTooltip(new Tooltip(Res.get("tooltip.openPopupForDetails")));
|
||||
setGraphic(field);
|
||||
} else {
|
||||
setGraphic(null);
|
||||
//TODO does get called on active items somehow...
|
||||
//if (field != null)
|
||||
// field.setOnAction(null);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
rejectedColumn.setComparator(Comparator.comparing(ProposalResultsListItem::getRejected));
|
||||
tableView.getColumns().add(rejectedColumn);*/
|
||||
|
||||
/* TableColumn<ProposalResultsListItem, ProposalResultsListItem> thresholdColumn = new AutoTooltipTableColumn<>(Res.get("dao.results.proposals.table.header.threshold"));
|
||||
thresholdColumn.setMinWidth(100);
|
||||
thresholdColumn.setMaxWidth(100);
|
||||
thresholdColumn.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
|
||||
thresholdColumn.setCellFactory(
|
||||
new Callback<TableColumn<ProposalResultsListItem, ProposalResultsListItem>, TableCell<ProposalResultsListItem,
|
||||
ProposalResultsListItem>>() {
|
||||
@Override
|
||||
public TableCell<ProposalResultsListItem, ProposalResultsListItem> call(
|
||||
TableColumn<ProposalResultsListItem, ProposalResultsListItem> column) {
|
||||
return new TableCell<ProposalResultsListItem, ProposalResultsListItem>() {
|
||||
@Override
|
||||
public void updateItem(final ProposalResultsListItem item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (item != null)
|
||||
setText(item.getThreshold());
|
||||
else
|
||||
setText("");
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
thresholdColumn.setComparator(Comparator.comparing(ProposalResultsListItem::getThreshold));
|
||||
tableView.getColumns().add(thresholdColumn);*/
|
||||
|
||||
/* TableColumn<ProposalResultsListItem, ProposalResultsListItem> quorumColumn = new AutoTooltipTableColumn<>(Res.get("dao.results.proposals.table.header.quorum"));
|
||||
quorumColumn.setMinWidth(130);
|
||||
quorumColumn.setMaxWidth(130);
|
||||
quorumColumn.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
|
||||
quorumColumn.setCellFactory(
|
||||
new Callback<TableColumn<ProposalResultsListItem, ProposalResultsListItem>, TableCell<ProposalResultsListItem,
|
||||
ProposalResultsListItem>>() {
|
||||
@Override
|
||||
public TableCell<ProposalResultsListItem, ProposalResultsListItem> call(
|
||||
TableColumn<ProposalResultsListItem, ProposalResultsListItem> column) {
|
||||
return new TableCell<ProposalResultsListItem, ProposalResultsListItem>() {
|
||||
@Override
|
||||
public void updateItem(final ProposalResultsListItem item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (item != null)
|
||||
setText(item.getQuorum());
|
||||
else
|
||||
setText("");
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
quorumColumn.setComparator(Comparator.comparing(ProposalResultsListItem::getThreshold));
|
||||
tableView.getColumns().add(quorumColumn);*/
|
||||
}
|
||||
}
|
|
@ -1,271 +0,0 @@
|
|||
/*
|
||||
* This file is part of Bisq.
|
||||
*
|
||||
* Bisq is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Bisq is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package bisq.desktop.main.dao.results.proposals;
|
||||
|
||||
import bisq.desktop.components.AutoTooltipLabel;
|
||||
import bisq.desktop.components.AutoTooltipTableColumn;
|
||||
import bisq.desktop.components.TableGroupHeadline;
|
||||
import bisq.desktop.main.MainView;
|
||||
import bisq.desktop.main.dao.results.model.ResultsOfCycle;
|
||||
import bisq.desktop.main.overlays.Overlay;
|
||||
import bisq.desktop.util.FormBuilder;
|
||||
import bisq.desktop.util.GUIUtil;
|
||||
|
||||
import bisq.core.dao.state.BsqStateService;
|
||||
import bisq.core.dao.voting.proposal.Proposal;
|
||||
import bisq.core.locale.Res;
|
||||
import bisq.core.util.BsqFormatter;
|
||||
|
||||
import bisq.common.util.Tuple2;
|
||||
|
||||
import de.jensd.fx.fontawesome.AwesomeDude;
|
||||
import de.jensd.fx.fontawesome.AwesomeIcon;
|
||||
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.TableCell;
|
||||
import javafx.scene.control.TableColumn;
|
||||
import javafx.scene.control.TableView;
|
||||
import javafx.scene.layout.GridPane;
|
||||
|
||||
import javafx.geometry.HPos;
|
||||
import javafx.geometry.Insets;
|
||||
|
||||
import javafx.beans.property.ReadOnlyObjectWrapper;
|
||||
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.collections.transformation.SortedList;
|
||||
|
||||
import javafx.util.Callback;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class VoteResultsForProposalWindow extends Overlay<VoteResultsForProposalWindow> {
|
||||
private Proposal proposal;
|
||||
private BsqStateService bsqStateService;
|
||||
private final BsqFormatter bsqFormatter;
|
||||
|
||||
private TableView<VoteResultsForProposalListItem> tableView;
|
||||
private int gridRow = 0;
|
||||
private final ObservableList<VoteResultsForProposalListItem> itemList = FXCollections.observableArrayList();
|
||||
private final SortedList<VoteResultsForProposalListItem> sortedList = new SortedList<>(itemList);
|
||||
protected ResultsOfCycle resultsOfCycle;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Public API
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public VoteResultsForProposalWindow(ResultsOfCycle resultsOfCycle,
|
||||
Proposal proposal,
|
||||
BsqStateService bsqStateService,
|
||||
BsqFormatter bsqFormatter) {
|
||||
this.resultsOfCycle = resultsOfCycle;
|
||||
this.proposal = proposal;
|
||||
this.bsqStateService = bsqStateService;
|
||||
this.bsqFormatter = bsqFormatter;
|
||||
type = Type.Confirmation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void show() {
|
||||
width = MainView.getRootContainer().getWidth() - 20;
|
||||
|
||||
createGridPane();
|
||||
addContent();
|
||||
display();
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Protected
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
protected void createGridPane() {
|
||||
super.createGridPane();
|
||||
|
||||
gridPane.setPadding(new Insets(35, 40, 30, 40));
|
||||
gridPane.getStyleClass().add("grid-pane");
|
||||
}
|
||||
|
||||
private void addContent() {
|
||||
TableGroupHeadline headline = new TableGroupHeadline(Res.get("dao.results.proposals.voting.detail.header"));
|
||||
GridPane.setRowIndex(headline, gridRow);
|
||||
GridPane.setMargin(headline, new Insets(0, -10, -10, -10));
|
||||
GridPane.setColumnSpan(headline, 2);
|
||||
gridPane.getChildren().add(headline);
|
||||
|
||||
// For some weird reason the stage key handler (ESC, ENTER) does not work as soon a tableView gets added...
|
||||
tableView = new TableView<>();
|
||||
tableView.setPlaceholder(new AutoTooltipLabel(Res.get("table.placeholder.noData")));
|
||||
tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
|
||||
|
||||
createColumns(tableView);
|
||||
GridPane.setRowIndex(tableView, gridRow);
|
||||
GridPane.setMargin(tableView, new Insets(20, -10, 5, -10));
|
||||
GridPane.setColumnSpan(tableView, 2);
|
||||
gridPane.getChildren().add(tableView);
|
||||
|
||||
tableView.setItems(sortedList);
|
||||
sortedList.comparatorProperty().bind(tableView.comparatorProperty());
|
||||
|
||||
fillList();
|
||||
|
||||
GUIUtil.setFitToRowsForTableView(tableView, 24, 28, 150);
|
||||
|
||||
// Somehow setting the margin for closeButton does not work here as expected. adding a row does give us the desired layout...
|
||||
++rowIndex;
|
||||
Button closeButton = FormBuilder.addButton(gridPane, ++rowIndex, Res.get("shared.close"));
|
||||
GridPane.setHalignment(closeButton, HPos.RIGHT);
|
||||
closeButton.setOnAction(e -> {
|
||||
closeHandlerOptional.ifPresent(Runnable::run);
|
||||
hide();
|
||||
});
|
||||
}
|
||||
|
||||
private void fillList() {
|
||||
itemList.clear();
|
||||
|
||||
resultsOfCycle.getEvaluatedProposals().stream()
|
||||
.filter(evaluatedProposal -> evaluatedProposal.getProposal().equals(proposal))
|
||||
.forEach(evaluatedProposal -> {
|
||||
resultsOfCycle.getDecryptedVotesForCycle().forEach(decryptedVote -> {
|
||||
itemList.add(new VoteResultsForProposalListItem(evaluatedProposal.getProposal(), decryptedVote,
|
||||
bsqStateService, bsqFormatter));
|
||||
});
|
||||
});
|
||||
|
||||
itemList.sort(Comparator.comparing(item -> item.getBlindVoteTxId()));
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// TableColumns
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private void createColumns(TableView<VoteResultsForProposalListItem> tableView) {
|
||||
TableColumn<VoteResultsForProposalListItem, VoteResultsForProposalListItem> blindVoteTxIdColumn = new AutoTooltipTableColumn<>(Res.get("dao.results.votes.table.header.blindVoteTxId"));
|
||||
blindVoteTxIdColumn.setSortable(false);
|
||||
blindVoteTxIdColumn.setMinWidth(150);
|
||||
blindVoteTxIdColumn.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
|
||||
blindVoteTxIdColumn.setCellFactory(
|
||||
new Callback<TableColumn<VoteResultsForProposalListItem, VoteResultsForProposalListItem>, TableCell<VoteResultsForProposalListItem,
|
||||
VoteResultsForProposalListItem>>() {
|
||||
@Override
|
||||
public TableCell<VoteResultsForProposalListItem, VoteResultsForProposalListItem> call(
|
||||
TableColumn<VoteResultsForProposalListItem, VoteResultsForProposalListItem> column) {
|
||||
return new TableCell<VoteResultsForProposalListItem, VoteResultsForProposalListItem>() {
|
||||
@Override
|
||||
public void updateItem(final VoteResultsForProposalListItem item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (item != null)
|
||||
setText(item.getBlindVoteTxId());
|
||||
else
|
||||
setText("");
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
tableView.getColumns().add(blindVoteTxIdColumn);
|
||||
|
||||
TableColumn<VoteResultsForProposalListItem, VoteResultsForProposalListItem> voteColumn = new AutoTooltipTableColumn<>(Res.get("dao.results.votes.table.header.vote"));
|
||||
voteColumn.setSortable(false);
|
||||
voteColumn.setMinWidth(150);
|
||||
voteColumn.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
|
||||
voteColumn.setCellFactory(
|
||||
new Callback<TableColumn<VoteResultsForProposalListItem, VoteResultsForProposalListItem>, TableCell<VoteResultsForProposalListItem,
|
||||
VoteResultsForProposalListItem>>() {
|
||||
@Override
|
||||
public TableCell<VoteResultsForProposalListItem, VoteResultsForProposalListItem> call(
|
||||
TableColumn<VoteResultsForProposalListItem, VoteResultsForProposalListItem> column) {
|
||||
return new TableCell<VoteResultsForProposalListItem, VoteResultsForProposalListItem>() {
|
||||
private Label icon;
|
||||
|
||||
@Override
|
||||
public void updateItem(final VoteResultsForProposalListItem item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
|
||||
if (item != null && !empty) {
|
||||
Tuple2<AwesomeIcon, String> iconStyleTuple = item.getIconStyleTuple();
|
||||
icon = new Label();
|
||||
AwesomeDude.setIcon(icon, iconStyleTuple.first);
|
||||
icon.getStyleClass().add(iconStyleTuple.second);
|
||||
setGraphic(icon);
|
||||
} else {
|
||||
setGraphic(null);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
tableView.getColumns().add(voteColumn);
|
||||
|
||||
TableColumn<VoteResultsForProposalListItem, VoteResultsForProposalListItem> meritColumn = new AutoTooltipTableColumn<>(Res.get("dao.results.votes.table.header.merit"));
|
||||
meritColumn.setSortable(false);
|
||||
meritColumn.setMinWidth(150);
|
||||
meritColumn.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
|
||||
meritColumn.setCellFactory(
|
||||
new Callback<TableColumn<VoteResultsForProposalListItem, VoteResultsForProposalListItem>, TableCell<VoteResultsForProposalListItem,
|
||||
VoteResultsForProposalListItem>>() {
|
||||
@Override
|
||||
public TableCell<VoteResultsForProposalListItem, VoteResultsForProposalListItem> call(
|
||||
TableColumn<VoteResultsForProposalListItem, VoteResultsForProposalListItem> column) {
|
||||
return new TableCell<VoteResultsForProposalListItem, VoteResultsForProposalListItem>() {
|
||||
@Override
|
||||
public void updateItem(final VoteResultsForProposalListItem item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (item != null)
|
||||
setText(item.getMerit());
|
||||
else
|
||||
setText("");
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
tableView.getColumns().add(meritColumn);
|
||||
|
||||
TableColumn<VoteResultsForProposalListItem, VoteResultsForProposalListItem> stakeColumn = new AutoTooltipTableColumn<>(Res.get("dao.results.votes.table.header.stake"));
|
||||
stakeColumn.setSortable(false);
|
||||
stakeColumn.setMinWidth(150);
|
||||
stakeColumn.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
|
||||
stakeColumn.setCellFactory(
|
||||
new Callback<TableColumn<VoteResultsForProposalListItem, VoteResultsForProposalListItem>, TableCell<VoteResultsForProposalListItem,
|
||||
VoteResultsForProposalListItem>>() {
|
||||
@Override
|
||||
public TableCell<VoteResultsForProposalListItem, VoteResultsForProposalListItem> call(
|
||||
TableColumn<VoteResultsForProposalListItem, VoteResultsForProposalListItem> column) {
|
||||
return new TableCell<VoteResultsForProposalListItem, VoteResultsForProposalListItem>() {
|
||||
@Override
|
||||
public void updateItem(final VoteResultsForProposalListItem item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (item != null)
|
||||
setText(item.getStake());
|
||||
else
|
||||
setText("");
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
tableView.getColumns().add(stakeColumn);
|
||||
}
|
||||
}
|
|
@ -1,425 +0,0 @@
|
|||
/*
|
||||
* This file is part of Bisq.
|
||||
*
|
||||
* Bisq is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Bisq is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package bisq.desktop.main.dao.results.votes;
|
||||
|
||||
import bisq.desktop.components.AutoTooltipTableColumn;
|
||||
import bisq.desktop.main.dao.results.BaseResultsGridPane;
|
||||
import bisq.desktop.main.dao.results.SelectionListener;
|
||||
import bisq.desktop.util.GUIUtil;
|
||||
|
||||
import bisq.core.btc.wallet.BsqWalletService;
|
||||
import bisq.core.dao.DaoFacade;
|
||||
import bisq.core.dao.state.BsqStateService;
|
||||
import bisq.core.dao.voting.voteresult.DecryptedVote;
|
||||
import bisq.core.dao.voting.voteresult.EvaluatedProposal;
|
||||
import bisq.core.locale.Res;
|
||||
import bisq.core.user.Preferences;
|
||||
import bisq.core.util.BsqFormatter;
|
||||
|
||||
import de.jensd.fx.fontawesome.AwesomeDude;
|
||||
import de.jensd.fx.fontawesome.AwesomeIcon;
|
||||
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.TableCell;
|
||||
import javafx.scene.control.TableColumn;
|
||||
import javafx.scene.control.TableView;
|
||||
import javafx.scene.control.Tooltip;
|
||||
|
||||
import javafx.beans.property.ReadOnlyObjectWrapper;
|
||||
|
||||
import javafx.util.Callback;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class VoteResultsGridPane extends BaseResultsGridPane<VoteResultsListItem> {
|
||||
private SelectionListener selectionListener;
|
||||
private final BsqStateService bsqStateService;
|
||||
private final Preferences preferences;
|
||||
|
||||
public VoteResultsGridPane(SelectionListener selectionListener,
|
||||
BsqWalletService bsqWalletService, DaoFacade daoFacade,
|
||||
BsqStateService bsqStateService, Preferences preferences, BsqFormatter bsqFormatter) {
|
||||
super(bsqWalletService, daoFacade, bsqFormatter, 1);
|
||||
this.selectionListener = selectionListener;
|
||||
|
||||
this.bsqStateService = bsqStateService;
|
||||
this.preferences = preferences;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSelected(VoteResultsListItem item) {
|
||||
itemList.forEach(VoteResultsListItem::resetTableRow);
|
||||
|
||||
if (item != null)
|
||||
selectionListener.onSelectedDecryptedVote(item.getDecryptedVote());
|
||||
}
|
||||
|
||||
public void onSelectedEvaluatedProposal(EvaluatedProposal evaluatedProposal) {
|
||||
itemList.forEach(item -> item.applyVoteAndProposal(item.getDecryptedVote(), evaluatedProposal));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillList() {
|
||||
itemList.forEach(VoteResultsListItem::resetTableRow);
|
||||
|
||||
List<DecryptedVote> decryptedVotesForCycle = new ArrayList<>(resultsOfCycle.getDecryptedVotesForCycle());
|
||||
decryptedVotesForCycle.sort(Comparator.comparing(DecryptedVote::getBlindVoteTxId));
|
||||
AtomicInteger index = new AtomicInteger();
|
||||
itemList.setAll(decryptedVotesForCycle.stream()
|
||||
.map(decryptedVote -> {
|
||||
int id = index.incrementAndGet();
|
||||
return new VoteResultsListItem(id, decryptedVote, bsqStateService, bsqFormatter);
|
||||
})
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTitle() {
|
||||
return Res.get("dao.results.votes.header");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createColumns(TableView<VoteResultsListItem> tableView) {
|
||||
TableColumn<VoteResultsListItem, VoteResultsListItem> stakeAndMeritColumn = new AutoTooltipTableColumn<>(Res.get("dao.results.votes.table.header.stakeAndMerit"));
|
||||
stakeAndMeritColumn.setMinWidth(90);
|
||||
stakeAndMeritColumn.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
|
||||
stakeAndMeritColumn.setCellFactory(
|
||||
new Callback<TableColumn<VoteResultsListItem, VoteResultsListItem>, TableCell<VoteResultsListItem,
|
||||
VoteResultsListItem>>() {
|
||||
|
||||
|
||||
@Override
|
||||
public TableCell<VoteResultsListItem, VoteResultsListItem> call(
|
||||
TableColumn<VoteResultsListItem, VoteResultsListItem> column) {
|
||||
return new TableCell<VoteResultsListItem, VoteResultsListItem>() {
|
||||
@Override
|
||||
public void updateItem(final VoteResultsListItem item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (item != null) {
|
||||
item.setTableRow(getTableRow());
|
||||
setText(item.getStakeAndMerit());
|
||||
} else {
|
||||
setText("");
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
stakeAndMeritColumn.setComparator(Comparator.comparing(VoteResultsListItem::getStakeAsCoin));
|
||||
tableView.getColumns().add(stakeAndMeritColumn);
|
||||
|
||||
TableColumn<VoteResultsListItem, VoteResultsListItem> stakeColumn = new AutoTooltipTableColumn<>(Res.get("dao.results.votes.table.header.stake"));
|
||||
stakeColumn.setMinWidth(90);
|
||||
stakeColumn.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
|
||||
stakeColumn.setCellFactory(
|
||||
new Callback<TableColumn<VoteResultsListItem, VoteResultsListItem>, TableCell<VoteResultsListItem,
|
||||
VoteResultsListItem>>() {
|
||||
@Override
|
||||
public TableCell<VoteResultsListItem, VoteResultsListItem> call(
|
||||
TableColumn<VoteResultsListItem, VoteResultsListItem> column) {
|
||||
return new TableCell<VoteResultsListItem, VoteResultsListItem>() {
|
||||
@Override
|
||||
public void updateItem(final VoteResultsListItem item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (item != null)
|
||||
setText(item.getStake());
|
||||
else
|
||||
setText("");
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
stakeColumn.setComparator(Comparator.comparing(VoteResultsListItem::getStakeAsCoin));
|
||||
tableView.getColumns().add(stakeColumn);
|
||||
|
||||
TableColumn<VoteResultsListItem, VoteResultsListItem> meritColumn = new AutoTooltipTableColumn<>(Res.get("dao.results.votes.table.header.merit"));
|
||||
meritColumn.setMinWidth(90);
|
||||
meritColumn.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
|
||||
meritColumn.setCellFactory(
|
||||
new Callback<TableColumn<VoteResultsListItem, VoteResultsListItem>, TableCell<VoteResultsListItem,
|
||||
VoteResultsListItem>>() {
|
||||
@Override
|
||||
public TableCell<VoteResultsListItem, VoteResultsListItem> call(
|
||||
TableColumn<VoteResultsListItem, VoteResultsListItem> column) {
|
||||
return new TableCell<VoteResultsListItem, VoteResultsListItem>() {
|
||||
@Override
|
||||
public void updateItem(final VoteResultsListItem item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (item != null)
|
||||
setText(item.getMerit());
|
||||
else
|
||||
setText("");
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
meritColumn.setComparator(Comparator.comparing(VoteResultsListItem::getMeritAsCoin));
|
||||
tableView.getColumns().add(meritColumn);
|
||||
|
||||
|
||||
TableColumn<VoteResultsListItem, VoteResultsListItem> detailsColumn = new TableColumn<>();
|
||||
detailsColumn.setMinWidth(60);
|
||||
detailsColumn.setMaxWidth(60);
|
||||
detailsColumn.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
|
||||
detailsColumn.setCellFactory(new Callback<TableColumn<VoteResultsListItem, VoteResultsListItem>,
|
||||
TableCell<VoteResultsListItem, VoteResultsListItem>>() {
|
||||
@Override
|
||||
public TableCell<VoteResultsListItem, VoteResultsListItem> call(TableColumn<VoteResultsListItem,
|
||||
VoteResultsListItem> column) {
|
||||
return new TableCell<VoteResultsListItem, VoteResultsListItem>() {
|
||||
Label icon;
|
||||
Button button;
|
||||
|
||||
@Override
|
||||
public void updateItem(final VoteResultsListItem item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
|
||||
if (item != null && !empty) {
|
||||
icon = new Label();
|
||||
AwesomeDude.setIcon(icon, AwesomeIcon.INFO_SIGN);
|
||||
icon.setTooltip(new Tooltip(Res.get("tooltip.openPopupForDetails")));
|
||||
icon.getStyleClass().add("info-icon");
|
||||
|
||||
button = new Button("", icon);
|
||||
button.getStyleClass().add("info-icon-button");
|
||||
button.setOnAction(e -> {
|
||||
/* new VoteResultsForProposalWindow(resultsOfCycle,
|
||||
item.getEvaluatedProposal().getProposal(),
|
||||
bsqStateService,
|
||||
bsqFormatter)
|
||||
.show();*/
|
||||
});
|
||||
setGraphic(button);
|
||||
} else {
|
||||
setGraphic(null);
|
||||
if (icon != null)
|
||||
icon = null;
|
||||
if (button != null)
|
||||
button = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
tableView.getColumns().add(detailsColumn);
|
||||
|
||||
/*
|
||||
|
||||
TableColumn<VoteResultsListItem, VoteResultsListItem> indexColumn = new AutoTooltipTableColumn<>(Res.get("dao.results.votes.table.header.id"));
|
||||
indexColumn.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
|
||||
indexColumn.setMinWidth(70);
|
||||
indexColumn.setCellFactory(
|
||||
new Callback<TableColumn<VoteResultsListItem, VoteResultsListItem>, TableCell<VoteResultsListItem,
|
||||
VoteResultsListItem>>() {
|
||||
@Override
|
||||
public TableCell<VoteResultsListItem, VoteResultsListItem> call(
|
||||
TableColumn<VoteResultsListItem, VoteResultsListItem> column) {
|
||||
return new TableCell<VoteResultsListItem, VoteResultsListItem>() {
|
||||
@Override
|
||||
public void updateItem(final VoteResultsListItem item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (item != null)
|
||||
setText(item.getId());
|
||||
else
|
||||
setText("");
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
indexColumn.setComparator(Comparator.comparing(VoteResultsListItem::getStakeAsCoin));
|
||||
tableView.getColumns().add(indexColumn);
|
||||
|
||||
TableColumn<VoteResultsListItem, VoteResultsListItem> stakeColumn = new AutoTooltipTableColumn<>(Res.get("dao.results.votes.table.header.stake"));
|
||||
stakeColumn.setMinWidth(70);
|
||||
stakeColumn.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
|
||||
stakeColumn.setCellFactory(
|
||||
new Callback<TableColumn<VoteResultsListItem, VoteResultsListItem>, TableCell<VoteResultsListItem,
|
||||
VoteResultsListItem>>() {
|
||||
@Override
|
||||
public TableCell<VoteResultsListItem, VoteResultsListItem> call(
|
||||
TableColumn<VoteResultsListItem, VoteResultsListItem> column) {
|
||||
return new TableCell<VoteResultsListItem, VoteResultsListItem>() {
|
||||
@Override
|
||||
public void updateItem(final VoteResultsListItem item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (item != null)
|
||||
setText(item.getStake());
|
||||
else
|
||||
setText("");
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
stakeColumn.setComparator(Comparator.comparing(VoteResultsListItem::getStakeAsCoin));
|
||||
tableView.getColumns().add(stakeColumn);
|
||||
|
||||
TableColumn<VoteResultsListItem, VoteResultsListItem> meritColumn = new AutoTooltipTableColumn<>(Res.get("dao.results.votes.table.header.merit"));
|
||||
meritColumn.setMinWidth(70);
|
||||
meritColumn.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
|
||||
meritColumn.setCellFactory(
|
||||
new Callback<TableColumn<VoteResultsListItem, VoteResultsListItem>, TableCell<VoteResultsListItem,
|
||||
VoteResultsListItem>>() {
|
||||
@Override
|
||||
public TableCell<VoteResultsListItem, VoteResultsListItem> call(
|
||||
TableColumn<VoteResultsListItem, VoteResultsListItem> column) {
|
||||
return new TableCell<VoteResultsListItem, VoteResultsListItem>() {
|
||||
@Override
|
||||
public void updateItem(final VoteResultsListItem item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (item != null)
|
||||
setText(item.getMerit());
|
||||
else
|
||||
setText("");
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
meritColumn.setComparator(Comparator.comparing(VoteResultsListItem::getMeritAsCoin));
|
||||
tableView.getColumns().add(meritColumn);
|
||||
|
||||
TableColumn<VoteResultsListItem, VoteResultsListItem> acceptedColumn = new AutoTooltipTableColumn<>(Res.get("dao.results.votes.table.header.accepted"));
|
||||
acceptedColumn.setMinWidth(70);
|
||||
acceptedColumn.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
|
||||
acceptedColumn.setCellFactory(
|
||||
new Callback<TableColumn<VoteResultsListItem, VoteResultsListItem>, TableCell<VoteResultsListItem,
|
||||
VoteResultsListItem>>() {
|
||||
@Override
|
||||
public TableCell<VoteResultsListItem, VoteResultsListItem> call(
|
||||
TableColumn<VoteResultsListItem, VoteResultsListItem> column) {
|
||||
return new TableCell<VoteResultsListItem, VoteResultsListItem>() {
|
||||
@Override
|
||||
public void updateItem(final VoteResultsListItem item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (item != null)
|
||||
setText(item.getNumAcceptedVotes());
|
||||
else
|
||||
setText("");
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
acceptedColumn.setComparator(Comparator.comparing(VoteResultsListItem::getNumAcceptedVotes));
|
||||
tableView.getColumns().add(acceptedColumn);
|
||||
|
||||
TableColumn<VoteResultsListItem, VoteResultsListItem> rejectedColumn = new AutoTooltipTableColumn<>(Res.get("dao.results.votes.table.header.rejected"));
|
||||
rejectedColumn.setMinWidth(70);
|
||||
rejectedColumn.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
|
||||
rejectedColumn.setCellFactory(
|
||||
new Callback<TableColumn<VoteResultsListItem, VoteResultsListItem>, TableCell<VoteResultsListItem,
|
||||
VoteResultsListItem>>() {
|
||||
@Override
|
||||
public TableCell<VoteResultsListItem, VoteResultsListItem> call(
|
||||
TableColumn<VoteResultsListItem, VoteResultsListItem> column) {
|
||||
return new TableCell<VoteResultsListItem, VoteResultsListItem>() {
|
||||
@Override
|
||||
public void updateItem(final VoteResultsListItem item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (item != null)
|
||||
setText(item.getNumRejectedVotes());
|
||||
else
|
||||
setText("");
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
rejectedColumn.setComparator(Comparator.comparing(VoteResultsListItem::getNumRejectedVotes));
|
||||
tableView.getColumns().add(rejectedColumn);
|
||||
|
||||
TableColumn<VoteResultsListItem, VoteResultsListItem> blindVoteTxIdColumn = new AutoTooltipTableColumn<>(Res.get("dao.results.votes.table.header.blindVoteTxId"));
|
||||
blindVoteTxIdColumn.setMinWidth(120);
|
||||
blindVoteTxIdColumn.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
|
||||
blindVoteTxIdColumn.setCellFactory(
|
||||
new Callback<TableColumn<VoteResultsListItem, VoteResultsListItem>, TableCell<VoteResultsListItem,
|
||||
VoteResultsListItem>>() {
|
||||
|
||||
@Override
|
||||
public TableCell<VoteResultsListItem, VoteResultsListItem> call(
|
||||
TableColumn<VoteResultsListItem, VoteResultsListItem> column) {
|
||||
return new TableCell<VoteResultsListItem, VoteResultsListItem>() {
|
||||
private HyperlinkWithIcon hyperlinkWithIcon;
|
||||
|
||||
@Override
|
||||
public void updateItem(final VoteResultsListItem item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
|
||||
if (item != null && !empty) {
|
||||
String txId = item.getBlindVoteTxId();
|
||||
hyperlinkWithIcon = new HyperlinkWithIcon(txId, AwesomeIcon.EXTERNAL_LINK);
|
||||
hyperlinkWithIcon.setOnAction(event -> openTxInBlockExplorer(txId));
|
||||
hyperlinkWithIcon.setTooltip(new Tooltip(Res.get("tooltip.openBlockchainForTx", txId)));
|
||||
setGraphic(hyperlinkWithIcon);
|
||||
} else {
|
||||
setGraphic(null);
|
||||
if (hyperlinkWithIcon != null)
|
||||
hyperlinkWithIcon.setOnAction(null);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
blindVoteTxIdColumn.setComparator(Comparator.comparing(VoteResultsListItem::getBlindVoteTxId));
|
||||
tableView.getColumns().add(blindVoteTxIdColumn);
|
||||
|
||||
TableColumn<VoteResultsListItem, VoteResultsListItem> voteRevealTxIdColumn = new AutoTooltipTableColumn<>(Res.get("dao.results.votes.table.header.voteRevealTxId"));
|
||||
voteRevealTxIdColumn.setMinWidth(120);
|
||||
voteRevealTxIdColumn.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
|
||||
voteRevealTxIdColumn.setCellFactory(
|
||||
new Callback<TableColumn<VoteResultsListItem, VoteResultsListItem>, TableCell<VoteResultsListItem,
|
||||
VoteResultsListItem>>() {
|
||||
@Override
|
||||
public TableCell<VoteResultsListItem, VoteResultsListItem> call(
|
||||
TableColumn<VoteResultsListItem, VoteResultsListItem> column) {
|
||||
return new TableCell<VoteResultsListItem, VoteResultsListItem>() {
|
||||
private HyperlinkWithIcon hyperlinkWithIcon;
|
||||
|
||||
@Override
|
||||
public void updateItem(final VoteResultsListItem item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
|
||||
if (item != null && !empty) {
|
||||
String txId = item.getVoteRevealTxId();
|
||||
hyperlinkWithIcon = new HyperlinkWithIcon(txId, AwesomeIcon.EXTERNAL_LINK);
|
||||
hyperlinkWithIcon.setOnAction(event -> openTxInBlockExplorer(txId));
|
||||
hyperlinkWithIcon.setTooltip(new Tooltip(Res.get("tooltip.openBlockchainForTx", txId)));
|
||||
setGraphic(hyperlinkWithIcon);
|
||||
} else {
|
||||
setGraphic(null);
|
||||
if (hyperlinkWithIcon != null)
|
||||
hyperlinkWithIcon.setOnAction(null);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
voteRevealTxIdColumn.setComparator(Comparator.comparing(VoteResultsListItem::getVoteRevealTxId));
|
||||
tableView.getColumns().add(voteRevealTxIdColumn);*/
|
||||
}
|
||||
|
||||
private void openTxInBlockExplorer(String txId) {
|
||||
if (txId != null)
|
||||
GUIUtil.openWebPage(preferences.getBsqBlockChainExplorer().txUrl + txId);
|
||||
}
|
||||
}
|
|
@ -1,124 +0,0 @@
|
|||
/*
|
||||
* This file is part of Bisq.
|
||||
*
|
||||
* Bisq is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Bisq is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package bisq.desktop.main.dao.results.votes;
|
||||
|
||||
import bisq.desktop.main.dao.results.BaseResultsListItem;
|
||||
|
||||
import bisq.core.dao.state.BsqStateService;
|
||||
import bisq.core.dao.voting.ballot.vote.BooleanVote;
|
||||
import bisq.core.dao.voting.ballot.vote.LongVote;
|
||||
import bisq.core.dao.voting.proposal.Proposal;
|
||||
import bisq.core.dao.voting.voteresult.DecryptedVote;
|
||||
import bisq.core.locale.Res;
|
||||
import bisq.core.util.BsqFormatter;
|
||||
|
||||
import org.bitcoinj.core.Coin;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
public class VoteResultsListItem extends BaseResultsListItem {
|
||||
private final BsqStateService bsqStateService;
|
||||
private final BsqFormatter bsqFormatter;
|
||||
private int id;
|
||||
@Getter
|
||||
private final DecryptedVote decryptedVote;
|
||||
|
||||
public VoteResultsListItem(int id, DecryptedVote decryptedVote, BsqStateService bsqStateService, BsqFormatter bsqFormatter) {
|
||||
this.id = id;
|
||||
this.decryptedVote = decryptedVote;
|
||||
this.bsqStateService = bsqStateService;
|
||||
this.bsqFormatter = bsqFormatter;
|
||||
}
|
||||
|
||||
public String getBlindVoteTxId() {
|
||||
return decryptedVote.getBlindVoteTxId();
|
||||
}
|
||||
|
||||
public String getVoteRevealTxId() {
|
||||
return decryptedVote.getVoteRevealTxId();
|
||||
}
|
||||
|
||||
public String getStake() {
|
||||
return bsqFormatter.formatCoinWithCode(getStakeAsCoin());
|
||||
}
|
||||
|
||||
public String getStakeAndMerit() {
|
||||
return bsqFormatter.formatCoinWithCode(getStakeAndMeritAsCoin());
|
||||
}
|
||||
|
||||
public Coin getStakeAndMeritAsCoin() {
|
||||
return getMeritAsCoin().add(getStakeAsCoin());
|
||||
}
|
||||
|
||||
|
||||
public Coin getStakeAsCoin() {
|
||||
return Coin.valueOf(decryptedVote.getStake());
|
||||
}
|
||||
|
||||
public String getMerit() {
|
||||
return bsqFormatter.formatCoinWithCode(getMeritAsCoin());
|
||||
}
|
||||
|
||||
public Coin getMeritAsCoin() {
|
||||
return Coin.valueOf(decryptedVote.getMerit(bsqStateService));
|
||||
}
|
||||
|
||||
public String getNumAcceptedVotes() {
|
||||
return String.valueOf(getBooleanVoteStream()
|
||||
.filter(BooleanVote::isAccepted)
|
||||
.collect(Collectors.toList())
|
||||
.size());
|
||||
}
|
||||
|
||||
public String getNumRejectedVotes() {
|
||||
return String.valueOf(getBooleanVoteStream()
|
||||
.filter(booleanVote -> !booleanVote.isAccepted())
|
||||
.collect(Collectors.toList())
|
||||
.size());
|
||||
}
|
||||
|
||||
private Stream<BooleanVote> getBooleanVoteStream() {
|
||||
return decryptedVote.getBallotList().getList().stream()
|
||||
.filter(ballot -> ballot.getVote() instanceof BooleanVote)
|
||||
.map(ballot -> (BooleanVote) ballot.getVote());
|
||||
}
|
||||
|
||||
public String getBallotList() {
|
||||
return Joiner.on(", ").join(decryptedVote.getBallotList().getList().stream()
|
||||
.map(ballot -> {
|
||||
Proposal proposal = ballot.getProposal();
|
||||
String proposalUid = proposal.getShortId();
|
||||
if (ballot.getVote() instanceof BooleanVote)
|
||||
return proposalUid + ": " + ((BooleanVote) ballot.getVote()).isAccepted();
|
||||
else if (ballot.getVote() instanceof LongVote)
|
||||
return proposalUid + ": " + ((LongVote) ballot.getVote()).getValue();
|
||||
else
|
||||
return proposalUid;
|
||||
})
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return Res.get("dao.results.votes.table.cell.id", id);
|
||||
}
|
||||
}
|
|
@ -1,96 +0,0 @@
|
|||
/*
|
||||
* This file is part of Bisq.
|
||||
*
|
||||
* Bisq is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Bisq is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package bisq.desktop.main.dao.voting;
|
||||
|
||||
import bisq.desktop.main.dao.BaseProposalListItem;
|
||||
|
||||
import bisq.core.btc.wallet.BsqWalletService;
|
||||
import bisq.core.dao.DaoFacade;
|
||||
import bisq.core.dao.state.period.DaoPhase;
|
||||
import bisq.core.dao.voting.ballot.Ballot;
|
||||
import bisq.core.dao.voting.ballot.vote.BooleanVote;
|
||||
import bisq.core.dao.voting.ballot.vote.Vote;
|
||||
import bisq.core.dao.voting.proposal.Proposal;
|
||||
import bisq.core.util.BsqFormatter;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.ToString;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@ToString
|
||||
@Slf4j
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class BaseBallotListItem extends BaseProposalListItem {
|
||||
@Getter
|
||||
private final Ballot ballot;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Constructor, lifecycle
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
protected BaseBallotListItem(Ballot ballot,
|
||||
DaoFacade daoFacade,
|
||||
BsqWalletService bsqWalletService,
|
||||
BsqFormatter bsqFormatter) {
|
||||
super(daoFacade,
|
||||
bsqWalletService,
|
||||
bsqFormatter);
|
||||
|
||||
this.ballot = ballot;
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Protected
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
protected void init() {
|
||||
super.init();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPhaseChanged(DaoPhase.Phase phase) {
|
||||
super.onPhaseChanged(phase);
|
||||
|
||||
final Vote vote = ballot.getVote();
|
||||
if (vote != null) {
|
||||
imageView.setVisible(true);
|
||||
if (vote instanceof BooleanVote) {
|
||||
if (((BooleanVote) vote).isAccepted()) {
|
||||
imageView.setId("accepted");
|
||||
} else {
|
||||
imageView.setId("rejected");
|
||||
}
|
||||
}/* else {
|
||||
// not impl.
|
||||
}*/
|
||||
} else {
|
||||
imageView.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Proposal getProposal() {
|
||||
return ballot.getProposal();
|
||||
}
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
~ This file is part of Bisq.
|
||||
~
|
||||
~ Bisq is free software: you can redistribute it and/or modify it
|
||||
~ under the terms of the GNU Affero General Public License as published by
|
||||
~ the Free Software Foundation, either version 3 of the License, or (at
|
||||
~ your option) any later version.
|
||||
~
|
||||
~ Bisq is distributed in the hope that it will be useful, but WITHOUT
|
||||
~ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
~ FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
~ License for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU Affero General Public License
|
||||
~ along with Bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<?import javafx.scene.control.ScrollPane?>
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
<AnchorPane fx:id="root" fx:controller="bisq.desktop.main.dao.voting.VotingView"
|
||||
xmlns:fx="http://javafx.com/fxml">
|
||||
|
||||
<VBox fx:id="leftVBox" prefWidth="240" spacing="5" AnchorPane.bottomAnchor="20" AnchorPane.leftAnchor="15"
|
||||
AnchorPane.topAnchor="20"/>
|
||||
|
||||
<ScrollPane fitToWidth="true" hbarPolicy="NEVER"
|
||||
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="270.0"
|
||||
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<AnchorPane fx:id="content" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
|
||||
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"/>
|
||||
</ScrollPane>
|
||||
|
||||
</AnchorPane>
|
|
@ -1,130 +0,0 @@
|
|||
/*
|
||||
* This file is part of Bisq.
|
||||
*
|
||||
* Bisq is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Bisq is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package bisq.desktop.main.dao.voting;
|
||||
|
||||
import bisq.desktop.Navigation;
|
||||
import bisq.desktop.common.view.ActivatableViewAndModel;
|
||||
import bisq.desktop.common.view.CachingViewLoader;
|
||||
import bisq.desktop.common.view.FxmlView;
|
||||
import bisq.desktop.common.view.View;
|
||||
import bisq.desktop.common.view.ViewLoader;
|
||||
import bisq.desktop.common.view.ViewPath;
|
||||
import bisq.desktop.components.MenuItem;
|
||||
import bisq.desktop.main.MainView;
|
||||
import bisq.desktop.main.dao.DaoView;
|
||||
import bisq.desktop.main.dao.voting.active.ActiveBallotsView;
|
||||
import bisq.desktop.main.dao.voting.closed.ClosedBallotsView;
|
||||
import bisq.desktop.main.dao.voting.dashboard.VotingDashboardView;
|
||||
|
||||
import bisq.core.locale.Res;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import de.jensd.fx.fontawesome.AwesomeIcon;
|
||||
|
||||
import javafx.fxml.FXML;
|
||||
|
||||
import javafx.scene.control.ToggleGroup;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.layout.VBox;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@FxmlView
|
||||
public class VotingView extends ActivatableViewAndModel {
|
||||
|
||||
private final ViewLoader viewLoader;
|
||||
private final Navigation navigation;
|
||||
|
||||
private MenuItem dashboard, activeBallots, closedBallots;
|
||||
private Navigation.Listener listener;
|
||||
|
||||
@FXML
|
||||
private VBox leftVBox;
|
||||
@FXML
|
||||
private AnchorPane content;
|
||||
|
||||
private Class<? extends View> selectedViewClass;
|
||||
|
||||
@Inject
|
||||
private VotingView(CachingViewLoader viewLoader, Navigation navigation) {
|
||||
this.viewLoader = viewLoader;
|
||||
this.navigation = navigation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
listener = viewPath -> {
|
||||
if (viewPath.size() != 4 || viewPath.indexOf(VotingView.class) != 2)
|
||||
return;
|
||||
|
||||
selectedViewClass = viewPath.tip();
|
||||
loadView(selectedViewClass);
|
||||
};
|
||||
|
||||
ToggleGroup toggleGroup = new ToggleGroup();
|
||||
final List<Class<? extends View>> baseNavPath = Arrays.asList(MainView.class, DaoView.class, VotingView.class);
|
||||
dashboard = new MenuItem(navigation, toggleGroup, Res.get("shared.dashboard"),
|
||||
VotingDashboardView.class, AwesomeIcon.DASHBOARD, baseNavPath);
|
||||
activeBallots = new MenuItem(navigation, toggleGroup, Res.get("dao.voting.menuItem.activeBallots"),
|
||||
ActiveBallotsView.class, AwesomeIcon.LIST_UL, baseNavPath);
|
||||
closedBallots = new MenuItem(navigation, toggleGroup, Res.get("dao.voting.menuItem.closedBallots"),
|
||||
ClosedBallotsView.class, AwesomeIcon.LIST_ALT, baseNavPath);
|
||||
leftVBox.getChildren().addAll(dashboard, activeBallots, closedBallots);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void activate() {
|
||||
dashboard.activate();
|
||||
activeBallots.activate();
|
||||
closedBallots.activate();
|
||||
|
||||
navigation.addListener(listener);
|
||||
ViewPath viewPath = navigation.getCurrentPath();
|
||||
if (viewPath.size() == 3 && viewPath.indexOf(VotingView.class) == 2 ||
|
||||
viewPath.size() == 2 && viewPath.indexOf(DaoView.class) == 1) {
|
||||
if (selectedViewClass == null)
|
||||
selectedViewClass = ActiveBallotsView.class;
|
||||
|
||||
loadView(selectedViewClass);
|
||||
|
||||
} else if (viewPath.size() == 4 && viewPath.indexOf(VotingView.class) == 2) {
|
||||
selectedViewClass = viewPath.get(3);
|
||||
loadView(selectedViewClass);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void deactivate() {
|
||||
navigation.removeListener(listener);
|
||||
|
||||
dashboard.deactivate();
|
||||
activeBallots.deactivate();
|
||||
closedBallots.deactivate();
|
||||
}
|
||||
|
||||
private void loadView(Class<? extends View> viewClass) {
|
||||
View view = viewLoader.load(viewClass);
|
||||
content.getChildren().setAll(view.getRoot());
|
||||
|
||||
if (view instanceof VotingDashboardView) dashboard.setSelected(true);
|
||||
else if (view instanceof ActiveBallotsView) activeBallots.setSelected(true);
|
||||
else if (view instanceof ClosedBallotsView) closedBallots.setSelected(true);
|
||||
}
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
/*
|
||||
* This file is part of Bisq.
|
||||
*
|
||||
* Bisq is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Bisq is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package bisq.desktop.main.dao.voting.active;
|
||||
|
||||
import bisq.desktop.main.dao.voting.BaseBallotListItem;
|
||||
|
||||
import bisq.core.btc.wallet.BsqWalletService;
|
||||
import bisq.core.dao.DaoFacade;
|
||||
import bisq.core.dao.voting.ballot.Ballot;
|
||||
import bisq.core.util.BsqFormatter;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@ToString
|
||||
@Slf4j
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
class ActiveBallotListItem extends BaseBallotListItem {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Constructor, lifecycle
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ActiveBallotListItem(Ballot ballot,
|
||||
DaoFacade daoFacade,
|
||||
BsqWalletService bsqWalletService,
|
||||
BsqFormatter bsqFormatter) {
|
||||
super(ballot,
|
||||
daoFacade,
|
||||
bsqWalletService,
|
||||
bsqFormatter);
|
||||
}
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
~ This file is part of Bisq.
|
||||
~
|
||||
~ Bisq is free software: you can redistribute it and/or modify it
|
||||
~ under the terms of the GNU Affero General Public License as published by
|
||||
~ the Free Software Foundation, either version 3 of the License, or (at
|
||||
~ your option) any later version.
|
||||
~
|
||||
~ Bisq is distributed in the hope that it will be useful, but WITHOUT
|
||||
~ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
~ FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
~ License for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU Affero General Public License
|
||||
~ along with Bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
<?import javafx.scene.layout.ColumnConstraints?>
|
||||
<?import javafx.scene.layout.GridPane?>
|
||||
<GridPane fx:id="root" fx:controller="bisq.desktop.main.dao.voting.active.ActiveBallotsView"
|
||||
hgap="5.0" vgap="5.0"
|
||||
AnchorPane.bottomAnchor="20.0" AnchorPane.leftAnchor="20.0"
|
||||
AnchorPane.rightAnchor="25.0" AnchorPane.topAnchor="20.0"
|
||||
xmlns:fx="http://javafx.com/fxml">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints hgrow="SOMETIMES" halignment="RIGHT" minWidth="160.0"/>
|
||||
<ColumnConstraints hgrow="ALWAYS" minWidth="300.0"/>
|
||||
</columnConstraints>
|
||||
</GridPane>
|
|
@ -1,395 +0,0 @@
|
|||
/*
|
||||
* This file is part of Bisq.
|
||||
*
|
||||
* Bisq is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Bisq is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package bisq.desktop.main.dao.voting.active;
|
||||
|
||||
import bisq.desktop.common.view.FxmlView;
|
||||
import bisq.desktop.components.BusyAnimation;
|
||||
import bisq.desktop.components.InputTextField;
|
||||
import bisq.desktop.main.dao.BaseProposalListItem;
|
||||
import bisq.desktop.main.dao.BaseProposalView;
|
||||
import bisq.desktop.main.overlays.popups.Popup;
|
||||
import bisq.desktop.util.GUIUtil;
|
||||
import bisq.desktop.util.Layout;
|
||||
import bisq.desktop.util.validation.BsqValidator;
|
||||
|
||||
import bisq.core.btc.exceptions.TransactionVerificationException;
|
||||
import bisq.core.btc.exceptions.WalletException;
|
||||
import bisq.core.btc.wallet.BsqBalanceListener;
|
||||
import bisq.core.btc.wallet.BsqWalletService;
|
||||
import bisq.core.dao.DaoFacade;
|
||||
import bisq.core.dao.state.BsqStateListener;
|
||||
import bisq.core.dao.state.blockchain.Block;
|
||||
import bisq.core.dao.state.period.DaoPhase;
|
||||
import bisq.core.dao.voting.ballot.Ballot;
|
||||
import bisq.core.dao.voting.ballot.vote.BooleanVote;
|
||||
import bisq.core.dao.voting.proposal.Proposal;
|
||||
import bisq.core.locale.Res;
|
||||
import bisq.core.util.BSFormatter;
|
||||
import bisq.core.util.BsqFormatter;
|
||||
|
||||
import bisq.common.util.Tuple2;
|
||||
import bisq.common.util.Tuple3;
|
||||
|
||||
import org.bitcoinj.core.Coin;
|
||||
import org.bitcoinj.core.InsufficientMoneyException;
|
||||
import org.bitcoinj.core.Transaction;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.TableCell;
|
||||
import javafx.scene.control.TableColumn;
|
||||
import javafx.scene.control.TableView;
|
||||
import javafx.scene.image.ImageView;
|
||||
|
||||
import javafx.beans.property.ReadOnlyObjectWrapper;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
|
||||
import javafx.collections.ListChangeListener;
|
||||
|
||||
import javafx.util.Callback;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static bisq.desktop.util.FormBuilder.add3ButtonsAfterGroup;
|
||||
import static bisq.desktop.util.FormBuilder.addButtonBusyAnimationLabelAfterGroup;
|
||||
import static bisq.desktop.util.FormBuilder.addLabelInputTextField;
|
||||
import static bisq.desktop.util.FormBuilder.addTitledGroupBg;
|
||||
|
||||
@FxmlView
|
||||
public class ActiveBallotsView extends BaseProposalView implements BsqBalanceListener, BsqStateListener {
|
||||
private Button acceptButton, rejectButton, removeMyVoteButton, voteButton;
|
||||
private InputTextField stakeInputTextField;
|
||||
private BusyAnimation voteButtonBusyAnimation;
|
||||
private Label voteButtonInfoLabel;
|
||||
private ListChangeListener<Ballot> listChangeListener;
|
||||
private ChangeListener<String> stakeListener;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Constructor, lifecycle
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
private ActiveBallotsView(DaoFacade daoFacade,
|
||||
BsqWalletService bsqWalletService,
|
||||
BsqFormatter bsqFormatter,
|
||||
BSFormatter btcFormatter) {
|
||||
|
||||
super(daoFacade, bsqWalletService, bsqFormatter, btcFormatter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
super.initialize();
|
||||
|
||||
createProposalsTableView();
|
||||
createVoteView();
|
||||
createEmptyProposalDisplay();
|
||||
|
||||
stakeListener = (observable, oldValue, newValue) -> updateButtons();
|
||||
listChangeListener = c -> updateListItems();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void activate() {
|
||||
super.activate();
|
||||
|
||||
stakeInputTextField.textProperty().addListener(stakeListener);
|
||||
daoFacade.getValidAndConfirmedBallots().addListener(listChangeListener);
|
||||
bsqWalletService.addBsqBalanceListener(this);
|
||||
|
||||
onUpdateBalances(bsqWalletService.getAvailableBalance(),
|
||||
bsqWalletService.getAvailableNonBsqBalance(),
|
||||
bsqWalletService.getUnverifiedBalance(),
|
||||
bsqWalletService.getLockedForVotingBalance(),
|
||||
bsqWalletService.getLockupBondsBalance(),
|
||||
bsqWalletService.getUnlockingBondsBalance());
|
||||
|
||||
voteButton.setOnAction(e -> onVote());
|
||||
|
||||
daoFacade.addBsqStateListener(this);
|
||||
|
||||
updateButtons();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void deactivate() {
|
||||
super.deactivate();
|
||||
|
||||
stakeInputTextField.textProperty().removeListener(stakeListener);
|
||||
daoFacade.getValidAndConfirmedBallots().removeListener(listChangeListener);
|
||||
bsqWalletService.removeBsqBalanceListener(this);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// BsqBalanceListener
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void onUpdateBalances(Coin confirmedBalance,
|
||||
Coin availableNonBsqBalance,
|
||||
Coin pendingBalance,
|
||||
Coin lockedForVotingBalance,
|
||||
Coin lockupBondsBalance,
|
||||
Coin unlockingBondsBalance) {
|
||||
stakeInputTextField.setPromptText(Res.get("dao.proposal.myVote.stake.prompt",
|
||||
bsqFormatter.formatCoinWithCode(confirmedBalance)));
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// BsqStateListener
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void onNewBlockHeight(int blockHeight) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEmptyBlockAdded(Block block) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onParseTxsComplete(Block block) {
|
||||
updateButtons();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onParseBlockChainComplete() {
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Protected
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
protected void fillListItems() {
|
||||
List<Ballot> list = daoFacade.getValidAndConfirmedBallots();
|
||||
proposalBaseProposalListItems.setAll(list.stream()
|
||||
.map(ballot -> new ActiveBallotListItem(ballot, daoFacade, bsqWalletService, bsqFormatter))
|
||||
.collect(Collectors.toSet()));
|
||||
updateButtons();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createAllFieldsOnProposalDisplay(Proposal proposal) {
|
||||
super.createAllFieldsOnProposalDisplay(proposal);
|
||||
|
||||
Tuple3<Button, Button, Button> tuple = add3ButtonsAfterGroup(detailsGridPane,
|
||||
proposalDisplay.incrementAndGetGridRow(),
|
||||
Res.get("dao.proposal.myVote.accept"),
|
||||
Res.get("dao.proposal.myVote.reject"),
|
||||
Res.get("dao.proposal.myVote.removeMyVote"));
|
||||
acceptButton = tuple.first;
|
||||
acceptButton.setDefaultButton(false);
|
||||
rejectButton = tuple.second;
|
||||
removeMyVoteButton = tuple.third;
|
||||
acceptButton.setOnAction(event -> onAccept());
|
||||
rejectButton.setOnAction(event -> onReject());
|
||||
removeMyVoteButton.setOnAction(event -> onCancelVote());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void hideProposalDisplay() {
|
||||
super.hideProposalDisplay();
|
||||
|
||||
if (acceptButton != null) {
|
||||
acceptButton.setManaged(false);
|
||||
acceptButton.setVisible(false);
|
||||
}
|
||||
if (rejectButton != null) {
|
||||
rejectButton.setManaged(false);
|
||||
rejectButton.setVisible(false);
|
||||
}
|
||||
if (removeMyVoteButton != null) {
|
||||
removeMyVoteButton.setManaged(false);
|
||||
removeMyVoteButton.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPhaseChanged(DaoPhase.Phase phase) {
|
||||
super.onPhaseChanged(phase);
|
||||
|
||||
updateButtons();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSelectProposal(BaseProposalListItem item) {
|
||||
super.onSelectProposal(item);
|
||||
|
||||
updateButtons();
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Handlers
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private void onAccept() {
|
||||
daoFacade.setVote(getBallotListItem().getBallot(), new BooleanVote(true));
|
||||
updateStateAfterVote();
|
||||
}
|
||||
|
||||
private void onReject() {
|
||||
daoFacade.setVote(getBallotListItem().getBallot(), new BooleanVote(false));
|
||||
updateStateAfterVote();
|
||||
}
|
||||
|
||||
private void onCancelVote() {
|
||||
daoFacade.setVote(getBallotListItem().getBallot(), null);
|
||||
updateStateAfterVote();
|
||||
}
|
||||
|
||||
private void onVote() {
|
||||
// TODO verify stake
|
||||
Coin stake = bsqFormatter.parseToCoin(stakeInputTextField.getText());
|
||||
final Coin blindVoteFee = daoFacade.getBlindVoteFeeForCycle();
|
||||
Transaction dummyTx = null;
|
||||
try {
|
||||
// We create a dummy tx to get the mining blindVoteFee for confirmation popup
|
||||
dummyTx = daoFacade.getDummyBlindVoteTx(stake, blindVoteFee);
|
||||
} catch (InsufficientMoneyException | WalletException | TransactionVerificationException exception) {
|
||||
new Popup<>().warning(exception.toString()).show();
|
||||
}
|
||||
|
||||
if (dummyTx != null) {
|
||||
Coin miningFee = dummyTx.getFee();
|
||||
int txSize = dummyTx.bitcoinSerialize().length;
|
||||
GUIUtil.showBsqFeeInfoPopup(blindVoteFee, miningFee, txSize, bsqFormatter, btcFormatter,
|
||||
Res.get("dao.blindVote"), () -> publishBlindVote(stake));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Private
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private void publishBlindVote(Coin stake) {
|
||||
voteButtonBusyAnimation.play();
|
||||
voteButtonInfoLabel.setText(Res.get("dao.blindVote.startPublishing"));
|
||||
daoFacade.publishBlindVote(stake,
|
||||
() -> {
|
||||
voteButtonBusyAnimation.stop();
|
||||
voteButtonInfoLabel.setText("");
|
||||
new Popup().feedback(Res.get("dao.blindVote.success"))
|
||||
.show();
|
||||
}, exception -> {
|
||||
voteButtonBusyAnimation.stop();
|
||||
voteButtonInfoLabel.setText("");
|
||||
new Popup<>().warning(exception.toString()).show();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void updateStateAfterVote() {
|
||||
hideProposalDisplay();
|
||||
proposalTableView.getSelectionModel().clearSelection();
|
||||
proposalTableView.refresh();
|
||||
}
|
||||
|
||||
private ActiveBallotListItem getBallotListItem() {
|
||||
return (ActiveBallotListItem) selectedBaseProposalListItem;
|
||||
}
|
||||
|
||||
private void updateButtons() {
|
||||
final boolean isBlindVotePhase = daoFacade.phaseProperty().get() == DaoPhase.Phase.BLIND_VOTE;
|
||||
stakeInputTextField.setDisable(!isBlindVotePhase);
|
||||
voteButton.setDisable(!isBlindVotePhase &&
|
||||
stakeInputTextField.getValidator().validate(stakeInputTextField.getText()).isValid);
|
||||
|
||||
if (acceptButton != null) acceptButton.setDisable(!isBlindVotePhase);
|
||||
if (rejectButton != null) rejectButton.setDisable(!isBlindVotePhase);
|
||||
if (removeMyVoteButton != null) removeMyVoteButton.setDisable(!isBlindVotePhase);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Create views
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private void createVoteView() {
|
||||
addTitledGroupBg(root, ++gridRow, 1,
|
||||
Res.get("dao.proposal.votes.header"), Layout.GROUP_DISTANCE - 20);
|
||||
final Tuple2<Label, InputTextField> tuple2 = addLabelInputTextField(root, gridRow,
|
||||
Res.getWithCol("dao.proposal.myVote.stake"), Layout.FIRST_ROW_AND_GROUP_DISTANCE - 20);
|
||||
stakeInputTextField = tuple2.second;
|
||||
stakeInputTextField.setValidator(new BsqValidator(bsqFormatter));
|
||||
|
||||
Tuple3<Button, BusyAnimation, Label> tuple = addButtonBusyAnimationLabelAfterGroup(root, ++gridRow,
|
||||
Res.get("dao.proposal.myVote.button"));
|
||||
voteButton = tuple.first;
|
||||
voteButtonBusyAnimation = tuple.second;
|
||||
voteButtonInfoLabel = tuple.third;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// TableColumns
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
protected void createProposalColumns(TableView<BaseProposalListItem> tableView) {
|
||||
super.createProposalColumns(tableView);
|
||||
createConfidenceColumn(tableView);
|
||||
|
||||
TableColumn<BaseProposalListItem, BaseProposalListItem> actionColumn = new TableColumn<>();
|
||||
actionColumn.setMinWidth(130);
|
||||
actionColumn.setMaxWidth(actionColumn.getMinWidth());
|
||||
|
||||
actionColumn.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
|
||||
|
||||
actionColumn.setCellFactory(new Callback<TableColumn<BaseProposalListItem, BaseProposalListItem>,
|
||||
TableCell<BaseProposalListItem, BaseProposalListItem>>() {
|
||||
|
||||
@Override
|
||||
public TableCell<BaseProposalListItem, BaseProposalListItem> call(TableColumn<BaseProposalListItem,
|
||||
BaseProposalListItem> column) {
|
||||
return new TableCell<BaseProposalListItem, BaseProposalListItem>() {
|
||||
ImageView imageView;
|
||||
|
||||
@Override
|
||||
public void updateItem(final BaseProposalListItem item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
|
||||
if (item != null && !empty) {
|
||||
ActiveBallotListItem activeBallotListItem = (ActiveBallotListItem) item;
|
||||
if (imageView == null) {
|
||||
imageView = activeBallotListItem.getImageView();
|
||||
setGraphic(imageView);
|
||||
}
|
||||
activeBallotListItem.onPhaseChanged(currentPhase);
|
||||
} else {
|
||||
setGraphic(null);
|
||||
if (imageView != null)
|
||||
imageView = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
tableView.getColumns().add(actionColumn);
|
||||
}
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
/*
|
||||
* This file is part of Bisq.
|
||||
*
|
||||
* Bisq is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Bisq is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package bisq.desktop.main.dao.voting.closed;
|
||||
|
||||
import bisq.desktop.main.dao.voting.BaseBallotListItem;
|
||||
|
||||
import bisq.core.btc.wallet.BsqWalletService;
|
||||
import bisq.core.dao.DaoFacade;
|
||||
import bisq.core.dao.voting.ballot.Ballot;
|
||||
import bisq.core.util.BsqFormatter;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@ToString
|
||||
@Slf4j
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
class ClosedBallotListItem extends BaseBallotListItem {
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Constructor, lifecycle
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public ClosedBallotListItem(Ballot ballot,
|
||||
DaoFacade daoFacade,
|
||||
BsqWalletService bsqWalletService,
|
||||
BsqFormatter bsqFormatter) {
|
||||
super(ballot,
|
||||
daoFacade,
|
||||
bsqWalletService,
|
||||
bsqFormatter);
|
||||
}
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
~ This file is part of Bisq.
|
||||
~
|
||||
~ Bisq is free software: you can redistribute it and/or modify it
|
||||
~ under the terms of the GNU Affero General Public License as published by
|
||||
~ the Free Software Foundation, either version 3 of the License, or (at
|
||||
~ your option) any later version.
|
||||
~
|
||||
~ Bisq is distributed in the hope that it will be useful, but WITHOUT
|
||||
~ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
~ FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
~ License for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU Affero General Public License
|
||||
~ along with Bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
<?import javafx.scene.layout.ColumnConstraints?>
|
||||
<?import javafx.scene.layout.GridPane?>
|
||||
<GridPane fx:id="root" fx:controller="bisq.desktop.main.dao.voting.closed.ClosedBallotsView"
|
||||
hgap="5.0" vgap="5.0"
|
||||
AnchorPane.bottomAnchor="20.0" AnchorPane.leftAnchor="20.0"
|
||||
AnchorPane.rightAnchor="25.0" AnchorPane.topAnchor="20.0"
|
||||
xmlns:fx="http://javafx.com/fxml">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints hgrow="SOMETIMES" halignment="RIGHT" minWidth="160.0"/>
|
||||
<ColumnConstraints hgrow="ALWAYS" minWidth="300.0"/>
|
||||
</columnConstraints>
|
||||
</GridPane>
|
||||
|
|
@ -1,155 +0,0 @@
|
|||
/*
|
||||
* This file is part of Bisq.
|
||||
*
|
||||
* Bisq is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Bisq is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package bisq.desktop.main.dao.voting.closed;
|
||||
|
||||
import bisq.desktop.common.view.FxmlView;
|
||||
import bisq.desktop.main.dao.BaseProposalListItem;
|
||||
import bisq.desktop.main.dao.BaseProposalView;
|
||||
|
||||
import bisq.core.btc.wallet.BsqWalletService;
|
||||
import bisq.core.dao.DaoFacade;
|
||||
import bisq.core.dao.voting.ballot.Ballot;
|
||||
import bisq.core.util.BSFormatter;
|
||||
import bisq.core.util.BsqFormatter;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import javafx.scene.control.TableCell;
|
||||
import javafx.scene.control.TableColumn;
|
||||
import javafx.scene.control.TableView;
|
||||
import javafx.scene.image.ImageView;
|
||||
|
||||
import javafx.beans.property.ReadOnlyObjectWrapper;
|
||||
|
||||
import javafx.collections.ListChangeListener;
|
||||
|
||||
import javafx.util.Callback;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@FxmlView
|
||||
public class ClosedBallotsView extends BaseProposalView {
|
||||
private ListChangeListener<Ballot> listChangeListener;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Constructor, lifecycle
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
private ClosedBallotsView(DaoFacade daoFacade,
|
||||
BsqWalletService bsqWalletService,
|
||||
BsqFormatter bsqFormatter,
|
||||
BSFormatter btcFormatter) {
|
||||
|
||||
super(daoFacade, bsqWalletService, bsqFormatter, btcFormatter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
super.initialize();
|
||||
|
||||
createProposalsTableView();
|
||||
createEmptyProposalDisplay();
|
||||
|
||||
listChangeListener = c -> updateListItems();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void activate() {
|
||||
super.activate();
|
||||
|
||||
daoFacade.getClosedBallots().addListener(listChangeListener);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void deactivate() {
|
||||
super.deactivate();
|
||||
|
||||
daoFacade.getClosedBallots().removeListener(listChangeListener);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Protected
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
protected void fillListItems() {
|
||||
List<Ballot> list = daoFacade.getClosedBallots();
|
||||
proposalBaseProposalListItems.setAll(list.stream()
|
||||
.map(ballot -> new ClosedBallotListItem(ballot, daoFacade, bsqWalletService, bsqFormatter))
|
||||
.collect(Collectors.toSet()));
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Private
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// TableColumns
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
protected void createProposalColumns(TableView<BaseProposalListItem> tableView) {
|
||||
super.createProposalColumns(tableView);
|
||||
createConfidenceColumn(tableView);
|
||||
|
||||
TableColumn<BaseProposalListItem, BaseProposalListItem> actionColumn = new TableColumn<>();
|
||||
actionColumn.setMinWidth(130);
|
||||
actionColumn.setMaxWidth(actionColumn.getMinWidth());
|
||||
|
||||
actionColumn.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
|
||||
|
||||
actionColumn.setCellFactory(new Callback<TableColumn<BaseProposalListItem, BaseProposalListItem>,
|
||||
TableCell<BaseProposalListItem, BaseProposalListItem>>() {
|
||||
|
||||
@Override
|
||||
public TableCell<BaseProposalListItem, BaseProposalListItem> call(TableColumn<BaseProposalListItem,
|
||||
BaseProposalListItem> column) {
|
||||
return new TableCell<BaseProposalListItem, BaseProposalListItem>() {
|
||||
ImageView imageView;
|
||||
|
||||
@Override
|
||||
public void updateItem(final BaseProposalListItem item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
|
||||
if (item != null && !empty) {
|
||||
ClosedBallotListItem closedBallotListItem = (ClosedBallotListItem) item;
|
||||
if (imageView == null) {
|
||||
imageView = closedBallotListItem.getImageView();
|
||||
setGraphic(imageView);
|
||||
}
|
||||
closedBallotListItem.onPhaseChanged(currentPhase);
|
||||
} else {
|
||||
setGraphic(null);
|
||||
if (imageView != null)
|
||||
imageView = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
actionColumn.setComparator(Comparator.comparing(BaseProposalListItem::getConfirmations));
|
||||
tableView.getColumns().add(actionColumn);
|
||||
}
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
~ This file is part of Bisq.
|
||||
~
|
||||
~ Bisq is free software: you can redistribute it and/or modify it
|
||||
~ under the terms of the GNU Affero General Public License as published by
|
||||
~ the Free Software Foundation, either version 3 of the License, or (at
|
||||
~ your option) any later version.
|
||||
~
|
||||
~ Bisq is distributed in the hope that it will be useful, but WITHOUT
|
||||
~ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
~ FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
~ License for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU Affero General Public License
|
||||
~ along with Bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
<?import javafx.scene.layout.ColumnConstraints?>
|
||||
<?import javafx.scene.layout.GridPane?>
|
||||
<GridPane fx:id="root" fx:controller="bisq.desktop.main.dao.voting.closed.VotingHistoryView"
|
||||
hgap="5.0" vgap="5.0"
|
||||
AnchorPane.bottomAnchor="20.0" AnchorPane.leftAnchor="20.0"
|
||||
AnchorPane.rightAnchor="25.0" AnchorPane.topAnchor="20.0"
|
||||
xmlns:fx="http://javafx.com/fxml">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints hgrow="SOMETIMES" halignment="RIGHT" minWidth="160.0"/>
|
||||
<ColumnConstraints hgrow="ALWAYS" minWidth="300.0"/>
|
||||
</columnConstraints>
|
||||
</GridPane>
|
|
@ -1,50 +0,0 @@
|
|||
/*
|
||||
* This file is part of Bisq.
|
||||
*
|
||||
* Bisq is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Bisq is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package bisq.desktop.main.dao.voting.closed;
|
||||
|
||||
import bisq.desktop.common.view.ActivatableView;
|
||||
import bisq.desktop.common.view.FxmlView;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import javafx.scene.layout.GridPane;
|
||||
|
||||
@FxmlView
|
||||
public class VotingHistoryView extends ActivatableView<GridPane, Void> {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Constructor, lifecycle
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
private VotingHistoryView() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void activate() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void deactivate() {
|
||||
}
|
||||
}
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
~ This file is part of Bisq.
|
||||
~
|
||||
~ Bisq is free software: you can redistribute it and/or modify it
|
||||
~ under the terms of the GNU Affero General Public License as published by
|
||||
~ the Free Software Foundation, either version 3 of the License, or (at
|
||||
~ your option) any later version.
|
||||
~
|
||||
~ Bisq is distributed in the hope that it will be useful, but WITHOUT
|
||||
~ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
~ FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
~ License for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU Affero General Public License
|
||||
~ along with Bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
<?import javafx.scene.layout.ColumnConstraints?>
|
||||
<?import javafx.scene.layout.GridPane?>
|
||||
<GridPane fx:id="root" fx:controller="bisq.desktop.main.dao.proposal.dashboard.ProposalDashboardView"
|
||||
hgap="5.0" vgap="5.0"
|
||||
AnchorPane.bottomAnchor="20.0" AnchorPane.leftAnchor="20.0"
|
||||
AnchorPane.rightAnchor="25.0" AnchorPane.topAnchor="20.0"
|
||||
xmlns:fx="http://javafx.com/fxml">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints hgrow="SOMETIMES" halignment="RIGHT" minWidth="160.0"/>
|
||||
<ColumnConstraints hgrow="ALWAYS" minWidth="300.0"/>
|
||||
</columnConstraints>
|
||||
</GridPane>
|
|
@ -1,57 +0,0 @@
|
|||
/*
|
||||
* This file is part of Bisq.
|
||||
*
|
||||
* Bisq is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Bisq is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package bisq.desktop.main.dao.voting.dashboard;
|
||||
|
||||
import bisq.desktop.common.view.FxmlView;
|
||||
import bisq.desktop.main.dao.proposal.CycleOverview;
|
||||
import bisq.desktop.main.dao.proposal.dashboard.ProposalDashboardView;
|
||||
|
||||
import bisq.core.dao.DaoFacade;
|
||||
import bisq.core.util.BSFormatter;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
@FxmlView
|
||||
public class VotingDashboardView extends ProposalDashboardView {
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Constructor, lifecycle
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
private VotingDashboardView(DaoFacade daoFacade, CycleOverview cycleOverview, BSFormatter formatter) {
|
||||
super(daoFacade, cycleOverview, formatter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
super.initialize();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void activate() {
|
||||
super.activate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void deactivate() {
|
||||
super.deactivate();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
~ This file is part of Bisq.
|
||||
~
|
||||
~ Bisq is free software: you can redistribute it and/or modify it
|
||||
~ under the terms of the GNU Affero General Public License as published by
|
||||
~ the Free Software Foundation, either version 3 of the License, or (at
|
||||
~ your option) any later version.
|
||||
~
|
||||
~ Bisq is distributed in the hope that it will be useful, but WITHOUT
|
||||
~ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
~ FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
~ License for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU Affero General Public License
|
||||
~ along with Bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
<?import javafx.scene.layout.ColumnConstraints?>
|
||||
<?import javafx.scene.layout.GridPane?>
|
||||
<GridPane fx:id="root" fx:controller="bisq.desktop.main.dao.voting.vote.VoteView"
|
||||
hgap="5.0" vgap="5.0"
|
||||
AnchorPane.bottomAnchor="20.0" AnchorPane.leftAnchor="20.0"
|
||||
AnchorPane.rightAnchor="25.0" AnchorPane.topAnchor="20.0"
|
||||
xmlns:fx="http://javafx.com/fxml">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints hgrow="SOMETIMES" halignment="RIGHT" minWidth="160.0"/>
|
||||
<ColumnConstraints hgrow="ALWAYS" minWidth="300.0"/>
|
||||
</columnConstraints>
|
||||
</GridPane>
|
|
@ -1,50 +0,0 @@
|
|||
/*
|
||||
* This file is part of Bisq.
|
||||
*
|
||||
* Bisq is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Bisq is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package bisq.desktop.main.dao.voting.vote;
|
||||
|
||||
import bisq.desktop.common.view.ActivatableView;
|
||||
import bisq.desktop.common.view.FxmlView;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import javafx.scene.layout.GridPane;
|
||||
|
||||
@FxmlView
|
||||
public class VoteView extends ActivatableView<GridPane, Void> {
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Constructor, lifecycle
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
private VoteView() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void activate() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void deactivate() {
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue