Search in sources :

Example 71 with ProcessHandler

use of com.intellij.execution.process.ProcessHandler in project intellij-community by JetBrains.

the class ConsoleViewImplTest method createConsole.

@NotNull
static ConsoleViewImpl createConsole() {
    Project project = getProject();
    ConsoleViewImpl console = new ConsoleViewImpl(project, GlobalSearchScope.allScope(project), false, false);
    // initConsoleEditor()
    console.getComponent();
    ProcessHandler processHandler = new NopProcessHandler();
    processHandler.startNotify();
    console.attachToProcess(processHandler);
    return console;
}
Also used : Project(com.intellij.openapi.project.Project) NopProcessHandler(com.intellij.execution.process.NopProcessHandler) ProcessHandler(com.intellij.execution.process.ProcessHandler) NopProcessHandler(com.intellij.execution.process.NopProcessHandler) NotNull(org.jetbrains.annotations.NotNull)

Example 72 with ProcessHandler

use of com.intellij.execution.process.ProcessHandler in project intellij-community by JetBrains.

the class RunContentManagerImpl method showRunContent.

private void showRunContent(@NotNull final Executor executor, @NotNull final RunContentDescriptor descriptor, final long executionId) {
    if (ApplicationManager.getApplication().isUnitTestMode()) {
        return;
    }
    final ContentManager contentManager = getContentManagerForRunner(executor, descriptor);
    RunContentDescriptor oldDescriptor = chooseReuseContentForDescriptor(contentManager, descriptor, executionId, descriptor.getDisplayName());
    final Content content;
    if (oldDescriptor == null) {
        content = createNewContent(descriptor, executor);
    } else {
        content = oldDescriptor.getAttachedContent();
        LOG.assertTrue(content != null);
        getSyncPublisher().contentRemoved(oldDescriptor, executor);
        // is of the same category, can be reused
        Disposer.dispose(oldDescriptor);
    }
    content.setExecutionId(executionId);
    content.setComponent(descriptor.getComponent());
    content.setPreferredFocusedComponent(descriptor.getPreferredFocusComputable());
    content.putUserData(RunContentDescriptor.DESCRIPTOR_KEY, descriptor);
    content.putUserData(EXECUTOR_KEY, executor);
    content.setDisplayName(descriptor.getDisplayName());
    descriptor.setAttachedContent(content);
    String toolWindowId = getToolWindowIdForRunner(executor, descriptor);
    final ToolWindow toolWindow = ToolWindowManager.getInstance(myProject).getToolWindow(toolWindowId);
    final ProcessHandler processHandler = descriptor.getProcessHandler();
    if (processHandler != null) {
        final ProcessAdapter processAdapter = new ProcessAdapter() {

            @Override
            public void startNotified(final ProcessEvent event) {
                UIUtil.invokeLaterIfNeeded(() -> {
                    content.setIcon(ExecutionUtil.getLiveIndicator(descriptor.getIcon()));
                    toolWindow.setIcon(ExecutionUtil.getLiveIndicator(myToolwindowIdToBaseIconMap.get(toolWindowId)));
                });
            }

            @Override
            public void processTerminated(final ProcessEvent event) {
                ApplicationManager.getApplication().invokeLater(() -> {
                    boolean alive = false;
                    ContentManager manager = myToolwindowIdToContentManagerMap.get(toolWindowId);
                    if (manager == null)
                        return;
                    for (Content content1 : manager.getContents()) {
                        RunContentDescriptor descriptor1 = getRunContentDescriptorByContent(content1);
                        if (descriptor1 != null) {
                            ProcessHandler handler = descriptor1.getProcessHandler();
                            if (handler != null && !handler.isProcessTerminated()) {
                                alive = true;
                                break;
                            }
                        }
                    }
                    Icon base = myToolwindowIdToBaseIconMap.get(toolWindowId);
                    toolWindow.setIcon(alive ? ExecutionUtil.getLiveIndicator(base) : base);
                    Icon icon = descriptor.getIcon();
                    content.setIcon(icon == null ? executor.getDisabledIcon() : IconLoader.getTransparentIcon(icon));
                });
            }
        };
        processHandler.addProcessListener(processAdapter);
        final Disposable disposer = content.getDisposer();
        if (disposer != null) {
            Disposer.register(disposer, new Disposable() {

                @Override
                public void dispose() {
                    processHandler.removeProcessListener(processAdapter);
                }
            });
        }
    }
    if (oldDescriptor == null) {
        contentManager.addContent(content);
        new CloseListener(content, executor);
    }
    content.getManager().setSelectedContent(content);
    if (!descriptor.isActivateToolWindowWhenAdded()) {
        return;
    }
    ApplicationManager.getApplication().invokeLater(() -> {
        ToolWindow window = ToolWindowManager.getInstance(myProject).getToolWindow(toolWindowId);
        // let's activate tool window, but don't move focus
        //
        // window.show() isn't valid here, because it will not
        // mark the window as "last activated" windows and thus
        // some action like navigation up/down in stacktrace wont
        // work correctly
        descriptor.getPreferredFocusComputable();
        window.activate(descriptor.getActivationCallback(), descriptor.isAutoFocusContent(), descriptor.isAutoFocusContent());
    }, myProject.getDisposed());
}
Also used : Disposable(com.intellij.openapi.Disposable) ProcessAdapter(com.intellij.execution.process.ProcessAdapter) ProcessEvent(com.intellij.execution.process.ProcessEvent) ToolWindow(com.intellij.openapi.wm.ToolWindow) ProcessHandler(com.intellij.execution.process.ProcessHandler)

Example 73 with ProcessHandler

use of com.intellij.execution.process.ProcessHandler in project intellij-community by JetBrains.

the class RunContentManagerImpl method isTerminated.

public static boolean isTerminated(@NotNull Content content) {
    RunContentDescriptor descriptor = getRunContentDescriptorByContent(content);
    ProcessHandler processHandler = descriptor == null ? null : descriptor.getProcessHandler();
    return processHandler == null || processHandler.isProcessTerminated();
}
Also used : ProcessHandler(com.intellij.execution.process.ProcessHandler)

Example 74 with ProcessHandler

use of com.intellij.execution.process.ProcessHandler in project intellij-community by JetBrains.

the class FakeRerunAction method isEnabled.

protected boolean isEnabled(AnActionEvent event) {
    RunContentDescriptor descriptor = getDescriptor(event);
    ProcessHandler processHandler = descriptor == null ? null : descriptor.getProcessHandler();
    ExecutionEnvironment environment = getEnvironment(event);
    return environment != null && !ExecutorRegistry.getInstance().isStarting(environment) && !(processHandler != null && processHandler.isProcessTerminating());
}
Also used : RunContentDescriptor(com.intellij.execution.ui.RunContentDescriptor) ProcessHandler(com.intellij.execution.process.ProcessHandler)

Example 75 with ProcessHandler

use of com.intellij.execution.process.ProcessHandler in project intellij-community by JetBrains.

the class RunTab method initLogConsoles.

protected final void initLogConsoles(@NotNull RunProfile runConfiguration, @NotNull RunContentDescriptor contentDescriptor, @Nullable ExecutionConsole console) {
    ProcessHandler processHandler = contentDescriptor.getProcessHandler();
    if (runConfiguration instanceof RunConfigurationBase) {
        RunConfigurationBase configuration = (RunConfigurationBase) runConfiguration;
        if (myManager == null) {
            myManager = new LogFilesManager(myProject, getLogConsoleManager(), contentDescriptor);
        }
        myManager.addLogConsoles(configuration, processHandler);
        if (processHandler != null) {
            OutputFileUtil.attachDumpListener(configuration, processHandler, console);
        }
    }
}
Also used : RunConfigurationBase(com.intellij.execution.configurations.RunConfigurationBase) LogFilesManager(com.intellij.diagnostic.logging.LogFilesManager) ProcessHandler(com.intellij.execution.process.ProcessHandler)

Aggregations

ProcessHandler (com.intellij.execution.process.ProcessHandler)100 NotNull (org.jetbrains.annotations.NotNull)31 RunContentDescriptor (com.intellij.execution.ui.RunContentDescriptor)24 ExecutionException (com.intellij.execution.ExecutionException)17 Project (com.intellij.openapi.project.Project)17 ConsoleView (com.intellij.execution.ui.ConsoleView)16 DefaultExecutionResult (com.intellij.execution.DefaultExecutionResult)15 ProcessEvent (com.intellij.execution.process.ProcessEvent)14 ExecutionEnvironment (com.intellij.execution.runners.ExecutionEnvironment)14 ProcessAdapter (com.intellij.execution.process.ProcessAdapter)13 ProgramRunner (com.intellij.execution.runners.ProgramRunner)12 Nullable (org.jetbrains.annotations.Nullable)10 Executor (com.intellij.execution.Executor)9 GeneralCommandLine (com.intellij.execution.configurations.GeneralCommandLine)7 Disposable (com.intellij.openapi.Disposable)7 RunProfile (com.intellij.execution.configurations.RunProfile)6 OSProcessHandler (com.intellij.execution.process.OSProcessHandler)6 SMTRunnerConsoleView (com.intellij.execution.testframework.sm.runner.ui.SMTRunnerConsoleView)6 File (java.io.File)6 DefaultRunExecutor (com.intellij.execution.executors.DefaultRunExecutor)5