Add MyProposalListService to CorePers.DataHost

This commit is contained in:
Manfred Karrer 2018-04-30 22:23:22 -05:00
parent c3f2ff29d8
commit ab1bcd3aa0
No known key found for this signature in database
GPG key ID: 401250966A6B2C46
5 changed files with 33 additions and 19 deletions

View file

@ -95,7 +95,7 @@ public abstract class BaseProposalListItem implements BlockListener {
// Public
///////////////////////////////////////////////////////////////////////////////////////////
public void onPhase(DaoPhase.Phase phase) {
public void onPhaseChanged(DaoPhase.Phase phase) {
}
public void cleanup() {
@ -131,7 +131,7 @@ public abstract class BaseProposalListItem implements BlockListener {
daoFacade.addBlockListener(this);
phaseChangeListener = (observable, oldValue, newValue) -> onPhase(newValue);
phaseChangeListener = (observable, oldValue, newValue) -> onPhaseChanged(newValue);
daoFacade.phaseProperty().addListener(phaseChangeListener);
}

View file

@ -37,7 +37,7 @@ import lombok.extern.slf4j.Slf4j;
@EqualsAndHashCode(callSuper = true)
public class ActiveProposalListItem extends ProposalListItem {
@Getter
private AutoTooltipButton actionButton;
private AutoTooltipButton removeButton;
///////////////////////////////////////////////////////////////////////////////////////////
@ -65,20 +65,20 @@ public class ActiveProposalListItem extends ProposalListItem {
imageView.setId("image-remove");
actionButton = new AutoTooltipButton();
actionButton.setMinWidth(70);
actionButton.setText(Res.get("shared.remove"));
actionButton.setGraphic(imageView);
removeButton = new AutoTooltipButton();
removeButton.setMinWidth(70);
removeButton.setText(Res.get("shared.remove"));
removeButton.setGraphic(imageView);
}
@Override
public void onPhase(DaoPhase.Phase phase) {
super.onPhase(phase);
public void onPhaseChanged(DaoPhase.Phase phase) {
super.onPhaseChanged(phase);
actionButton.setDisable(phase != DaoPhase.Phase.PROPOSAL);
removeButton.setDisable(phase != DaoPhase.Phase.PROPOSAL);
final boolean myProposal = daoFacade.isMyProposal(proposal);
actionButton.setVisible(myProposal);
actionButton.setManaged(myProposal);
removeButton.setVisible(myProposal);
removeButton.setManaged(myProposal);
}
}

View file

@ -107,6 +107,21 @@ public class ActiveProposalsView extends ProposalItemsView {
.collect(Collectors.toSet()));
}
@Override
public void onPhaseChanged(DaoPhase.Phase phase) {
super.onPhaseChanged(phase);
if (removeButton != null) {
removeButton.setDisable(phase != DaoPhase.Phase.PROPOSAL);
if (selectedBaseProposalListItem != null && selectedBaseProposalListItem.getProposal() != null) {
final boolean myProposal = daoFacade.isMyProposal(selectedBaseProposalListItem.getProposal());
removeButton.setVisible(myProposal);
removeButton.setManaged(myProposal);
}
}
}
///////////////////////////////////////////////////////////////////////////////////////////
// Handlers
///////////////////////////////////////////////////////////////////////////////////////////
@ -153,14 +168,14 @@ public class ActiveProposalsView extends ProposalItemsView {
if (item != null && !empty) {
ActiveProposalListItem activeProposalListItem = (ActiveProposalListItem) item;
if (button == null) {
button = activeProposalListItem.getActionButton();
button = activeProposalListItem.getRemoveButton();
button.setOnAction(e -> {
ActiveProposalsView.this.selectedBaseProposalListItem = item;
ActiveProposalsView.this.onRemove();
});
setGraphic(button);
}
activeProposalListItem.onPhase(currentPhase);
activeProposalListItem.onPhaseChanged(currentPhase);
} else {
setGraphic(null);
if (button != null) {

View file

@ -69,8 +69,8 @@ public class ActiveBallotListItem extends BaseProposalListItem {
}
@Override
public void onPhase(DaoPhase.Phase phase) {
super.onPhase(phase);
public void onPhaseChanged(DaoPhase.Phase phase) {
super.onPhaseChanged(phase);
final Vote vote = ballot.getVote();
if (vote != null) {

View file

@ -20,7 +20,6 @@ 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.components.TitledGroupBg;
import bisq.desktop.main.dao.BaseProposalListItem;
import bisq.desktop.main.dao.BaseProposalView;
import bisq.desktop.main.overlays.popups.Popup;
@ -294,7 +293,7 @@ public class ActiveBallotsView extends BaseProposalView implements BsqBalanceLis
///////////////////////////////////////////////////////////////////////////////////////////
private void createVoteView() {
TitledGroupBg titledGroupBg = addTitledGroupBg(root, ++gridRow, 1,
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);
@ -341,7 +340,7 @@ public class ActiveBallotsView extends BaseProposalView implements BsqBalanceLis
imageView = activeBallotListItem.getImageView();
setGraphic(imageView);
}
activeBallotListItem.onPhase(currentPhase);
activeBallotListItem.onPhaseChanged(currentPhase);
} else {
setGraphic(null);
if (imageView != null)