19 package org.sleuthkit.autopsy.directorytree;
21 import java.awt.event.ActionEvent;
22 import javax.swing.AbstractAction;
23 import org.openide.explorer.ExplorerManager;
24 import org.openide.explorer.view.BeanTreeView;
25 import org.openide.nodes.Children;
26 import org.openide.nodes.Node;
33 class CollapseAction
extends AbstractAction {
35 CollapseAction(String title) {
40 public void actionPerformed(ActionEvent e) {
41 ExplorerManager em = DirectoryTreeTopComponent.findInstance().getExplorerManager();
42 Node[] selectedNode = em.getSelectedNodes();
46 BeanTreeView tree = DirectoryTreeTopComponent.findInstance().getTree();
47 if(selectedNode.length != 0) {
48 collapseSelectedNode(tree, selectedNode[0]);
52 for(Node childOfRoot: em.getRootContext().getChildren().getNodes())
53 collapseSelectedNode(tree, childOfRoot);
63 private void collapseSelectedNode(BeanTreeView tree, Node currentNode) {
65 Children c = currentNode.getChildren();
67 for (Node next : c.getNodes()) {
68 if (tree.isExpanded(next)) {
69 this.collapseSelectedNode(tree, next);
73 tree.collapseNode(currentNode);