Search in sources :

Example 11 with RunContentDescriptor

use of com.intellij.execution.ui.RunContentDescriptor in project intellij-community by JetBrains.

the class RunDashboardManagerImpl method getRunConfigurations.

@Override
public List<Pair<RunnerAndConfigurationSettings, RunContentDescriptor>> getRunConfigurations() {
    List<Pair<RunnerAndConfigurationSettings, RunContentDescriptor>> result = new ArrayList<>();
    List<RunnerAndConfigurationSettings> configurations = RunManager.getInstance(myProject).getAllSettings().stream().filter(runConfiguration -> RunDashboardContributor.isShowInDashboard(runConfiguration.getType())).collect(Collectors.toList());
    //noinspection ConstantConditions ???
    ExecutionManagerImpl executionManager = ExecutionManagerImpl.getInstance(myProject);
    configurations.forEach(configurationSettings -> {
        List<RunContentDescriptor> descriptors = executionManager.getDescriptors(settings -> Comparing.equal(settings.getConfiguration(), configurationSettings.getConfiguration()));
        if (descriptors.isEmpty()) {
            result.add(Pair.create(configurationSettings, null));
        } else {
            descriptors.forEach(descriptor -> result.add(Pair.create(configurationSettings, descriptor)));
        }
    });
    // It is possible that run configuration was deleted, but there is running content descriptor for such run configuration.
    // It should be shown in he dashboard tree.
    List<RunConfiguration> storedConfigurations = configurations.stream().map(RunnerAndConfigurationSettings::getConfiguration).collect(Collectors.toList());
    List<RunContentDescriptor> notStoredDescriptors = executionManager.getRunningDescriptors(settings -> {
        RunConfiguration configuration = settings.getConfiguration();
        return RunDashboardContributor.isShowInDashboard(settings.getType()) && !storedConfigurations.contains(configuration);
    });
    notStoredDescriptors.forEach(descriptor -> {
        Set<RunnerAndConfigurationSettings> settings = executionManager.getConfigurations(descriptor);
        settings.forEach(setting -> result.add(Pair.create(setting, descriptor)));
    });
    return result;
}
Also used : Storage(com.intellij.openapi.components.Storage) ToolWindowManager(com.intellij.openapi.wm.ToolWindowManager) Arrays(java.util.Arrays) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) AllIcons(com.intellij.icons.AllIcons) PersistentStateComponent(com.intellij.openapi.components.PersistentStateComponent) ArrayList(java.util.ArrayList) MessageBusConnection(com.intellij.util.messages.MessageBusConnection) ExecutionEnvironment(com.intellij.execution.runners.ExecutionEnvironment) Comparing(com.intellij.openapi.util.Comparing) DashboardGrouper(com.intellij.execution.dashboard.tree.DashboardGrouper) ToolWindowId(com.intellij.openapi.wm.ToolWindowId) State(com.intellij.openapi.components.State) Disposer(com.intellij.openapi.util.Disposer) Project(com.intellij.openapi.project.Project) ContentUI(com.intellij.ui.content.ContentUI) ToolWindowAnchor(com.intellij.openapi.wm.ToolWindowAnchor) DumbService(com.intellij.openapi.project.DumbService) ToolWindow(com.intellij.openapi.wm.ToolWindow) Content(com.intellij.ui.content.Content) Set(java.util.Set) Collectors(java.util.stream.Collectors) ProcessHandler(com.intellij.execution.process.ProcessHandler) com.intellij.execution(com.intellij.execution) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) ContentFactory(com.intellij.ui.content.ContentFactory) RunContentDescriptor(com.intellij.execution.ui.RunContentDescriptor) StoragePathMacros(com.intellij.openapi.components.StoragePathMacros) Pair(com.intellij.openapi.util.Pair) ExecutionManagerImpl(com.intellij.execution.impl.ExecutionManagerImpl) ContentManager(com.intellij.ui.content.ContentManager) Registry(com.intellij.openapi.util.registry.Registry) NotNull(org.jetbrains.annotations.NotNull) javax.swing(javax.swing) RunContentDescriptor(com.intellij.execution.ui.RunContentDescriptor) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) ArrayList(java.util.ArrayList) Pair(com.intellij.openapi.util.Pair) ExecutionManagerImpl(com.intellij.execution.impl.ExecutionManagerImpl)

Example 12 with RunContentDescriptor

use of com.intellij.execution.ui.RunContentDescriptor in project intellij-community by JetBrains.

the class ExecutorAction method doActionPerformed.

@Override
protected void doActionPerformed(DashboardRunConfigurationNode node) {
    RunContentDescriptor descriptor = node.getDescriptor();
    ExecutionManager.getInstance(node.getProject()).restartRunProfile(node.getProject(), getExecutor(), ExecutionTargetManager.getActiveTarget(node.getProject()), node.getConfigurationSettings(), descriptor == null ? null : descriptor.getProcessHandler());
}
Also used : RunContentDescriptor(com.intellij.execution.ui.RunContentDescriptor)

Example 13 with RunContentDescriptor

use of com.intellij.execution.ui.RunContentDescriptor in project intellij-community by JetBrains.

the class EOFAction method update.

@Override
public void update(AnActionEvent e) {
    RunContentDescriptor descriptor = StopAction.getRecentlyStartedContentDescriptor(e.getDataContext());
    ProcessHandler handler = descriptor != null ? descriptor.getProcessHandler() : null;
    e.getPresentation().setEnabledAndVisible(e.getData(LangDataKeys.CONSOLE_VIEW) != null && e.getData(CommonDataKeys.EDITOR) != null && handler != null && !handler.isProcessTerminated());
}
Also used : RunContentDescriptor(com.intellij.execution.ui.RunContentDescriptor) ProcessHandler(com.intellij.execution.process.ProcessHandler)

Example 14 with RunContentDescriptor

use of com.intellij.execution.ui.RunContentDescriptor in project intellij-community by JetBrains.

the class ExecutionManagerTest method getProcessHandler.

@NotNull
private static FakeProcessHandler getProcessHandler(@NotNull ExecutionManagerImpl executionManager) {
    RunContentDescriptor descriptor = ExecutionTestUtil.getSingleRunContentDescriptor(executionManager);
    ProcessHandler processHandler = descriptor.getProcessHandler();
    assertNotNull(processHandler);
    return (FakeProcessHandler) processHandler;
}
Also used : RunContentDescriptor(com.intellij.execution.ui.RunContentDescriptor) ProcessHandler(com.intellij.execution.process.ProcessHandler) NotNull(org.jetbrains.annotations.NotNull)

Example 15 with RunContentDescriptor

use of com.intellij.execution.ui.RunContentDescriptor in project intellij-community by JetBrains.

the class ExecutionTestUtil method getSingleRunContentDescriptor.

@NotNull
public static RunContentDescriptor getSingleRunContentDescriptor(@NotNull ExecutionManager executionManager) {
    List<RunContentDescriptor> descriptors = ((ExecutionManagerImpl) executionManager).getRunningDescriptors(Conditions.alwaysTrue());
    String actualDescriptorsMsg = stringifyDescriptors(descriptors);
    Assert.assertEquals(actualDescriptorsMsg, 1, descriptors.size());
    RunContentDescriptor descriptor = ContainerUtil.getFirstItem(descriptors);
    return ObjectUtils.notNull(descriptor);
}
Also used : RunContentDescriptor(com.intellij.execution.ui.RunContentDescriptor) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

RunContentDescriptor (com.intellij.execution.ui.RunContentDescriptor)70 ProcessHandler (com.intellij.execution.process.ProcessHandler)26 Project (com.intellij.openapi.project.Project)18 NotNull (org.jetbrains.annotations.NotNull)14 Nullable (org.jetbrains.annotations.Nullable)13 ExecutionEnvironment (com.intellij.execution.runners.ExecutionEnvironment)11 Executor (com.intellij.execution.Executor)10 DefaultRunExecutor (com.intellij.execution.executors.DefaultRunExecutor)9 ProcessEvent (com.intellij.execution.process.ProcessEvent)8 ExecutionException (com.intellij.execution.ExecutionException)7 ProcessAdapter (com.intellij.execution.process.ProcessAdapter)7 ArrayList (java.util.ArrayList)7 ProgramRunner (com.intellij.execution.runners.ProgramRunner)6 ExecutionResult (com.intellij.execution.ExecutionResult)5 RunProfile (com.intellij.execution.configurations.RunProfile)5 CloseAction (com.intellij.execution.ui.actions.CloseAction)5 Pair (com.intellij.openapi.util.Pair)5 IOException (java.io.IOException)5 RunContentManager (com.intellij.execution.ui.RunContentManager)4 ApplicationManager (com.intellij.openapi.application.ApplicationManager)4