19 package org.sleuthkit.autopsy.directorytree;
 
   21 import java.awt.EventQueue;
 
   22 import java.awt.event.ActionEvent;
 
   23 import java.beans.PropertyVetoException;
 
   24 import java.util.ArrayList;
 
   25 import java.util.Collections;
 
   26 import java.util.List;
 
   27 import java.util.Objects;
 
   28 import java.util.logging.Level;
 
   30 import javax.swing.AbstractAction;
 
   31 import org.openide.nodes.AbstractNode;
 
   32 import org.openide.explorer.ExplorerManager;
 
   33 import org.openide.explorer.view.TreeView;
 
   34 import org.openide.nodes.Children;
 
   35 import org.openide.nodes.Node;
 
   36 import org.openide.util.NbBundle.Messages;
 
   84         this.content = artifactNode.getLookup().lookup(Content.class);
 
   85         if (this.content != null && this.content instanceof AbstractFile) {
 
   86             AbstractFile file = (AbstractFile) content;
 
   90                 this.setEnabled(
false);
 
  107         this.content = fileSystemContentNode.getLookup().lookup(Content.class);
 
  122         this.content = abstractAbstractFileNode.getLookup().lookup(Content.class);
 
  149         "ViewContextAction.errorMessage.cannotFindDirectory=Failed to locate directory.",
 
  150         "ViewContextAction.errorMessage.cannotSelectDirectory=Failed to select directory in tree.",
 
  151         "ViewContextAction.errorMessage.cannotFindNode=Failed to locate data source node in tree." 
  154         EventQueue.invokeLater(() -> {
 
  163             Content parentContent = null;
 
  165                 parentContent = content.getParent();
 
  166             } 
catch (TskCoreException ex) {
 
  168                 logger.log(Level.SEVERE, String.format(
"Could not get parent of Content object: %s", content), ex); 
 
  177             Node parentTreeViewNode = null;
 
  180                 SleuthkitCase skCase;
 
  185                     long contentDSObjid = content.getDataSource().getId();
 
  186                     DataSource datasource = skCase.getDataSource(contentDSObjid);
 
  187                     dsname = datasource.getName();
 
  188                     Children rootChildren = treeViewExplorerMgr.getRootContext().getChildren();
 
  190                     if (null != parentContent) {
 
  197                         for (
int i = 0; i < rootChildren.getNodesCount(); i++) {
 
  199                             Node treeNode = rootChildren.getNodeAt(i);
 
  200                             if (!(treeNode.getName().equals(dsname))) {
 
  209                             if (parentTreeViewNode != null) {
 
  218                         Node datasourceGroupingNode = rootChildren.findChild(dsname);
 
  219                         if (!Objects.isNull(datasourceGroupingNode)) {
 
  220                             Children dsChildren = datasourceGroupingNode.getChildren();
 
  225                     if (parentTreeViewNode == null) {
 
  227                         logger.log(Level.SEVERE, 
"Failed to locate data source node in tree."); 
 
  232                     logger.log(Level.SEVERE, 
"Failed to locate data source node in tree.", ex); 
 
  237                 parentTreeViewNode = treeViewExplorerMgr.getRootContext().getChildren().findChild(
DataSourcesNode.
NAME);
 
  239                 if (null != parentContent) {
 
  242                     if (potentialParentTreeViewNode != null) {
 
  243                         parentTreeViewNode = potentialParentTreeViewNode;
 
  257             if (content instanceof BlackboardArtifact) {
 
  258                 BlackboardArtifact artifact = ((BlackboardArtifact) content);
 
  259                 long associatedId = artifact.getObjectID();
 
  261                     Content associatedFileContent = artifact.getSleuthkitCase().getContentById(associatedId);
 
  263                 } 
catch (TskCoreException ex) {
 
  264                     logger.log(Level.SEVERE, 
"Could not find associated content from artifact with id %d", artifact.getId());
 
  268             TreeView treeView = treeViewTopComponent.getTree();
 
  269             treeView.expandNode(parentTreeViewNode);
 
  270             if (treeViewTopComponent.
getSelectedNode().equals(parentTreeViewNode)) {
 
  277                 treeViewTopComponent.respondSelection(treeViewExplorerMgr.getSelectedNodes(), 
new Node[]{parentTreeViewNode});
 
  280                     treeViewExplorerMgr.setExploredContextAndSelection(parentTreeViewNode, 
new Node[]{parentTreeViewNode});
 
  281                 } 
catch (PropertyVetoException ex) {
 
  283                     logger.log(Level.SEVERE, 
"Failed to select the parent node in the tree view", ex); 
 
  304         List<Content> contentBranch = parentContent.accept(ancestorVisitor);
 
  305         Collections.reverse(contentBranch);
 
  318         Node dummyRootNode = 
new DirectoryTreeFilterNode(
new AbstractNode(
new RootContentChildren(contentBranch)), 
true);
 
  319         Children ancestorChildren = dummyRootNode.getChildren();
 
  327         Children treeNodeChildren = node.getChildren();
 
  328         Node parentTreeViewNode = null;
 
  329         for (
int i = 0; i < ancestorChildren.getNodesCount(); i++) {
 
  330             Node ancestorNode = ancestorChildren.getNodeAt(i);
 
  331             for (
int j = 0; j < treeNodeChildren.getNodesCount(); j++) {
 
  332                 Node treeNode = treeNodeChildren.getNodeAt(j);
 
  333                 if (ancestorNode.getName().equals(treeNode.getName())) {
 
  334                     parentTreeViewNode = treeNode;
 
  335                     treeNodeChildren = treeNode.getChildren();
 
  340         return parentTreeViewNode;
 
  350         List<Content> lineage = 
new ArrayList<>();
 
  354             lineage.add(content);
 
  355             Content parent = null;
 
  357                 parent = content.getParent();
 
  358             } 
catch (TskCoreException ex) {
 
  359                 logger.log(Level.SEVERE, String.format(
"Could not get parent of Content object: %s", content), ex); 
 
  361             return parent == null ? lineage : parent.accept(
this);
 
  365         public List<Content> 
visit(VolumeSystem volumeSystem) {
 
  375         public List<Content> 
visit(FileSystem fileSystem) {
 
  385             Content parent = null;
 
  387                 parent = content.getParent();
 
  388             } 
catch (TskCoreException ex) {
 
  389                 logger.log(Level.SEVERE, String.format(
"Could not get parent of Content object: %s", content), ex); 
 
  391             return parent == null ? lineage : parent.accept(
this);
 
void setDirectoryListingActive()
 
static boolean hideSlackFilesInDataSourcesTree()
 
ViewContextAction(String displayName, Content content)
 
ViewContextAction(String displayName, BlackboardArtifactNode artifactNode)
 
ViewContextAction(String displayName, AbstractFsContentNode<?extends AbstractFile > fileSystemContentNode)
 
Node findParentNodeInTree(Content parentContent, Node node)
 
static final long serialVersionUID
 
List< Content > visit(VolumeSystem volumeSystem)
 
ExplorerManager getExplorerManager()
 
SleuthkitCase getSleuthkitCase()
 
ViewContextAction(String displayName, AbstractAbstractFileNode<?extends AbstractFile > abstractAbstractFileNode)
 
static Boolean getGroupItemsInTreeByDataSource()
 
void actionPerformed(ActionEvent event)
 
List< Content > defaultVisit(Content content)
 
List< Content > visit(FileSystem fileSystem)
 
static boolean hideKnownFilesInDataSourcesTree()
 
synchronized static Logger getLogger(String name)
 
static final Logger logger
 
static Case getCurrentCaseThrows()
 
void setChildNodeSelectionInfo(NodeSelectionInfo selectedChildNodeInfo)
 
static synchronized DirectoryTreeTopComponent findInstance()
 
List< Content > skipToParent(Content content)
 
static void error(String message)