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;
82 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);
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);
262 BlackboardArtifact art = key.getLookup().lookup(BlackboardArtifact.class);
265 && art.getArtifactTypeID() != BlackboardArtifact.ARTIFACT_TYPE.TSK_EMAIL_MSG.getTypeID()
266 && art.getArtifactTypeID() != BlackboardArtifact.ARTIFACT_TYPE.TSK_MESSAGE.getTypeID()) {
274 @NbBundle.Messages(
"DataResultFilterNode.viewSourceArtifact.text=View Source Result")
288 List<Action> actionsList =
new ArrayList<>();
294 BlackboardArtifact ba = ban.getLookup().lookup(BlackboardArtifact.class);
295 final int artifactTypeID = ba.getArtifactTypeID();
297 if (artifactTypeID == BlackboardArtifact.ARTIFACT_TYPE.TSK_HASHSET_HIT.getTypeID()
298 || artifactTypeID == BlackboardArtifact.ARTIFACT_TYPE.TSK_KEYWORD_HIT.getTypeID()) {
299 if (ban.getLookup().lookup(AbstractFile.class) != null) {
303 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.viewFileInDir.text"), ban));
305 }
else if (artifactTypeID == BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_ARTIFACT_HIT.getTypeID()) {
307 actionsList.add(
new ViewSourceArtifactAction(DataResultFilterNode_viewSourceArtifact_text(), ba));
310 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.viewSrcFileInDir.text"), ban));
317 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.viewFileInDir.text"), c));
321 Content fileContent = ban.getLookup().lookup(AbstractFile.class);
322 if (fileContent == null) {
323 Content content = ban.getLookup().lookup(Content.class);
324 actionsList.add(
new ViewContextAction(
"View Source Content in Directory", content));
327 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.viewSrcFileInDir.text"), ban));
330 Content c = ban.getLookup().lookup(File.class);
334 }
else if ((c = ban.getLookup().lookup(Directory.class)) != null) {
336 }
else if ((c = ban.getLookup().lookup(VirtualDirectory.class)) != null) {
338 }
else if ((c = ban.getLookup().lookup(LocalDirectory.class)) != null) {
340 }
else if ((c = ban.getLookup().lookup(LayoutFile.class)) != null) {
342 }
else if ((c = ban.getLookup().lookup(LocalFile.class)) != null
343 || (c = ban.getLookup().lookup(DerivedFile.class)) != null) {
347 if (c.getArtifacts(BlackboardArtifact.ARTIFACT_TYPE.TSK_ENCRYPTION_DETECTED).size() > 0) {
350 }
catch (TskCoreException ex) {
351 LOGGER.log(Level.WARNING,
"Unable to add unzip with password action to context menus", ex);
354 }
else if ((c = ban.getLookup().lookup(SlackFile.class)) != null) {
356 }
else if ((c = ban.getLookup().lookup(Report.class)) != null) {
360 final Collection<AbstractFile> selectedFilesList
361 =
new HashSet<>(Utilities.actionsGlobalContext().lookupAll(AbstractFile.class));
362 actionsList.add(null);
364 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.viewInNewWin.text"), n));
365 if (selectedFilesList.size() == 1) {
367 NbBundle.getMessage(
this.getClass(),
"DataResultFilterNode.action.openInExtViewer.text"), n));
371 actionsList.add(null);
374 actionsList.add(null);
378 if (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) {
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