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;
84 import org.
sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE;
105 public void preferenceChange(PreferenceChangeEvent evt) {
106 switch (evt.getKey()) {
150 InstanceCountNode innerNode = getLookup().lookup(InstanceCountNode.class);
184 List<Action> actions =
new ArrayList<>();
187 List<Action> accept = originalNode.
accept(getActionsDIV);
188 if (accept != null) {
189 actions.addAll(accept);
193 return actions.toArray(
new Action[actions.size()]);
204 final Node original = this.getOriginal();
210 final DisplayableItemNode originalNode = (DisplayableItemNode) this.getOriginal();
211 return originalNode.
accept(getPreferredActionsDIV);
216 Node.PropertySet[] propertySets = super.getPropertySets();
218 for (
int i = 0; i < propertySets.length; i++) {
219 Node.PropertySet ps = propertySets[i];
221 if (ps.getName().equals(Sheet.PROPERTIES)) {
222 Sheet.Set newPs =
new Sheet.Set();
223 newPs.setName(ps.getName());
224 newPs.setDisplayName(ps.getDisplayName());
225 newPs.setShortDescription(ps.getShortDescription());
227 newPs.put(ps.getProperties());
231 propertySets[i] = newPs;
251 final Node orig = getOriginal();
252 String name = orig.getDisplayName();
254 name = ((BlackboardArtifactNode) orig).getSourceName();
280 return ((DisplayableItemNode) getOriginal()).getChildNodeSelectionInfo();
305 this.filterArtifacts =
false;
306 switch (SelectionContext.getSelectionContext(arg)) {
310 filterArtifacts =
true;
333 AbstractFile file = key.getLookup().lookup(AbstractFile.class);
335 if (filterKnown && (file.getKnown() == TskData.FileKnown.KNOWN)) {
339 if (filterSlack && file.getType().equals(TskData.TSK_DB_FILES_TYPE_ENUM.SLACK)) {
346 BlackboardArtifact art = key.getLookup().lookup(BlackboardArtifact.class);
349 && art.getArtifactTypeID() != BlackboardArtifact.ARTIFACT_TYPE.TSK_EMAIL_MSG.getTypeID()
350 && art.getArtifactTypeID() != BlackboardArtifact.ARTIFACT_TYPE.TSK_MESSAGE.getTypeID()) {
359 @NbBundle.Messages(
"DataResultFilterNode.viewSourceArtifact.text=View Source Result")
373 List<Action> actionsList =
new ArrayList<>();
379 BlackboardArtifact ba = ban.getLookup().lookup(BlackboardArtifact.class);
380 final int artifactTypeID = ba.getArtifactTypeID();
382 if (artifactTypeID == BlackboardArtifact.ARTIFACT_TYPE.TSK_HASHSET_HIT.getTypeID()
383 || artifactTypeID == BlackboardArtifact.ARTIFACT_TYPE.TSK_KEYWORD_HIT.getTypeID()) {
384 if (ban.getLookup().lookup(AbstractFile.class) != null) {
388 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.viewFileInDir.text"), ban));
390 }
else if (artifactTypeID == BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_ARTIFACT_HIT.getTypeID()) {
392 actionsList.add(
new ViewSourceArtifactAction(DataResultFilterNode_viewSourceArtifact_text(), ba));
395 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.viewSrcFileInDir.text"), ban));
402 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.viewFileInDir.text"), c));
406 Content fileContent = ban.getLookup().lookup(AbstractFile.class);
407 if (fileContent == null) {
408 Content content = ban.getLookup().lookup(Content.class);
409 actionsList.add(
new ViewContextAction(
"View Source Content in Directory", content));
412 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.viewSrcFileInDir.text"), ban));
415 Content c = ban.getLookup().lookup(File.class);
419 }
else if ((c = ban.getLookup().lookup(Directory.class)) != null) {
421 }
else if ((c = ban.getLookup().lookup(VirtualDirectory.class)) != null) {
423 }
else if ((c = ban.getLookup().lookup(LocalDirectory.class)) != null) {
425 }
else if ((c = ban.getLookup().lookup(LayoutFile.class)) != null) {
427 }
else if ((c = ban.getLookup().lookup(LocalFile.class)) != null
428 || (c = ban.getLookup().lookup(DerivedFile.class)) != null) {
432 if (c.getArtifacts(BlackboardArtifact.ARTIFACT_TYPE.TSK_ENCRYPTION_DETECTED).size() > 0) {
435 }
catch (TskCoreException ex) {
436 LOGGER.log(Level.WARNING,
"Unable to add unzip with password action to context menus", ex);
439 }
else if ((c = ban.getLookup().lookup(SlackFile.class)) != null) {
441 }
else if ((c = ban.getLookup().lookup(Report.class)) != null) {
445 actionsList.add(null);
447 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.viewInNewWin.text"), n));
449 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.openInExtViewer.text"), n));
450 actionsList.add(null);
452 actionsList.add(null);
456 final Collection<AbstractFile> selectedFilesList
457 =
new HashSet<>(Utilities.actionsGlobalContext().lookupAll(AbstractFile.class));
458 if (selectedFilesList.size() == 1) {
464 actionsList.add(null);
468 final Collection<BlackboardArtifact> selectedArtifactsList
469 =
new HashSet<>(Utilities.actionsGlobalContext().lookupAll(BlackboardArtifact.class));
470 if (selectedArtifactsList.size() == 1) {
495 List<Action> actions =
new ArrayList<>();
497 for (Action action : ditem.getActions(
true)) {
505 BlackboardArtifact art = ba.getLookup().lookup(BlackboardArtifact.class);
508 for (BlackboardAttribute attr : art.getAttributes()) {
509 if (attr.getAttributeType().getTypeID() == BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PATH_ID.getTypeID()) {
510 switch (attr.getAttributeType().getValueType()) {
512 int i = attr.getValueInt();
514 c = art.getSleuthkitCase().getContentById(i);
518 long l = attr.getValueLong();
520 c = art.getSleuthkitCase().getContentById(l);
526 }
catch (TskException ex) {
527 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)
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)
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)