Search in sources :

Example 76 with Content

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

Example 77 with Content

use of com.intellij.ui.content.Content in project intellij-code-outline by sitano.

the class CodeOutlinePlugin method regForProject.

/**
     * Creates a code outline tool window for the given project.
     *
     * @param project the project to register
     */
private synchronized void regForProject(final Project project) {
    final CodeOutlineToolWindow window = new CodeOutlineToolWindow(this, project);
    ToolWindowManager twm = ToolWindowManager.getInstance(project);
    ToolWindowManagerEx twmEx = (ToolWindowManagerEx) twm;
    ToolWindow tw = twm.registerToolWindow(TOOLWINDOW_ID, false, ToolWindowAnchor.RIGHT);
    ContentFactory contentFactory = ServiceManager.getService(ContentFactory.class);
    Content content = contentFactory.createContent(window, "", false);
    tw.getContentManager().addContent(content);
    tw.getContentManager().setSelectedContent(content, false);
    twmEx.addToolWindowManagerListener(window.getToolWindowManagerListener());
}
Also used : ToolWindow(com.intellij.openapi.wm.ToolWindow) Content(com.intellij.ui.content.Content) ToolWindowManager(com.intellij.openapi.wm.ToolWindowManager) ContentFactory(com.intellij.ui.content.ContentFactory) ToolWindowManagerEx(com.intellij.openapi.wm.ex.ToolWindowManagerEx)

Example 78 with Content

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

the class KarmaConsoleView method registerConsoleContent.

@NotNull
private Content registerConsoleContent(@NotNull final RunnerLayoutUi ui) {
    ui.getOptions().setMinimizeActionEnabled(false);
    final Content consoleContent = ui.createContent(ExecutionConsole.CONSOLE_CONTENT_ID, getComponent(), "Test Run", AllIcons.Debugger.Console, getPreferredFocusableComponent());
    ui.addContent(consoleContent, 1, PlaceInGrid.bottom, false);
    consoleContent.setCloseable(false);
    final KarmaRootTestProxyFormatter rootFormatter = new KarmaRootTestProxyFormatter(this, myServer);
    if (myServer.areBrowsersReady()) {
        KarmaUtil.selectAndFocusIfNotDisposed(ui, consoleContent, false, false);
    } else {
        myServer.onPortBound(() -> {
            KarmaUtil.selectAndFocusIfNotDisposed(ui, consoleContent, false, false);
            scheduleBrowserCapturingSuggestion();
        });
    }
    final ProcessAdapter listener = new ProcessAdapter() {

        @Override
        public void processTerminated(ProcessEvent event) {
            if (myServer.getProcessHandler().isProcessTerminated()) {
                rootFormatter.onServerProcessTerminated();
                printServerFinishedInfo();
            }
            rootFormatter.onTestRunProcessTerminated();
        }
    };
    myExecutionSession.getProcessHandler().addProcessListener(listener);
    Disposer.register(this, new Disposable() {

        @Override
        public void dispose() {
            myExecutionSession.getProcessHandler().removeProcessListener(listener);
        }
    });
    return consoleContent;
}
Also used : Disposable(com.intellij.openapi.Disposable) ProcessAdapter(com.intellij.execution.process.ProcessAdapter) ProcessEvent(com.intellij.execution.process.ProcessEvent) Content(com.intellij.ui.content.Content) NotNull(org.jetbrains.annotations.NotNull)

Example 79 with Content

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

the class KarmaServerLogComponent method register.

public static void register(@NotNull Project project, @NotNull final KarmaServer server, @NotNull final RunnerLayoutUi ui, boolean requestFocus) {
    final ConsoleView console = createConsole(project);
    KarmaServerLogComponent component = new KarmaServerLogComponent(console, server);
    final Content content = ui.createContent("KarmaServer", component, "Karma Server", null, console.getPreferredFocusableComponent());
    content.setCloseable(false);
    ui.addContent(content, 4, PlaceInGrid.bottom, false);
    if (requestFocus && !server.isPortBound()) {
        ui.selectAndFocus(content, false, false);
    }
    final KarmaServerTerminatedListener terminationCallback = new KarmaServerTerminatedListener() {

        @Override
        public void onTerminated(int exitCode) {
            KarmaUtil.selectAndFocusIfNotDisposed(ui, content, false, false);
        }
    };
    server.onTerminated(terminationCallback);
    final ArchivedOutputListener outputListener = new ArchivedOutputListener() {

        @Override
        public void onOutputAvailable(@NotNull String text, Key outputType, boolean archived) {
            ConsoleViewContentType contentType = ConsoleViewContentType.getConsoleViewType(outputType);
            console.print(text, contentType);
            if (!archived && text.startsWith("ERROR ")) {
                ApplicationManager.getApplication().invokeLater(() -> content.fireAlert(), ModalityState.any());
            }
        }
    };
    server.getProcessOutputManager().addOutputListener(outputListener);
    Disposer.register(content, console);
    Disposer.register(console, new Disposable() {

        @Override
        public void dispose() {
            server.removeTerminatedListener(terminationCallback);
            server.getProcessOutputManager().removeOutputListener(outputListener);
        }
    });
}
Also used : Disposable(com.intellij.openapi.Disposable) ConsoleView(com.intellij.execution.ui.ConsoleView) Content(com.intellij.ui.content.Content) ArchivedOutputListener(com.intellij.javascript.karma.util.ArchivedOutputListener) NotNull(org.jetbrains.annotations.NotNull) Key(com.intellij.openapi.util.Key) ConsoleViewContentType(com.intellij.execution.ui.ConsoleViewContentType)

Example 80 with Content

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

the class JstdToolWindowManager method setAvailable.

public void setAvailable(boolean available) {
    if (available) {
        if (myContentManager.getContentCount() == 0) {
            JstdToolWindowSession session = new JstdToolWindowSession(myProject);
            myCurrentSession = session;
            Content content = myContentManager.getFactory().createContent(session.getComponent(), null, true);
            content.setCloseable(true);
            myContentManager.addContent(content);
        }
    } else {
        myContentManager.removeAllContents(true);
        myCurrentSession = null;
    }
    myToolWindow.setAvailable(available, null);
}
Also used : Content(com.intellij.ui.content.Content)

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