void (@NotNull TreeExpansionEvent e) { dropUpdaterStateIfExternalChange(); TreePath path = e.getPath(); DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent(); NodeDescriptor<?> descriptor = getDescriptorFrom(node); if (descriptor == null) return; TreePath pathToSelect = null; if (isSelectionInside(node)) { pathToSelect = new TreePath(node.getPath()); } if (getBuilder().isDisposeOnCollapsing(descriptor)) { runDone(new TreeRunnable("AbstractTreeUi.MyExpansionListener.treeCollapsed") { @Override public void perform() { if (isDisposed(node)) return; TreePath nodePath = new TreePath(node.getPath()); if (myTree.isExpanded(nodePath)) return; removeChildren(node); makeLoadingOrLeafIfNoChildren(node); } }); if (node.equals(getRootNode())) { if (myTree.isRootVisible()) { //todo kirillk to investigate -- should be done by standard selction move //addSelectionPath(new TreePath(getRootNode().getPath()), true, Condition.FALSE); } } else { myTreeModel.reload(node); } } if (pathToSelect != null && myTree.isSelectionEmpty()) { addSelectionPath(pathToSelect, true, Conditions.alwaysFalse(), null); } }