Search in sources :

Example 1 with HierarchyBrowserBase

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;
}
Also used : Disposable(com.intellij.openapi.Disposable) Content(com.intellij.ui.content.Content) ContentManager(com.intellij.ui.content.ContentManager) HierarchyBrowser(com.intellij.ide.hierarchy.HierarchyBrowser) HierarchyBrowserManager(com.intellij.ide.hierarchy.HierarchyBrowserManager) HierarchyBrowserBase(com.intellij.ide.hierarchy.HierarchyBrowserBase) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with HierarchyBrowserBase

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)"));
    }
}
Also used : ToolWindow(com.intellij.openapi.wm.ToolWindow) Content(com.intellij.ui.content.Content) ContentManager(com.intellij.ui.content.ContentManager) HierarchyBrowserBase(com.intellij.ide.hierarchy.HierarchyBrowserBase) PsiElement(com.intellij.psi.PsiElement)

Aggregations

HierarchyBrowserBase (com.intellij.ide.hierarchy.HierarchyBrowserBase)2 Content (com.intellij.ui.content.Content)2 ContentManager (com.intellij.ui.content.ContentManager)2 HierarchyBrowser (com.intellij.ide.hierarchy.HierarchyBrowser)1 HierarchyBrowserManager (com.intellij.ide.hierarchy.HierarchyBrowserManager)1 Disposable (com.intellij.openapi.Disposable)1 ToolWindow (com.intellij.openapi.wm.ToolWindow)1 PsiElement (com.intellij.psi.PsiElement)1 NotNull (org.jetbrains.annotations.NotNull)1