Fix icon handling in vote result table, fix #2141

This commit is contained in:
sqrrm 2018-12-25 22:07:11 +01:00
parent 5cc3c57d52
commit 9fc76a4cfc
No known key found for this signature in database
GPG Key ID: 45235F9EF87089EC

View File

@ -701,21 +701,14 @@ public class VoteResultView extends ActivatableView<GridPane, Void> implements D
public TableCell<ProposalListItem, ProposalListItem> call(TableColumn<ProposalListItem, public TableCell<ProposalListItem, ProposalListItem> call(TableColumn<ProposalListItem,
ProposalListItem> column) { ProposalListItem> column) {
return new TableCell<>() { return new TableCell<>() {
Label myVoteIcon;
@Override @Override
public void updateItem(final ProposalListItem item, boolean empty) { public void updateItem(final ProposalListItem item, boolean empty) {
super.updateItem(item, empty); super.updateItem(item, empty);
if (item != null && !empty) { if (item != null && !empty) {
if (myVoteIcon == null) { setGraphic(item.getMyVoteIcon());
myVoteIcon = item.getMyVoteIcon();
setGraphic(myVoteIcon);
}
} else { } else {
setGraphic(null); setGraphic(null);
if (myVoteIcon != null)
myVoteIcon = null;
} }
} }
}; };
@ -734,21 +727,17 @@ public class VoteResultView extends ActivatableView<GridPane, Void> implements D
public TableCell<ProposalListItem, ProposalListItem> call(TableColumn<ProposalListItem, public TableCell<ProposalListItem, ProposalListItem> call(TableColumn<ProposalListItem,
ProposalListItem> column) { ProposalListItem> column) {
return new TableCell<>() { return new TableCell<>() {
Label icon;
@Override @Override
public void updateItem(final ProposalListItem item, boolean empty) { public void updateItem(final ProposalListItem item, boolean empty) {
super.updateItem(item, empty); super.updateItem(item, empty);
if (item != null && !empty) { if (item != null && !empty) {
icon = new Label(); Label icon = new Label();
AwesomeDude.setIcon(icon, item.getIcon()); AwesomeDude.setIcon(icon, item.getIcon());
icon.getStyleClass().add(item.getColorStyleClass()); icon.getStyleClass().add(item.getColorStyleClass());
setGraphic(icon); setGraphic(icon);
} else { } else {
setGraphic(null); setGraphic(null);
if (icon != null)
icon = null;
} }
} }
}; };