19 package org.sleuthkit.autopsy.directorytree;
21 import java.awt.event.ActionEvent;
22 import java.beans.PropertyVetoException;
23 import java.util.ArrayList;
24 import java.util.Collection;
25 import java.util.HashSet;
26 import java.util.List;
27 import java.util.logging.Level;
28 import java.util.prefs.PreferenceChangeEvent;
29 import java.util.prefs.PreferenceChangeListener;
30 import javax.swing.AbstractAction;
31 import javax.swing.Action;
32 import org.openide.explorer.ExplorerManager;
33 import org.openide.nodes.AbstractNode;
34 import org.openide.nodes.FilterNode;
35 import org.openide.nodes.Node;
36 import org.openide.nodes.Sheet;
37 import org.openide.util.NbBundle;
38 import org.openide.util.Utilities;
92 public void preferenceChange(PreferenceChangeEvent evt) {
93 switch (evt.getKey()) {
159 List<Action> actions =
new ArrayList<>();
162 List<Action> accept = originalNode.
accept(getActionsDIV);
163 if (accept != null) {
164 actions.addAll(accept);
168 return actions.toArray(
new Action[actions.size()]);
179 final Node original = this.getOriginal();
185 final DisplayableItemNode originalNode = (DisplayableItemNode) this.getOriginal();
186 return originalNode.
accept(getPreferredActionsDIV);
191 Node.PropertySet[] propertySets = super.getPropertySets();
193 for (
int i = 0; i < propertySets.length; i++) {
194 Node.PropertySet ps = propertySets[i];
196 if (ps.getName().equals(Sheet.PROPERTIES)) {
197 Sheet.Set newPs =
new Sheet.Set();
198 newPs.setName(ps.getName());
199 newPs.setDisplayName(ps.getDisplayName());
200 newPs.setShortDescription(ps.getShortDescription());
202 newPs.put(ps.getProperties());
206 propertySets[i] = newPs;
234 return ((DisplayableItemNode) getOriginal()).getChildNodeSelectionInfo();
257 switch (SelectionContext.getSelectionContext(arg)) {
283 AbstractFile file = key.getLookup().lookup(AbstractFile.class);
285 if (filterKnown && (file.getKnown() == TskData.FileKnown.KNOWN)) {
289 if (filterSlack && file.getType().equals(TskData.TSK_DB_FILES_TYPE_ENUM.SLACK)) {
298 @NbBundle.Messages(
"DataResultFilterNode.viewSourceArtifact.text=View Source Result")
312 List<Action> actionsList =
new ArrayList<>();
318 BlackboardArtifact ba = ban.getLookup().lookup(BlackboardArtifact.class);
319 final int artifactTypeID = ba.getArtifactTypeID();
321 if (artifactTypeID == BlackboardArtifact.ARTIFACT_TYPE.TSK_HASHSET_HIT.getTypeID()
322 || artifactTypeID == BlackboardArtifact.ARTIFACT_TYPE.TSK_KEYWORD_HIT.getTypeID()) {
324 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.viewFileInDir.text"), ban));
325 }
else if (artifactTypeID == BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_ARTIFACT_HIT.getTypeID()) {
327 actionsList.add(
new ViewSourceArtifactAction(DataResultFilterNode_viewSourceArtifact_text(), ba));
330 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.viewSrcFileInDir.text"), ban));
337 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.viewFileInDir.text"), c));
341 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.viewSrcFileInDir.text"), ban));
343 Content c = ban.getLookup().lookup(File.class);
345 boolean md5Action =
false;
349 }
else if ((c = ban.getLookup().lookup(Directory.class)) != null) {
351 }
else if ((c = ban.getLookup().lookup(VirtualDirectory.class)) != null) {
353 }
else if ((c = ban.getLookup().lookup(LayoutFile.class)) != null) {
355 }
else if ((c = ban.getLookup().lookup(LocalFile.class)) != null
356 || (c = ban.getLookup().lookup(DerivedFile.class)) != null) {
358 }
else if ((c = ban.getLookup().lookup(SlackFile.class)) != null) {
362 actionsList.add(null);
364 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.viewInNewWin.text"), n));
366 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.openInExtViewer.text"), n));
367 actionsList.add(null);
371 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.searchFilesSameMd5.text"), n));
373 actionsList.add(null);
377 final Collection<AbstractFile> selectedFilesList
378 =
new HashSet<>(Utilities.actionsGlobalContext().lookupAll(AbstractFile.class));
379 if (selectedFilesList.size() == 1) {
385 actionsList.add(null);
389 final Collection<BlackboardArtifact> selectedArtifactsList
390 =
new HashSet<>(Utilities.actionsGlobalContext().lookupAll(BlackboardArtifact.class));
391 if (selectedArtifactsList.size() == 1) {
416 List<Action> actions =
new ArrayList<>();
418 for (Action action : ditem.getActions(
true)) {
426 BlackboardArtifact art = ba.getLookup().lookup(BlackboardArtifact.class);
429 for (BlackboardAttribute attr : art.getAttributes()) {
430 if (attr.getAttributeType().getTypeID() == BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PATH_ID.getTypeID()) {
431 switch (attr.getAttributeType().getValueType()) {
433 int i = attr.getValueInt();
435 c = art.getSleuthkitCase().getContentById(i);
439 long l = attr.getValueLong();
441 c = art.getSleuthkitCase().getContentById(l);
447 }
catch (TskException ex) {
448 Logger.
getLogger(this.getClass().getName()).log(Level.WARNING,
"Error getting linked file", ex);
463 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.viewInDir.text"), ban);
479 if (fn.hasContentChildren()) {
488 if (dfn.hasContentChildren()) {
497 return reportNode.getPreferredAction();
518 private AbstractAction
openChild(
final AbstractNode dataModelNode) {
524 final Node currentSelectionInDirectoryTree = sourceEm.getSelectedNodes()[0];
526 return new AbstractAction() {
528 public void actionPerformed(ActionEvent e) {
529 if (currentSelectionInDirectoryTree != null) {
531 final org.openide.nodes.Children children = currentSelectionInDirectoryTree.getChildren();
533 Node newSelection = children.findChild(dataModelNode.getName());
542 if (newSelection != null) {
544 sourceEm.setExploredContextAndSelection(newSelection,
new Node[]{newSelection});
545 }
catch (PropertyVetoException ex) {
547 logger.log(Level.WARNING,
"Error: can't open the selected directory.", ex);
565 Node[] selectedFilterNodes = sourceEm.getSelectedNodes();
566 Node selectedFilterNode = selectedFilterNodes[0];
567 final Node parentNode = selectedFilterNode.getParentNode();
569 return new AbstractAction() {
571 public void actionPerformed(ActionEvent e) {
573 sourceEm.setSelectedNodes(
new Node[]{parentNode});
574 }
catch (PropertyVetoException ex) {
576 logger.log(Level.WARNING,
"Error: can't open the parent directory.", ex);
AbstractAction openChild(final AbstractNode dataModelNode)
AbstractAction defaultVisit(DisplayableItemNode c)
AbstractAction visit(BlackboardArtifactNode ban)
static final String DOTDIR
static final String HIDE_SLACK_FILES_IN_VIEWS_TREE
static final String HIDE_KNOWN_FILES_IN_VIEWS_TREE
static boolean filterKnownFromDataSources
abstract< T > T accept(DisplayableItemNodeVisitor< T > visitor)
DataResultFilterNode(Node node, ExplorerManager em)
NodeSelectionInfo getChildNodeSelectionInfo()
Node.PropertySet[] getPropertySets()
static boolean hideSlackFilesInDataSourcesTree()
static final String DOTDOTDIR
static final DisplayableItemNodeVisitor< List< Action > > getActionsDIV
static synchronized AddBlackboardArtifactTagAction getInstance()
DataResultFilterChildren(Node arg, ExplorerManager sourceEm)
static synchronized DeleteFileBlackboardArtifactTagAction getInstance()
DataResultFilterChildren(Node arg, ExplorerManager sourceEm, boolean filterKnown, boolean filterSlack)
AbstractAction visit(Reports.ReportNode reportNode)
static boolean filterKnownFromViews
static boolean hideKnownFilesInViewsTree()
static final String HIDE_KNOWN_FILES_IN_DATA_SRCS_TREE
Action[] getActions(boolean context)
void setChildNodeSelectionInfo(NodeSelectionInfo selectedChildNodeInfo)
static boolean filterSlackFromViews
AbstractAction visit(LocalFileNode dfn)
static synchronized DeleteFileContentTagAction getInstance()
static final String HIDE_PARENT
Action getPreferredAction()
final ExplorerManager sourceEm
AbstractAction openParent(AbstractNode node)
final DisplayableItemNodeVisitor< AbstractAction > getPreferredActionsDIV
Action[] getActions(boolean popup)
static boolean hideSlackFilesInViewsTree()
static final String HIDE_SLACK_FILES_IN_DATA_SRCS_TREE
AbstractAction visit(FileTypesNode fileTypes)
static boolean hideKnownFilesInDataSourcesTree()
AbstractAction visit(FileNode fn)
synchronized static Logger getLogger(String name)
static void addChangeListener(PreferenceChangeListener listener)
static final Logger LOGGER
AbstractAction visit(DirectoryNode dn)
static boolean filterSlackFromDataSources
Node[] createNodes(Node key)
static synchronized AddContentTagAction getInstance()
final ExplorerManager sourceEm
DataResultFilterNode(Node node, ExplorerManager em, boolean filterKnown, boolean filterSlack)