public void removeWatch(DebuggerTreeNodeImpl node) { ApplicationManager.getApplication().assertIsDispatchThread(); LOG.assertTrue(node.getDescriptor() instanceof WatchItemDescriptor); DebuggerTreeNodeImpl root = (DebuggerTreeNodeImpl) getModel().getRoot(); DebuggerTreeNodeImpl nodeToSelect = (DebuggerTreeNodeImpl) node.getNextSibling(); getMutableModel().removeNodeFromParent(node); treeChanged(); if (nodeToSelect == null && root.getChildCount() > 0) { nodeToSelect = (DebuggerTreeNodeImpl) root.getChildAt(root.getChildCount() - 1); } if (nodeToSelect != null) { setSelectionPath(new TreePath(nodeToSelect.getPath())); } }