Search in sources :

Example 6 with ToolWindowManagerEx

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

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

the class ExternalProjectsViewImpl method init.

public void init() {
    Disposer.register(myProject, this);
    initTree();
    final ToolWindowManagerEx manager = ToolWindowManagerEx.getInstanceEx(myProject);
    final ToolWindowManagerAdapter listener = new ToolWindowManagerAdapter() {

        boolean wasVisible = false;

        @Override
        public void stateChanged() {
            if (myToolWindow.isDisposed())
                return;
            boolean visible = myToolWindow.isVisible();
            if (!visible || wasVisible) {
                wasVisible = visible;
                return;
            }
            scheduleStructureUpdate();
            wasVisible = true;
        }
    };
    manager.addToolWindowManagerListener(listener, myProject);
    getShortcutsManager().addListener(new ExternalSystemShortcutsManager.Listener() {

        @Override
        public void shortcutsUpdated() {
            scheduleTasksUpdate();
            scheduleStructureRequest(() -> {
                assert myStructure != null;
                myStructure.updateNodes(RunConfigurationNode.class);
            });
        }
    });
    getTaskActivator().addListener(new ExternalSystemTaskActivator.Listener() {

        @Override
        public void tasksActivationChanged() {
            scheduleTasksUpdate();
            scheduleStructureRequest(() -> {
                assert myStructure != null;
                myStructure.updateNodes(RunConfigurationNode.class);
            });
        }
    });
    ((RunManagerEx) RunManager.getInstance(myProject)).addRunManagerListener(new RunManagerListener() {

        private void changed() {
            scheduleStructureRequest(() -> {
                assert myStructure != null;
                myStructure.visitNodes(ModuleNode.class, node -> node.updateRunConfigurations());
            });
        }

        @Override
        public void runConfigurationAdded(@NotNull RunnerAndConfigurationSettings settings) {
            changed();
        }

        @Override
        public void runConfigurationRemoved(@NotNull RunnerAndConfigurationSettings settings) {
            changed();
        }

        @Override
        public void runConfigurationChanged(@NotNull RunnerAndConfigurationSettings settings) {
            changed();
        }
    });
    ExternalSystemApiUtil.subscribe(myProject, myExternalSystemId, new ExternalSystemSettingsListenerAdapter() {

        @Override
        public void onUseAutoImportChange(boolean currentValue, @NotNull final String linkedProjectPath) {
            scheduleStructureRequest(() -> {
                assert myStructure != null;
                final List<ProjectNode> projectNodes = myStructure.getNodes(ProjectNode.class);
                for (ProjectNode projectNode : projectNodes) {
                    final ProjectData projectData = projectNode.getData();
                    if (projectData != null && projectData.getLinkedExternalProjectPath().equals(linkedProjectPath)) {
                        projectNode.updateProject();
                        break;
                    }
                }
            });
        }
    });
    myToolWindow.setAdditionalGearActions(createAdditionalGearActionsGroup());
    scheduleStructureUpdate();
}
Also used : ExternalSystemTaskActivator(com.intellij.openapi.externalSystem.service.project.manage.ExternalSystemTaskActivator) ProjectDataManager(com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager) VirtualFile(com.intellij.openapi.vfs.VirtualFile) ModalityState(com.intellij.openapi.application.ModalityState) TreeState(com.intellij.ide.util.treeView.TreeState) PopupHandler(com.intellij.ui.PopupHandler) ExternalSystemApiUtil(com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil) SmartList(com.intellij.util.SmartList) Disposer(com.intellij.openapi.util.Disposer) Logger(com.intellij.openapi.diagnostic.Logger) MultiMap(com.intellij.util.containers.MultiMap) ExternalSystemSettingsListenerAdapter(com.intellij.openapi.externalSystem.settings.ExternalSystemSettingsListenerAdapter) ProjectData(com.intellij.openapi.externalSystem.model.project.ProjectData) ToolWindowManagerEx(com.intellij.openapi.wm.ex.ToolWindowManagerEx) ToolWindowManagerAdapter(com.intellij.openapi.wm.ex.ToolWindowManagerAdapter) Nullable(org.jetbrains.annotations.Nullable) SimpleToolWindowPanel(com.intellij.openapi.ui.SimpleToolWindowPanel) List(java.util.List) SimpleTree(com.intellij.ui.treeStructure.SimpleTree) ApplicationManager(com.intellij.openapi.application.ApplicationManager) WriteExternalException(com.intellij.openapi.util.WriteExternalException) NotNull(org.jetbrains.annotations.NotNull) ExternalTaskExecutionInfo(com.intellij.openapi.externalSystem.model.execution.ExternalTaskExecutionInfo) InputEvent(java.awt.event.InputEvent) java.util(java.util) ExternalSystemActionUtil(com.intellij.openapi.externalSystem.action.ExternalSystemActionUtil) ExternalSystemTaskActivator(com.intellij.openapi.externalSystem.service.project.manage.ExternalSystemTaskActivator) ExternalSystemViewGearAction(com.intellij.openapi.externalSystem.action.ExternalSystemViewGearAction) NonNls(org.jetbrains.annotations.NonNls) ExternalSystemShortcutsManager(com.intellij.openapi.externalSystem.service.project.manage.ExternalSystemShortcutsManager) InvalidDataException(com.intellij.openapi.util.InvalidDataException) ContainerUtil(com.intellij.util.containers.ContainerUtil) ExternalProjectsManager(com.intellij.openapi.externalSystem.service.project.manage.ExternalProjectsManager) NotificationGroup(com.intellij.notification.NotificationGroup) Project(com.intellij.openapi.project.Project) ExternalSystemUiUtil(com.intellij.openapi.externalSystem.util.ExternalSystemUiUtil) com.intellij.openapi.externalSystem.model(com.intellij.openapi.externalSystem.model) VfsUtilCore(com.intellij.openapi.vfs.VfsUtilCore) DisposeAwareRunnable(com.intellij.util.DisposeAwareRunnable) TreeSelectionModel(javax.swing.tree.TreeSelectionModel) ExternalSystemUiAware(com.intellij.openapi.externalSystem.ExternalSystemUiAware) ExternalSystemTaskLocation(com.intellij.openapi.externalSystem.service.execution.ExternalSystemTaskLocation) Disposable(com.intellij.openapi.Disposable) com.intellij.execution(com.intellij.execution) java.awt(java.awt) com.intellij.openapi.actionSystem(com.intellij.openapi.actionSystem) ToolWindowEx(com.intellij.openapi.wm.ex.ToolWindowEx) TaskData(com.intellij.openapi.externalSystem.model.task.TaskData) ToolWindowImpl(com.intellij.openapi.wm.impl.ToolWindowImpl) Navigatable(com.intellij.pom.Navigatable) Element(org.jdom.Element) ScrollPaneFactory(com.intellij.ui.ScrollPaneFactory) ExternalSystemSettingsListenerAdapter(com.intellij.openapi.externalSystem.settings.ExternalSystemSettingsListenerAdapter) ToolWindowManagerAdapter(com.intellij.openapi.wm.ex.ToolWindowManagerAdapter) ToolWindowManagerEx(com.intellij.openapi.wm.ex.ToolWindowManagerEx) ExternalSystemShortcutsManager(com.intellij.openapi.externalSystem.service.project.manage.ExternalSystemShortcutsManager) SmartList(com.intellij.util.SmartList) List(java.util.List) ProjectData(com.intellij.openapi.externalSystem.model.project.ProjectData)

Example 8 with ToolWindowManagerEx

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

the class DockablePopupManager method restorePopupBehavior.

protected void restorePopupBehavior() {
    if (myToolWindow != null) {
        PropertiesComponent.getInstance().setValue(getShowInToolWindowProperty(), Boolean.FALSE.toString());
        ToolWindowManagerEx toolWindowManagerEx = ToolWindowManagerEx.getInstanceEx(myProject);
        toolWindowManagerEx.hideToolWindow(getToolwindowId(), false);
        toolWindowManagerEx.unregisterToolWindow(getToolwindowId());
        Disposer.dispose(myToolWindow.getContentManager());
        myToolWindow = null;
        restartAutoUpdate(false);
    }
}
Also used : ToolWindowManagerEx(com.intellij.openapi.wm.ex.ToolWindowManagerEx)

Example 9 with ToolWindowManagerEx

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

the class ToggleFloatingModeAction method setSelected.

public void setSelected(AnActionEvent event, boolean flag) {
    Project project = event.getProject();
    if (project == null) {
        return;
    }
    String id = ToolWindowManager.getInstance(project).getActiveToolWindowId();
    if (id == null) {
        return;
    }
    ToolWindowManagerEx mgr = ToolWindowManagerEx.getInstanceEx(project);
    ToolWindowEx toolWindow = (ToolWindowEx) mgr.getToolWindow(id);
    ToolWindowType type = toolWindow.getType();
    if (ToolWindowType.FLOATING == type) {
        toolWindow.setType(toolWindow.getInternalType(), null);
    } else {
        toolWindow.setType(ToolWindowType.FLOATING, null);
    }
}
Also used : Project(com.intellij.openapi.project.Project) ToolWindowEx(com.intellij.openapi.wm.ex.ToolWindowEx) ToolWindowType(com.intellij.openapi.wm.ToolWindowType) ToolWindowManagerEx(com.intellij.openapi.wm.ex.ToolWindowManagerEx)

Example 10 with ToolWindowManagerEx

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

the class TogglePresentationModeAction method restoreToolWindows.

static void restoreToolWindows(Project project, boolean needsRestore, boolean inPresentation) {
    if (project == null || !needsRestore)
        return;
    ToolWindowManagerEx manager = ToolWindowManagerEx.getInstanceEx(project);
    DesktopLayout restoreLayout = manager.getLayoutToRestoreLater();
    if (!inPresentation && restoreLayout != null) {
        manager.setLayout(restoreLayout);
    }
}
Also used : DesktopLayout(com.intellij.openapi.wm.impl.DesktopLayout) 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