19 package org.sleuthkit.autopsy.directorytree;
21 import java.awt.event.ActionEvent;
22 import java.beans.PropertyVetoException;
23 import java.text.MessageFormat;
24 import java.util.ArrayList;
25 import java.util.Collection;
26 import java.util.HashSet;
27 import java.util.List;
28 import java.util.logging.Level;
29 import java.util.prefs.PreferenceChangeEvent;
30 import java.util.prefs.PreferenceChangeListener;
31 import javax.swing.AbstractAction;
32 import javax.swing.Action;
33 import org.openide.explorer.ExplorerManager;
34 import org.openide.nodes.AbstractNode;
35 import org.openide.nodes.FilterNode;
36 import org.openide.nodes.Node;
37 import org.openide.nodes.Sheet;
38 import org.openide.util.NbBundle;
39 import org.openide.util.Utilities;
86 import org.
sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE;
107 public void preferenceChange(PreferenceChangeEvent evt) {
108 switch (evt.getKey()) {
174 List<Action> actions =
new ArrayList<>();
177 List<Action> accept = originalNode.
accept(getActionsDIV);
178 if (accept != null) {
179 actions.addAll(accept);
183 return actions.toArray(
new Action[actions.size()]);
194 final Node original = this.getOriginal();
200 final DisplayableItemNode originalNode = (DisplayableItemNode) this.getOriginal();
201 return originalNode.
accept(getPreferredActionsDIV);
206 Node.PropertySet[] propertySets = super.getPropertySets();
208 for (
int i = 0; i < propertySets.length; i++) {
209 Node.PropertySet ps = propertySets[i];
211 if (ps.getName().equals(Sheet.PROPERTIES)) {
212 Sheet.Set newPs =
new Sheet.Set();
213 newPs.setName(ps.getName());
214 newPs.setDisplayName(ps.getDisplayName());
215 newPs.setShortDescription(ps.getShortDescription());
217 newPs.put(ps.getProperties());
221 propertySets[i] = newPs;
241 final Node orig = getOriginal();
242 String name = orig.getDisplayName();
244 name = ((BlackboardArtifactNode) orig).getSourceName();
270 return ((DisplayableItemNode) getOriginal()).getChildNodeSelectionInfo();
295 this.filterArtifacts =
false;
296 switch (SelectionContext.getSelectionContext(arg)) {
300 filterArtifacts =
true;
323 AbstractFile file = key.getLookup().lookup(AbstractFile.class);
325 if (filterKnown && (file.getKnown() == TskData.FileKnown.KNOWN)) {
329 if (filterSlack && file.getType().equals(TskData.TSK_DB_FILES_TYPE_ENUM.SLACK)) {
336 BlackboardArtifact art = key.getLookup().lookup(BlackboardArtifact.class);
339 && art.getArtifactTypeID() != BlackboardArtifact.ARTIFACT_TYPE.TSK_EMAIL_MSG.getTypeID()
340 && art.getArtifactTypeID() != BlackboardArtifact.ARTIFACT_TYPE.TSK_MESSAGE.getTypeID()) {
349 @NbBundle.Messages(
"DataResultFilterNode.viewSourceArtifact.text=View Source Result")
363 List<Action> actionsList =
new ArrayList<>();
369 BlackboardArtifact ba = ban.getLookup().lookup(BlackboardArtifact.class);
370 final int artifactTypeID = ba.getArtifactTypeID();
372 if (artifactTypeID == BlackboardArtifact.ARTIFACT_TYPE.TSK_HASHSET_HIT.getTypeID()
373 || artifactTypeID == BlackboardArtifact.ARTIFACT_TYPE.TSK_KEYWORD_HIT.getTypeID()) {
374 if (ban.getLookup().lookup(AbstractFile.class) != null) {
378 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.viewFileInDir.text"), ban));
380 }
else if (artifactTypeID == BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_ARTIFACT_HIT.getTypeID()) {
382 actionsList.add(
new ViewSourceArtifactAction(DataResultFilterNode_viewSourceArtifact_text(), ba));
385 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.viewSrcFileInDir.text"), ban));
392 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.viewFileInDir.text"), c));
396 Content fileContent = ban.getLookup().lookup(AbstractFile.class);
397 if (fileContent == null) {
398 Content content = ban.getLookup().lookup(Content.class);
399 actionsList.add(
new ViewContextAction(
"View Source Content in Directory", content));
402 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.viewSrcFileInDir.text"), ban));
405 Content c = ban.getLookup().lookup(File.class);
409 }
else if ((c = ban.getLookup().lookup(Directory.class)) != null) {
411 }
else if ((c = ban.getLookup().lookup(VirtualDirectory.class)) != null) {
413 }
else if ((c = ban.getLookup().lookup(LocalDirectory.class)) != null) {
415 }
else if ((c = ban.getLookup().lookup(LayoutFile.class)) != null) {
417 }
else if ((c = ban.getLookup().lookup(LocalFile.class)) != null
418 || (c = ban.getLookup().lookup(DerivedFile.class)) != null) {
422 if (c.getArtifacts(BlackboardArtifact.ARTIFACT_TYPE.TSK_ENCRYPTION_DETECTED).size() > 0) {
425 }
catch (TskCoreException ex) {
426 LOGGER.log(Level.WARNING,
"Unable to add unzip with password action to context menus", ex);
429 }
else if ((c = ban.getLookup().lookup(SlackFile.class)) != null) {
431 }
else if ((c = ban.getLookup().lookup(Report.class)) != null) {
435 final Collection<AbstractFile> selectedFilesList
436 =
new HashSet<>(Utilities.actionsGlobalContext().lookupAll(AbstractFile.class));
437 actionsList.add(null);
439 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.viewInNewWin.text"), n));
440 if (selectedFilesList.size() == 1) {
442 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.openInExtViewer.text"), n));
446 actionsList.add(null);
448 actionsList.add(null);
452 if (selectedFilesList.size() == 1) {
458 actionsList.add(null);
462 final Collection<BlackboardArtifact> selectedArtifactsList
463 =
new HashSet<>(Utilities.actionsGlobalContext().lookupAll(BlackboardArtifact.class));
464 if (selectedArtifactsList.size() == 1) {
489 List<Action> actions =
new ArrayList<>();
491 for (Action action : ditem.getActions(
true)) {
499 BlackboardArtifact art = ba.getLookup().lookup(BlackboardArtifact.class);
502 for (BlackboardAttribute attr : art.getAttributes()) {
503 if (attr.getAttributeType().getTypeID() == BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PATH_ID.getTypeID()) {
504 switch (attr.getAttributeType().getValueType()) {
506 int i = attr.getValueInt();
508 c = art.getSleuthkitCase().getContentById(i);
512 long l = attr.getValueLong();
514 c = art.getSleuthkitCase().getContentById(l);
520 }
catch (TskException ex) {
521 Logger.
getLogger(this.getClass().getName()).log(Level.WARNING,
"Error getting linked file", ex);
567 if ((artifact.getArtifactTypeID() == ARTIFACT_TYPE.TSK_EMAIL_MSG.getTypeID())
568 || (artifact.getArtifactTypeID() == ARTIFACT_TYPE.TSK_MESSAGE.getTypeID())) {
569 if (artifact.hasChildren()) {
573 }
catch (TskCoreException ex) {
574 LOGGER.log(Level.SEVERE, MessageFormat.format(
"Error getting children from blackboard artifact{0}.", artifact.getArtifactID()), ex);
577 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.viewInDir.text"), ban);
593 if (fn.hasContentChildren()) {
602 if (dfn.hasContentChildren()) {
611 return reportNode.getPreferredAction();
632 private AbstractAction
openChild(
final AbstractNode dataModelNode) {
638 final Node currentSelectionInDirectoryTree = sourceEm.getSelectedNodes()[0];
640 return new AbstractAction() {
642 public void actionPerformed(ActionEvent e) {
643 if (currentSelectionInDirectoryTree != null) {
645 final org.openide.nodes.Children children = currentSelectionInDirectoryTree.getChildren();
647 Node newSelection = children.findChild(dataModelNode.getName());
656 if (newSelection != null) {
658 sourceEm.setExploredContextAndSelection(newSelection,
new Node[]{newSelection});
659 }
catch (PropertyVetoException ex) {
661 logger.log(Level.WARNING,
"Error: can't open the selected directory.", ex);
679 Node[] selectedFilterNodes = sourceEm.getSelectedNodes();
680 Node selectedFilterNode = selectedFilterNodes[0];
681 final Node parentNode = selectedFilterNode.getParentNode();
683 return new AbstractAction() {
685 public void actionPerformed(ActionEvent e) {
687 sourceEm.setSelectedNodes(
new Node[]{parentNode});
688 }
catch (PropertyVetoException ex) {
690 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)
AbstractAction visit(InstanceCountNode icn)
static final String DOTDIR
static final String HIDE_SLACK_FILES_IN_VIEWS_TREE
static List< String > getArchiveExtensions()
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 List< Action > getActions(File file, boolean isArtifactSource)
static boolean hideSlackFilesInDataSourcesTree()
static final String DOTDOTDIR
static final DisplayableItemNodeVisitor< List< Action > > getActionsDIV
AbstractAction visit(CaseDBCommonAttributeInstanceNode fin)
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)
AbstractAction visit(CommonAttributeValueNode md5n)
final DisplayableItemNodeVisitor< AbstractAction > getPreferredActionsDIV
Action[] getActions(boolean popup)
AbstractAction visit(InstanceDataSourceNode icn)
static boolean hideSlackFilesInViewsTree()
static final String HIDE_SLACK_FILES_IN_DATA_SRCS_TREE
AbstractAction visit(InstanceCaseNode icn)
AbstractAction visit(FileTypesNode fileTypes)
BlackboardArtifact getArtifact()
static synchronized ExternalViewerShortcutAction getInstance()
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)
AbstractAction visit(CentralRepoCommonAttributeInstanceNode iccan)
static boolean filterSlackFromDataSources
Node[] createNodes(Node key)
static synchronized AddContentTagAction getInstance()
final ExplorerManager sourceEm
DataResultFilterNode(Node node, ExplorerManager em, boolean filterKnown, boolean filterSlack)