[dependencies] ensure usages tree is not treated as empty (IDEA-200110; IDEA-222840)

GitOrigin-RevId: 01739e09f79e424d2d9b43e32a37462ff6a0ffe2
This commit is contained in:
Anna Kozlova
2022-07-20 13:48:51 +00:00
committed by intellij-monorepo-bot
parent 6356f95be3
commit 30c49600aa
2 changed files with 10 additions and 6 deletions
@@ -1,4 +1,4 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.packageDependencies.ui;
import com.intellij.CommonBundle;
@@ -133,7 +133,10 @@ public final class DependenciesPanel extends JPanel implements Disposable, DataP
splitter.setFirstComponent(treeSplitter);
splitter.setSecondComponent(myUsagesPanel);
add(splitter, BorderLayout.CENTER);
add(createToolbar(), BorderLayout.NORTH);
ActionToolbar toolbar = createToolbar();
toolbar.setTargetComponent(treeSplitter);
add(toolbar.getComponent(), BorderLayout.NORTH);
myRightTreeExpansionMonitor = PackageTreeExpansionMonitor.install(myRightTree, myProject);
myLeftTreeExpansionMonitor = PackageTreeExpansionMonitor.install(myLeftTree, myProject);
@@ -277,7 +280,7 @@ public final class DependenciesPanel extends JPanel implements Disposable, DataP
}
}
private JComponent createToolbar() {
private @NotNull ActionToolbar createToolbar() {
DefaultActionGroup group = new DefaultActionGroup();
group.add(new CloseAction());
group.add(new RerunAction(this));
@@ -298,8 +301,7 @@ public final class DependenciesPanel extends JPanel implements Disposable, DataP
group.add(new EditDependencyRulesAction());
group.add(CommonActionsManager.getInstance().createExportToTextFileAction(new DependenciesExporterToTextFile()));
ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar("PackageDependencies", group, true);
return toolbar.getComponent();
return ActionManager.getInstance().createActionToolbar("PackageDependencies", group, true);
}
@NotNull
@@ -1,4 +1,4 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.packageDependencies.ui;
import com.intellij.codeInsight.CodeInsightBundle;
@@ -15,6 +15,7 @@ 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.Nls;
import org.jetbrains.annotations.NonNls;
@@ -61,6 +62,7 @@ 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).expandRoot();
setToComponent(myCurrentUsageView.getComponent());
}
catch (ProcessCanceledException e) {