Autopsy  4.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
KeywordSearchFilterNode.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2013 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.List;
23 import javax.swing.Action;
24 import org.openide.nodes.FilterNode;
25 import org.openide.nodes.Node;
26 import org.openide.nodes.Node.Property;
27 import org.openide.nodes.PropertySupport;
28 import org.openide.nodes.Sheet;
29 import org.openide.util.NbBundle;
30 import org.openide.util.lookup.Lookups;
31 import org.openide.util.lookup.ProxyLookup;
38 import org.sleuthkit.datamodel.Content;
39 import org.sleuthkit.datamodel.ContentVisitor;
40 import org.sleuthkit.datamodel.DerivedFile;
41 import org.sleuthkit.datamodel.File;
42 
46 class KeywordSearchFilterNode extends FilterNode {
47 
48  KeywordSearchFilterNode(HighlightedText highlights, Node original) {
49  super(original, null, new ProxyLookup(Lookups.singleton(highlights), original.getLookup()));
50  }
51 
52  @Override
53  public Node.PropertySet[] getPropertySets() {
54  Node.PropertySet[] propertySets = super.getPropertySets();
55 
56  for (int i = 0; i < propertySets.length; i++) {
57  Node.PropertySet ps = propertySets[i];
58 
59  if (ps.getName().equals(Sheet.PROPERTIES)) {
60  Sheet.Set newPs = new Sheet.Set();
61  newPs.setName(ps.getName());
62  newPs.setDisplayName(ps.getDisplayName());
63  newPs.setShortDescription(ps.getShortDescription());
64 
65  Property<?>[] oldProperties = ps.getProperties();
66 
67  int j = 0;
68  for (Property<?> p : oldProperties) {
69  newPs.put(p);
70  }
71 
72  propertySets[i] = newPs;
73  }
74  }
75 
76  return propertySets;
77  }
78 
87  @Override
88  public Action[] getActions(boolean popup) {
89 
90  List<Action> actions = new ArrayList<>();
91 
92  Content content = this.getOriginal().getLookup().lookup(Content.class);
93  actions.addAll(content.accept(new GetPopupActionsContentVisitor()));
94 
95  return actions.toArray(new Action[actions.size()]);
96  }
97 
98  private class GetPopupActionsContentVisitor extends ContentVisitor.Default<List<Action>> {
99 
100  @Override
101  public List<Action> visit(File f) {
102  return getFileActions();
103  }
104 
105  @Override
106  public List<Action> visit(DerivedFile f) {
107  return getFileActions();
108  }
109 
110  private List<Action> getFileActions() {
111  List<Action> actions = new ArrayList<>();
112  actions.add(new NewWindowViewAction(NbBundle.getMessage(this.getClass(), "KeywordSearchFilterNode.getFileActions.viewInNewWinActionLbl"), KeywordSearchFilterNode.this));
113  actions.add(new ExternalViewerAction(NbBundle.getMessage(this.getClass(), "KeywordSearchFilterNode.getFileActions.openExternViewActLbl"), getOriginal()));
114  actions.add(null);
115  actions.add(ExtractAction.getInstance());
116  actions.add(new HashSearchAction(NbBundle.getMessage(this.getClass(), "KeywordSearchFilterNode.getFileActions.searchSameMd5"), getOriginal()));
117  actions.add(null); // creates a menu separator
118  actions.add(AddContentTagAction.getInstance());
119  actions.addAll(ContextMenuExtensionPoint.getActions());
120  return actions;
121  }
122 
123  @Override
124  protected List<Action> defaultVisit(Content c) {
125  return new ArrayList<>();
126  }
127  }
128 }
static synchronized ExtractAction getInstance()
static synchronized AddContentTagAction getInstance()

Copyright © 2012-2016 Basis Technology. Generated on: Mon Jan 2 2017
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.