Improve layout and fix issue with phase breaks

This commit is contained in:
Christoph Atteneder 2019-03-25 20:47:28 +01:00
parent 942d8366b2
commit f6f2a663e8
No known key found for this signature in database
GPG key ID: CD5DC1C529CDFD3B
4 changed files with 42 additions and 16 deletions

View file

@ -1681,6 +1681,7 @@ dao.proposal.active.remove.confirm=Are you sure you want to remove that proposal
The already paid proposal fee will be lost. The already paid proposal fee will be lost.
dao.proposal.active.remove.doRemove=Yes, remove my proposal dao.proposal.active.remove.doRemove=Yes, remove my proposal
dao.proposal.active.remove.failed=Could not remove proposal. dao.proposal.active.remove.failed=Could not remove proposal.
dao.proposal.myVote.title=Voting
dao.proposal.myVote.accept=Accept proposal dao.proposal.myVote.accept=Accept proposal
dao.proposal.myVote.reject=Reject proposal dao.proposal.myVote.reject=Reject proposal
dao.proposal.myVote.removeMyVote=Ignore proposal dao.proposal.myVote.removeMyVote=Ignore proposal

View file

@ -140,9 +140,10 @@ public class ProposalDisplay {
private final ChangeListener<Object> inputListener; private final ChangeListener<Object> inputListener;
private ChangeListener<Param> paramChangeListener; private ChangeListener<Param> paramChangeListener;
private ChangeListener<BondedRoleType> requiredBondForRoleListener; private ChangeListener<BondedRoleType> requiredBondForRoleListener;
private TitledGroupBg titledGroupBg; private TitledGroupBg myVoteTitledGroup;
private int titledGroupBgRowSpan; private int titledGroupBgRowSpan;
private VBox linkWithIconContainer, comboBoxValueContainer, myVoteBox, voteResultBox; private VBox linkWithIconContainer, comboBoxValueContainer, myVoteBox, voteResultBox;
private int votingBoxRowSpan;
public ProposalDisplay(GridPane gridPane, public ProposalDisplay(GridPane gridPane,
BsqFormatter bsqFormatter, BsqFormatter bsqFormatter,
@ -176,6 +177,11 @@ public class ProposalDisplay {
public void createAllFields(String title, int gridRowStartIndex, double top, ProposalType proposalType, public void createAllFields(String title, int gridRowStartIndex, double top, ProposalType proposalType,
boolean isMakeProposalScreen) { boolean isMakeProposalScreen) {
createAllFields(title, gridRowStartIndex, top, proposalType, isMakeProposalScreen, null);
}
public void createAllFields(String title, int gridRowStartIndex, double top, ProposalType proposalType,
boolean isMakeProposalScreen, String titledGroupStyle) {
removeAllFields(); removeAllFields();
this.gridRowStartIndex = gridRowStartIndex; this.gridRowStartIndex = gridRowStartIndex;
this.gridRow = gridRowStartIndex; this.gridRow = gridRowStartIndex;
@ -200,16 +206,22 @@ public class ProposalDisplay {
break; break;
} }
titledGroupBg = addTitledGroupBg(gridPane, gridRow, titledGroupBgRowSpan, title, top); TitledGroupBg titledGroupBg = addTitledGroupBg(gridPane, gridRow, titledGroupBgRowSpan, title, top);
if (titledGroupStyle != null) titledGroupBg.getStyleClass().add(titledGroupStyle);
double proposalTypeTop; double proposalTypeTop;
if (top == Layout.GROUP_DISTANCE_WITHOUT_SEPARATOR) { if (top == Layout.GROUP_DISTANCE_WITHOUT_SEPARATOR) {
proposalTypeTop = Layout.COMPACT_FIRST_ROW_AND_GROUP_DISTANCE_WITHOUT_SEPARATOR; proposalTypeTop = Layout.COMPACT_FIRST_ROW_AND_GROUP_DISTANCE_WITHOUT_SEPARATOR;
} else if (top == Layout.GROUP_DISTANCE) { } else if (top == Layout.GROUP_DISTANCE) {
proposalTypeTop = Layout.FIRST_ROW_AND_GROUP_DISTANCE; proposalTypeTop = Layout.FIRST_ROW_AND_GROUP_DISTANCE;
} else { } else if (top == 0) {
proposalTypeTop = Layout.FIRST_ROW_DISTANCE; proposalTypeTop = Layout.FIRST_ROW_DISTANCE;
} else {
proposalTypeTop = Layout.FIRST_ROW_DISTANCE + top;
} }
proposalTypeTextField = addTopLabelTextField(gridPane, gridRow, proposalTypeTextField = addTopLabelTextField(gridPane, gridRow,
Res.get("dao.proposal.display.type"), proposalType.getDisplayName(), proposalTypeTop).second; Res.get("dao.proposal.display.type"), proposalType.getDisplayName(), proposalTypeTop).second;
@ -325,7 +337,7 @@ public class ProposalDisplay {
} }
}); });
comboBoxes.add(bondedRoleTypeComboBox); comboBoxes.add(bondedRoleTypeComboBox);
requiredBondForRoleTextField = addTopLabelTextField(gridPane, ++gridRow, requiredBondForRoleTextField = addTopLabelReadOnlyTextField(gridPane, ++gridRow,
Res.get("dao.proposal.display.requiredBondForRole.label")).second; Res.get("dao.proposal.display.requiredBondForRole.label")).second;
requiredBondForRoleListener = (observable, oldValue, newValue) -> { requiredBondForRoleListener = (observable, oldValue, newValue) -> {
@ -407,7 +419,11 @@ public class ProposalDisplay {
proposalFeeTextField.setText(bsqFormatter.formatCoinWithCode(daoFacade.getProposalFee(daoFacade.getChainHeight()))); proposalFeeTextField.setText(bsqFormatter.formatCoinWithCode(daoFacade.getProposalFee(daoFacade.getChainHeight())));
} }
Tuple3<Label, TextField, VBox> tuple3 = addTopLabelTextField(gridPane, ++gridRow, Res.get("dao.proposal.display.myVote")); votingBoxRowSpan = 4;
myVoteTitledGroup = addTitledGroupBg(gridPane, ++gridRow, 4, Res.get("dao.proposal.myVote.title"), Layout.COMPACT_FIRST_ROW_DISTANCE);
Tuple3<Label, TextField, VBox> tuple3 = addTopLabelTextField(gridPane, ++gridRow, Res.get("dao.proposal.display.myVote"), Layout.COMPACT_FIRST_ROW_DISTANCE);
myVoteBox = tuple3.third; myVoteBox = tuple3.third;
setMyVoteBoxVisibility(false); setMyVoteBoxVisibility(false);
@ -439,7 +455,6 @@ public class ProposalDisplay {
} }
public void applyEvaluatedProposal(@Nullable EvaluatedProposal evaluatedProposal) { public void applyEvaluatedProposal(@Nullable EvaluatedProposal evaluatedProposal) {
GridPane.setRowSpan(titledGroupBg, titledGroupBgRowSpan + 1);
boolean isEvaluatedProposalNotNull = evaluatedProposal != null; boolean isEvaluatedProposalNotNull = evaluatedProposal != null;
if (isEvaluatedProposalNotNull) { if (isEvaluatedProposalNotNull) {
@ -475,6 +490,8 @@ public class ProposalDisplay {
String myVoteSummary = Res.get("dao.proposal.myVote.summary", myVote, String myVoteSummary = Res.get("dao.proposal.myVote.summary", myVote,
weight, meritString, stakeString); weight, meritString, stakeString);
myVoteTextField.setText(myVoteSummary); myVoteTextField.setText(myVoteSummary);
GridPane.setRowSpan(myVoteTitledGroup, votingBoxRowSpan - 1);
} }
boolean show = ballotIsNotNull && hasVoted; boolean show = ballotIsNotNull && hasVoted;
@ -666,11 +683,9 @@ public class ProposalDisplay {
} }
private void setMyVoteBoxVisibility(boolean visibility) { private void setMyVoteBoxVisibility(boolean visibility) {
myVoteTitledGroup.setVisible(visibility);
myVoteTitledGroup.setManaged(visibility);
myVoteBox.setVisible(visibility); myVoteBox.setVisible(visibility);
myVoteBox.setManaged(visibility); myVoteBox.setManaged(visibility);
if (visibility) {
GridPane.setRowSpan(titledGroupBg, titledGroupBgRowSpan);
}
} }
} }

View file

@ -394,8 +394,8 @@ public class ProposalsView extends ActivatableView<GridPane, Void> implements Bs
.findAny() .findAny()
.orElse(null); .orElse(null);
showVoteOnProposalWindow(selectedItem.getProposal(), selectedItem.getBallot(), evaluatedProposal);
applyMerit(); applyMerit();
showVoteOnProposalWindow(selectedItem.getProposal(), selectedItem.getBallot(), evaluatedProposal);
} }
onPhaseChanged(daoFacade.phaseProperty().get()); onPhaseChanged(daoFacade.phaseProperty().get());

View file

@ -3,6 +3,7 @@ package bisq.desktop.main.overlays.windows;
import bisq.desktop.Navigation; import bisq.desktop.Navigation;
import bisq.desktop.main.dao.governance.ProposalDisplay; import bisq.desktop.main.dao.governance.ProposalDisplay;
import bisq.desktop.main.overlays.Overlay; import bisq.desktop.main.overlays.Overlay;
import bisq.desktop.util.Layout;
import bisq.core.dao.DaoFacade; import bisq.core.dao.DaoFacade;
import bisq.core.dao.governance.myvote.MyVote; import bisq.core.dao.governance.myvote.MyVote;
@ -127,8 +128,8 @@ public class SelectProposalWindow extends Overlay<SelectProposalWindow> {
private void addContent(Proposal proposal, EvaluatedProposal evaluatedProposal, Ballot ballot) { private void addContent(Proposal proposal, EvaluatedProposal evaluatedProposal, Ballot ballot) {
ProposalDisplay proposalDisplay = new ProposalDisplay(gridPane, bsqFormatter, daoFacade, changeParamValidator, ProposalDisplay proposalDisplay = new ProposalDisplay(gridPane, bsqFormatter, daoFacade, changeParamValidator,
navigation, preferences); navigation, preferences);
proposalDisplay.createAllFields("", rowIndex, 0, proposal.getType(), proposalDisplay.createAllFields("", rowIndex, -Layout.FIRST_ROW_DISTANCE, proposal.getType(),
false); false, "last");
proposalDisplay.setEditable(false); proposalDisplay.setEditable(false);
proposalDisplay.applyProposalPayload(proposal); proposalDisplay.applyProposalPayload(proposal);
proposalDisplay.applyEvaluatedProposal(evaluatedProposal); proposalDisplay.applyEvaluatedProposal(evaluatedProposal);
@ -142,7 +143,9 @@ public class SelectProposalWindow extends Overlay<SelectProposalWindow> {
List<MyVote> myVoteListForCycle = daoFacade.getMyVoteListForCycle(); List<MyVote> myVoteListForCycle = daoFacade.getMyVoteListForCycle();
boolean hasAlreadyVoted = !myVoteListForCycle.isEmpty(); boolean hasAlreadyVoted = !myVoteListForCycle.isEmpty();
if (daoFacade.phaseProperty().get() == DaoPhase.Phase.PROPOSAL) { DaoPhase.Phase currentPhase = daoFacade.phaseProperty().get();
if (currentPhase == DaoPhase.Phase.PROPOSAL) {
Tuple2<Button, Button> proposalPhaseButtonsTuple = add2ButtonsAfterGroup(gridPane, proposalDisplay.incrementAndGetGridRow(), Res.get("shared.remove"), Res.get("shared.close")); Tuple2<Button, Button> proposalPhaseButtonsTuple = add2ButtonsAfterGroup(gridPane, proposalDisplay.incrementAndGetGridRow(), Res.get("shared.remove"), Res.get("shared.close"));
Button removeProposalButton = proposalPhaseButtonsTuple.first; Button removeProposalButton = proposalPhaseButtonsTuple.first;
@ -158,9 +161,12 @@ public class SelectProposalWindow extends Overlay<SelectProposalWindow> {
proposalPhaseButtonsTuple.second.setOnAction(event -> doClose()); proposalPhaseButtonsTuple.second.setOnAction(event -> doClose());
} else if (daoFacade.phaseProperty().get() == DaoPhase.Phase.BLIND_VOTE && !hasAlreadyVoted) { } else if (currentPhase == DaoPhase.Phase.BLIND_VOTE &&
!hasAlreadyVoted &&
daoFacade.isInPhaseButNotLastBlock(currentPhase)) {
int rowIndexForVoting = proposalDisplay.incrementAndGetGridRow();
Tuple3<Button, Button, Button> tuple = add3ButtonsAfterGroup(gridPane, Tuple3<Button, Button, Button> tuple = add3ButtonsAfterGroup(gridPane,
proposalDisplay.incrementAndGetGridRow(), rowIndexForVoting,
Res.get("dao.proposal.myVote.accept"), Res.get("dao.proposal.myVote.accept"),
Res.get("dao.proposal.myVote.reject"), Res.get("dao.proposal.myVote.reject"),
Res.get("dao.proposal.myVote.removeMyVote")); Res.get("dao.proposal.myVote.removeMyVote"));
@ -191,6 +197,10 @@ public class SelectProposalWindow extends Overlay<SelectProposalWindow> {
ignoreHandlerOptional.ifPresent(Runnable::run); ignoreHandlerOptional.ifPresent(Runnable::run);
doClose(); doClose();
}); });
Button closeButton = addButtonAfterGroup(gridPane, ++rowIndexForVoting, Res.get("shared.close"));
closeButton.setOnAction(event -> doClose());
} else { } else {
Button closeButton = addButtonAfterGroup(gridPane, proposalDisplay.incrementAndGetGridRow(), Res.get("shared.close")); Button closeButton = addButtonAfterGroup(gridPane, proposalDisplay.incrementAndGetGridRow(), Res.get("shared.close"));
closeButton.setOnAction(event -> doClose()); closeButton.setOnAction(event -> doClose());