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.logging.Level;
29 import javax.swing.AbstractAction;
30 import org.openide.nodes.AbstractNode;
31 import org.openide.explorer.ExplorerManager;
32 import org.openide.explorer.view.TreeView;
33 import org.openide.nodes.Children;
34 import org.openide.nodes.Node;
35 import org.openide.util.NbBundle.Messages;
75 this.content = artifactNode.getLookup().lookup(AbstractFile.class);
76 if (this.content != null) {
77 AbstractFile file = (AbstractFile) content;
80 this.setEnabled(
false);
97 this.content = fileSystemContentNode.getLookup().lookup(Content.class);
124 "ViewContextAction.errorMessage.cannotFindDirectory=Failed to locate directory.",
125 "ViewContextAction.errorMessage.cannotSelectDirectory=Failed to select directory in tree.",})
127 EventQueue.invokeLater(() -> {
133 Node parentTreeViewNode = treeViewExplorerMgr.getRootContext().getChildren().findChild(
DataSourcesNode.
NAME);
141 Content parentContent = null;
143 parentContent = content.getParent();
144 }
catch (TskCoreException ex) {
146 logger.log(Level.SEVERE, String.format(
"Could not get parent of Content object: %s", content), ex);
149 if (null != parentContent) {
156 List<Content> contentBranch = parentContent.accept(ancestorVisitor);
157 Collections.reverse(contentBranch);
171 Node dummyRootNode =
new DirectoryTreeFilterNode(
new AbstractNode(
new RootContentChildren(contentBranch)),
true);
172 Children ancestorChildren = dummyRootNode.getChildren();
180 Children treeNodeChildren = parentTreeViewNode.getChildren();
181 for (
int i = 0; i < ancestorChildren.getNodesCount(); i++) {
182 Node ancestorNode = ancestorChildren.getNodeAt(i);
183 for (
int j = 0; j < treeNodeChildren.getNodesCount(); j++) {
184 Node treeNode = treeNodeChildren.getNodeAt(j);
185 if (ancestorNode.getDisplayName().equals(treeNode.getDisplayName())) {
186 parentTreeViewNode = treeNode;
187 treeNodeChildren = treeNode.getChildren();
203 TreeView treeView = treeViewTopComponent.
getTree();
204 treeView.expandNode(parentTreeViewNode);
205 if (treeViewTopComponent.
getSelectedNode().equals(parentTreeViewNode)) {
212 treeViewTopComponent.respondSelection(treeViewExplorerMgr.getSelectedNodes(),
new Node[]{parentTreeViewNode});
215 treeViewExplorerMgr.setExploredContextAndSelection(parentTreeViewNode,
new Node[]{parentTreeViewNode});
216 }
catch (PropertyVetoException ex) {
218 logger.log(Level.SEVERE,
"Failed to select the parent node in the tree view", ex);
231 List<Content> lineage =
new ArrayList<>();
235 lineage.add(content);
236 Content parent = null;
238 parent = content.getParent();
239 }
catch (TskCoreException ex) {
240 logger.log(Level.SEVERE, String.format(
"Could not get parent of Content object: %s", content), ex);
242 return parent == null ? lineage : parent.accept(
this);
246 public List<Content>
visit(VolumeSystem volumeSystem) {
256 public List<Content>
visit(FileSystem fileSystem) {
266 Content parent = null;
268 parent = content.getParent();
269 }
catch (TskCoreException ex) {
270 logger.log(Level.SEVERE, String.format(
"Could not get parent of Content object: %s", content), ex);
272 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()
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
void setChildNodeSelectionInfo(NodeSelectionInfo selectedChildNodeInfo)
static synchronized DirectoryTreeTopComponent findInstance()
List< Content > skipToParent(Content content)
static void error(String message)