Search in sources :

Example 1 with ToolWindowEP

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

the class ExternalSystemUtil method ensureToolWindowInitialized.

public static void ensureToolWindowInitialized(@NotNull Project project, @NotNull ProjectSystemId externalSystemId) {
    try {
        ToolWindowManager manager = ToolWindowManager.getInstance(project);
        if (!(manager instanceof ToolWindowManagerEx)) {
            return;
        }
        ToolWindowManagerEx managerEx = (ToolWindowManagerEx) manager;
        String id = externalSystemId.getReadableName();
        ToolWindow window = manager.getToolWindow(id);
        if (window != null) {
            return;
        }
        ToolWindowEP[] beans = Extensions.getExtensions(ToolWindowEP.EP_NAME);
        for (final ToolWindowEP bean : beans) {
            if (id.equals(bean.id)) {
                managerEx.initToolWindow(bean);
            }
        }
    } catch (Exception e) {
        LOG.error(String.format("Unable to initialize %s tool window", externalSystemId.getReadableName()), e);
    }
}
Also used : ToolWindow(com.intellij.openapi.wm.ToolWindow) ToolWindowManager(com.intellij.openapi.wm.ToolWindowManager) ToolWindowEP(com.intellij.openapi.wm.ToolWindowEP) ImportCanceledException(com.intellij.openapi.externalSystem.service.ImportCanceledException) IOException(java.io.IOException) ToolWindowManagerEx(com.intellij.openapi.wm.ex.ToolWindowManagerEx)

Example 2 with ToolWindowEP

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

the class HiddenSidebarButtonTest method testHiddenButton.

public void testHiddenButton() throws Exception {
    DesktopLayout layout = myManager.getLayout();
    layout.readExternal(JdomKt.loadElement(LAYOUT));
    for (String ID : IDS) {
        assertFalse(layout.isToolWindowRegistered(ID));
        assertTrue(layout.isToolWindowUnregistered(ID));
    }
    ToolWindowEP[] extensions = Extensions.getExtensions(ToolWindowEP.EP_NAME);
    for (ToolWindowEP extension : extensions) {
        if (Arrays.asList(ToolWindowId.TODO_VIEW, ToolWindowId.FIND, ToolWindowId.PROJECT_VIEW).contains(extension.id)) {
            myManager.initToolWindow(extension);
        }
    }
    new UsageViewManagerImpl(myManager.getProject(), myManager);
    for (int i = 0; i < IDS.length; i++) {
        assertTrue(layout.isToolWindowRegistered(IDS[i]));
        assertFalse(layout.isToolWindowUnregistered(IDS[i]));
        assertTrue(ESTIMATED_TO_SHOW[i] == layout.getInfo(IDS[i], true).isShowStripeButton());
        assertTrue(ESTIMATED_VISIBILITY[i] == myManager.getStripeButton(IDS[i]).isVisible());
    }
}
Also used : UsageViewManagerImpl(com.intellij.usageView.impl.UsageViewManagerImpl) ToolWindowEP(com.intellij.openapi.wm.ToolWindowEP)

Example 3 with ToolWindowEP

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

the class ProjectToolWindowTest method testProjectViewActivate.

public void testProjectViewActivate() throws Exception {
    ToolWindowEP[] extensions = Extensions.getExtensions(ToolWindowEP.EP_NAME);
    for (ToolWindowEP extension : extensions) {
        if (ToolWindowId.PROJECT_VIEW.equals(extension.id)) {
            myManager.initToolWindow(extension);
        }
    }
    DesktopLayout layout = myManager.getLayout();
    WindowInfoImpl info = layout.getInfo(ToolWindowId.PROJECT_VIEW, false);
    assertFalse(info.isVisible());
    info.setVisible(true);
    ToolWindow window = myManager.getToolWindow(ToolWindowId.PROJECT_VIEW);
    assertTrue(window.isVisible());
    ProjectView.getInstance(getProject());
    ProjectViewSharedSettings.Companion.getInstance().setAutoscrollFromSource(true);
    try {
        window.activate(null);
    } finally {
        // cleanup
        info.setVisible(false);
    }
}
Also used : ToolWindow(com.intellij.openapi.wm.ToolWindow) ToolWindowEP(com.intellij.openapi.wm.ToolWindowEP)

Example 4 with ToolWindowEP

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

the class ProjectViewTestUtil method setupImpl.

public static void setupImpl(@NotNull Project project, boolean loadPaneExtensions) {
    ToolWindowManagerEx toolWindowManager = ToolWindowManagerEx.getInstanceEx(project);
    ToolWindow toolWindow = toolWindowManager.getToolWindow(ToolWindowId.PROJECT_VIEW);
    if (toolWindow == null) {
        ToolWindowEP[] beans = Extensions.getExtensions(ToolWindowEP.EP_NAME);
        for (final ToolWindowEP bean : beans) {
            if (bean.id.equals(ToolWindowId.PROJECT_VIEW)) {
                toolWindow = toolWindowManager.registerToolWindow(bean.id, new JLabel(), ToolWindowAnchor.fromText(bean.anchor), project, false, bean.canCloseContents);
                break;
            }
        }
    }
    ((ProjectViewImpl) ProjectView.getInstance(project)).setupImpl(toolWindow, loadPaneExtensions);
}
Also used : ToolWindow(com.intellij.openapi.wm.ToolWindow) ToolWindowEP(com.intellij.openapi.wm.ToolWindowEP) ProjectViewImpl(com.intellij.ide.projectView.impl.ProjectViewImpl) ToolWindowManagerEx(com.intellij.openapi.wm.ex.ToolWindowManagerEx)

Example 5 with ToolWindowEP

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

ToolWindowEP (com.intellij.openapi.wm.ToolWindowEP)5 ToolWindow (com.intellij.openapi.wm.ToolWindow)4 ToolWindowManager (com.intellij.openapi.wm.ToolWindowManager)2 ToolWindowManagerEx (com.intellij.openapi.wm.ex.ToolWindowManagerEx)2 ProjectViewImpl (com.intellij.ide.projectView.impl.ProjectViewImpl)1 ImportCanceledException (com.intellij.openapi.externalSystem.service.ImportCanceledException)1 DumbAwareRunnable (com.intellij.openapi.project.DumbAwareRunnable)1 UsageViewManagerImpl (com.intellij.usageView.impl.UsageViewManagerImpl)1 IOException (java.io.IOException)1 MvcToolWindowDescriptor (org.jetbrains.plugins.groovy.mvc.projectView.MvcToolWindowDescriptor)1