From 0f40c5d1bcb908b1c8938e6754f4dd3e79444591 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Fri, 17 Mar 2017 17:59:13 +0300 Subject: [PATCH] sometimes the usage view component is invisible, re-fixes IDEA-169722 "Analyze dependencies" bottom tree is empty --- .../com/intellij/packageDependencies/ui/UsagesPanel.java | 2 -- .../src/com/intellij/usages/impl/UsageViewImpl.java | 7 +++++-- 2 files changed, 5 insertions(+), 4 deletions(-) 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