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;
80 import org.
sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE;
101 public void preferenceChange(PreferenceChangeEvent evt) {
102 switch (evt.getKey()) {
168 List<Action> actions =
new ArrayList<>();
171 List<Action> accept = originalNode.
accept(getActionsDIV);
172 if (accept != null) {
173 actions.addAll(accept);
177 return actions.toArray(
new Action[actions.size()]);
188 final Node original = this.getOriginal();
194 final DisplayableItemNode originalNode = (DisplayableItemNode) this.getOriginal();
195 return originalNode.
accept(getPreferredActionsDIV);
200 Node.PropertySet[] propertySets = super.getPropertySets();
202 for (
int i = 0; i < propertySets.length; i++) {
203 Node.PropertySet ps = propertySets[i];
205 if (ps.getName().equals(Sheet.PROPERTIES)) {
206 Sheet.Set newPs =
new Sheet.Set();
207 newPs.setName(ps.getName());
208 newPs.setDisplayName(ps.getDisplayName());
209 newPs.setShortDescription(ps.getShortDescription());
211 newPs.put(ps.getProperties());
215 propertySets[i] = newPs;
235 final Node orig = getOriginal();
236 String name = orig.getDisplayName();
238 name = ((BlackboardArtifactNode) orig).getSourceName();
264 return ((DisplayableItemNode) getOriginal()).getChildNodeSelectionInfo();
289 this.filterArtifacts =
false;
290 switch (SelectionContext.getSelectionContext(arg)) {
294 filterArtifacts =
true;
317 AbstractFile file = key.getLookup().lookup(AbstractFile.class);
319 if (filterKnown && (file.getKnown() == TskData.FileKnown.KNOWN)) {
323 if (filterSlack && file.getType().equals(TskData.TSK_DB_FILES_TYPE_ENUM.SLACK)) {
330 BlackboardArtifact art = key.getLookup().lookup(BlackboardArtifact.class);
333 && art.getArtifactTypeID() != BlackboardArtifact.ARTIFACT_TYPE.TSK_EMAIL_MSG.getTypeID()
334 && art.getArtifactTypeID() != BlackboardArtifact.ARTIFACT_TYPE.TSK_MESSAGE.getTypeID()) {
343 @NbBundle.Messages(
"DataResultFilterNode.viewSourceArtifact.text=View Source Result")
357 List<Action> actionsList =
new ArrayList<>();
363 BlackboardArtifact ba = ban.getLookup().lookup(BlackboardArtifact.class);
364 final int artifactTypeID = ba.getArtifactTypeID();
366 if (artifactTypeID == BlackboardArtifact.ARTIFACT_TYPE.TSK_HASHSET_HIT.getTypeID()
367 || artifactTypeID == BlackboardArtifact.ARTIFACT_TYPE.TSK_KEYWORD_HIT.getTypeID()) {
368 if (ban.getLookup().lookup(AbstractFile.class) != null) {
372 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.viewFileInDir.text"), ban));
374 }
else if (artifactTypeID == BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_ARTIFACT_HIT.getTypeID()) {
376 actionsList.add(
new ViewSourceArtifactAction(DataResultFilterNode_viewSourceArtifact_text(), ba));
379 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.viewSrcFileInDir.text"), ban));
386 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.viewFileInDir.text"), c));
390 Content fileContent = ban.getLookup().lookup(AbstractFile.class);
391 if (fileContent == null) {
392 Content content = ban.getLookup().lookup(Content.class);
393 actionsList.add(
new ViewContextAction(
"View Source Content in Directory", content));
396 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.viewSrcFileInDir.text"), ban));
399 Content c = ban.getLookup().lookup(File.class);
401 boolean md5Action =
false;
405 }
else if ((c = ban.getLookup().lookup(Directory.class)) != null) {
407 }
else if ((c = ban.getLookup().lookup(VirtualDirectory.class)) != null) {
409 }
else if ((c = ban.getLookup().lookup(LocalDirectory.class)) != null) {
411 }
else if ((c = ban.getLookup().lookup(LayoutFile.class)) != null) {
413 }
else if ((c = ban.getLookup().lookup(LocalFile.class)) != null
414 || (c = ban.getLookup().lookup(DerivedFile.class)) != null) {
418 if (c.getArtifacts(BlackboardArtifact.ARTIFACT_TYPE.TSK_ENCRYPTION_DETECTED).size() > 0) {
421 }
catch (TskCoreException ex) {
422 LOGGER.log(Level.WARNING,
"Unable to add unzip with password action to context menus", ex);
425 }
else if ((c = ban.getLookup().lookup(SlackFile.class)) != null) {
427 }
else if ((c = ban.getLookup().lookup(Report.class)) != null) {
431 actionsList.add(null);
433 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.viewInNewWin.text"), n));
435 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.openInExtViewer.text"), n));
436 actionsList.add(null);
440 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.searchFilesSameMd5.text"), n));
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);
533 if ((artifact.getArtifactTypeID() == ARTIFACT_TYPE.TSK_EMAIL_MSG.getTypeID())
534 || (artifact.getArtifactTypeID() == ARTIFACT_TYPE.TSK_MESSAGE.getTypeID())) {
535 if (artifact.hasChildren()) {
539 }
catch (TskCoreException ex) {
540 LOGGER.log(Level.SEVERE, MessageFormat.format(
"Error getting children from blackboard artifact{0}.", artifact.getArtifactID()), ex);
543 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.viewInDir.text"), ban);
559 if (fn.hasContentChildren()) {
568 if (dfn.hasContentChildren()) {
577 return reportNode.getPreferredAction();
598 private AbstractAction
openChild(
final AbstractNode dataModelNode) {
604 final Node currentSelectionInDirectoryTree = sourceEm.getSelectedNodes()[0];
606 return new AbstractAction() {
608 public void actionPerformed(ActionEvent e) {
609 if (currentSelectionInDirectoryTree != null) {
611 final org.openide.nodes.Children children = currentSelectionInDirectoryTree.getChildren();
613 Node newSelection = children.findChild(dataModelNode.getName());
622 if (newSelection != null) {
624 sourceEm.setExploredContextAndSelection(newSelection,
new Node[]{newSelection});
625 }
catch (PropertyVetoException ex) {
627 logger.log(Level.WARNING,
"Error: can't open the selected directory.", ex);
645 Node[] selectedFilterNodes = sourceEm.getSelectedNodes();
646 Node selectedFilterNode = selectedFilterNodes[0];
647 final Node parentNode = selectedFilterNode.getParentNode();
649 return new AbstractAction() {
651 public void actionPerformed(ActionEvent e) {
653 sourceEm.setSelectedNodes(
new Node[]{parentNode});
654 }
catch (PropertyVetoException ex) {
656 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 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
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)
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)
static boolean filterSlackFromDataSources
Node[] createNodes(Node key)
static synchronized AddContentTagAction getInstance()
final ExplorerManager sourceEm
DataResultFilterNode(Node node, ExplorerManager em, boolean filterKnown, boolean filterSlack)