use of com.intellij.ide.hierarchy.HierarchyBrowserBase 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;
}
use of com.intellij.ide.hierarchy.HierarchyBrowserBase in project intellij-community by JetBrains.
the class PredefinedSearchScopeProviderImpl method addHierarchyScope.
private static void addHierarchyScope(@NotNull Project project, Collection<SearchScope> result) {
final ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.HIERARCHY);
if (toolWindow == null) {
return;
}
final ContentManager contentManager = toolWindow.getContentManager();
final Content content = contentManager.getSelectedContent();
if (content == null) {
return;
}
final String name = content.getDisplayName();
final JComponent component = content.getComponent();
if (!(component instanceof HierarchyBrowserBase)) {
return;
}
final HierarchyBrowserBase hierarchyBrowserBase = (HierarchyBrowserBase) component;
final PsiElement[] elements = hierarchyBrowserBase.getAvailableElements();
if (elements.length > 0) {
result.add(new LocalSearchScope(elements, "Hierarchy '" + name + "' (visible nodes only)"));
}
}
Aggregations