private void restorePath(ArrayList<Object> newPath, int idx) { if (idx >= myPath.length) return; InspectionTreeNode oldNode = (InspectionTreeNode) myPath[idx]; InspectionTreeNode newRoot = (InspectionTreeNode) newPath.get(idx - 1); InspectionResultsViewComparator comparator = InspectionResultsViewComparator.getInstance(); Enumeration children = newRoot.children(); while (children.hasMoreElements()) { InspectionTreeNode child = (InspectionTreeNode) children.nextElement(); if (comparator.compare(child, oldNode) == 0) { newPath.add(child); restorePath(newPath, idx + 1); return; } } // Exactly same element not found. Trying to select somewhat near. int count = newRoot.getChildCount(); if (count > 0) { if (myIndicies[idx] < count) { newPath.add(newRoot.getChildAt(myIndicies[idx])); } else { newPath.add(newRoot.getChildAt(count - 1)); } } }
private static void traverseDescriptors( InspectionTreeNode node, LinkedHashSet<CommonProblemDescriptor> descriptors) { if (node instanceof ProblemDescriptionNode) { descriptors.add(((ProblemDescriptionNode) node).getDescriptor()); } for (int i = node.getChildCount() - 1; i >= 0; i--) { traverseDescriptors((InspectionTreeNode) node.getChildAt(i), descriptors); } }
@Override public void treeWillExpand(TreeExpansionEvent event) throws ExpandVetoException { final InspectionTreeNode node = (InspectionTreeNode) event.getPath().getLastPathComponent(); final Object userObject = node.getUserObject(); // TODO: never re-sort if (node.isValid() && !myExpandedUserObjects.contains(userObject)) { sortChildren(node); nodeStructureChanged(node); } myExpandedUserObjects.add(userObject); // Smart expand if (node.getChildCount() == 1) { ApplicationManager.getApplication() .invokeLater( new Runnable() { @Override public void run() { expandPath(new TreePath(node.getPath())); } }); } }