Search in sources :

Example 36 with ToolWindowManager

use of com.intellij.openapi.wm.ToolWindowManager in project intellij-code-outline by sitano.

the class CodeOutlinePlugin method unregForProject.

/**
     * Removes the code outline tool window from the given project.
     *
     * @param project the project to unregister
     */
private synchronized void unregForProject(Project project) {
    ToolWindowManager twm = ToolWindowManager.getInstance(project);
    CodeOutlineToolWindow window = windows.get(project);
    if (window != null) {
        ToolWindowManagerEx twmEx = (ToolWindowManagerEx) twm;
        twmEx.removeToolWindowManagerListener(window.getToolWindowManagerListener());
    }
    try {
        twm.unregisterToolWindow(TOOLWINDOW_ID);
    } catch (IllegalArgumentException ignored) {
    }
    CodeOutlineToolWindow win = windows.remove(project);
    if (win == null)
        return;
    win.stop();
}
Also used : ToolWindowManager(com.intellij.openapi.wm.ToolWindowManager) ToolWindowManagerEx(com.intellij.openapi.wm.ex.ToolWindowManagerEx)

Example 37 with ToolWindowManager

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

Example 38 with ToolWindowManager

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

the class ActivateToolWindowAction method actionPerformed.

public void actionPerformed(final AnActionEvent e) {
    Project project = getEventProject(e);
    if (project == null)
        return;
    ToolWindowManager windowManager = ToolWindowManager.getInstance(project);
    final ToolWindow window = windowManager.getToolWindow(myToolWindowId);
    InputEvent event = e.getInputEvent();
    Runnable run = null;
    if (event instanceof KeyEvent && event.isShiftDown()) {
        final Content[] contents = window.getContentManager().getContents();
        if (contents.length > 0 && window.getContentManager().getSelectedContent() != contents[0]) {
            run = () -> window.getContentManager().setSelectedContent(contents[0], true, true);
        }
    }
    if (windowManager.isEditorComponentActive() || !myToolWindowId.equals(windowManager.getActiveToolWindowId()) || run != null) {
        if (run != null && window.isActive()) {
            run.run();
        } else {
            window.activate(run);
        }
    } else {
        windowManager.getToolWindow(myToolWindowId).hide(null);
    }
}
Also used : KeyEvent(java.awt.event.KeyEvent) Project(com.intellij.openapi.project.Project) ToolWindow(com.intellij.openapi.wm.ToolWindow) Content(com.intellij.ui.content.Content) ToolWindowManager(com.intellij.openapi.wm.ToolWindowManager) InputEvent(java.awt.event.InputEvent)

Example 39 with ToolWindowManager

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

the class RemoteServersViewImpl method showDeployment.

@Override
public void showDeployment(@NotNull final ServerConnection<?> connection, @NotNull final String deploymentName) {
    ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(myProject);
    final ToolWindow toolWindow = toolWindowManager.getToolWindow(getToolWindowId(connection));
    if (toolWindow != null) {
        toolWindowManager.invokeLater(() -> {
            ServersToolWindowContent component = getServersViewComponent(toolWindow);
            if (component != null) {
                component.select(connection, deploymentName);
            }
        });
    }
}
Also used : ToolWindow(com.intellij.openapi.wm.ToolWindow) ToolWindowManager(com.intellij.openapi.wm.ToolWindowManager)

Example 40 with ToolWindowManager

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

the class PrevSplitAction method update.

public void update(final AnActionEvent event) {
    final Project project = event.getProject();
    final Presentation presentation = event.getPresentation();
    if (project == null) {
        presentation.setEnabled(false);
        return;
    }
    final FileEditorManagerEx manager = FileEditorManagerEx.getInstanceEx(project);
    final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);
    presentation.setEnabled(toolWindowManager.isEditorComponentActive() && manager.isInSplitter() && manager.getCurrentWindow() != null);
}
Also used : Project(com.intellij.openapi.project.Project) ToolWindowManager(com.intellij.openapi.wm.ToolWindowManager) Presentation(com.intellij.openapi.actionSystem.Presentation) FileEditorManagerEx(com.intellij.openapi.fileEditor.ex.FileEditorManagerEx)

Aggregations

ToolWindowManager (com.intellij.openapi.wm.ToolWindowManager)60 ToolWindow (com.intellij.openapi.wm.ToolWindow)34 Project (com.intellij.openapi.project.Project)27 Presentation (com.intellij.openapi.actionSystem.Presentation)8 Content (com.intellij.ui.content.Content)7 ToolWindowManagerEx (com.intellij.openapi.wm.ex.ToolWindowManagerEx)5 Nullable (org.jetbrains.annotations.Nullable)5 Module (com.intellij.openapi.module.Module)3 ContentManager (com.intellij.ui.content.ContentManager)3 ContentImpl (com.intellij.ui.content.impl.ContentImpl)3 NotNull (org.jetbrains.annotations.NotNull)3 ConsoleView (com.intellij.execution.ui.ConsoleView)2 ProjectView (com.intellij.ide.projectView.ProjectView)2 FileEditorManagerEx (com.intellij.openapi.fileEditor.ex.FileEditorManagerEx)2 ModuleUtilCore (com.intellij.openapi.module.ModuleUtilCore)2 ActionCallback (com.intellij.openapi.util.ActionCallback)2 ToolWindowId (com.intellij.openapi.wm.ToolWindowId)2 ToolWindowImpl (com.intellij.openapi.wm.impl.ToolWindowImpl)2 StudyToolWindow (org.stepik.core.ui.StudyToolWindow)2 AbstractProjectStructureAction.getSelectedAndroidModule (com.android.tools.idea.gradle.actions.AbstractProjectStructureAction.getSelectedAndroidModule)1