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;
 
   83         this.content = artifactNode.getLookup().lookup(Content.class);
 
   84         if (this.content != null && this.content instanceof AbstractFile) {
 
   85             AbstractFile file = (AbstractFile) content;
 
   89                 this.setEnabled(
false);
 
  106         this.content = fileSystemContentNode.getLookup().lookup(Content.class);
 
  133         "ViewContextAction.errorMessage.cannotFindDirectory=Failed to locate directory.",
 
  134         "ViewContextAction.errorMessage.cannotSelectDirectory=Failed to select directory in tree.",
 
  135         "ViewContextAction.errorMessage.cannotFindNode=Failed to locate data source node in tree." 
  138         EventQueue.invokeLater(() -> {
 
  144             Node parentTreeViewNode;
 
  147                 SleuthkitCase skCase;
 
  152                     long contentDSObjid = content.getDataSource().getId();
 
  153                     DataSource datasource = skCase.getDataSource(contentDSObjid);
 
  154                     dsname = datasource.getName();
 
  156                     Children rootChildren = treeViewExplorerMgr.getRootContext().getChildren();
 
  157                     Node datasourceGroupingNode = rootChildren.findChild(dsname);
 
  158                     if (!Objects.isNull(datasourceGroupingNode)) {
 
  159                         Children dsChildren = datasourceGroupingNode.getChildren();
 
  163                         logger.log(Level.SEVERE, 
"Failed to locate data source node in tree."); 
 
  168                     logger.log(Level.SEVERE, 
"Failed to locate data source node in tree.", ex); 
 
  173                 parentTreeViewNode = treeViewExplorerMgr.getRootContext().getChildren().findChild(
DataSourcesNode.
NAME);
 
  183             Content parentContent = null;
 
  186                 parentContent = content.getParent();
 
  187             } 
catch (TskCoreException ex) {
 
  189                 logger.log(Level.SEVERE, String.format(
"Could not get parent of Content object: %s", content), ex); 
 
  192             if (null != parentContent) {
 
  199                 List<Content> contentBranch = parentContent.accept(ancestorVisitor);
 
  200                 Collections.reverse(contentBranch);
 
  214                 Node dummyRootNode = 
new DirectoryTreeFilterNode(
new AbstractNode(
new RootContentChildren(contentBranch)), 
true);
 
  215                 Children ancestorChildren = dummyRootNode.getChildren();
 
  223                 Children treeNodeChildren = parentTreeViewNode.getChildren();
 
  224                 for (
int i = 0; i < ancestorChildren.getNodesCount(); i++) {
 
  225                     Node ancestorNode = ancestorChildren.getNodeAt(i);
 
  226                     for (
int j = 0; j < treeNodeChildren.getNodesCount(); j++) {
 
  227                         Node treeNode = treeNodeChildren.getNodeAt(j);
 
  228                         if (ancestorNode.getName().equals(treeNode.getName())) {
 
  229                             parentTreeViewNode = treeNode;
 
  230                             treeNodeChildren = treeNode.getChildren();
 
  246             if (content instanceof BlackboardArtifact) {
 
  247                 BlackboardArtifact artifact = ((BlackboardArtifact) content);
 
  248                 long associatedId = artifact.getObjectID();
 
  250                     Content associatedFileContent = artifact.getSleuthkitCase().getContentById(associatedId);
 
  252                 } 
catch (TskCoreException ex) {
 
  253                     logger.log(Level.SEVERE, 
"Could not find associated content from artifact with id %d", artifact.getId());
 
  257             TreeView treeView = treeViewTopComponent.
getTree();
 
  258             treeView.expandNode(parentTreeViewNode);
 
  259             if (treeViewTopComponent.
getSelectedNode().equals(parentTreeViewNode)) {
 
  266                 treeViewTopComponent.respondSelection(treeViewExplorerMgr.getSelectedNodes(), 
new Node[]{parentTreeViewNode});
 
  269                     treeViewExplorerMgr.setExploredContextAndSelection(parentTreeViewNode, 
new Node[]{parentTreeViewNode});
 
  270                 } 
catch (PropertyVetoException ex) {
 
  272                     logger.log(Level.SEVERE, 
"Failed to select the parent node in the tree view", ex); 
 
  285         List<Content> lineage = 
new ArrayList<>();
 
  289             lineage.add(content);
 
  290             Content parent = null;
 
  292                 parent = content.getParent();
 
  293             } 
catch (TskCoreException ex) {
 
  294                 logger.log(Level.SEVERE, String.format(
"Could not get parent of Content object: %s", content), ex); 
 
  296             return parent == null ? lineage : parent.accept(
this);
 
  300         public List<Content> 
visit(VolumeSystem volumeSystem) {
 
  310         public List<Content> 
visit(FileSystem fileSystem) {
 
  320             Content parent = null;
 
  322                 parent = content.getParent();
 
  323             } 
catch (TskCoreException ex) {
 
  324                 logger.log(Level.SEVERE, String.format(
"Could not get parent of Content object: %s", content), ex); 
 
  326             return parent == null ? lineage : parent.accept(
this);
 
void setDirectoryListingActive()
ExpansionBeanTreeView getTree()
static boolean hideSlackFilesInDataSourcesTree()
ViewContextAction(String displayName, Content content)
ViewContextAction(String displayName, BlackboardArtifactNode artifactNode)
ViewContextAction(String displayName, AbstractFsContentNode<?extends AbstractFile > fileSystemContentNode)
static final long serialVersionUID
List< Content > visit(VolumeSystem volumeSystem)
ExplorerManager getExplorerManager()
SleuthkitCase getSleuthkitCase()
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)