Autopsy  4.10.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;
40 import org.sleuthkit.datamodel.AbstractFile;
41 import org.sleuthkit.datamodel.Content;
42 import org.sleuthkit.datamodel.ContentVisitor;
43 import org.sleuthkit.datamodel.DerivedFile;
44 import org.sleuthkit.datamodel.Directory;
45 import org.sleuthkit.datamodel.File;
46 import org.sleuthkit.datamodel.LayoutFile;
47 import org.sleuthkit.datamodel.LocalFile;
48 import org.sleuthkit.datamodel.Report;
49 import org.sleuthkit.datamodel.SlackFile;
50 import org.sleuthkit.datamodel.VirtualDirectory;
51 
57 class AdHocSearchFilterNode extends FilterNode {
58 
64  AdHocSearchFilterNode(Node original) {
65  super(original, null, new ProxyLookup(original.getLookup()));
66  }
67 
68  @Override
69  public Node.PropertySet[] getPropertySets() {
70  Node.PropertySet[] propertySets = super.getPropertySets();
71 
72  for (int i = 0; i < propertySets.length; i++) {
73  Node.PropertySet ps = propertySets[i];
74 
75  if (ps.getName().equals(Sheet.PROPERTIES)) {
76  Sheet.Set newPs = new Sheet.Set();
77  newPs.setName(ps.getName());
78  newPs.setDisplayName(ps.getDisplayName());
79  newPs.setShortDescription(ps.getShortDescription());
80 
81  Property<?>[] oldProperties = ps.getProperties();
82 
83  int j = 0;
84  for (Property<?> p : oldProperties) {
85  newPs.put(p);
86  }
87 
88  propertySets[i] = newPs;
89  }
90  }
91 
92  return propertySets;
93  }
94 
103  @Override
104  public Action[] getActions(boolean popup) {
105 
106  List<Action> actions = new ArrayList<>();
107  actions.addAll(Arrays.asList(super.getActions(popup)));
108  Content content = this.getOriginal().getLookup().lookup(Content.class);
109  actions.addAll(content.accept(new GetPopupActionsContentVisitor()));
110 
111  return actions.toArray(new Action[actions.size()]);
112  }
113 
114  private class GetPopupActionsContentVisitor extends ContentVisitor.Default<List<Action>> {
115 
116  @Override
117  public List<Action> visit(Report r) {
118  List<Action> actionsList = new ArrayList<>();
119  actionsList.add(new NewWindowViewAction(NbBundle.getMessage(this.getClass(), "KeywordSearchFilterNode.getFileActions.viewInNewWinActionLbl"), AdHocSearchFilterNode.this));
120 
121  actionsList.addAll(ContextMenuExtensionPoint.getActions());
122  return actionsList;
123  }
124 
125  @Override
126  public List<Action> visit(File f) {
127  return getFileActions();
128  }
129 
130  @Override
131  public List<Action> visit(DerivedFile f) {
132  return getFileActions();
133  }
134 
135  @Override
136  public List<Action> visit(Directory d) {
137  return getFileActions();
138  }
139 
140  @Override
141  public List<Action> visit(LayoutFile lf) {
142  return getFileActions();
143  }
144 
145  @Override
146  public List<Action> visit(LocalFile lf) {
147  return getFileActions();
148  }
149 
150  @Override
151  public List<Action> visit(SlackFile f) {
152  return getFileActions();
153  }
154 
155  @Override
156  public List<Action> visit(VirtualDirectory dir) {
157  return getFileActions();
158  }
159 
160  private List<Action> getFileActions() {
161  List<Action> actionsList = new ArrayList<>();
162  actionsList.add(new NewWindowViewAction(NbBundle.getMessage(this.getClass(), "KeywordSearchFilterNode.getFileActions.viewInNewWinActionLbl"), AdHocSearchFilterNode.this));
163  actionsList.add(new ExternalViewerAction(NbBundle.getMessage(this.getClass(), "KeywordSearchFilterNode.getFileActions.openExternViewActLbl"), getOriginal()));
164  actionsList.add(null);
165  actionsList.add(ExtractAction.getInstance());
166  actionsList.add(null); // creates a menu separator
167  actionsList.add(AddContentTagAction.getInstance());
168 
169  final Collection<AbstractFile> selectedFilesList
170  = new HashSet<>(Utilities.actionsGlobalContext().lookupAll(AbstractFile.class));
171  if (selectedFilesList.size() == 1) {
172  actionsList.add(DeleteFileContentTagAction.getInstance());
173  }
174 
175  actionsList.addAll(ContextMenuExtensionPoint.getActions());
176  return actionsList;
177  }
178 
179  @Override
180  protected List<Action> defaultVisit(Content c) {
181  return getFileActions();
182  }
183  }
184 }
static synchronized ExtractAction getInstance()
static synchronized DeleteFileContentTagAction getInstance()
static synchronized AddContentTagAction getInstance()

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