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;
82 this.content = artifactNode.getLookup().lookup(AbstractFile.class);
83 if (this.content != null) {
84 AbstractFile file = (AbstractFile) content;
87 this.setEnabled(
false);
104 this.content = fileSystemContentNode.getLookup().lookup(Content.class);
131 "ViewContextAction.errorMessage.cannotFindDirectory=Failed to locate directory.",
132 "ViewContextAction.errorMessage.cannotSelectDirectory=Failed to select directory in tree.",
133 "ViewContextAction.errorMessage.cannotFindNode=Failed to locate data source node in tree."
136 EventQueue.invokeLater(() -> {
142 Node parentTreeViewNode;
145 SleuthkitCase skCase;
150 long contentDSObjid = content.getDataSource().getId();
151 DataSource datasource = skCase.getDataSource(contentDSObjid);
152 dsname = datasource.getName();
154 Children rootChildren = treeViewExplorerMgr.getRootContext().getChildren();
155 Node datasourceGroupingNode = rootChildren.findChild(dsname);
156 if (! Objects.isNull(datasourceGroupingNode) ) {
157 Children dsChildren = datasourceGroupingNode.getChildren();
162 logger.log(Level.SEVERE,
"Failed to locate data source node in tree.");
167 logger.log(Level.SEVERE,
"Failed to locate data source node in tree.", ex);
172 parentTreeViewNode = treeViewExplorerMgr.getRootContext().getChildren().findChild(
DataSourcesNode.
NAME);
182 Content parentContent = null;
184 parentContent = content.getParent();
185 }
catch (TskCoreException ex) {
187 logger.log(Level.SEVERE, String.format(
"Could not get parent of Content object: %s", content), ex);
190 if (null != parentContent) {
197 List<Content> contentBranch = parentContent.accept(ancestorVisitor);
198 Collections.reverse(contentBranch);
212 Node dummyRootNode =
new DirectoryTreeFilterNode(
new AbstractNode(
new RootContentChildren(contentBranch)),
true);
213 Children ancestorChildren = dummyRootNode.getChildren();
221 Children treeNodeChildren = parentTreeViewNode.getChildren();
222 for (
int i = 0; i < ancestorChildren.getNodesCount(); i++) {
223 Node ancestorNode = ancestorChildren.getNodeAt(i);
224 for (
int j = 0; j < treeNodeChildren.getNodesCount(); j++) {
225 Node treeNode = treeNodeChildren.getNodeAt(j);
226 if (ancestorNode.getDisplayName().equals(treeNode.getDisplayName())) {
227 parentTreeViewNode = treeNode;
228 treeNodeChildren = treeNode.getChildren();
244 TreeView treeView = treeViewTopComponent.
getTree();
245 treeView.expandNode(parentTreeViewNode);
246 if (treeViewTopComponent.
getSelectedNode().equals(parentTreeViewNode)) {
253 treeViewTopComponent.respondSelection(treeViewExplorerMgr.getSelectedNodes(),
new Node[]{parentTreeViewNode});
256 treeViewExplorerMgr.setExploredContextAndSelection(parentTreeViewNode,
new Node[]{parentTreeViewNode});
257 }
catch (PropertyVetoException ex) {
259 logger.log(Level.SEVERE,
"Failed to select the parent node in the tree view", ex);
272 List<Content> lineage =
new ArrayList<>();
276 lineage.add(content);
277 Content parent = null;
279 parent = content.getParent();
280 }
catch (TskCoreException ex) {
281 logger.log(Level.SEVERE, String.format(
"Could not get parent of Content object: %s", content), ex);
283 return parent == null ? lineage : parent.accept(
this);
287 public List<Content>
visit(VolumeSystem volumeSystem) {
297 public List<Content>
visit(FileSystem fileSystem) {
307 Content parent = null;
309 parent = content.getParent();
310 }
catch (TskCoreException ex) {
311 logger.log(Level.SEVERE, String.format(
"Could not get parent of Content object: %s", content), ex);
313 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)
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)