From 2d0a94d0241b4bdb01752fc691716a85a8d946e1 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Tue, 16 Apr 2024 14:34:27 +0200 Subject: [PATCH] add copy context menu to date/address/output column in search wallet dialog --- .../sparrowwallet/sparrow/control/EntryCell.java | 2 +- .../sparrow/control/SearchWalletDialog.java | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/control/EntryCell.java b/src/main/java/com/sparrowwallet/sparrow/control/EntryCell.java index 3a0e526a..98465555 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/EntryCell.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/EntryCell.java @@ -606,7 +606,7 @@ public class EntryCell extends TreeTableCell implements Confirmati } } - private static class TransactionContextMenu extends ContextMenu { + protected static class TransactionContextMenu extends ContextMenu { public TransactionContextMenu(String date, BlockTransaction blockTransaction) { MenuItem viewTransaction = new MenuItem("View Transaction"); viewTransaction.setGraphic(getViewTransactionGlyph()); diff --git a/src/main/java/com/sparrowwallet/sparrow/control/SearchWalletDialog.java b/src/main/java/com/sparrowwallet/sparrow/control/SearchWalletDialog.java index a217eb09..b5719f48 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/SearchWalletDialog.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/SearchWalletDialog.java @@ -48,7 +48,7 @@ public class SearchWalletDialog extends Dialog { dialogPane.getStylesheets().add(AppServices.class.getResource("wallet/wallet.css").toExternalForm()); dialogPane.getStylesheets().add(AppServices.class.getResource("search.css").toExternalForm()); AppServices.setStageIcon(dialogPane.getScene().getWindow()); - dialogPane.setHeaderText(showWallet ? "Search All Wallets" : "Search Wallet"); + dialogPane.setHeaderText(showWallet ? "Search All Wallets" : "Search Wallet " + walletForms.get(0).getMasterWallet().getName()); Image image = new Image("image/sparrow-small.png", 50, 50, false, false); if(!image.isError()) { @@ -265,7 +265,19 @@ public class SearchWalletDialog extends Dialog { @Override protected void updateItem(Entry entry, boolean empty) { super.updateItem(entry, empty); - setContextMenu(null); + + ContextMenu copyMenu; + if(entry instanceof TransactionEntry transactionEntry) { + copyMenu = new TransactionContextMenu(getText(), transactionEntry.getBlockTransaction()); + } else if(entry instanceof NodeEntry nodeEntry) { + copyMenu = new AddressContextMenu(nodeEntry.getAddress(), nodeEntry.getOutputDescriptor(), null, false, null); + } else if(entry instanceof UtxoEntry utxoEntry) { + copyMenu = new HashIndexEntryContextMenu(null, utxoEntry); + } else { + copyMenu = new ContextMenu(); + } + copyMenu.getItems().removeIf(menuItem -> !menuItem.getText().startsWith("Copy")); + setContextMenu(copyMenu); } } }