add icons to wallet context menu items where they appear as action buttons

This commit is contained in:
Craig Raw 2021-04-30 13:19:53 +02:00
parent 45a9093055
commit 45f6ae214a
3 changed files with 127 additions and 50 deletions

View file

@ -72,9 +72,7 @@ public class EntryCell extends TreeTableCell<Entry, Entry> {
HBox actionBox = new HBox(); HBox actionBox = new HBox();
Button viewTransactionButton = new Button(""); Button viewTransactionButton = new Button("");
Glyph searchGlyph = new Glyph(FontAwesome5.FONT_NAME, FontAwesome5.Glyph.SEARCH); viewTransactionButton.setGraphic(getViewTransactionGlyph());
searchGlyph.setFontSize(12);
viewTransactionButton.setGraphic(searchGlyph);
viewTransactionButton.setOnAction(event -> { viewTransactionButton.setOnAction(event -> {
EventManager.get().post(new ViewTransactionEvent(this.getScene().getWindow(), transactionEntry.getBlockTransaction())); EventManager.get().post(new ViewTransactionEvent(this.getScene().getWindow(), transactionEntry.getBlockTransaction()));
}); });
@ -83,9 +81,7 @@ public class EntryCell extends TreeTableCell<Entry, Entry> {
BlockTransaction blockTransaction = transactionEntry.getBlockTransaction(); BlockTransaction blockTransaction = transactionEntry.getBlockTransaction();
if(blockTransaction.getHeight() <= 0 && blockTransaction.getTransaction().isReplaceByFee() && transactionEntry.getWallet().allInputsFromWallet(blockTransaction.getHash())) { if(blockTransaction.getHeight() <= 0 && blockTransaction.getTransaction().isReplaceByFee() && transactionEntry.getWallet().allInputsFromWallet(blockTransaction.getHash())) {
Button increaseFeeButton = new Button(""); Button increaseFeeButton = new Button("");
Glyph increaseFeeGlyph = new Glyph(FontAwesome5.FONT_NAME, FontAwesome5.Glyph.HAND_HOLDING_MEDICAL); increaseFeeButton.setGraphic(getIncreaseFeeRBFGlyph());
increaseFeeGlyph.setFontSize(12);
increaseFeeButton.setGraphic(increaseFeeGlyph);
increaseFeeButton.setOnAction(event -> { increaseFeeButton.setOnAction(event -> {
increaseFee(transactionEntry); increaseFee(transactionEntry);
}); });
@ -94,9 +90,7 @@ public class EntryCell extends TreeTableCell<Entry, Entry> {
if(blockTransaction.getHeight() <= 0 && containsWalletOutputs(transactionEntry)) { if(blockTransaction.getHeight() <= 0 && containsWalletOutputs(transactionEntry)) {
Button cpfpButton = new Button(""); Button cpfpButton = new Button("");
Glyph cpfpGlyph = new Glyph(FontAwesome5.FONT_NAME, FontAwesome5.Glyph.SIGN_OUT_ALT); cpfpButton.setGraphic(getIncreaseFeeCPFPGlyph());
cpfpGlyph.setFontSize(12);
cpfpButton.setGraphic(cpfpGlyph);
cpfpButton.setOnAction(event -> { cpfpButton.setOnAction(event -> {
createCpfp(transactionEntry); createCpfp(transactionEntry);
}); });
@ -116,9 +110,7 @@ public class EntryCell extends TreeTableCell<Entry, Entry> {
HBox actionBox = new HBox(); HBox actionBox = new HBox();
Button receiveButton = new Button(""); Button receiveButton = new Button("");
Glyph receiveGlyph = new Glyph("FontAwesome", FontAwesome.Glyph.ARROW_DOWN); receiveButton.setGraphic(getReceiveGlyph());
receiveGlyph.setFontSize(12);
receiveButton.setGraphic(receiveGlyph);
receiveButton.setOnAction(event -> { receiveButton.setOnAction(event -> {
EventManager.get().post(new ReceiveActionEvent(nodeEntry)); EventManager.get().post(new ReceiveActionEvent(nodeEntry));
Platform.runLater(() -> EventManager.get().post(new ReceiveToEvent(nodeEntry))); Platform.runLater(() -> EventManager.get().post(new ReceiveToEvent(nodeEntry)));
@ -128,9 +120,7 @@ public class EntryCell extends TreeTableCell<Entry, Entry> {
if(nodeEntry.getWallet().getKeystores().size() == 1 && if(nodeEntry.getWallet().getKeystores().size() == 1 &&
(nodeEntry.getWallet().getKeystores().get(0).hasPrivateKey() || nodeEntry.getWallet().getKeystores().get(0).getSource() == KeystoreSource.HW_USB)) { (nodeEntry.getWallet().getKeystores().get(0).hasPrivateKey() || nodeEntry.getWallet().getKeystores().get(0).getSource() == KeystoreSource.HW_USB)) {
Button signMessageButton = new Button(""); Button signMessageButton = new Button("");
Glyph signMessageGlyph = new Glyph(FontAwesome5.FONT_NAME, FontAwesome5.Glyph.PEN_FANCY); signMessageButton.setGraphic(getSignMessageGlyph());
signMessageGlyph.setFontSize(12);
signMessageButton.setGraphic(signMessageGlyph);
signMessageButton.setOnAction(event -> { signMessageButton.setOnAction(event -> {
MessageSignDialog messageSignDialog = new MessageSignDialog(nodeEntry.getWallet(), nodeEntry.getNode()); MessageSignDialog messageSignDialog = new MessageSignDialog(nodeEntry.getWallet(), nodeEntry.getNode());
messageSignDialog.showAndWait(); messageSignDialog.showAndWait();
@ -150,9 +140,7 @@ public class EntryCell extends TreeTableCell<Entry, Entry> {
HBox actionBox = new HBox(); HBox actionBox = new HBox();
Button viewTransactionButton = new Button(""); Button viewTransactionButton = new Button("");
Glyph searchGlyph = new Glyph(FontAwesome5.FONT_NAME, FontAwesome5.Glyph.SEARCH); viewTransactionButton.setGraphic(getViewTransactionGlyph());
searchGlyph.setFontSize(12);
viewTransactionButton.setGraphic(searchGlyph);
viewTransactionButton.setOnAction(event -> { viewTransactionButton.setOnAction(event -> {
EventManager.get().post(new ViewTransactionEvent(this.getScene().getWindow(), hashIndexEntry.getBlockTransaction(), hashIndexEntry)); EventManager.get().post(new ViewTransactionEvent(this.getScene().getWindow(), hashIndexEntry.getBlockTransaction(), hashIndexEntry));
}); });
@ -160,9 +148,7 @@ public class EntryCell extends TreeTableCell<Entry, Entry> {
if(hashIndexEntry.getType().equals(HashIndexEntry.Type.OUTPUT) && hashIndexEntry.isSpendable() && !hashIndexEntry.getHashIndex().isSpent()) { if(hashIndexEntry.getType().equals(HashIndexEntry.Type.OUTPUT) && hashIndexEntry.isSpendable() && !hashIndexEntry.getHashIndex().isSpent()) {
Button spendUtxoButton = new Button(""); Button spendUtxoButton = new Button("");
Glyph sendGlyph = new Glyph("FontAwesome", FontAwesome.Glyph.SEND); spendUtxoButton.setGraphic(getSendGlyph());
sendGlyph.setFontSize(12);
spendUtxoButton.setGraphic(sendGlyph);
spendUtxoButton.setOnAction(event -> { spendUtxoButton.setOnAction(event -> {
sendSelectedUtxos(getTreeTableView(), hashIndexEntry); sendSelectedUtxos(getTreeTableView(), hashIndexEntry);
}); });
@ -314,21 +300,74 @@ public class EntryCell extends TreeTableCell<Entry, Entry> {
EventManager.get().post(new WalletUtxoStatusChangedEvent(hashIndexEntry.getWallet(), hashIndexEntry.getHashIndex())); EventManager.get().post(new WalletUtxoStatusChangedEvent(hashIndexEntry.getWallet(), hashIndexEntry.getHashIndex()));
} }
private static Glyph getViewTransactionGlyph() {
Glyph searchGlyph = new Glyph(FontAwesome5.FONT_NAME, FontAwesome5.Glyph.SEARCH);
searchGlyph.setFontSize(12);
return searchGlyph;
}
private static Glyph getIncreaseFeeRBFGlyph() {
Glyph increaseFeeGlyph = new Glyph(FontAwesome5.FONT_NAME, FontAwesome5.Glyph.HAND_HOLDING_MEDICAL);
increaseFeeGlyph.setFontSize(12);
return increaseFeeGlyph;
}
private static Glyph getIncreaseFeeCPFPGlyph() {
Glyph cpfpGlyph = new Glyph(FontAwesome5.FONT_NAME, FontAwesome5.Glyph.SIGN_OUT_ALT);
cpfpGlyph.setFontSize(12);
return cpfpGlyph;
}
private static Glyph getReceiveGlyph() {
Glyph receiveGlyph = new Glyph("FontAwesome", FontAwesome.Glyph.ARROW_DOWN);
receiveGlyph.setFontSize(12);
return receiveGlyph;
}
private static Glyph getSignMessageGlyph() {
Glyph signMessageGlyph = new Glyph(FontAwesome5.FONT_NAME, FontAwesome5.Glyph.PEN_FANCY);
signMessageGlyph.setFontSize(12);
return signMessageGlyph;
}
private static Glyph getSendGlyph() {
Glyph sendGlyph = new Glyph("FontAwesome", FontAwesome.Glyph.SEND);
sendGlyph.setFontSize(12);
return sendGlyph;
}
private static Glyph getCopyGlyph() {
Glyph copyGlyph = new Glyph(FontAwesome5.FONT_NAME, FontAwesome5.Glyph.COPY);
copyGlyph.setFontSize(12);
return copyGlyph;
}
private static Glyph getFreezeGlyph() {
Glyph copyGlyph = new Glyph(FontAwesome5.FONT_NAME, FontAwesome5.Glyph.SNOWFLAKE);
copyGlyph.setFontSize(12);
return copyGlyph;
}
private static Glyph getUnfreezeGlyph() {
Glyph copyGlyph = new Glyph(FontAwesome5.FONT_NAME, FontAwesome5.Glyph.SUN);
copyGlyph.setFontSize(12);
return copyGlyph;
}
private static class UnconfirmedTransactionContextMenu extends ContextMenu { private static class UnconfirmedTransactionContextMenu extends ContextMenu {
public UnconfirmedTransactionContextMenu(TransactionEntry transactionEntry) { public UnconfirmedTransactionContextMenu(TransactionEntry transactionEntry) {
BlockTransaction blockTransaction = transactionEntry.getBlockTransaction(); BlockTransaction blockTransaction = transactionEntry.getBlockTransaction();
MenuItem copyTxid = new MenuItem("Copy Transaction ID"); MenuItem viewTransaction = new MenuItem("View Transaction");
copyTxid.setOnAction(AE -> { viewTransaction.setGraphic(getViewTransactionGlyph());
viewTransaction.setOnAction(AE -> {
hide(); hide();
ClipboardContent content = new ClipboardContent(); EventManager.get().post(new ViewTransactionEvent(this.getOwnerWindow(), blockTransaction));
content.putString(blockTransaction.getHashAsString());
Clipboard.getSystemClipboard().setContent(content);
}); });
getItems().add(viewTransaction);
getItems().add(copyTxid);
if(blockTransaction.getTransaction().isReplaceByFee() && transactionEntry.getWallet().allInputsFromWallet(blockTransaction.getHash())) { if(blockTransaction.getTransaction().isReplaceByFee() && transactionEntry.getWallet().allInputsFromWallet(blockTransaction.getHash())) {
MenuItem increaseFee = new MenuItem("Increase Fee (RBF)"); MenuItem increaseFee = new MenuItem("Increase Fee (RBF)");
increaseFee.setGraphic(getIncreaseFeeRBFGlyph());
increaseFee.setOnAction(AE -> { increaseFee.setOnAction(AE -> {
hide(); hide();
increaseFee(transactionEntry); increaseFee(transactionEntry);
@ -339,6 +378,7 @@ public class EntryCell extends TreeTableCell<Entry, Entry> {
if(containsWalletOutputs(transactionEntry)) { if(containsWalletOutputs(transactionEntry)) {
MenuItem createCpfp = new MenuItem("Increase Effective Fee (CPFP)"); MenuItem createCpfp = new MenuItem("Increase Effective Fee (CPFP)");
createCpfp.setGraphic(getIncreaseFeeCPFPGlyph());
createCpfp.setOnAction(AE -> { createCpfp.setOnAction(AE -> {
hide(); hide();
createCpfp(transactionEntry); createCpfp(transactionEntry);
@ -346,11 +386,28 @@ public class EntryCell extends TreeTableCell<Entry, Entry> {
getItems().add(createCpfp); getItems().add(createCpfp);
} }
MenuItem copyTxid = new MenuItem("Copy Transaction ID");
copyTxid.setOnAction(AE -> {
hide();
ClipboardContent content = new ClipboardContent();
content.putString(blockTransaction.getHashAsString());
Clipboard.getSystemClipboard().setContent(content);
});
getItems().add(copyTxid);
} }
} }
private static class TransactionContextMenu extends ContextMenu { private static class TransactionContextMenu extends ContextMenu {
public TransactionContextMenu(String date, BlockTransaction blockTransaction) { public TransactionContextMenu(String date, BlockTransaction blockTransaction) {
MenuItem viewTransaction = new MenuItem("View Transaction");
viewTransaction.setGraphic(getViewTransactionGlyph());
viewTransaction.setOnAction(AE -> {
hide();
EventManager.get().post(new ViewTransactionEvent(this.getOwnerWindow(), blockTransaction));
});
MenuItem copyDate = new MenuItem("Copy Date"); MenuItem copyDate = new MenuItem("Copy Date");
copyDate.setOnAction(AE -> { copyDate.setOnAction(AE -> {
hide(); hide();
@ -375,12 +432,32 @@ public class EntryCell extends TreeTableCell<Entry, Entry> {
Clipboard.getSystemClipboard().setContent(content); Clipboard.getSystemClipboard().setContent(content);
}); });
getItems().addAll(copyDate, copyTxid, copyHeight); getItems().addAll(viewTransaction, copyDate, copyTxid, copyHeight);
} }
} }
public static class AddressContextMenu extends ContextMenu { public static class AddressContextMenu extends ContextMenu {
public AddressContextMenu(Address address, String outputDescriptor, NodeEntry nodeEntry) { public AddressContextMenu(Address address, String outputDescriptor, NodeEntry nodeEntry) {
MenuItem receiveToAddress = new MenuItem("Receive To");
receiveToAddress.setGraphic(getReceiveGlyph());
receiveToAddress.setOnAction(event -> {
hide();
EventManager.get().post(new ReceiveActionEvent(nodeEntry));
Platform.runLater(() -> EventManager.get().post(new ReceiveToEvent(nodeEntry)));
});
getItems().add(receiveToAddress);
if(nodeEntry != null) {
MenuItem signVerifyMessage = new MenuItem("Sign/Verify Message");
signVerifyMessage.setGraphic(getSignMessageGlyph());
signVerifyMessage.setOnAction(AE -> {
hide();
MessageSignDialog messageSignDialog = new MessageSignDialog(nodeEntry.getWallet(), nodeEntry.getNode());
messageSignDialog.showAndWait();
});
getItems().add(signVerifyMessage);
}
MenuItem copyAddress = new MenuItem("Copy Address"); MenuItem copyAddress = new MenuItem("Copy Address");
copyAddress.setOnAction(AE -> { copyAddress.setOnAction(AE -> {
hide(); hide();
@ -406,34 +483,22 @@ public class EntryCell extends TreeTableCell<Entry, Entry> {
}); });
getItems().addAll(copyAddress, copyHex, copyOutputDescriptor); getItems().addAll(copyAddress, copyHex, copyOutputDescriptor);
if(nodeEntry != null) {
MenuItem signVerifyMessage = new MenuItem("Sign/Verify Message");
signVerifyMessage.setOnAction(AE -> {
hide();
MessageSignDialog messageSignDialog = new MessageSignDialog(nodeEntry.getWallet(), nodeEntry.getNode());
messageSignDialog.showAndWait();
});
getItems().add(signVerifyMessage);
}
} }
} }
private static class HashIndexEntryContextMenu extends ContextMenu { private static class HashIndexEntryContextMenu extends ContextMenu {
public HashIndexEntryContextMenu(TreeTableView<Entry> treeTableView, HashIndexEntry hashIndexEntry) { public HashIndexEntryContextMenu(TreeTableView<Entry> treeTableView, HashIndexEntry hashIndexEntry) {
String label = "Copy " + (hashIndexEntry.getType().equals(HashIndexEntry.Type.OUTPUT) ? "Transaction Output" : "Transaction Input"); MenuItem viewTransaction = new MenuItem("View Transaction");
MenuItem copyHashIndex = new MenuItem(label); viewTransaction.setGraphic(getViewTransactionGlyph());
copyHashIndex.setOnAction(AE -> { viewTransaction.setOnAction(AE -> {
hide(); hide();
ClipboardContent content = new ClipboardContent(); EventManager.get().post(new ViewTransactionEvent(this.getOwnerWindow(), hashIndexEntry.getBlockTransaction()));
content.putString(hashIndexEntry.getHashIndex().toString());
Clipboard.getSystemClipboard().setContent(content);
}); });
getItems().add(copyHashIndex); getItems().add(viewTransaction);
if(hashIndexEntry.getType().equals(HashIndexEntry.Type.OUTPUT) && hashIndexEntry.isSpendable() && !hashIndexEntry.getHashIndex().isSpent()) { if(hashIndexEntry.getType().equals(HashIndexEntry.Type.OUTPUT) && hashIndexEntry.isSpendable() && !hashIndexEntry.getHashIndex().isSpent()) {
MenuItem sendSelected = new MenuItem("Send Selected"); MenuItem sendSelected = new MenuItem("Send Selected");
sendSelected.setGraphic(getSendGlyph());
sendSelected.setOnAction(AE -> { sendSelected.setOnAction(AE -> {
hide(); hide();
sendSelectedUtxos(treeTableView, hashIndexEntry); sendSelectedUtxos(treeTableView, hashIndexEntry);
@ -444,6 +509,7 @@ public class EntryCell extends TreeTableCell<Entry, Entry> {
if(hashIndexEntry.getType().equals(HashIndexEntry.Type.OUTPUT) && !hashIndexEntry.getHashIndex().isSpent()) { if(hashIndexEntry.getType().equals(HashIndexEntry.Type.OUTPUT) && !hashIndexEntry.getHashIndex().isSpent()) {
if(hashIndexEntry.getHashIndex().getStatus() == null || hashIndexEntry.getHashIndex().getStatus() != Status.FROZEN) { if(hashIndexEntry.getHashIndex().getStatus() == null || hashIndexEntry.getHashIndex().getStatus() != Status.FROZEN) {
MenuItem freezeUtxo = new MenuItem("Freeze UTXO"); MenuItem freezeUtxo = new MenuItem("Freeze UTXO");
freezeUtxo.setGraphic(getFreezeGlyph());
freezeUtxo.setOnAction(AE -> { freezeUtxo.setOnAction(AE -> {
hide(); hide();
freezeUtxo(hashIndexEntry); freezeUtxo(hashIndexEntry);
@ -451,6 +517,7 @@ public class EntryCell extends TreeTableCell<Entry, Entry> {
getItems().add(freezeUtxo); getItems().add(freezeUtxo);
} else { } else {
MenuItem unfreezeUtxo = new MenuItem("Unfreeze UTXO"); MenuItem unfreezeUtxo = new MenuItem("Unfreeze UTXO");
unfreezeUtxo.setGraphic(getUnfreezeGlyph());
unfreezeUtxo.setOnAction(AE -> { unfreezeUtxo.setOnAction(AE -> {
hide(); hide();
unfreezeUtxo(hashIndexEntry); unfreezeUtxo(hashIndexEntry);
@ -458,6 +525,16 @@ public class EntryCell extends TreeTableCell<Entry, Entry> {
getItems().add(unfreezeUtxo); getItems().add(unfreezeUtxo);
} }
} }
String label = "Copy " + (hashIndexEntry.getType().equals(HashIndexEntry.Type.OUTPUT) ? "Transaction Output" : "Transaction Input");
MenuItem copyHashIndex = new MenuItem(label);
copyHashIndex.setOnAction(AE -> {
hide();
ClipboardContent content = new ClipboardContent();
content.putString(hashIndexEntry.getHashIndex().toString());
Clipboard.getSystemClipboard().setContent(content);
});
getItems().add(copyHashIndex);
} }
} }

View file

@ -24,6 +24,7 @@ public class FontAwesome5 extends GlyphFont {
CHECK_CIRCLE('\uf058'), CHECK_CIRCLE('\uf058'),
CIRCLE('\uf111'), CIRCLE('\uf111'),
COINS('\uf51e'), COINS('\uf51e'),
COPY('\uf0c5'),
EXCHANGE_ALT('\uf362'), EXCHANGE_ALT('\uf362'),
EXCLAMATION_CIRCLE('\uf06a'), EXCLAMATION_CIRCLE('\uf06a'),
EXCLAMATION_TRIANGLE('\uf071'), EXCLAMATION_TRIANGLE('\uf071'),
@ -50,6 +51,8 @@ public class FontAwesome5 extends GlyphFont {
SEARCH('\uf002'), SEARCH('\uf002'),
SIGN_OUT_ALT('\uf2f5'), SIGN_OUT_ALT('\uf2f5'),
SQUARE('\uf0c8'), SQUARE('\uf0c8'),
SNOWFLAKE('\uf2dc'),
SUN('\uf185'),
TIMES_CIRCLE('\uf057'), TIMES_CIRCLE('\uf057'),
TOGGLE_OFF('\uf204'), TOGGLE_OFF('\uf204'),
TOGGLE_ON('\uf205'), TOGGLE_ON('\uf205'),

View file

@ -135,7 +135,6 @@ public class ReceiveController extends WalletFormController implements Initializ
lastUsed.setText("Never"); lastUsed.setText("Never");
lastUsed.setGraphic(getUnusedGlyph()); lastUsed.setGraphic(getUnusedGlyph());
address.getStyleClass().remove("error"); address.getStyleClass().remove("error");
address.setDisable(false);
} else if(!currentOutputs.isEmpty()) { } else if(!currentOutputs.isEmpty()) {
long count = currentOutputs.size(); long count = currentOutputs.size();
BlockTransactionHashIndex lastUsedReference = currentOutputs.stream().skip(count - 1).findFirst().get(); BlockTransactionHashIndex lastUsedReference = currentOutputs.stream().skip(count - 1).findFirst().get();
@ -143,13 +142,11 @@ public class ReceiveController extends WalletFormController implements Initializ
lastUsed.setGraphic(getWarningGlyph()); lastUsed.setGraphic(getWarningGlyph());
if(!address.getStyleClass().contains("error")) { if(!address.getStyleClass().contains("error")) {
address.getStyleClass().add("error"); address.getStyleClass().add("error");
address.setDisable(true);
} }
} else { } else {
lastUsed.setText("Unknown"); lastUsed.setText("Unknown");
lastUsed.setGraphic(getUnknownGlyph()); lastUsed.setGraphic(getUnknownGlyph());
address.getStyleClass().remove("error"); address.getStyleClass().remove("error");
address.setDisable(false);
} }
} }