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;
203 final Node orig = getOriginal();
204 String name = orig.getDisplayName();
206 name = ((BlackboardArtifactNode) orig).getSourceName();
232 return ((DisplayableItemNode) getOriginal()).getChildNodeSelectionInfo();
254 filterArtifacts = SelectionContext.getSelectionContext(arg).equals(SelectionContext.DATA_SOURCES);
266 BlackboardArtifact art = key.getLookup().lookup(BlackboardArtifact.class);
267 if (art != null && filterArtifacts
268 && ((FilterNodeUtils.showMessagesInDatasourceTree() ==
false)
269 || (FilterNodeUtils.showMessagesInDatasourceTree()
270 && art.getArtifactTypeID() != BlackboardArtifact.ARTIFACT_TYPE.TSK_EMAIL_MSG.getTypeID()
271 && art.getArtifactTypeID() != BlackboardArtifact.ARTIFACT_TYPE.TSK_MESSAGE.getTypeID()))) {
279 @NbBundle.Messages(
"DataResultFilterNode.viewSourceArtifact.text=View Source Result")
293 List<Action> actionsList =
new ArrayList<>();
301 actionsList.add(null);
302 BlackboardArtifact ba = ban.getLookup().lookup(BlackboardArtifact.class);
303 final int artifactTypeID = ba.getArtifactTypeID();
305 if (artifactTypeID == BlackboardArtifact.ARTIFACT_TYPE.TSK_HASHSET_HIT.getTypeID()
306 || artifactTypeID == BlackboardArtifact.ARTIFACT_TYPE.TSK_KEYWORD_HIT.getTypeID()) {
307 if (ban.getLookup().lookup(AbstractFile.class) != null) {
311 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.viewFileInDir.text"), ban));
313 }
else if (artifactTypeID == BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_ARTIFACT_HIT.getTypeID()) {
315 actionsList.add(
new ViewSourceArtifactAction(DataResultFilterNode_viewSourceArtifact_text(), ba));
318 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.viewSrcFileInDir.text"), ban));
325 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.viewFileInDir.text"), c));
329 Content fileContent = ban.getLookup().lookup(AbstractFile.class);
330 if (fileContent == null) {
331 Content content = ban.getLookup().lookup(Content.class);
332 actionsList.add(
new ViewContextAction(
"View Source Content in Directory", content));
335 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.viewSrcFileInDir.text"), ban));
338 Content c = ban.getLookup().lookup(File.class);
342 }
else if ((c = ban.getLookup().lookup(Directory.class)) != null) {
344 }
else if ((c = ban.getLookup().lookup(VirtualDirectory.class)) != null) {
346 }
else if ((c = ban.getLookup().lookup(LocalDirectory.class)) != null) {
348 }
else if ((c = ban.getLookup().lookup(LayoutFile.class)) != null) {
350 }
else if ((c = ban.getLookup().lookup(LocalFile.class)) != null
351 || (c = ban.getLookup().lookup(DerivedFile.class)) != null) {
355 if (c.getArtifacts(BlackboardArtifact.ARTIFACT_TYPE.TSK_ENCRYPTION_DETECTED).size() > 0) {
358 }
catch (TskCoreException ex) {
359 LOGGER.log(Level.WARNING,
"Unable to add unzip with password action to context menus", ex);
362 }
else if ((c = ban.getLookup().lookup(SlackFile.class)) != null) {
364 }
else if ((c = ban.getLookup().lookup(Report.class)) != null) {
368 final Collection<AbstractFile> selectedFilesList
369 =
new HashSet<>(Utilities.actionsGlobalContext().lookupAll(AbstractFile.class));
370 actionsList.add(null);
372 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.viewInNewWin.text"), n));
373 if (selectedFilesList.size() == 1) {
375 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.openInExtViewer.text"), n));
379 actionsList.add(null);
382 actionsList.add(null);
386 if (selectedFilesList.size() == 1) {
392 actionsList.add(null);
396 final Collection<BlackboardArtifact> selectedArtifactsList
397 =
new HashSet<>(Utilities.actionsGlobalContext().lookupAll(BlackboardArtifact.class));
398 if (selectedArtifactsList.size() == 1) {
423 List<Action> actions =
new ArrayList<>();
425 for (Action action : ditem.getActions(
true)) {
433 BlackboardArtifact art = ba.getLookup().lookup(BlackboardArtifact.class);
436 for (BlackboardAttribute attr : art.getAttributes()) {
437 if (attr.getAttributeType().getTypeID() == BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PATH_ID.getTypeID()) {
438 switch (attr.getAttributeType().getValueType()) {
440 int i = attr.getValueInt();
442 c = art.getSleuthkitCase().getContentById(i);
446 long l = attr.getValueLong();
448 c = art.getSleuthkitCase().getContentById(l);
454 }
catch (TskException ex) {
455 Logger.
getLogger(this.getClass().getName()).log(Level.WARNING,
"Error getting linked file", ex);
500 Action preferredAction = ban.getPreferredAction();
501 if(preferredAction instanceof AbstractAction) {
502 return (AbstractAction) preferredAction;
507 if ((artifact.getArtifactTypeID() == ARTIFACT_TYPE.TSK_EMAIL_MSG.getTypeID())
508 || (artifact.getArtifactTypeID() == ARTIFACT_TYPE.TSK_MESSAGE.getTypeID())) {
509 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 if(sourceEm == null || sourceEm.getSelectedNodes().length == 0) {
581 final Node currentSelectionInDirectoryTree = sourceEm.getSelectedNodes()[0];
583 return new AbstractAction() {
585 public void actionPerformed(ActionEvent e) {
586 if (currentSelectionInDirectoryTree != null) {
588 final org.openide.nodes.Children children = currentSelectionInDirectoryTree.getChildren();
590 Node newSelection = children.findChild(dataModelNode.getName());
599 if (newSelection != null) {
601 sourceEm.setExploredContextAndSelection(newSelection,
new Node[]{newSelection});
602 }
catch (PropertyVetoException ex) {
604 logger.log(Level.WARNING,
"Error: can't open the selected directory.", ex);
621 if(sourceEm == null) {
625 Node[] selectedFilterNodes = sourceEm.getSelectedNodes();
626 Node selectedFilterNode = selectedFilterNodes[0];
627 final Node parentNode = selectedFilterNode.getParentNode();
629 return new AbstractAction() {
631 public void actionPerformed(ActionEvent e) {
633 sourceEm.setSelectedNodes(
new Node[]{parentNode});
634 }
catch (PropertyVetoException ex) {
636 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