diff --git a/platform/lang-impl/src/com/intellij/packageDependencies/ui/UsagesPanel.java b/platform/lang-impl/src/com/intellij/packageDependencies/ui/UsagesPanel.java index 29976508e197..bde049e74eb9 100644 --- a/platform/lang-impl/src/com/intellij/packageDependencies/ui/UsagesPanel.java +++ b/platform/lang-impl/src/com/intellij/packageDependencies/ui/UsagesPanel.java @@ -28,7 +28,6 @@ import com.intellij.openapi.util.Disposer; import com.intellij.psi.PsiElement; import com.intellij.usageView.UsageInfo; import com.intellij.usages.*; -import com.intellij.usages.impl.UsageViewImpl; import com.intellij.util.Alarm; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -75,7 +74,6 @@ public abstract class UsagesPanel extends JPanel implements Disposable, DataProv UsageViewPresentation presentation = new UsageViewPresentation(); presentation.setCodeUsagesString(getCodeUsagesString()); myCurrentUsageView = UsageViewManager.getInstance(myProject).createUsageView(UsageTarget.EMPTY_ARRAY, usages, presentation, null); - ((UsageViewImpl)myCurrentUsageView).expandAll(); setToComponent(myCurrentUsageView.getComponent()); } catch (ProcessCanceledException e) { diff --git a/platform/usageView/src/com/intellij/usages/impl/UsageViewImpl.java b/platform/usageView/src/com/intellij/usages/impl/UsageViewImpl.java index b1f237ee9d83..fee94e7dac1f 100644 --- a/platform/usageView/src/com/intellij/usages/impl/UsageViewImpl.java +++ b/platform/usageView/src/com/intellij/usages/impl/UsageViewImpl.java @@ -249,7 +249,10 @@ public class UsageViewImpl implements UsageView { toolWindowPanel.setContent(myCentralPanel); myTree.setCellRenderer(myUsageViewTreeCellRenderer); - collapseAll(); + SwingUtilities.invokeLater(() -> { + if (isDisposed || myProject.isDisposed()) return; + collapseAll(); + }); myModelTracker.addListener(isPropertyChange-> { if (!isPropertyChange) { @@ -945,7 +948,7 @@ public class UsageViewImpl implements UsageView { void expandRoot() { ApplicationManager.getApplication().assertIsDispatchThread(); fireEvents(); - myTree.expandPath(new TreePath(myTree.getModel().getRoot())); + TreeUtil.expand(myTree, 1); } @NotNull