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(Content.class);
76 if (content instanceof AbstractFile) {
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.",
128 EventQueue.invokeLater(() -> {
134 Node parentTreeViewNode = treeViewExplorerMgr.getRootContext().getChildren().findChild(
DataSourcesNode.
NAME);
143 Content parentContent = null;
145 parentContent = content.getParent();
146 }
catch (TskCoreException ex) {
148 logger.log(Level.SEVERE, String.format(
"Could not get parent of Content object: %s", content), ex);
151 if (null != parentContent) {
158 List<Content> contentBranch = parentContent.accept(ancestorVisitor);
159 Collections.reverse(contentBranch);
173 Node dummyRootNode =
new DirectoryTreeFilterNode(
new AbstractNode(
new RootContentChildren(contentBranch)),
true);
174 Children ancestorChildren = dummyRootNode.getChildren();
182 Children treeNodeChildren = parentTreeViewNode.getChildren();
183 for (
int i = 0; i < ancestorChildren.getNodesCount(); i++) {
184 Node ancestorNode = ancestorChildren.getNodeAt(i);
185 for (
int j = 0; j < treeNodeChildren.getNodesCount(); j++) {
186 Node treeNode = treeNodeChildren.getNodeAt(j);
187 if (ancestorNode.getDisplayName().equals(treeNode.getDisplayName())) {
188 parentTreeViewNode = treeNode;
189 treeNodeChildren = treeNode.getChildren();
205 TreeView treeView = treeViewTopComponent.
getTree();
206 treeView.expandNode(parentTreeViewNode);
208 treeViewExplorerMgr.setExploredContextAndSelection(parentTreeViewNode,
new Node[]{parentTreeViewNode});
209 }
catch (PropertyVetoException ex) {
211 logger.log(Level.SEVERE,
"Failed to select the parent node in the tree view", ex);
223 List<Content> lineage =
new ArrayList<>();
227 lineage.add(content);
228 Content parent = null;
230 parent = content.getParent();
231 }
catch (TskCoreException ex) {
232 logger.log(Level.SEVERE, String.format(
"Could not get parent of Content object: %s", content), ex);
234 return parent == null ? lineage : parent.accept(
this);
238 public List<Content>
visit(VolumeSystem volumeSystem) {
248 public List<Content>
visit(FileSystem fileSystem) {
258 Content parent = null;
260 parent = content.getParent();
261 }
catch (TskCoreException ex) {
262 logger.log(Level.SEVERE, String.format(
"Could not get parent of Content object: %s", content), ex);
264 return parent == null ? lineage : parent.accept(
this);
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)