Search in sources :

Example 56 with ToolWindowManager

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

the class MvcModuleStructureSynchronizer method updateProjectViewVisibility.

private void updateProjectViewVisibility() {
    if (ApplicationManager.getApplication().isUnitTestMode())
        return;
    StartupManager.getInstance(myProject).runWhenProjectIsInitialized(new DumbAwareRunnable() {

        @Override
        public void run() {
            ApplicationManager.getApplication().invokeLater(() -> {
                if (myProject.isDisposed())
                    return;
                for (ToolWindowEP ep : ToolWindowEP.EP_NAME.getExtensions()) {
                    if (MvcToolWindowDescriptor.class.isAssignableFrom(ep.getFactoryClass())) {
                        MvcToolWindowDescriptor descriptor = (MvcToolWindowDescriptor) ep.getToolWindowFactory();
                        String id = descriptor.getToolWindowId();
                        boolean shouldShow = descriptor.value(myProject);
                        ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(myProject);
                        ToolWindow toolWindow = toolWindowManager.getToolWindow(id);
                        if (shouldShow && toolWindow == null) {
                            toolWindow = toolWindowManager.registerToolWindow(id, true, ToolWindowAnchor.LEFT, myProject, true);
                            toolWindow.setIcon(descriptor.getFramework().getToolWindowIcon());
                            descriptor.createToolWindowContent(myProject, toolWindow);
                        } else if (!shouldShow && toolWindow != null) {
                            toolWindowManager.unregisterToolWindow(id);
                            Disposer.dispose(toolWindow.getContentManager());
                        }
                    }
                }
            });
        }
    });
}
Also used : ToolWindow(com.intellij.openapi.wm.ToolWindow) MvcToolWindowDescriptor(org.jetbrains.plugins.groovy.mvc.projectView.MvcToolWindowDescriptor) ToolWindowManager(com.intellij.openapi.wm.ToolWindowManager) ToolWindowEP(com.intellij.openapi.wm.ToolWindowEP) DumbAwareRunnable(com.intellij.openapi.project.DumbAwareRunnable)

Example 57 with ToolWindowManager

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

the class StudyUtils method registerStudyToolWindow.

public static void registerStudyToolWindow(@Nullable final Course course, Project project) {
    if (course != null && "PyCharm".equals(course.getCourseType())) {
        final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);
        registerToolWindows(toolWindowManager, project);
        final ToolWindow studyToolWindow = toolWindowManager.getToolWindow(StudyToolWindowFactory.STUDY_TOOL_WINDOW);
        if (studyToolWindow != null) {
            studyToolWindow.show(null);
            initToolWindows(project);
        }
    }
}
Also used : ToolWindow(com.intellij.openapi.wm.ToolWindow) StudyToolWindow(com.jetbrains.edu.learning.ui.StudyToolWindow) ToolWindowManager(com.intellij.openapi.wm.ToolWindowManager)

Example 58 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 59 with ToolWindowManager

use of com.intellij.openapi.wm.ToolWindowManager in project intellij-plugins by StepicOrg.

the class StudyUtils method getStudyToolWindow.

@Nullable
static StudyToolWindow getStudyToolWindow(@NotNull final Project project) {
    if (project.isDisposed()) {
        return null;
    }
    ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);
    if (toolWindowManager == null) {
        return null;
    }
    ToolWindow toolWindow = toolWindowManager.getToolWindow(StudyToolWindowFactory.STUDY_TOOL_WINDOW);
    if (toolWindow != null) {
        Content[] contents = toolWindow.getContentManager().getContents();
        for (Content content : contents) {
            JComponent component = content.getComponent();
            if (component != null && component instanceof StudyToolWindow) {
                return (StudyToolWindow) component;
            }
        }
    }
    return null;
}
Also used : ToolWindow(com.intellij.openapi.wm.ToolWindow) StudyToolWindow(org.stepik.core.ui.StudyToolWindow) Content(com.intellij.ui.content.Content) ToolWindowManager(com.intellij.openapi.wm.ToolWindowManager) StudyToolWindow(org.stepik.core.ui.StudyToolWindow) Nullable(org.jetbrains.annotations.Nullable)

Example 60 with ToolWindowManager

use of com.intellij.openapi.wm.ToolWindowManager in project intellij-plugins by StepicOrg.

the class StudyProjectComponent method registerStudyToolWindow.

public void registerStudyToolWindow() {
    if (!StepikProjectManager.isStepikProject(project)) {
        return;
    }
    final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);
    registerToolWindows(toolWindowManager);
    final ToolWindow studyToolWindow = toolWindowManager.getToolWindow(StudyToolWindowFactory.STUDY_TOOL_WINDOW);
    if (studyToolWindow != null) {
        studyToolWindow.show(null);
        StudyUtils.initToolWindows(project);
    }
}
Also used : ToolWindow(com.intellij.openapi.wm.ToolWindow) StudyToolWindow(org.stepik.core.ui.StudyToolWindow) ToolWindowManager(com.intellij.openapi.wm.ToolWindowManager)

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