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;
78 import org.
sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE;
98 public void preferenceChange(PreferenceChangeEvent evt) {
99 switch (evt.getKey()) {
165 List<Action> actions =
new ArrayList<>();
168 List<Action> accept = originalNode.
accept(getActionsDIV);
169 if (accept != null) {
170 actions.addAll(accept);
174 return actions.toArray(
new Action[actions.size()]);
185 final Node original = this.getOriginal();
191 final DisplayableItemNode originalNode = (DisplayableItemNode) this.getOriginal();
192 return originalNode.
accept(getPreferredActionsDIV);
197 Node.PropertySet[] propertySets = super.getPropertySets();
199 for (
int i = 0; i < propertySets.length; i++) {
200 Node.PropertySet ps = propertySets[i];
202 if (ps.getName().equals(Sheet.PROPERTIES)) {
203 Sheet.Set newPs =
new Sheet.Set();
204 newPs.setName(ps.getName());
205 newPs.setDisplayName(ps.getDisplayName());
206 newPs.setShortDescription(ps.getShortDescription());
208 newPs.put(ps.getProperties());
212 propertySets[i] = newPs;
231 final Node orig = getOriginal();
232 String name = orig.getDisplayName();
234 name = ((BlackboardArtifactNode) orig).getSourceName();
260 return ((DisplayableItemNode) getOriginal()).getChildNodeSelectionInfo();
285 this.filterArtifacts =
false;
286 switch (SelectionContext.getSelectionContext(arg)) {
290 filterArtifacts =
true;
313 AbstractFile file = key.getLookup().lookup(AbstractFile.class);
315 if (filterKnown && (file.getKnown() == TskData.FileKnown.KNOWN)) {
319 if (filterSlack && file.getType().equals(TskData.TSK_DB_FILES_TYPE_ENUM.SLACK)) {
326 BlackboardArtifact art = key.getLookup().lookup(BlackboardArtifact.class);
327 if (art != null && filterArtifacts) {
328 if ( (art.getArtifactTypeID() != BlackboardArtifact.ARTIFACT_TYPE.TSK_EMAIL_MSG.getTypeID()) &&
329 (art.getArtifactTypeID() != BlackboardArtifact.ARTIFACT_TYPE.TSK_MESSAGE.getTypeID()) ) {
338 @NbBundle.Messages(
"DataResultFilterNode.viewSourceArtifact.text=View Source Result")
352 List<Action> actionsList =
new ArrayList<>();
358 BlackboardArtifact ba = ban.getLookup().lookup(BlackboardArtifact.class);
359 final int artifactTypeID = ba.getArtifactTypeID();
361 if (artifactTypeID == BlackboardArtifact.ARTIFACT_TYPE.TSK_HASHSET_HIT.getTypeID()
362 || artifactTypeID == BlackboardArtifact.ARTIFACT_TYPE.TSK_KEYWORD_HIT.getTypeID()) {
364 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.viewFileInDir.text"), ban));
365 }
else if (artifactTypeID == BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_ARTIFACT_HIT.getTypeID()) {
367 actionsList.add(
new ViewSourceArtifactAction(DataResultFilterNode_viewSourceArtifact_text(), ba));
370 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.viewSrcFileInDir.text"), ban));
377 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.viewFileInDir.text"), c));
381 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.viewSrcFileInDir.text"), ban));
383 Content c = ban.getLookup().lookup(File.class);
385 boolean md5Action =
false;
389 }
else if ((c = ban.getLookup().lookup(Directory.class)) != null) {
391 }
else if ((c = ban.getLookup().lookup(VirtualDirectory.class)) != null) {
393 }
else if ((c = ban.getLookup().lookup(LocalDirectory.class)) != null) {
395 }
else if ((c = ban.getLookup().lookup(LayoutFile.class)) != null) {
397 }
else if ((c = ban.getLookup().lookup(LocalFile.class)) != null
398 || (c = ban.getLookup().lookup(DerivedFile.class)) != null) {
400 }
else if ((c = ban.getLookup().lookup(SlackFile.class)) != null) {
404 actionsList.add(null);
406 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.viewInNewWin.text"), n));
408 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.openInExtViewer.text"), n));
409 actionsList.add(null);
413 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.searchFilesSameMd5.text"), n));
415 actionsList.add(null);
419 final Collection<AbstractFile> selectedFilesList
420 =
new HashSet<>(Utilities.actionsGlobalContext().lookupAll(AbstractFile.class));
421 if (selectedFilesList.size() == 1) {
427 actionsList.add(null);
431 final Collection<BlackboardArtifact> selectedArtifactsList
432 =
new HashSet<>(Utilities.actionsGlobalContext().lookupAll(BlackboardArtifact.class));
433 if (selectedArtifactsList.size() == 1) {
458 List<Action> actions =
new ArrayList<>();
460 for (Action action : ditem.getActions(
true)) {
468 BlackboardArtifact art = ba.getLookup().lookup(BlackboardArtifact.class);
471 for (BlackboardAttribute attr : art.getAttributes()) {
472 if (attr.getAttributeType().getTypeID() == BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PATH_ID.getTypeID()) {
473 switch (attr.getAttributeType().getValueType()) {
475 int i = attr.getValueInt();
477 c = art.getSleuthkitCase().getContentById(i);
481 long l = attr.getValueLong();
483 c = art.getSleuthkitCase().getContentById(l);
489 }
catch (TskException ex) {
490 Logger.
getLogger(this.getClass().getName()).log(Level.WARNING,
"Error getting linked file", ex);
506 if ( (artifact.getArtifactTypeID() == ARTIFACT_TYPE.TSK_EMAIL_MSG.getTypeID()) ||
507 (artifact.getArtifactTypeID() == ARTIFACT_TYPE.TSK_MESSAGE.getTypeID()) ) {
508 if (artifact.hasChildren()) {
513 catch (TskCoreException ex) {
514 LOGGER.log(Level.SEVERE, MessageFormat.format(
"Error getting children from blackboard artifact{0}.", artifact.getArtifactID()), ex);
517 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.viewInDir.text"), ban);
533 if (fn.hasContentChildren()) {
542 if (dfn.hasContentChildren()) {
551 return reportNode.getPreferredAction();
572 private AbstractAction
openChild(
final AbstractNode dataModelNode) {
578 final Node currentSelectionInDirectoryTree = sourceEm.getSelectedNodes()[0];
580 return new AbstractAction() {
582 public void actionPerformed(ActionEvent e) {
583 if (currentSelectionInDirectoryTree != null) {
585 final org.openide.nodes.Children children = currentSelectionInDirectoryTree.getChildren();
587 Node newSelection = children.findChild(dataModelNode.getName());
596 if (newSelection != null) {
598 sourceEm.setExploredContextAndSelection(newSelection,
new Node[]{newSelection});
599 }
catch (PropertyVetoException ex) {
601 logger.log(Level.WARNING,
"Error: can't open the selected directory.", ex);
619 Node[] selectedFilterNodes = sourceEm.getSelectedNodes();
620 Node selectedFilterNode = selectedFilterNodes[0];
621 final Node parentNode = selectedFilterNode.getParentNode();
623 return new AbstractAction() {
625 public void actionPerformed(ActionEvent e) {
627 sourceEm.setSelectedNodes(
new Node[]{parentNode});
628 }
catch (PropertyVetoException ex) {
630 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)
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)