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;
32 class CollapseAction
extends AbstractAction {
34 CollapseAction(String title) {
39 public void actionPerformed(ActionEvent e) {
40 ExplorerManager em = DirectoryTreeTopComponent.findInstance().getExplorerManager();
41 Node[] selectedNode = em.getSelectedNodes();
44 BeanTreeView tree = DirectoryTreeTopComponent.findInstance().getTree();
45 if (selectedNode.length != 0) {
46 collapseSelectedNode(tree, selectedNode[0]);
50 for (Node childOfRoot : em.getRootContext().getChildren().getNodes()) {
51 collapseSelectedNode(tree, childOfRoot);
62 private void collapseSelectedNode(BeanTreeView tree, Node currentNode) {
64 Children c = currentNode.getChildren();
66 for (Node next : c.getNodes()) {
67 if (tree.isExpanded(next)) {
68 this.collapseSelectedNode(tree, next);
72 tree.collapseNode(currentNode);