avoid adding block explorer to transaction context menu when configured to none

This commit is contained in:
Craig Raw 2024-03-09 10:24:42 +02:00
parent e1564217ed
commit d1ac5b076e

View file

@ -585,12 +585,14 @@ public class EntryCell extends TreeTableCell<Entry, Entry> implements Confirmati
getItems().add(createCpfp); getItems().add(createCpfp);
} }
if(!Config.get().isBlockExplorerDisabled()) {
MenuItem openBlockExplorer = new MenuItem("Open in Block Explorer"); MenuItem openBlockExplorer = new MenuItem("Open in Block Explorer");
openBlockExplorer.setOnAction(AE -> { openBlockExplorer.setOnAction(AE -> {
hide(); hide();
AppServices.openBlockExplorer(blockTransaction.getHashAsString()); AppServices.openBlockExplorer(blockTransaction.getHashAsString());
}); });
getItems().add(openBlockExplorer); getItems().add(openBlockExplorer);
}
MenuItem copyTxid = new MenuItem("Copy Transaction ID"); MenuItem copyTxid = new MenuItem("Copy Transaction ID");
copyTxid.setOnAction(AE -> { copyTxid.setOnAction(AE -> {
@ -612,12 +614,16 @@ public class EntryCell extends TreeTableCell<Entry, Entry> implements Confirmati
hide(); hide();
EventManager.get().post(new ViewTransactionEvent(this.getOwnerWindow(), blockTransaction)); EventManager.get().post(new ViewTransactionEvent(this.getOwnerWindow(), blockTransaction));
}); });
getItems().add(viewTransaction);
if(!Config.get().isBlockExplorerDisabled()) {
MenuItem openBlockExplorer = new MenuItem("Open in Block Explorer"); MenuItem openBlockExplorer = new MenuItem("Open in Block Explorer");
openBlockExplorer.setOnAction(AE -> { openBlockExplorer.setOnAction(AE -> {
hide(); hide();
AppServices.openBlockExplorer(blockTransaction.getHashAsString()); AppServices.openBlockExplorer(blockTransaction.getHashAsString());
}); });
getItems().add(openBlockExplorer);
}
MenuItem copyDate = new MenuItem("Copy Date"); MenuItem copyDate = new MenuItem("Copy Date");
copyDate.setOnAction(AE -> { copyDate.setOnAction(AE -> {
@ -626,6 +632,7 @@ public class EntryCell extends TreeTableCell<Entry, Entry> implements Confirmati
content.putString(date); content.putString(date);
Clipboard.getSystemClipboard().setContent(content); Clipboard.getSystemClipboard().setContent(content);
}); });
getItems().add(copyDate);
MenuItem copyTxid = new MenuItem("Copy Transaction ID"); MenuItem copyTxid = new MenuItem("Copy Transaction ID");
copyTxid.setOnAction(AE -> { copyTxid.setOnAction(AE -> {
@ -634,6 +641,7 @@ public class EntryCell extends TreeTableCell<Entry, Entry> implements Confirmati
content.putString(blockTransaction.getHashAsString()); content.putString(blockTransaction.getHashAsString());
Clipboard.getSystemClipboard().setContent(content); Clipboard.getSystemClipboard().setContent(content);
}); });
getItems().add(copyTxid);
MenuItem copyHeight = new MenuItem("Copy Block Height"); MenuItem copyHeight = new MenuItem("Copy Block Height");
copyHeight.setOnAction(AE -> { copyHeight.setOnAction(AE -> {
@ -642,8 +650,7 @@ public class EntryCell extends TreeTableCell<Entry, Entry> implements Confirmati
content.putString(blockTransaction.getHeight() > 0 ? Integer.toString(blockTransaction.getHeight()) : "Mempool"); content.putString(blockTransaction.getHeight() > 0 ? Integer.toString(blockTransaction.getHeight()) : "Mempool");
Clipboard.getSystemClipboard().setContent(content); Clipboard.getSystemClipboard().setContent(content);
}); });
getItems().add(copyHeight);
getItems().addAll(viewTransaction, openBlockExplorer, copyDate, copyTxid, copyHeight);
} }
} }