Search in sources :

Example 21 with ToolWindowManager

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

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

the class ExternalSystemUtil method ensureToolWindowContentInitialized.

@Nullable
public static ToolWindow ensureToolWindowContentInitialized(@NotNull Project project, @NotNull ProjectSystemId externalSystemId) {
    final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);
    if (toolWindowManager == null)
        return null;
    final ToolWindow toolWindow = toolWindowManager.getToolWindow(externalSystemId.getReadableName());
    if (toolWindow == null)
        return null;
    if (toolWindow instanceof ToolWindowImpl) {
        ((ToolWindowImpl) toolWindow).ensureContentInitialized();
    }
    return toolWindow;
}
Also used : ToolWindow(com.intellij.openapi.wm.ToolWindow) ToolWindowImpl(com.intellij.openapi.wm.impl.ToolWindowImpl) ToolWindowManager(com.intellij.openapi.wm.ToolWindowManager) Nullable(org.jetbrains.annotations.Nullable)

Example 23 with ToolWindowManager

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

the class ExternalToolWindowManager method getToolWindow.

@Nullable
private static ToolWindow getToolWindow(@NotNull Project project, @NotNull ProjectSystemId externalSystemId) {
    final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);
    if (toolWindowManager == null) {
        return null;
    }
    ToolWindow result = toolWindowManager.getToolWindow(externalSystemId.getReadableName());
    if (result instanceof ToolWindowImpl) {
        ((ToolWindowImpl) result).ensureContentInitialized();
    }
    return result;
}
Also used : ToolWindow(com.intellij.openapi.wm.ToolWindow) ToolWindowImpl(com.intellij.openapi.wm.impl.ToolWindowImpl) ToolWindowManager(com.intellij.openapi.wm.ToolWindowManager) Nullable(org.jetbrains.annotations.Nullable)

Example 24 with ToolWindowManager

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

the class RunDashboardManagerImpl method updateDashboard.

private void updateDashboard(final boolean withStructure) {
    final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(myProject);
    toolWindowManager.invokeLater(() -> {
        if (myProject.isDisposed()) {
            return;
        }
        if (withStructure) {
            boolean available = hasContent();
            ToolWindow toolWindow = toolWindowManager.getToolWindow(getToolWindowId());
            if (toolWindow == null) {
                if (available) {
                    createToolWindow();
                }
                return;
            }
            boolean doShow = !toolWindow.isAvailable() && available;
            toolWindow.setAvailable(available, null);
            if (doShow) {
                toolWindow.show(null);
            }
        }
        if (myDashboardContent != null) {
            myDashboardContent.updateContent(withStructure);
        }
    });
}
Also used : ToolWindow(com.intellij.openapi.wm.ToolWindow) ToolWindowManager(com.intellij.openapi.wm.ToolWindowManager)

Example 25 with ToolWindowManager

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

the class ProgramRunnerUtil method executeConfiguration.

public static void executeConfiguration(@NotNull final ExecutionEnvironment environment, boolean showSettings, boolean assignNewId) {
    if (ExecutorRegistry.getInstance().isStarting(environment)) {
        return;
    }
    RunnerAndConfigurationSettings runnerAndConfigurationSettings = environment.getRunnerAndConfigurationSettings();
    final Project project = environment.getProject();
    if (runnerAndConfigurationSettings != null) {
        if (!ExecutionTargetManager.canRun(environment)) {
            ExecutionUtil.handleExecutionError(environment, new ExecutionException(StringUtil.escapeXml("Cannot run '" + environment.getRunProfile().getName() + "' on '" + environment.getExecutionTarget().getDisplayName() + "'")));
            return;
        }
        if ((!RunManagerImpl.canRunConfiguration(environment) || (showSettings && runnerAndConfigurationSettings.isEditBeforeRun())) && !DumbService.isDumb(project)) {
            if (!RunDialog.editConfiguration(environment, "Edit configuration")) {
                return;
            }
            while (!RunManagerImpl.canRunConfiguration(environment)) {
                if (Messages.YES == Messages.showYesNoDialog(project, "Configuration is still incorrect. Do you want to edit it again?", "Change Configuration Settings", "Edit", "Continue Anyway", Messages.getErrorIcon())) {
                    if (!RunDialog.editConfiguration(environment, "Edit configuration")) {
                        return;
                    }
                } else {
                    break;
                }
            }
        }
        ConfigurationType configurationType = runnerAndConfigurationSettings.getType();
        if (configurationType != null) {
            UsageTrigger.trigger("execute." + ConvertUsagesUtil.ensureProperKey(configurationType.getId()) + "." + environment.getExecutor().getId());
        }
    }
    try {
        if (assignNewId) {
            environment.assignNewExecutionId();
        }
        if (DumbService.isDumb(project) && Registry.is("dumb.aware.run.configurations")) {
            UIUtil.invokeLaterIfNeeded(() -> {
                if (project.isDisposed()) {
                    return;
                }
                final String toolWindowId = ExecutionManager.getInstance(project).getContentManager().getToolWindowIdByEnvironment(environment);
                ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);
                if (toolWindowManager.canShowNotification(toolWindowId)) {
                    //noinspection SSBasedInspection
                    toolWindowManager.notifyByBalloon(toolWindowId, MessageType.INFO, "Some actions may not work as expected if you start a Run/debug configuration while indexing is in progress.");
                }
            });
        }
        environment.getRunner().execute(environment);
    } catch (ExecutionException e) {
        String name = runnerAndConfigurationSettings != null ? runnerAndConfigurationSettings.getName() : null;
        if (name == null) {
            name = environment.getRunProfile().getName();
        }
        if (name == null && environment.getContentToReuse() != null) {
            name = environment.getContentToReuse().getDisplayName();
        }
        if (name == null) {
            name = "<Unknown>";
        }
        ExecutionUtil.handleExecutionError(project, ExecutionManager.getInstance(project).getContentManager().getToolWindowIdByEnvironment(environment), name, e);
    }
}
Also used : ConfigurationType(com.intellij.execution.configurations.ConfigurationType) Project(com.intellij.openapi.project.Project) 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