IJPL-172840 Use Tree's suspend expand/collapse accessibility announcements API in the Usages tree

This fixes a crash in Find Usages (IJPL-171433)


(cherry picked from commit 70eef793231c7819b88453eb55c05a63df9142d3)

IJ-CR-151182

GitOrigin-RevId: 3afbe9798ae200508739cc3e264af8fae187323f
This commit is contained in:
Dmitry Drobotov
2024-12-09 13:41:26 +01:00
committed by intellij-monorepo-bot
parent 727fb4c760
commit 39e4a4f371

View File

@@ -317,7 +317,7 @@ public class UsageViewImpl implements UsageViewEx {
public int getId() {
return myUniqueIdentifier;
}
@ApiStatus.Internal
public JTree getTree() {
return myTree;
@@ -1138,11 +1138,21 @@ public class UsageViewImpl implements UsageViewEx {
ThreadingAssertions.assertEventDispatchThread();
//always expand the last level group
DefaultMutableTreeNode root = (DefaultMutableTreeNode)myTree.getModel().getRoot();
for (int i = root.getChildCount() - 1; i >= 0; i--) {
DefaultMutableTreeNode child = (DefaultMutableTreeNode)root.getChildAt(i);
if (child instanceof GroupNode) {
TreePath treePath = new TreePath(child.getPath());
myTree.expandPath(treePath);
try {
if (myTree instanceof Tree jbTree) {
jbTree.suspendExpandCollapseAccessibilityAnnouncements();
}
for (int i = root.getChildCount() - 1; i >= 0; i--) {
DefaultMutableTreeNode child = (DefaultMutableTreeNode)root.getChildAt(i);
if (child instanceof GroupNode) {
TreePath treePath = new TreePath(child.getPath());
myTree.expandPath(treePath);
}
}
}
finally {
if (myTree instanceof Tree jbTree) {
jbTree.resumeExpandCollapseAccessibilityAnnouncements();
}
}
myTree.getSelectionModel().clearSelection();