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 actionsList.add(
new ViewSourceArtifactAction(DataResultFilterNode_viewSourceArtifact_text(), ba));
298 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.viewSrcFileInDir.text"), ban));
305 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);
364 if (!(ban.
getArtifact() instanceof DataArtifact)) {
371 if ((!(ban.
getArtifact() instanceof DataArtifact)) && (selectedFilesList.size() == 1)) {
377 actionsList.add(null);
381 final Collection<BlackboardArtifact> selectedArtifactsList
382 =
new HashSet<>(Utilities.actionsGlobalContext().lookupAll(BlackboardArtifact.class));
383 if (selectedArtifactsList.size() == 1) {
408 List<Action> actions =
new ArrayList<>();
410 for (Action action : ditem.getActions(
true)) {
418 BlackboardArtifact art = ba.getLookup().lookup(BlackboardArtifact.class);
421 for (BlackboardAttribute attr : art.getAttributes()) {
422 if (attr.getAttributeType().getTypeID() == BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PATH_ID.getTypeID()) {
423 switch (attr.getAttributeType().getValueType()) {
425 int i = attr.getValueInt();
427 c = art.getSleuthkitCase().getContentById(i);
431 long l = attr.getValueLong();
433 c = art.getSleuthkitCase().getContentById(l);
439 }
catch (TskException ex) {
440 Logger.
getLogger(this.getClass().getName()).log(Level.WARNING,
"Error getting linked file", ex);
485 Action preferredAction = ban.getPreferredAction();
486 if(preferredAction instanceof AbstractAction) {
487 return (AbstractAction) preferredAction;
492 if ((artifact.getArtifactTypeID() == ARTIFACT_TYPE.TSK_EMAIL_MSG.getTypeID())
493 || (artifact.getArtifactTypeID() == ARTIFACT_TYPE.TSK_MESSAGE.getTypeID())) {
494 if (artifact.hasChildren()) {
498 }
catch (TskCoreException ex) {
499 LOGGER.log(Level.SEVERE, MessageFormat.format(
"Error getting children from blackboard artifact{0}.", artifact.getArtifactID()), ex);
502 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.viewInDir.text"), ban);
518 if (fn.hasContentChildren()) {
527 if (dfn.hasContentChildren()) {
536 return reportNode.getPreferredAction();
557 private AbstractAction
openChild(
final AbstractNode dataModelNode) {
563 if(sourceEm == null || sourceEm.getSelectedNodes().length == 0) {
566 final Node currentSelectionInDirectoryTree = sourceEm.getSelectedNodes()[0];
568 return new AbstractAction() {
570 public void actionPerformed(ActionEvent e) {
571 if (currentSelectionInDirectoryTree != null) {
573 final org.openide.nodes.Children children = currentSelectionInDirectoryTree.getChildren();
575 Node newSelection = children.findChild(dataModelNode.getName());
584 if (newSelection != null) {
586 sourceEm.setExploredContextAndSelection(newSelection,
new Node[]{newSelection});
587 }
catch (PropertyVetoException ex) {
589 logger.log(Level.WARNING,
"Error: can't open the selected directory.", ex);
606 if(sourceEm == null) {
610 Node[] selectedFilterNodes = sourceEm.getSelectedNodes();
611 Node selectedFilterNode = selectedFilterNodes[0];
612 final Node parentNode = selectedFilterNode.getParentNode();
614 return new AbstractAction() {
616 public void actionPerformed(ActionEvent e) {
618 sourceEm.setSelectedNodes(
new Node[]{parentNode});
619 }
catch (PropertyVetoException ex) {
621 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