Search in sources :

Example 66 with Content

use of com.intellij.ui.content.Content 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 67 with Content

use of com.intellij.ui.content.Content in project intellij-community by JetBrains.

the class DependenciesHandlerBase method onSuccess.

private void onSuccess(final List<DependenciesBuilder> builders) {
    //noinspection SSBasedInspection
    SwingUtilities.invokeLater(() -> {
        if (shouldShowDependenciesPanel(builders)) {
            final String displayName = getPanelDisplayName(builders);
            DependenciesPanel panel = new DependenciesPanel(myProject, builders, myExcluded);
            Content content = ContentFactory.SERVICE.getInstance().createContent(panel, displayName, false);
            content.setDisposer(panel);
            panel.setContent(content);
            DependenciesToolWindow.getInstance(myProject).addContent(content);
        }
    });
}
Also used : DependenciesPanel(com.intellij.packageDependencies.ui.DependenciesPanel) Content(com.intellij.ui.content.Content)

Example 68 with Content

use of com.intellij.ui.content.Content in project intellij-community by JetBrains.

the class CopyHandler method updateSelectionInActiveProjectView.

static void updateSelectionInActiveProjectView(PsiElement newElement, Project project, boolean selectInActivePanel) {
    String id = ToolWindowManager.getInstance(project).getActiveToolWindowId();
    if (id != null) {
        ToolWindow window = ToolWindowManager.getInstance(project).getToolWindow(id);
        Content selectedContent = window.getContentManager().getSelectedContent();
        if (selectedContent != null) {
            JComponent component = selectedContent.getComponent();
            if (component instanceof TwoPaneIdeView) {
                ((TwoPaneIdeView) component).selectElement(newElement, selectInActivePanel);
                return;
            }
        }
    }
    if (ToolWindowId.PROJECT_VIEW.equals(id)) {
        ProjectView.getInstance(project).selectPsiElement(newElement, true);
    } else if (ToolWindowId.STRUCTURE_VIEW.equals(id)) {
        VirtualFile virtualFile = newElement.getContainingFile().getVirtualFile();
        FileEditor editor = FileEditorManager.getInstance(newElement.getProject()).getSelectedEditor(virtualFile);
        StructureViewFactoryEx.getInstanceEx(project).getStructureViewWrapper().selectCurrentElement(editor, virtualFile, true);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ToolWindow(com.intellij.openapi.wm.ToolWindow) FileEditor(com.intellij.openapi.fileEditor.FileEditor) Content(com.intellij.ui.content.Content) TwoPaneIdeView(com.intellij.ide.TwoPaneIdeView)

Example 69 with Content

use of com.intellij.ui.content.Content in project intellij-community by JetBrains.

the class DocumentationManager method showJavaDocInfoAtToolWindow.

public void showJavaDocInfoAtToolWindow(@NotNull PsiElement element, @NotNull PsiElement original) {
    final Content content = recreateToolWindow(element, original);
    if (content == null)
        return;
    fetchDocInfo(getDefaultCollector(element, original), (DocumentationComponent) content.getComponent(), true);
}
Also used : Content(com.intellij.ui.content.Content)

Example 70 with Content

use of com.intellij.ui.content.Content in project intellij-community by JetBrains.

the class DocumentationManager method doShowJavaDocInfo.

private void doShowJavaDocInfo(@NotNull final PsiElement element, boolean requestFocus, PopupUpdateProcessor updateProcessor, final PsiElement originalElement, @Nullable final Runnable closeCallback) {
    Project project = getProject(element);
    if (!project.isOpen())
        return;
    storeOriginalElement(project, originalElement, element);
    myPreviouslyFocused = WindowManagerEx.getInstanceEx().getFocusedComponent(project);
    JBPopup _oldHint = getDocInfoHint();
    if (PreviewManager.SERVICE.preview(myProject, DocumentationPreviewPanelProvider.ID, Couple.of(element, originalElement), requestFocus) != null) {
        return;
    }
    if (myToolWindow == null && PropertiesComponent.getInstance().isTrueValue(SHOW_DOCUMENTATION_IN_TOOL_WINDOW)) {
        createToolWindow(element, originalElement);
    } else if (myToolWindow != null) {
        Content content = myToolWindow.getContentManager().getSelectedContent();
        if (content != null) {
            DocumentationComponent component = (DocumentationComponent) content.getComponent();
            boolean sameElement = element.getManager().areElementsEquivalent(component.getElement(), element);
            if (sameElement) {
                JComponent preferredFocusableComponent = content.getPreferredFocusableComponent();
                // focus toolwindow on the second actionPerformed
                boolean focus = requestFocus || CommandProcessor.getInstance().getCurrentCommand() != null;
                if (preferredFocusableComponent != null && focus) {
                    IdeFocusManager.getInstance(myProject).requestFocus(preferredFocusableComponent, true);
                }
            }
            if (!sameElement || !component.isUpToDate()) {
                content.setDisplayName(getTitle(element, true));
                fetchDocInfo(getDefaultCollector(element, originalElement), component, true);
            }
        }
        if (!myToolWindow.isVisible()) {
            myToolWindow.show(null);
        }
    } else if (_oldHint != null && _oldHint.isVisible() && _oldHint instanceof AbstractPopup) {
        DocumentationComponent oldComponent = (DocumentationComponent) ((AbstractPopup) _oldHint).getComponent();
        fetchDocInfo(getDefaultCollector(element, originalElement), oldComponent);
    } else {
        showInPopup(element, requestFocus, updateProcessor, originalElement, closeCallback);
    }
}
Also used : Project(com.intellij.openapi.project.Project) AbstractPopup(com.intellij.ui.popup.AbstractPopup) Content(com.intellij.ui.content.Content) JBPopup(com.intellij.openapi.ui.popup.JBPopup)

Aggregations

Content (com.intellij.ui.content.Content)157 ContentManager (com.intellij.ui.content.ContentManager)42 ToolWindow (com.intellij.openapi.wm.ToolWindow)37 NotNull (org.jetbrains.annotations.NotNull)19 ContentFactory (com.intellij.ui.content.ContentFactory)14 Project (com.intellij.openapi.project.Project)13 Nullable (org.jetbrains.annotations.Nullable)13 MessageView (com.intellij.ui.content.MessageView)10 Disposable (com.intellij.openapi.Disposable)8 ToolWindowManager (com.intellij.openapi.wm.ToolWindowManager)8 RunnerLayoutUi (com.intellij.execution.ui.RunnerLayoutUi)7 ToolWindowManagerEx (com.intellij.openapi.wm.ex.ToolWindowManagerEx)7 ConsoleView (com.intellij.execution.ui.ConsoleView)6 SimpleToolWindowPanel (com.intellij.openapi.ui.SimpleToolWindowPanel)6 TabbedContent (com.intellij.ui.content.TabbedContent)6 DefaultActionGroup (com.intellij.openapi.actionSystem.DefaultActionGroup)5 Ref (com.intellij.openapi.util.Ref)5 ExecutionConsole (com.intellij.execution.ui.ExecutionConsole)4 ToolWindowManagerAdapter (com.intellij.openapi.wm.ex.ToolWindowManagerAdapter)4 Assert.assertNotNull (junit.framework.Assert.assertNotNull)4