use of com.intellij.ide.hierarchy.HierarchyBrowserManager in project intellij-community by JetBrains.
the class BrowseHierarchyActionBase method createAndAddToPanel.
@NotNull
public static HierarchyBrowser createAndAddToPanel(@NotNull Project project, @NotNull final HierarchyProvider provider, @NotNull PsiElement target) {
HierarchyBrowser hierarchyBrowser = provider.createHierarchyBrowser(target);
final Content content;
HierarchyBrowserManager hierarchyBrowserManager = HierarchyBrowserManager.getInstance(project);
final ContentManager contentManager = hierarchyBrowserManager.getContentManager();
final Content selectedContent = contentManager.getSelectedContent();
if (selectedContent != null && !selectedContent.isPinned()) {
content = selectedContent;
final Component component = content.getComponent();
if (component instanceof Disposable) {
Disposer.dispose((Disposable) component);
}
content.setComponent(hierarchyBrowser.getComponent());
} else {
content = ContentFactory.SERVICE.getInstance().createContent(hierarchyBrowser.getComponent(), null, true);
contentManager.addContent(content);
}
contentManager.setSelectedContent(content);
hierarchyBrowser.setContent(content);
final Runnable runnable = () -> {
if (hierarchyBrowser instanceof HierarchyBrowserBase && ((HierarchyBrowserBase) hierarchyBrowser).isDisposed()) {
return;
}
provider.browserActivated(hierarchyBrowser);
};
ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.HIERARCHY).activate(runnable);
return hierarchyBrowser;
}
Aggregations