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.concurrent.ExecutionException;
28 import java.util.logging.Level;
30 import javax.swing.AbstractAction;
31 import javax.swing.SwingWorker;
32 import org.openide.nodes.AbstractNode;
33 import org.openide.explorer.ExplorerManager;
34 import org.openide.explorer.view.TreeView;
35 import org.openide.nodes.Children;
36 import org.openide.nodes.Node;
66 this.content = node.getLookup().lookup(
Content.class);
72 this.content = node.getLookup().lookup(
Content.class);
82 EventQueue.invokeLater(
new Runnable() {
88 List<Content> hierarchy = content.
accept(vtor);
89 Collections.reverse(hierarchy);
91 Node generated =
new DirectoryTreeFilterNode(
new AbstractNode(
new RootContentChildren(hierarchy)),
true);
92 Children genChilds = generated.getChildren();
95 TreeView dirTreeView = dirTree.
getTree();
97 Node dirTreeRootNode = dirTreeExplorerManager.getRootContext();
98 Children dirChilds = dirTreeRootNode.getChildren();
101 Node dirExplored = null;
104 for (
int i = 0; i < genChilds.getNodesCount() - 1; i++) {
105 Node currentGeneratedNode = genChilds.getNodeAt(i);
106 for (
int j = 0; j < currentChildren.getNodesCount(); j++) {
107 Node currentDirectoryTreeNode = currentChildren.getNodeAt(j);
108 if (currentGeneratedNode.getDisplayName().equals(currentDirectoryTreeNode.getDisplayName())) {
109 dirExplored = currentDirectoryTreeNode;
110 dirTreeView.expandNode(dirExplored);
111 currentChildren = currentDirectoryTreeNode.getChildren();
120 if (dirExplored != null) {
121 dirTreeView.expandNode(dirExplored);
122 dirTreeExplorerManager.setExploredContextAndSelection(dirExplored,
new Node[]{dirExplored});
124 }
catch (PropertyVetoException ex) {
125 logger.log(Level.WARNING,
"Couldn't set selected node", ex);
129 EventQueue.invokeLater(
new Runnable() {
133 Node currentRootNodeOfDataResultTC = dataResultTC.
getRootNode();
135 new SelectionWorker(dataResultTC, contentNode.getName(), currentRootNodeOfDataResultTC).execute();
150 String nameOfNodeToSelect;
151 Node originalRootNodeOfDataResultTC;
154 this.dataResultTC = dataResult;
155 this.nameOfNodeToSelect = nameToSelect;
156 this.originalRootNodeOfDataResultTC = originalRoot;
167 return originalRootNodeOfDataResultTC.getChildren().getNodes(
true);
172 Node[] nodesDisplayedInDataResultViewer;
174 nodesDisplayedInDataResultViewer =
get();
175 }
catch (InterruptedException | ExecutionException ex) {
176 logger.log(Level.WARNING,
"Failed to get nodes in selection worker.", ex);
180 catch (java.util.concurrent.CancellationException ex ) {
190 if (dataResultTC.
getRootNode().equals(originalRootNodeOfDataResultTC) ==
false) {
197 for (Node node : nodesDisplayedInDataResultViewer) {
198 if (nameOfNodeToSelect.equals(node.getName())) {
199 dataResultTC.requestActive();
220 List<Content> ret =
new ArrayList<Content>();
227 logger.log(Level.WARNING,
"Couldn't get parent of Content object: " + content);
229 return parent == null ? ret : parent.
accept(
this);
239 logger.log(Level.WARNING,
"Couldn't get parent of Content object: " + content);
241 return parent == null ? ret : parent.
accept(
this);
DataResultTopComponent getDirectoryListing()
ViewContextAction(String title, BlackboardArtifactNode node)
List< Content > visit(FileSystem fs)
static synchronized DirectoryTreeTopComponent getDefault()
ViewContextAction(String title, Content content)
ViewContextAction(String title, AbstractFsContentNode<?extends AbstractFile > node)
ExplorerManager getExplorerManager()
static final Logger logger
public< T > T accept(ContentVisitor< T > v)
List< Content > defaultVisit(Content content)
void actionPerformed(ActionEvent e)
void setSelectedNodes(Node[] selected)
static synchronized DirectoryTreeTopComponent findInstance()
static Logger getLogger(String name)
List< Content > visit(VolumeSystem vs)
List< Content > visitParentButDontAddMe(Content content)