void (TreeExpansionEvent event) { final Object[] path = event.getPath().getPath(); if (path.length == 2 && path[1] instanceof DefaultMutableTreeNode) { // the top node has been expanded => watch disk recursively final Object userObject = ((DefaultMutableTreeNode)path[1]).getUserObject(); if (userObject instanceof FileNodeDescriptor) { final VirtualFile file = ((FileNodeDescriptor)userObject).getElement().getFile(); if (file != null && file.isDirectory()) { final String rootPath = file.getPath(); if (myRequests.get(rootPath) == null) { final LocalFileSystem.WatchRequest watchRequest = LocalFileSystem.getInstance().addRootToWatch(rootPath, true); if (watchRequest != null) { myRequests.put(rootPath, watchRequest); } } } } } }