Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DAO governance and bond improvements #2595

Merged
merged 3 commits into from
Mar 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions core/src/main/resources/i18n/displayStrings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ shared.actions=Actions
shared.buyerUpperCase=Buyer
shared.sellerUpperCase=Seller
shared.new=NEW
shared.new=NEW
shared.blindVoteTxId=Blind vote transaction ID

####################################################################
# UI views
Expand Down Expand Up @@ -1677,7 +1677,6 @@ dao.proposal.type.short.GENERIC=Generic proposal
# suppress inspection "UnusedProperty"
dao.proposal.type.short.CONFISCATE_BOND=Confiscating a bond


dao.proposal.details=Proposal details
dao.proposal.selectedProposal=Selected proposal
dao.proposal.active.header=Proposals of current cycle
Expand All @@ -1691,7 +1690,6 @@ dao.proposal.myVote.reject=Reject proposal
dao.proposal.myVote.removeMyVote=Ignore proposal
dao.proposal.myVote.merit=Vote weight from earned BSQ
dao.proposal.myVote.stake=Vote weight from stake
dao.proposal.myVote.blindVoteTxId=Blind vote transaction ID
dao.proposal.myVote.revealTxId=Vote reveal transaction ID
dao.proposal.myVote.stake.prompt=Max. available stake for voting: {0}
dao.proposal.votes.header=Set stake for voting and publish your votes
Expand Down
1 change: 1 addition & 0 deletions desktop/src/main/java/bisq/desktop/bisq.css
Original file line number Diff line number Diff line change
Expand Up @@ -952,6 +952,7 @@ textfield */
}

.hyperlink,
.hyperlink.force-underline .text,
.hyperlink:hover,
.hyperlink:visited,
.hyperlink:hover:visited,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ public HyperlinkWithIcon(String text, GlyphIcons icon) {
setIcon(textIcon);
}

public void hideIcon() {
setGraphic(null);
}

private void setIcon(Node icon) {
setGraphic(icon);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,39 +19,48 @@

import bisq.common.UserThread;

import de.jensd.fx.fontawesome.AwesomeIcon;
import de.jensd.fx.glyphs.GlyphIcons;

import org.controlsfx.control.PopOver;

import javafx.scene.Node;
import javafx.scene.control.ContentDisplay;
import javafx.scene.control.Label;
import javafx.scene.text.Text;

import javafx.geometry.Insets;

import java.util.concurrent.TimeUnit;

import static bisq.desktop.util.FormBuilder.getIcon;



import de.jensd.fx.glyphs.GlyphIcons;

public class InfoAutoTooltipLabel extends AutoTooltipLabel {

private Text textIcon;
private Node textIcon;
private Boolean hidePopover;
private PopOver infoPopover;

public InfoAutoTooltipLabel(String text, GlyphIcons icon, ContentDisplay contentDisplay, String info) {
super(text);

textIcon = getIcon(icon);
addIcon(contentDisplay, info, 300);
}

public InfoAutoTooltipLabel(String text, AwesomeIcon icon, ContentDisplay contentDisplay, String info, double width) {
super(text);

textIcon = getIcon(icon);
addIcon(contentDisplay, info, width);
}

private void addIcon(ContentDisplay contentDisplay, String info, double width) {
textIcon.setOpacity(0.4);

textIcon.setOnMouseEntered(e -> {
hidePopover = false;
final Label helpLabel = new Label(info);
helpLabel.setMaxWidth(300);
helpLabel.setMaxWidth(width);
helpLabel.setWrapText(true);
helpLabel.setPadding(new Insets(10));
showInfoPopOver(helpLabel);
Expand All @@ -73,6 +82,7 @@ public InfoAutoTooltipLabel(String text, GlyphIcons icon, ContentDisplay content
setContentDisplay(contentDisplay);
}


private void showInfoPopOver(Node node) {
node.getStyleClass().add("default-text");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import bisq.desktop.common.view.FxmlView;
import bisq.desktop.components.AutoTooltipTableColumn;
import bisq.desktop.components.HyperlinkWithIcon;
import bisq.desktop.components.InfoAutoTooltipLabel;
import bisq.desktop.util.FormBuilder;
import bisq.desktop.util.GUIUtil;

Expand All @@ -35,8 +36,10 @@

import javax.inject.Inject;

import de.jensd.fx.fontawesome.AwesomeIcon;
import de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIcon;

import javafx.scene.control.ContentDisplay;
import javafx.scene.control.TableCell;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
Expand Down Expand Up @@ -253,14 +256,27 @@ public void updateItem(final BondListItem item, boolean empty) {
@Override
public TableCell<BondListItem, BondListItem> call(TableColumn<BondListItem, BondListItem> column) {
return new TableCell<>() {
private InfoAutoTooltipLabel infoTextField;

@Override
public void updateItem(final BondListItem item, boolean empty) {
super.updateItem(item, empty);
if (item != null && !empty) {
setText(item.getBondDetails());
String info = Res.get("shared.id") + ": " + item.getBond().getBondedAsset().getUid();

if (item.getBond() instanceof BondedRole) {
info = item.getBondDetails() + "\n" + info;
}

infoTextField = new InfoAutoTooltipLabel(item.getBondDetails(),
AwesomeIcon.INFO_SIGN,
ContentDisplay.LEFT,
info,
350
);
setGraphic(infoTextField);
} else
setText("");
setGraphic(null);
}
};
}
Expand Down Expand Up @@ -308,6 +324,7 @@ public void updateItem(final BondListItem item, boolean empty) {
hyperlinkWithIcon = new HyperlinkWithIcon(lockupTxId, MaterialDesignIcon.LINK);
hyperlinkWithIcon.setOnAction(event -> GUIUtil.openTxInBsqBlockExplorer(lockupTxId, preferences));
hyperlinkWithIcon.setTooltip(new Tooltip(Res.get("tooltip.openBlockchainForTx", lockupTxId)));
if (item.getLockupDateString().equals("-")) hyperlinkWithIcon.hideIcon();
setGraphic(hyperlinkWithIcon);
} else {
setGraphic(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
import bisq.asset.Asset;

import bisq.common.util.Tuple3;
import bisq.common.util.Utilities;

import org.bitcoinj.core.Coin;

Expand All @@ -87,6 +86,7 @@
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;

import lombok.Getter;
Expand Down Expand Up @@ -141,10 +141,11 @@ public class ProposalDisplay {
private ChangeListener<Param> paramChangeListener;
private ChangeListener<BondedRoleType> requiredBondForRoleListener;
private TitledGroupBg myVoteTitledGroup;
private int titledGroupBgRowSpan;
private VBox linkWithIconContainer, comboBoxValueContainer, myVoteBox, voteResultBox;
private int votingBoxRowSpan;

private Optional<Runnable> navigateHandlerOptional;

public ProposalDisplay(GridPane gridPane,
BsqFormatter bsqFormatter,
DaoFacade daoFacade,
Expand Down Expand Up @@ -179,31 +180,27 @@ public void createAllFields(String title, int gridRowStartIndex, double top, Pro
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();
this.gridRowStartIndex = gridRowStartIndex;
this.gridRow = gridRowStartIndex;
titledGroupBgRowSpan = 5;
int titledGroupBgRowSpan = 5;

switch (proposalType) {
case COMPENSATION_REQUEST:
case REIMBURSEMENT_REQUEST:
case CONFISCATE_BOND:
case REMOVE_ASSET:
break;
case CHANGE_PARAM:
titledGroupBgRowSpan = 6;
break;
case BONDED_ROLE:
titledGroupBgRowSpan = 6;
break;
case CONFISCATE_BOND:
break;
case GENERIC:
titledGroupBgRowSpan = 4;
break;
case REMOVE_ASSET:
break;
}

TitledGroupBg titledGroupBg = addTitledGroupBg(gridPane, gridRow, titledGroupBgRowSpan, title, top);
Expand Down Expand Up @@ -358,16 +355,13 @@ public BondedRoleType fromString(String string) {
confiscateBondComboBox.setConverter(new StringConverter<>() {
@Override
public String toString(Bond bond) {
String bondType;
String bondDetails;
if (bond instanceof BondedRole) {
bondType = Res.get("dao.bond.bondedRoles");
bondDetails = bond.getBondedAsset().getDisplayString();
} else {
bondType = Res.get("dao.bond.bondedReputation");
bondDetails = Utilities.bytesAsHexString(bond.getBondedAsset().getHash());
bondDetails = Res.get("dao.bond.bondedReputation");
}
return bondType + ": " + bondDetails;
return bondDetails + " (" + Res.get("shared.id") + ": " + bond.getBondedAsset().getUid() + ")";
}

@Override
Expand Down Expand Up @@ -414,7 +408,6 @@ public Asset fromString(String string) {

if (isMakeProposalScreen) {
proposalFeeTextField = addTopLabelTextField(gridPane, ++gridRow, Res.get("dao.proposal.display.proposalFee")).second;
//noinspection ConstantConditions
proposalFeeTextField.setText(bsqFormatter.formatCoinWithCode(daoFacade.getProposalFee(daoFacade.getChainHeight())));
}

Expand Down Expand Up @@ -553,10 +546,13 @@ public void applyProposalPayload(Proposal proposal) {
.ifPresent(bond -> {
confiscateBondComboBox.getSelectionModel().select(bond);
comboBoxValueTextField.setText(confiscateBondComboBox.getConverter().toString(bond));
comboBoxValueTextField.setOnMouseClicked(e ->
navigation.navigateToWithData(bond, MainView.class, DaoView.class, BondingView.class,
BondsView.class));
comboBoxValueTextField.getStyleClass().addAll("hyperlink", "show-hand");
comboBoxValueTextField.setOnMouseClicked(e -> {
navigateHandlerOptional.ifPresent(Runnable::run);
navigation.navigateToWithData(bond, MainView.class, DaoView.class, BondingView.class,
BondsView.class);
});

comboBoxValueTextField.getStyleClass().addAll("hyperlink", "force-underline", "show-hand");
});
} else if (proposal instanceof GenericProposal) {
// do nothing
Expand Down Expand Up @@ -651,6 +647,10 @@ public void removeAllFields() {
comboBoxes.clear();
}

public void onNavigate(Runnable navigateHandler) {
this.navigateHandlerOptional = Optional.of(navigateHandler);
}

public int incrementAndGetGridRow() {
return ++gridRow;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ private void createVoteView() {
voteFields.add(stakeInputTextField);

Tuple3<Label, TxIdTextField, VBox> tuple = addTopLabelTxIdTextField(root, ++gridRow,
Res.get("dao.proposal.myVote.blindVoteTxId"), 0);
Res.get("shared.blindVoteTxId"), 0);
blindVoteTxIdTextField = tuple.second;
blindVoteTxIdContainer = tuple.third;
blindVoteTxIdTextField.setBsq(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

import de.jensd.fx.fontawesome.AwesomeIcon;

import java.util.Date;
import java.util.Optional;

import lombok.Getter;
Expand All @@ -48,6 +49,8 @@ public class VoteListItem {
private String blindVoteTxId = "";
@Getter
private String voteRevealTxId = "";
@Getter
private Date blindVoteDate;

VoteListItem(Proposal proposal,
DecryptedBallotsWithMerits decryptedBallotsWithMerits,
Expand All @@ -62,6 +65,7 @@ public class VoteListItem {
merit = decryptedBallotsWithMerits.getMerit(daoStateService);
stake = decryptedBallotsWithMerits.getStake();
blindVoteTxId = decryptedBallotsWithMerits.getBlindVoteTxId();
daoStateService.getTx(blindVoteTxId).ifPresent(tx -> blindVoteDate = new Date(tx.getTime()));
voteRevealTxId = decryptedBallotsWithMerits.getVoteRevealTxId();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ public class VoteResultView extends ActivatableView<GridPane, Void> implements D
private final BsqFormatter bsqFormatter;
private final MyProposalListService myProposalListService;
private final MyBlindVoteListService myBlindVoteListService;
private ProposalResultsWindow proposalResultsWindow;
private final ProposalResultsWindow proposalResultsWindow;

private Button exportButton;

private int gridRow = 0;
Expand Down Expand Up @@ -192,6 +193,8 @@ public void initialize() {
GridPane.setMargin(exportButton, new Insets(10, -10, -50, 0));
GridPane.setColumnSpan(exportButton, 2);
GridPane.setHalignment(exportButton, HPos.RIGHT);

proposalResultsWindow.onClose(() -> proposalsTableView.getSelectionModel().clearSelection());
}

@Override
Expand Down Expand Up @@ -267,7 +270,7 @@ private void onResultsListItemSelected(CycleListItem item) {
item.getResultsOfCycle().getCycle().getHeightOfFirstBlock()))
.forEach(e -> {
sb.append("\n")
.append(Res.getWithCol("dao.proposal.myVote.blindVoteTxId")).append(" ")
.append(Res.getWithCol("shared.blindVoteTxId")).append(" ")
.append(e.getBlindVoteTxId()).append("\n")
.append(Res.getWithCol("dao.results.votes.table.header.stake")).append(" ")
.append(bsqFormatter.formatCoinWithCode(Coin.valueOf(e.getStake()))).append("\n");
Expand Down
Loading