Search in sources :

Example 1 with ToolWindowManagerListener

use of com.intellij.openapi.wm.ex.ToolWindowManagerListener in project freeline by alibaba.

the class FreelineTerminal method initTerminal.

public void initTerminal(final ToolWindow toolWindow) {
    toolWindow.setToHideOnEmptyContent(true);
    LocalTerminalDirectRunner terminalRunner = LocalTerminalDirectRunner.createTerminalRunner(myProject);
    toolWindow.setStripeTitle("Freeline");
    Content content = createTerminalInContentPanel(terminalRunner, toolWindow);
    toolWindow.getContentManager().addContent(content);
    toolWindow.setShowStripeButton(true);
    toolWindow.setTitle("Console");
    ((ToolWindowManagerEx) ToolWindowManager.getInstance(this.myProject)).addToolWindowManagerListener(new ToolWindowManagerListener() {

        @Override
        public void toolWindowRegistered(@NotNull String s) {
        }

        @Override
        public void stateChanged() {
            ToolWindow window = ToolWindowManager.getInstance(myProject).getToolWindow(FreelineToolWindowFactory.TOOL_WINDOW_ID);
            if (window != null) {
                boolean visible = window.isVisible();
                if (visible && toolWindow.getContentManager().getContentCount() == 0) {
                    initTerminal(window);
                }
            }
        }
    });
    toolWindow.show(null);
    JBTabbedTerminalWidget terminalWidget = getTerminalWidget(toolWindow);
    if (terminalWidget != null && terminalWidget.getCurrentSession() != null) {
        Terminal terminal = terminalWidget.getCurrentSession().getTerminal();
        if (terminal != null) {
            terminal.setCursorVisible(false);
        }
    }
}
Also used : ToolWindowManagerListener(com.intellij.openapi.wm.ex.ToolWindowManagerListener) ToolWindow(com.intellij.openapi.wm.ToolWindow) Content(com.intellij.ui.content.Content) LocalTerminalDirectRunner(org.jetbrains.plugins.terminal.LocalTerminalDirectRunner) JBTabbedTerminalWidget(org.jetbrains.plugins.terminal.JBTabbedTerminalWidget) Terminal(com.jediterm.terminal.Terminal) ToolWindowManagerEx(com.intellij.openapi.wm.ex.ToolWindowManagerEx)

Example 2 with ToolWindowManagerListener

use of com.intellij.openapi.wm.ex.ToolWindowManagerListener in project intellij-community by JetBrains.

the class PythonConsoleToolWindow method doInit.

private void doInit(@NotNull final ToolWindow toolWindow) {
    myInitialized = true;
    toolWindow.setToHideOnEmptyContent(true);
    ((ToolWindowManagerEx) ToolWindowManager.getInstance(myProject)).addToolWindowManagerListener(new ToolWindowManagerListener() {

        @Override
        public void toolWindowRegistered(@NotNull String id) {
        }

        @Override
        public void stateChanged() {
            ToolWindow window = getToolWindow(myProject);
            if (window != null) {
                boolean visible = window.isVisible();
                if (visible && toolWindow.getContentManager().getContentCount() == 0) {
                    PydevConsoleRunner runner = PythonConsoleRunnerFactory.getInstance().createConsoleRunner(myProject, null);
                    runner.run();
                }
            }
        }
    });
}
Also used : ToolWindowManagerListener(com.intellij.openapi.wm.ex.ToolWindowManagerListener) ToolWindow(com.intellij.openapi.wm.ToolWindow) ToolWindowManagerEx(com.intellij.openapi.wm.ex.ToolWindowManagerEx)

Example 3 with ToolWindowManagerListener

use of com.intellij.openapi.wm.ex.ToolWindowManagerListener in project intellij-community by JetBrains.

the class TerminalToolWindowPanel method initTerminal.

public void initTerminal(final ToolWindow toolWindow) {
    LocalTerminalDirectRunner terminalRunner = LocalTerminalDirectRunner.createTerminalRunner(myProject);
    toolWindow.setToHideOnEmptyContent(true);
    Content content = createTerminalInContentPanel(terminalRunner, toolWindow);
    toolWindow.getContentManager().addContent(content);
    ((ToolWindowManagerEx) ToolWindowManager.getInstance(myProject)).addToolWindowManagerListener(new ToolWindowManagerListener() {

        @Override
        public void toolWindowRegistered(@NotNull String id) {
        }

        @Override
        public void stateChanged() {
            ToolWindow window = ToolWindowManager.getInstance(myProject).getToolWindow(TerminalToolWindowFactory.TOOL_WINDOW_ID);
            if (window != null) {
                boolean visible = window.isVisible();
                if (visible && toolWindow.getContentManager().getContentCount() == 0) {
                    initTerminal(window);
                }
            }
        }
    });
    Disposer.register(myProject, new Disposable() {

        @Override
        public void dispose() {
            if (myTerminalWidget != null) {
                myTerminalWidget.dispose();
                myTerminalWidget = null;
            }
        }
    });
    if (myDockContainer == null) {
        myDockContainer = new TerminalDockContainer(toolWindow);
        Disposer.register(myProject, myDockContainer);
        DockManager.getInstance(myProject).register(myDockContainer);
    }
}
Also used : ToolWindowManagerListener(com.intellij.openapi.wm.ex.ToolWindowManagerListener) Disposable(com.intellij.openapi.Disposable) ToolWindow(com.intellij.openapi.wm.ToolWindow) Content(com.intellij.ui.content.Content) DockableContent(com.intellij.ui.docking.DockableContent) ToolWindowManagerEx(com.intellij.openapi.wm.ex.ToolWindowManagerEx)

Example 4 with ToolWindowManagerListener

use of com.intellij.openapi.wm.ex.ToolWindowManagerListener in project android by JetBrains.

the class AndroidUtils method activateConsoleToolWindow.

public static void activateConsoleToolWindow(@NotNull Project project, @NotNull final Runnable runAfterActivation) {
    final ToolWindowManager manager = ToolWindowManager.getInstance(project);
    final String toolWindowId = AndroidBundle.message("android.console.tool.window.title");
    ToolWindow toolWindow = manager.getToolWindow(toolWindowId);
    if (toolWindow != null) {
        runAfterActivation.run();
        return;
    }
    toolWindow = manager.registerToolWindow(toolWindowId, true, ToolWindowAnchor.BOTTOM);
    final ConsoleView console = new ConsoleViewImpl(project, false);
    project.putUserData(CONSOLE_VIEW_KEY, console);
    toolWindow.getContentManager().addContent(new ContentImpl(console.getComponent(), "", false));
    final ToolWindowManagerListener listener = new ToolWindowManagerListener() {

        @Override
        public void toolWindowRegistered(@NotNull String id) {
        }

        @Override
        public void stateChanged() {
            ToolWindow window = manager.getToolWindow(toolWindowId);
            if (window != null && !window.isVisible()) {
                ((ToolWindowManagerEx) manager).removeToolWindowManagerListener(this);
                getApplication().invokeLater(() -> manager.unregisterToolWindow(toolWindowId));
            }
        }
    };
    toolWindow.show(() -> {
        runAfterActivation.run();
        ((ToolWindowManagerEx) manager).addToolWindowManagerListener(listener);
    });
}
Also used : ToolWindowManagerListener(com.intellij.openapi.wm.ex.ToolWindowManagerListener) ToolWindow(com.intellij.openapi.wm.ToolWindow) ConsoleView(com.intellij.execution.ui.ConsoleView) ToolWindowManager(com.intellij.openapi.wm.ToolWindowManager) ContentImpl(com.intellij.ui.content.impl.ContentImpl) NotNull(org.jetbrains.annotations.NotNull) ConsoleViewImpl(com.intellij.execution.impl.ConsoleViewImpl) ToolWindowManagerEx(com.intellij.openapi.wm.ex.ToolWindowManagerEx)

Aggregations

ToolWindow (com.intellij.openapi.wm.ToolWindow)4 ToolWindowManagerEx (com.intellij.openapi.wm.ex.ToolWindowManagerEx)4 ToolWindowManagerListener (com.intellij.openapi.wm.ex.ToolWindowManagerListener)4 Content (com.intellij.ui.content.Content)2 ConsoleViewImpl (com.intellij.execution.impl.ConsoleViewImpl)1 ConsoleView (com.intellij.execution.ui.ConsoleView)1 Disposable (com.intellij.openapi.Disposable)1 ToolWindowManager (com.intellij.openapi.wm.ToolWindowManager)1 ContentImpl (com.intellij.ui.content.impl.ContentImpl)1 DockableContent (com.intellij.ui.docking.DockableContent)1 Terminal (com.jediterm.terminal.Terminal)1 NotNull (org.jetbrains.annotations.NotNull)1 JBTabbedTerminalWidget (org.jetbrains.plugins.terminal.JBTabbedTerminalWidget)1 LocalTerminalDirectRunner (org.jetbrains.plugins.terminal.LocalTerminalDirectRunner)1