Autopsy  4.12.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
AdHocSearchFilterNode.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2013-2018 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.keywordsearch;
20 
21 import java.util.ArrayList;
22 import java.util.Arrays;
23 import java.util.Collection;
24 import java.util.HashSet;
25 import java.util.List;
26 import javax.swing.Action;
27 import org.openide.nodes.FilterNode;
28 import org.openide.nodes.Node;
29 import org.openide.nodes.Node.Property;
30 import org.openide.nodes.Sheet;
31 import org.openide.util.NbBundle;
32 import org.openide.util.Utilities;
33 import org.openide.util.lookup.ProxyLookup;
41 import org.sleuthkit.datamodel.AbstractFile;
42 import org.sleuthkit.datamodel.Content;
43 import org.sleuthkit.datamodel.ContentVisitor;
44 import org.sleuthkit.datamodel.DerivedFile;
45 import org.sleuthkit.datamodel.Directory;
46 import org.sleuthkit.datamodel.File;
47 import org.sleuthkit.datamodel.LayoutFile;
48 import org.sleuthkit.datamodel.LocalFile;
49 import org.sleuthkit.datamodel.Report;
50 import org.sleuthkit.datamodel.SlackFile;
51 import org.sleuthkit.datamodel.VirtualDirectory;
52 
58 class AdHocSearchFilterNode extends FilterNode {
59 
65  AdHocSearchFilterNode(Node original) {
66  super(original, null, new ProxyLookup(original.getLookup()));
67  }
68 
69  @Override
70  public Node.PropertySet[] getPropertySets() {
71  Node.PropertySet[] propertySets = super.getPropertySets();
72 
73  for (int i = 0; i < propertySets.length; i++) {
74  Node.PropertySet ps = propertySets[i];
75 
76  if (ps.getName().equals(Sheet.PROPERTIES)) {
77  Sheet.Set newPs = new Sheet.Set();
78  newPs.setName(ps.getName());
79  newPs.setDisplayName(ps.getDisplayName());
80  newPs.setShortDescription(ps.getShortDescription());
81 
82  Property<?>[] oldProperties = ps.getProperties();
83 
84  int j = 0;
85  for (Property<?> p : oldProperties) {
86  newPs.put(p);
87  }
88 
89  propertySets[i] = newPs;
90  }
91  }
92 
93  return propertySets;
94  }
95 
104  @Override
105  public Action[] getActions(boolean popup) {
106 
107  List<Action> actions = new ArrayList<>();
108  actions.addAll(Arrays.asList(super.getActions(popup)));
109  Content content = this.getOriginal().getLookup().lookup(Content.class);
110  actions.addAll(content.accept(new GetPopupActionsContentVisitor()));
111 
112  return actions.toArray(new Action[actions.size()]);
113  }
114 
115  private class GetPopupActionsContentVisitor extends ContentVisitor.Default<List<Action>> {
116 
117  @Override
118  public List<Action> visit(Report r) {
119  List<Action> actionsList = new ArrayList<>();
120  actionsList.add(new NewWindowViewAction(NbBundle.getMessage(this.getClass(), "KeywordSearchFilterNode.getFileActions.viewInNewWinActionLbl"), AdHocSearchFilterNode.this));
121 
122  actionsList.addAll(ContextMenuExtensionPoint.getActions());
123  return actionsList;
124  }
125 
126  @Override
127  public List<Action> visit(File f) {
128  return getFileActions();
129  }
130 
131  @Override
132  public List<Action> visit(DerivedFile f) {
133  return getFileActions();
134  }
135 
136  @Override
137  public List<Action> visit(Directory d) {
138  return getFileActions();
139  }
140 
141  @Override
142  public List<Action> visit(LayoutFile lf) {
143  return getFileActions();
144  }
145 
146  @Override
147  public List<Action> visit(LocalFile lf) {
148  return getFileActions();
149  }
150 
151  @Override
152  public List<Action> visit(SlackFile f) {
153  return getFileActions();
154  }
155 
156  @Override
157  public List<Action> visit(VirtualDirectory dir) {
158  return getFileActions();
159  }
160 
161  private List<Action> getFileActions() {
162  List<Action> actionsList = new ArrayList<>();
163  actionsList.add(new NewWindowViewAction(NbBundle.getMessage(this.getClass(), "KeywordSearchFilterNode.getFileActions.viewInNewWinActionLbl"), AdHocSearchFilterNode.this));
164  actionsList.add(new ExternalViewerAction(NbBundle.getMessage(this.getClass(), "KeywordSearchFilterNode.getFileActions.openExternViewActLbl"), getOriginal()));
165  actionsList.add(null);
166  actionsList.add(ExtractAction.getInstance());
167  actionsList.add(ExportCSVAction.getInstance());
168  actionsList.add(null); // creates a menu separator
169  actionsList.add(AddContentTagAction.getInstance());
170 
171  final Collection<AbstractFile> selectedFilesList
172  = new HashSet<>(Utilities.actionsGlobalContext().lookupAll(AbstractFile.class));
173  if (selectedFilesList.size() == 1) {
174  actionsList.add(DeleteFileContentTagAction.getInstance());
175  }
176 
177  actionsList.addAll(ContextMenuExtensionPoint.getActions());
178  return actionsList;
179  }
180 
181  @Override
182  protected List<Action> defaultVisit(Content c) {
183  return getFileActions();
184  }
185  }
186 }
static synchronized ExportCSVAction getInstance()
static synchronized ExtractAction getInstance()
static synchronized DeleteFileContentTagAction getInstance()
static synchronized AddContentTagAction getInstance()

Copyright © 2012-2018 Basis Technology. Generated on: Wed Sep 18 2019
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.