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 javax.swing.AbstractAction;
30 import javax.swing.Action;
31 import org.openide.explorer.ExplorerManager;
32 import org.openide.nodes.AbstractNode;
33 import org.openide.nodes.FilterNode;
34 import org.openide.nodes.Node;
35 import org.openide.nodes.Sheet;
36 import org.openide.util.NbBundle;
37 import org.openide.util.Utilities;
81 import org.
sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE;
137 List<Action> actions =
new ArrayList<>();
140 List<Action> accept = originalNode.
accept(getActionsDIV);
141 if (accept != null) {
142 actions.addAll(accept);
147 return actions.toArray(
new Action[actions.size()]);
158 final Node original = this.getOriginal();
164 final DisplayableItemNode originalNode = (DisplayableItemNode) this.getOriginal();
165 return originalNode.
accept(getPreferredActionsDIV);
170 Node.PropertySet[] propertySets = super.getPropertySets();
172 for (
int i = 0; i < propertySets.length; i++) {
173 Node.PropertySet ps = propertySets[i];
175 if (ps.getName().equals(Sheet.PROPERTIES)) {
176 Sheet.Set newPs =
new Sheet.Set();
177 newPs.setName(ps.getName());
178 newPs.setDisplayName(ps.getDisplayName());
179 newPs.setShortDescription(ps.getShortDescription());
181 newPs.put(ps.getProperties());
183 propertySets[i] = newPs;
211 return ((DisplayableItemNode) getOriginal()).getChildNodeSelectionInfo();
233 filterArtifacts = SelectionContext.getSelectionContext(arg).equals(SelectionContext.DATA_SOURCES);
245 BlackboardArtifact art = key.getLookup().lookup(BlackboardArtifact.class);
246 if (art != null && filterArtifacts
247 && ((FilterNodeUtils.showMessagesInDatasourceTree() ==
false)
248 || (FilterNodeUtils.showMessagesInDatasourceTree()
249 && art.getArtifactTypeID() != BlackboardArtifact.ARTIFACT_TYPE.TSK_EMAIL_MSG.getTypeID()
250 && art.getArtifactTypeID() != BlackboardArtifact.ARTIFACT_TYPE.TSK_MESSAGE.getTypeID()))) {
258 @NbBundle.Messages(
"DataResultFilterNode.viewSourceArtifact.text=View Source Result")
272 List<Action> actionsList =
new ArrayList<>();
280 actionsList.add(null);
281 BlackboardArtifact ba = ban.getLookup().lookup(BlackboardArtifact.class);
282 final int artifactTypeID = ba.getArtifactTypeID();
284 if (artifactTypeID == BlackboardArtifact.ARTIFACT_TYPE.TSK_HASHSET_HIT.getTypeID()
285 || artifactTypeID == BlackboardArtifact.ARTIFACT_TYPE.TSK_KEYWORD_HIT.getTypeID()) {
286 if (ban.getLookup().lookup(AbstractFile.class) != null) {
290 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.viewFileInDir.text"), ban));
292 }
else if (artifactTypeID == BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_ARTIFACT_HIT.getTypeID()) {
294 actionsList.add(
new ViewSourceArtifactAction(DataResultFilterNode_viewSourceArtifact_text(), ba));
297 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.viewSrcFileInDir.text"), ban));
304 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.viewFileInDir.text"), c));
308 Content fileContent = ban.getLookup().lookup(AbstractFile.class);
309 if (fileContent == null) {
310 Content content = ban.getLookup().lookup(Content.class);
311 actionsList.add(
new ViewContextAction(
"View Source Content in Directory", content));
314 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.viewSrcFileInDir.text"), ban));
317 Content c = ban.getLookup().lookup(File.class);
321 }
else if ((c = ban.getLookup().lookup(Directory.class)) != null) {
323 }
else if ((c = ban.getLookup().lookup(VirtualDirectory.class)) != null) {
325 }
else if ((c = ban.getLookup().lookup(LocalDirectory.class)) != null) {
327 }
else if ((c = ban.getLookup().lookup(LayoutFile.class)) != null) {
329 }
else if ((c = ban.getLookup().lookup(LocalFile.class)) != null
330 || (c = ban.getLookup().lookup(DerivedFile.class)) != null) {
334 if (c.getArtifacts(BlackboardArtifact.ARTIFACT_TYPE.TSK_ENCRYPTION_DETECTED).size() > 0) {
337 }
catch (TskCoreException ex) {
338 LOGGER.log(Level.WARNING,
"Unable to add unzip with password action to context menus", ex);
341 }
else if ((c = ban.getLookup().lookup(SlackFile.class)) != null) {
343 }
else if ((c = ban.getLookup().lookup(Report.class)) != null) {
347 final Collection<AbstractFile> selectedFilesList
348 =
new HashSet<>(Utilities.actionsGlobalContext().lookupAll(AbstractFile.class));
349 actionsList.add(null);
351 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.viewInNewWin.text"), n));
352 if (selectedFilesList.size() == 1) {
354 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.openInExtViewer.text"), n));
358 actionsList.add(null);
361 actionsList.add(null);
365 if (selectedFilesList.size() == 1) {
371 actionsList.add(null);
375 final Collection<BlackboardArtifact> selectedArtifactsList
376 =
new HashSet<>(Utilities.actionsGlobalContext().lookupAll(BlackboardArtifact.class));
377 if (selectedArtifactsList.size() == 1) {
402 List<Action> actions =
new ArrayList<>();
404 for (Action action : ditem.getActions(
true)) {
412 BlackboardArtifact art = ba.getLookup().lookup(BlackboardArtifact.class);
415 for (BlackboardAttribute attr : art.getAttributes()) {
416 if (attr.getAttributeType().getTypeID() == BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PATH_ID.getTypeID()) {
417 switch (attr.getAttributeType().getValueType()) {
419 int i = attr.getValueInt();
421 c = art.getSleuthkitCase().getContentById(i);
425 long l = attr.getValueLong();
427 c = art.getSleuthkitCase().getContentById(l);
433 }
catch (TskException ex) {
434 Logger.
getLogger(this.getClass().getName()).log(Level.WARNING,
"Error getting linked file", ex);
479 Action preferredAction = ban.getPreferredAction();
480 if(preferredAction instanceof AbstractAction) {
481 return (AbstractAction) preferredAction;
486 if ((artifact.getArtifactTypeID() == ARTIFACT_TYPE.TSK_EMAIL_MSG.getTypeID())
487 || (artifact.getArtifactTypeID() == ARTIFACT_TYPE.TSK_MESSAGE.getTypeID())) {
488 if (artifact.hasChildren()) {
492 }
catch (TskCoreException ex) {
493 LOGGER.log(Level.SEVERE, MessageFormat.format(
"Error getting children from blackboard artifact{0}.", artifact.getArtifactID()), ex);
496 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.viewInDir.text"), ban);
512 if (fn.hasContentChildren()) {
521 if (dfn.hasContentChildren()) {
530 return reportNode.getPreferredAction();
551 private AbstractAction
openChild(
final AbstractNode dataModelNode) {
557 if(sourceEm == null || sourceEm.getSelectedNodes().length == 0) {
560 final Node currentSelectionInDirectoryTree = sourceEm.getSelectedNodes()[0];
562 return new AbstractAction() {
564 public void actionPerformed(ActionEvent e) {
565 if (currentSelectionInDirectoryTree != null) {
567 final org.openide.nodes.Children children = currentSelectionInDirectoryTree.getChildren();
569 Node newSelection = children.findChild(dataModelNode.getName());
578 if (newSelection != null) {
580 sourceEm.setExploredContextAndSelection(newSelection,
new Node[]{newSelection});
581 }
catch (PropertyVetoException ex) {
583 logger.log(Level.WARNING,
"Error: can't open the selected directory.", ex);
600 if(sourceEm == null) {
604 Node[] selectedFilterNodes = sourceEm.getSelectedNodes();
605 Node selectedFilterNode = selectedFilterNodes[0];
606 final Node parentNode = selectedFilterNode.getParentNode();
608 return new AbstractAction() {
610 public void actionPerformed(ActionEvent e) {
612 sourceEm.setSelectedNodes(
new Node[]{parentNode});
613 }
catch (PropertyVetoException ex) {
615 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 List< String > getArchiveExtensions()
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 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()
AbstractAction visit(Reports.ReportNode reportNode)
static synchronized ExportCSVAction getInstance()
Action[] getActions(boolean context)
void setChildNodeSelectionInfo(NodeSelectionInfo selectedChildNodeInfo)
AbstractAction visit(LocalFileNode dfn)
static synchronized DeleteFileContentTagAction getInstance()
static final String HIDE_PARENT
Action getPreferredAction()
final ExplorerManager sourceEm
AbstractAction openParent(AbstractNode node)
final boolean filterArtifacts
AbstractAction visit(CommonAttributeValueNode md5n)
final DisplayableItemNodeVisitor< AbstractAction > getPreferredActionsDIV
Action[] getActions(boolean popup)
AbstractAction visit(InstanceDataSourceNode icn)
DataResultFilterNode(Node node)
AbstractAction visit(InstanceCaseNode icn)
AbstractAction visit(FileTypesNode fileTypes)
BlackboardArtifact getArtifact()
static synchronized ExternalViewerShortcutAction getInstance()
AbstractAction visit(FileNode fn)
synchronized static Logger getLogger(String name)
static final Logger LOGGER
AbstractAction visit(DirectoryNode dn)
AbstractAction visit(CentralRepoCommonAttributeInstanceNode iccan)
Node[] createNodes(Node key)
static synchronized AddContentTagAction getInstance()
final ExplorerManager sourceEm