From 22ca11bc17f0fa1f50c1d00e65008468f91f8304 Mon Sep 17 00:00:00 2001
From: Greg DiCristofaro <gregd@basistech.com>
Date: Thu, 30 Sep 2021 19:59:38 -0400
Subject: [PATCH] 8074 improve context menu for ad hoc search

---
 .../keywordsearch/AdHocSearchFilterNode.java  | 20 ++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/AdHocSearchFilterNode.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/AdHocSearchFilterNode.java
index cff13cc16e..fb7731a66c 100644
--- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/AdHocSearchFilterNode.java
+++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/AdHocSearchFilterNode.java
@@ -52,15 +52,15 @@
 
 /**
  * FilterNode containing properties and actions for keyword search.
- * 
+ *
  * Wraps the generic KeyValue node and customizes the property sheet and lookup
  */
 class AdHocSearchFilterNode extends FilterNode {
 
     /**
      * Instantiate a KeywordSearchFilterNode.
-     * 
-     * @param original         The original source node.
+     *
+     * @param original The original source node.
      */
     AdHocSearchFilterNode(Node original) {
         super(original, null, new ProxyLookup(original.getLookup()));
@@ -160,10 +160,20 @@ public List<Action> visit(VirtualDirectory dir) {
 
         private List<Action> getFileActions() {
             List<Action> actionsList = new ArrayList<>();
+            
+            boolean hasAbstractFile = getOriginal().getLookup().lookup(AbstractFile.class) != null;
+            
             actionsList.add(new NewWindowViewAction(NbBundle.getMessage(this.getClass(), "KeywordSearchFilterNode.getFileActions.viewInNewWinActionLbl"), AdHocSearchFilterNode.this));
-            actionsList.add(new ExternalViewerAction(NbBundle.getMessage(this.getClass(), "KeywordSearchFilterNode.getFileActions.openExternViewActLbl"), getOriginal()));
+
+            if (hasAbstractFile) {
+                actionsList.add(new ExternalViewerAction(NbBundle.getMessage(this.getClass(), "KeywordSearchFilterNode.getFileActions.openExternViewActLbl"), getOriginal()));
+            }
+            
             actionsList.add(null);
-            actionsList.add(ExtractAction.getInstance());
+            if (hasAbstractFile) {
+                actionsList.add(ExtractAction.getInstance());
+            }
+            
             actionsList.add(ExportCSVAction.getInstance());
             actionsList.add(null); // creates a menu separator
             actionsList.add(AddContentTagAction.getInstance());
-- 
GitLab