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-2017 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.Sheet;
28 import org.openide.util.NbBundle;
29 import org.openide.util.lookup.Lookups;
30 import org.openide.util.lookup.ProxyLookup;
41 
45 class KeywordSearchFilterNode extends FilterNode {
46 
47  KeywordSearchFilterNode(QueryResults highlights, Node original) {
48  super(original, null, new ProxyLookup(Lookups.singleton(highlights), original.getLookup()));
49  }
50 
51  @Override
52  public Node.PropertySet[] getPropertySets() {
53  Node.PropertySet[] propertySets = super.getPropertySets();
54 
55  for (int i = 0; i < propertySets.length; i++) {
56  Node.PropertySet ps = propertySets[i];
57 
58  if (ps.getName().equals(Sheet.PROPERTIES)) {
59  Sheet.Set newPs = new Sheet.Set();
60  newPs.setName(ps.getName());
61  newPs.setDisplayName(ps.getDisplayName());
62  newPs.setShortDescription(ps.getShortDescription());
63 
64  Property<?>[] oldProperties = ps.getProperties();
65 
66  int j = 0;
67  for (Property<?> p : oldProperties) {
68  newPs.put(p);
69  }
70 
71  propertySets[i] = newPs;
72  }
73  }
74 
75  return propertySets;
76  }
77 
86  @Override
87  public Action[] getActions(boolean popup) {
88 
89  List<Action> actions = new ArrayList<>();
90 
91  Content content = this.getOriginal().getLookup().lookup(Content.class);
92  actions.addAll(content.accept(new GetPopupActionsContentVisitor()));
93 
94  return actions.toArray(new Action[actions.size()]);
95  }
96 
97  private class GetPopupActionsContentVisitor extends ContentVisitor.Default<List<Action>> {
98 
99  @Override
100  public List<Action> visit(File f) {
101  return getFileActions();
102  }
103 
104  @Override
105  public List<Action> visit(DerivedFile f) {
106  return getFileActions();
107  }
108 
109  private List<Action> getFileActions() {
110  List<Action> actions = new ArrayList<>();
111  actions.add(new NewWindowViewAction(NbBundle.getMessage(this.getClass(), "KeywordSearchFilterNode.getFileActions.viewInNewWinActionLbl"), KeywordSearchFilterNode.this));
112  actions.add(new ExternalViewerAction(NbBundle.getMessage(this.getClass(), "KeywordSearchFilterNode.getFileActions.openExternViewActLbl"), getOriginal()));
113  actions.add(null);
114  actions.add(ExtractAction.getInstance());
115  actions.add(new HashSearchAction(NbBundle.getMessage(this.getClass(), "KeywordSearchFilterNode.getFileActions.searchSameMd5"), getOriginal()));
116  actions.add(null); // creates a menu separator
117  actions.add(AddContentTagAction.getInstance());
118  actions.addAll(ContextMenuExtensionPoint.getActions());
119  return actions;
120  }
121 
122  @Override
123  protected List<Action> defaultVisit(Content c) {
124  return new ArrayList<>();
125  }
126  }
127 }
static synchronized ExtractAction getInstance()
static synchronized AddContentTagAction getInstance()

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