Autopsy  3.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;
42 
46 class KeywordSearchFilterNode extends FilterNode {
47 
48  KeywordSearchFilterNode(HighlightedTextMarkup 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 
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-2015 Basis Technology. Generated on: Mon Oct 19 2015
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.