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 actionsList.add(null);
437 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.viewInNewWin.text"), n));
439 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.openInExtViewer.text"), n));
440 actionsList.add(null);
442 actionsList.add(null);
446 final Collection<AbstractFile> selectedFilesList
447 =
new HashSet<>(Utilities.actionsGlobalContext().lookupAll(AbstractFile.class));
448 if (selectedFilesList.size() == 1) {
454 actionsList.add(null);
458 final Collection<BlackboardArtifact> selectedArtifactsList
459 =
new HashSet<>(Utilities.actionsGlobalContext().lookupAll(BlackboardArtifact.class));
460 if (selectedArtifactsList.size() == 1) {
485 List<Action> actions =
new ArrayList<>();
487 for (Action action : ditem.getActions(
true)) {
495 BlackboardArtifact art = ba.getLookup().lookup(BlackboardArtifact.class);
498 for (BlackboardAttribute attr : art.getAttributes()) {
499 if (attr.getAttributeType().getTypeID() == BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PATH_ID.getTypeID()) {
500 switch (attr.getAttributeType().getValueType()) {
502 int i = attr.getValueInt();
504 c = art.getSleuthkitCase().getContentById(i);
508 long l = attr.getValueLong();
510 c = art.getSleuthkitCase().getContentById(l);
516 }
catch (TskException ex) {
517 Logger.
getLogger(this.getClass().getName()).log(Level.WARNING,
"Error getting linked file", ex);
563 if ((artifact.getArtifactTypeID() == ARTIFACT_TYPE.TSK_EMAIL_MSG.getTypeID())
564 || (artifact.getArtifactTypeID() == ARTIFACT_TYPE.TSK_MESSAGE.getTypeID())) {
565 if (artifact.hasChildren()) {
569 }
catch (TskCoreException ex) {
570 LOGGER.log(Level.SEVERE, MessageFormat.format(
"Error getting children from blackboard artifact{0}.", artifact.getArtifactID()), ex);
573 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.viewInDir.text"), ban);
589 if (fn.hasContentChildren()) {
598 if (dfn.hasContentChildren()) {
607 return reportNode.getPreferredAction();
628 private AbstractAction
openChild(
final AbstractNode dataModelNode) {
634 final Node currentSelectionInDirectoryTree = sourceEm.getSelectedNodes()[0];
636 return new AbstractAction() {
638 public void actionPerformed(ActionEvent e) {
639 if (currentSelectionInDirectoryTree != null) {
641 final org.openide.nodes.Children children = currentSelectionInDirectoryTree.getChildren();
643 Node newSelection = children.findChild(dataModelNode.getName());
652 if (newSelection != null) {
654 sourceEm.setExploredContextAndSelection(newSelection,
new Node[]{newSelection});
655 }
catch (PropertyVetoException ex) {
657 logger.log(Level.WARNING,
"Error: can't open the selected directory.", ex);
675 Node[] selectedFilterNodes = sourceEm.getSelectedNodes();
676 Node selectedFilterNode = selectedFilterNodes[0];
677 final Node parentNode = selectedFilterNode.getParentNode();
679 return new AbstractAction() {
681 public void actionPerformed(ActionEvent e) {
683 sourceEm.setSelectedNodes(
new Node[]{parentNode});
684 }
catch (PropertyVetoException ex) {
686 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 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)