Search in sources :

Example 1 with ToolWindowManagerEx

use of com.intellij.openapi.wm.ex.ToolWindowManagerEx in project intellij-leiningen-plugin by derkork.

the class LeiningenProjectNavigator method addPanel.

private void addPanel() {
    initTree();
    myStructure = new LeiningenProjectStructure(myProject, myProjectsManager, myTree);
    JPanel panel = new LeiningenProjectNavigatorPanel(myProject, myTree);
    final ToolWindowManagerEx manager = ToolWindowManagerEx.getInstanceEx(myProject);
    myToolWindow = manager.registerToolWindow(TOOL_WINDOW_ID, panel, ToolWindowAnchor.RIGHT, myProject, true);
    myToolWindow.setIcon(LeiningenIcons.PROJECT_ICON);
    final ToolWindowManagerAdapter listener = new ToolWindowManagerAdapter() {

        boolean wasVisible = false;

        @Override
        public void stateChanged() {
            if (myToolWindow.isDisposed())
                return;
            boolean visible = myToolWindow.isVisible();
            if (!visible || visible == wasVisible)
                return;
            scheduleStructureUpdate();
            wasVisible = visible;
        }
    };
    manager.addToolWindowManagerListener(listener);
    Disposer.register(myProject, new Disposable() {

        public void dispose() {
            manager.removeToolWindowManagerListener(listener);
        }
    });
    scheduleStructureUpdate();
}
Also used : Disposable(com.intellij.openapi.Disposable) ToolWindowManagerAdapter(com.intellij.openapi.wm.ex.ToolWindowManagerAdapter) ToolWindowManagerEx(com.intellij.openapi.wm.ex.ToolWindowManagerEx)

Example 2 with ToolWindowManagerEx

use of com.intellij.openapi.wm.ex.ToolWindowManagerEx 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 3 with ToolWindowManagerEx

use of com.intellij.openapi.wm.ex.ToolWindowManagerEx 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 4 with ToolWindowManagerEx

use of com.intellij.openapi.wm.ex.ToolWindowManagerEx 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 5 with ToolWindowManagerEx

use of com.intellij.openapi.wm.ex.ToolWindowManagerEx 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)

Aggregations

ToolWindowManagerEx (com.intellij.openapi.wm.ex.ToolWindowManagerEx)37 Project (com.intellij.openapi.project.Project)14 ToolWindow (com.intellij.openapi.wm.ToolWindow)13 ToolWindowManagerAdapter (com.intellij.openapi.wm.ex.ToolWindowManagerAdapter)9 Content (com.intellij.ui.content.Content)7 ToolWindowEx (com.intellij.openapi.wm.ex.ToolWindowEx)6 ToolWindowManager (com.intellij.openapi.wm.ToolWindowManager)5 Presentation (com.intellij.openapi.actionSystem.Presentation)4 ToolWindowManagerListener (com.intellij.openapi.wm.ex.ToolWindowManagerListener)4 DesktopLayout (com.intellij.openapi.wm.impl.DesktopLayout)4 Disposable (com.intellij.openapi.Disposable)3 ToolWindowType (com.intellij.openapi.wm.ToolWindowType)3 ContentManager (com.intellij.ui.content.ContentManager)2 LightToolWindow (com.intellij.designer.LightToolWindow)1 com.intellij.execution (com.intellij.execution)1 RunDashboardManager (com.intellij.execution.dashboard.RunDashboardManager)1 ConsoleViewImpl (com.intellij.execution.impl.ConsoleViewImpl)1 ConsoleView (com.intellij.execution.ui.ConsoleView)1 OccurenceNavigator (com.intellij.ide.OccurenceNavigator)1 ProjectViewImpl (com.intellij.ide.projectView.impl.ProjectViewImpl)1