Search in sources :

Example 1 with MvcToolWindowDescriptor

use of org.jetbrains.plugins.groovy.mvc.projectView.MvcToolWindowDescriptor 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)

Aggregations

DumbAwareRunnable (com.intellij.openapi.project.DumbAwareRunnable)1 ToolWindow (com.intellij.openapi.wm.ToolWindow)1 ToolWindowEP (com.intellij.openapi.wm.ToolWindowEP)1 ToolWindowManager (com.intellij.openapi.wm.ToolWindowManager)1 MvcToolWindowDescriptor (org.jetbrains.plugins.groovy.mvc.projectView.MvcToolWindowDescriptor)1