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;
138 List<Action> actions =
new ArrayList<>();
141 List<Action> accept = originalNode.
accept(getActionsDIV);
142 if (accept != null) {
143 actions.addAll(accept);
148 return actions.toArray(
new Action[actions.size()]);
159 final Node original = this.getOriginal();
165 final DisplayableItemNode originalNode = (DisplayableItemNode) this.getOriginal();
166 return originalNode.
accept(getPreferredActionsDIV);
171 Node.PropertySet[] propertySets = super.getPropertySets();
173 for (
int i = 0; i < propertySets.length; i++) {
174 Node.PropertySet ps = propertySets[i];
176 if (ps.getName().equals(Sheet.PROPERTIES)) {
177 Sheet.Set newPs =
new Sheet.Set();
178 newPs.setName(ps.getName());
179 newPs.setDisplayName(ps.getDisplayName());
180 newPs.setShortDescription(ps.getShortDescription());
182 newPs.put(ps.getProperties());
184 propertySets[i] = newPs;
212 return ((DisplayableItemNode) getOriginal()).getChildNodeSelectionInfo();
234 filterArtifacts = SelectionContext.getSelectionContext(arg).equals(SelectionContext.DATA_SOURCES);
246 BlackboardArtifact art = key.getLookup().lookup(BlackboardArtifact.class);
247 if (art != null && filterArtifacts
248 && ((FilterNodeUtils.showMessagesInDatasourceTree() ==
false)
249 || (FilterNodeUtils.showMessagesInDatasourceTree()
250 && art.getArtifactTypeID() != BlackboardArtifact.ARTIFACT_TYPE.TSK_EMAIL_MSG.getTypeID()
251 && art.getArtifactTypeID() != BlackboardArtifact.ARTIFACT_TYPE.TSK_MESSAGE.getTypeID()))) {
259 @NbBundle.Messages(
"DataResultFilterNode.viewSourceArtifact.text=View Source Result")
273 List<Action> actionsList =
new ArrayList<>();
281 actionsList.add(null);
282 BlackboardArtifact ba = ban.getLookup().lookup(BlackboardArtifact.class);
283 final int artifactTypeID = ba.getArtifactTypeID();
285 if (artifactTypeID == BlackboardArtifact.ARTIFACT_TYPE.TSK_HASHSET_HIT.getTypeID()
286 || artifactTypeID == BlackboardArtifact.ARTIFACT_TYPE.TSK_KEYWORD_HIT.getTypeID()) {
287 if (ban.getLookup().lookup(AbstractFile.class) != null) {
291 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.viewFileInDir.text"), ban));
293 }
else if (artifactTypeID == BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_ARTIFACT_HIT.getTypeID()) {
295 if (ba.getAttribute(BlackboardAttribute.Type.TSK_ASSOCIATED_ARTIFACT) != null) {
297 actionsList.add(
new ViewSourceArtifactAction(DataResultFilterNode_viewSourceArtifact_text(), ba));
301 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.viewSrcFileInDir.text"), ban));
303 }
catch (TskCoreException ex) {
304 LOGGER.log(Level.WARNING,
"Error looking up attributes for artifact with ID=" + ba.getId());
312 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.viewFileInDir.text"), c));
315 Content fileContent = ban.getLookup().lookup(AbstractFile.class);
316 if (fileContent == null) {
317 Content content = ban.getLookup().lookup(Content.class);
318 actionsList.add(
new ViewContextAction(
"View Source Content in Directory", content));
321 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.viewSrcFileInDir.text"), ban));
324 Content c = ban.getLookup().lookup(File.class);
328 }
else if ((c = ban.getLookup().lookup(Directory.class)) != null) {
330 }
else if ((c = ban.getLookup().lookup(VirtualDirectory.class)) != null) {
332 }
else if ((c = ban.getLookup().lookup(LocalDirectory.class)) != null) {
334 }
else if ((c = ban.getLookup().lookup(LayoutFile.class)) != null) {
336 }
else if ((c = ban.getLookup().lookup(LocalFile.class)) != null
337 || (c = ban.getLookup().lookup(DerivedFile.class)) != null) {
341 if (c.getArtifacts(BlackboardArtifact.ARTIFACT_TYPE.TSK_ENCRYPTION_DETECTED).size() > 0) {
344 }
catch (TskCoreException ex) {
345 LOGGER.log(Level.WARNING,
"Unable to add unzip with password action to context menus", ex);
348 }
else if ((c = ban.getLookup().lookup(SlackFile.class)) != null) {
350 }
else if ((c = ban.getLookup().lookup(Report.class)) != null) {
354 final Collection<AbstractFile> selectedFilesList
355 =
new HashSet<>(Utilities.actionsGlobalContext().lookupAll(AbstractFile.class));
356 actionsList.add(null);
358 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.viewInNewWin.text"), n));
359 if (selectedFilesList.size() == 1) {
361 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.openInExtViewer.text"), n));
365 actionsList.add(null);
368 actionsList.add(null);
371 if (!(ban.
getArtifact() instanceof DataArtifact)) {
378 if ((!(ban.
getArtifact() instanceof DataArtifact)) && (selectedFilesList.size() == 1)) {
384 actionsList.add(null);
388 final Collection<BlackboardArtifact> selectedArtifactsList
389 =
new HashSet<>(Utilities.actionsGlobalContext().lookupAll(BlackboardArtifact.class));
390 if (selectedArtifactsList.size() == 1) {
415 List<Action> actions =
new ArrayList<>();
417 for (Action action : ditem.getActions(
true)) {
425 BlackboardArtifact art = ba.getLookup().lookup(BlackboardArtifact.class);
428 for (BlackboardAttribute attr : art.getAttributes()) {
429 if (attr.getAttributeType().getTypeID() == BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PATH_ID.getTypeID()) {
430 switch (attr.getAttributeType().getValueType()) {
432 int i = attr.getValueInt();
434 c = art.getSleuthkitCase().getContentById(i);
438 long l = attr.getValueLong();
440 c = art.getSleuthkitCase().getContentById(l);
446 }
catch (TskException ex) {
447 Logger.
getLogger(this.getClass().getName()).log(Level.WARNING,
"Error getting linked file", ex);
492 Action preferredAction = ban.getPreferredAction();
493 if(preferredAction instanceof AbstractAction) {
494 return (AbstractAction) preferredAction;
499 if ((artifact.getArtifactTypeID() == ARTIFACT_TYPE.TSK_EMAIL_MSG.getTypeID())
500 || (artifact.getArtifactTypeID() == ARTIFACT_TYPE.TSK_MESSAGE.getTypeID())) {
501 if (artifact.hasChildren()) {
505 }
catch (TskCoreException ex) {
506 LOGGER.log(Level.SEVERE, MessageFormat.format(
"Error getting children from blackboard artifact{0}.", artifact.getArtifactID()), ex);
509 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.viewInDir.text"), ban);
525 if (fn.hasContentChildren()) {
534 if (dfn.hasContentChildren()) {
543 return reportNode.getPreferredAction();
564 private AbstractAction
openChild(
final AbstractNode dataModelNode) {
570 if(sourceEm == null || sourceEm.getSelectedNodes().length == 0) {
573 final Node currentSelectionInDirectoryTree = sourceEm.getSelectedNodes()[0];
575 return new AbstractAction() {
577 public void actionPerformed(ActionEvent e) {
578 if (currentSelectionInDirectoryTree != null) {
580 final org.openide.nodes.Children children = currentSelectionInDirectoryTree.getChildren();
582 Node newSelection = children.findChild(dataModelNode.getName());
591 if (newSelection != null) {
593 sourceEm.setExploredContextAndSelection(newSelection,
new Node[]{newSelection});
594 }
catch (PropertyVetoException ex) {
596 logger.log(Level.WARNING,
"Error: can't open the selected directory.", ex);
613 if(sourceEm == null) {
617 Node[] selectedFilterNodes = sourceEm.getSelectedNodes();
618 Node selectedFilterNode = selectedFilterNodes[0];
619 final Node parentNode = selectedFilterNode.getParentNode();
621 return new AbstractAction() {
623 public void actionPerformed(ActionEvent e) {
625 sourceEm.setSelectedNodes(
new Node[]{parentNode});
626 }
catch (PropertyVetoException ex) {
628 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