Search in sources :

Example 1 with NopProcessHandler

use of com.intellij.execution.process.NopProcessHandler in project intellij-plugins by JetBrains.

the class JstdRunProfileState method createProcessHandler.

@NotNull
private ProcessHandler createProcessHandler(@Nullable JstdServer ideServer) throws ExecutionException {
    String serverUrl = getServerUrl(ideServer);
    if (serverUrl != null) {
        return createOSProcessHandler(serverUrl);
    }
    final NopProcessHandler nopProcessHandler = new NopProcessHandler();
    if (ideServer != null) {
        ideServer.addLifeCycleListener(new JstdServerLifeCycleAdapter() {

            @Override
            public void onServerTerminated(int exitCode) {
                nopProcessHandler.destroyProcess();
            }
        }, myEnvironment.getProject());
    }
    return nopProcessHandler;
}
Also used : NopProcessHandler(com.intellij.execution.process.NopProcessHandler) JstdServerLifeCycleAdapter(com.google.jstestdriver.idea.server.JstdServerLifeCycleAdapter) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with NopProcessHandler

use of com.intellij.execution.process.NopProcessHandler in project intellij-plugins by JetBrains.

the class JstdCoverageProgramRunner method start.

@Nullable
private static RunContentDescriptor start(@Nullable JstdServer server, @NotNull ExecutionEnvironment environment) throws ExecutionException {
    FileDocumentManager.getInstance().saveAllDocuments();
    JstdRunConfiguration runConfiguration = (JstdRunConfiguration) environment.getRunProfile();
    CoverageEnabledConfiguration coverageEnabledConfiguration = CoverageEnabledConfiguration.getOrCreate(runConfiguration);
    String coverageFilePath = coverageEnabledConfiguration.getCoverageFilePath();
    JstdRunProfileState jstdState = new JstdRunProfileState(environment, runConfiguration.getRunSettings(), coverageFilePath);
    ExecutionResult executionResult = jstdState.executeWithServer(server);
    RunContentBuilder contentBuilder = new RunContentBuilder(executionResult, environment);
    final RunContentDescriptor descriptor = contentBuilder.showRunContent(environment.getContentToReuse());
    ProcessHandler processHandler = executionResult.getProcessHandler();
    if (processHandler instanceof NopProcessHandler) {
        if (server != null) {
            server.addLifeCycleListener(new JstdServerLifeCycleAdapter() {

                @Override
                public void onBrowserCaptured(@NotNull JstdBrowserInfo info) {
                    ExecutionUtil.restartIfActive(descriptor);
                    server.removeLifeCycleListener(this);
                }
            }, contentBuilder);
        }
    } else {
        CoverageHelper.attachToProcess(runConfiguration, processHandler, environment.getRunnerSettings());
    }
    return descriptor;
}
Also used : JstdRunConfiguration(com.google.jstestdriver.idea.execution.JstdRunConfiguration) RunContentDescriptor(com.intellij.execution.ui.RunContentDescriptor) CoverageEnabledConfiguration(com.intellij.execution.configurations.coverage.CoverageEnabledConfiguration) JstdRunProfileState(com.google.jstestdriver.idea.execution.JstdRunProfileState) NopProcessHandler(com.intellij.execution.process.NopProcessHandler) ProcessHandler(com.intellij.execution.process.ProcessHandler) ExecutionResult(com.intellij.execution.ExecutionResult) NopProcessHandler(com.intellij.execution.process.NopProcessHandler) RunContentBuilder(com.intellij.execution.runners.RunContentBuilder) JstdServerLifeCycleAdapter(com.google.jstestdriver.idea.server.JstdServerLifeCycleAdapter) JstdBrowserInfo(com.google.jstestdriver.idea.server.JstdBrowserInfo) Nullable(org.jetbrains.annotations.Nullable)

Example 3 with NopProcessHandler

use of com.intellij.execution.process.NopProcessHandler in project intellij-plugins by JetBrains.

the class JstdRunProgramRunner method start.

public static RunContentDescriptor start(@Nullable JstdServer server, boolean fromDebug, @NotNull RunProfileState state, @NotNull ExecutionEnvironment environment) throws ExecutionException {
    FileDocumentManager.getInstance().saveAllDocuments();
    JstdRunProfileState jstdState = JstdRunProfileState.cast(state);
    ExecutionResult executionResult = jstdState.executeWithServer(server);
    RunContentBuilder contentBuilder = new RunContentBuilder(executionResult, environment);
    final RunContentDescriptor descriptor = contentBuilder.showRunContent(environment.getContentToReuse());
    if (server != null && executionResult.getProcessHandler() instanceof NopProcessHandler) {
        server.addLifeCycleListener(new JstdServerLifeCycleAdapter() {

            @Override
            public void onBrowserCaptured(@NotNull JstdBrowserInfo info) {
                if (fromDebug) {
                    final Alarm alarm = new Alarm(Alarm.ThreadToUse.SWING_THREAD, descriptor);
                    alarm.addRequest(() -> ExecutionUtil.restartIfActive(descriptor), 1000);
                } else {
                    ExecutionUtil.restartIfActive(descriptor);
                }
                server.removeLifeCycleListener(this);
            }
        }, contentBuilder);
    }
    return descriptor;
}
Also used : RunContentDescriptor(com.intellij.execution.ui.RunContentDescriptor) Alarm(com.intellij.util.Alarm) ExecutionResult(com.intellij.execution.ExecutionResult) NopProcessHandler(com.intellij.execution.process.NopProcessHandler) RunContentBuilder(com.intellij.execution.runners.RunContentBuilder) JstdServerLifeCycleAdapter(com.google.jstestdriver.idea.server.JstdServerLifeCycleAdapter) JstdBrowserInfo(com.google.jstestdriver.idea.server.JstdBrowserInfo)

Example 4 with NopProcessHandler

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

the class DuplexConsoleActionsTest method createConsoleWithReversedActions.

@NotNull
private static ConsoleViewImpl createConsoleWithReversedActions() {
    Project project = getProject();
    ConsoleViewImpl console = new ConsoleViewImpl(project, GlobalSearchScope.allScope(project), false, false) {

        @NotNull
        @Override
        public AnAction[] createConsoleActions() {
            return ContainerUtil.reverse(Arrays.asList(super.createConsoleActions())).toArray(AnAction.EMPTY_ARRAY);
        }
    };
    console.getComponent();
    ProcessHandler processHandler = new NopProcessHandler();
    processHandler.startNotify();
    console.attachToProcess(processHandler);
    return console;
}
Also used : Project(com.intellij.openapi.project.Project) ProcessHandler(com.intellij.execution.process.ProcessHandler) NopProcessHandler(com.intellij.execution.process.NopProcessHandler) NopProcessHandler(com.intellij.execution.process.NopProcessHandler) AnAction(com.intellij.openapi.actionSystem.AnAction) NotNull(org.jetbrains.annotations.NotNull)

Example 5 with NopProcessHandler

use of com.intellij.execution.process.NopProcessHandler 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)

Aggregations

NopProcessHandler (com.intellij.execution.process.NopProcessHandler)5 JstdServerLifeCycleAdapter (com.google.jstestdriver.idea.server.JstdServerLifeCycleAdapter)3 ProcessHandler (com.intellij.execution.process.ProcessHandler)3 NotNull (org.jetbrains.annotations.NotNull)3 JstdBrowserInfo (com.google.jstestdriver.idea.server.JstdBrowserInfo)2 ExecutionResult (com.intellij.execution.ExecutionResult)2 RunContentBuilder (com.intellij.execution.runners.RunContentBuilder)2 RunContentDescriptor (com.intellij.execution.ui.RunContentDescriptor)2 Project (com.intellij.openapi.project.Project)2 JstdRunConfiguration (com.google.jstestdriver.idea.execution.JstdRunConfiguration)1 JstdRunProfileState (com.google.jstestdriver.idea.execution.JstdRunProfileState)1 CoverageEnabledConfiguration (com.intellij.execution.configurations.coverage.CoverageEnabledConfiguration)1 AnAction (com.intellij.openapi.actionSystem.AnAction)1 Alarm (com.intellij.util.Alarm)1 Nullable (org.jetbrains.annotations.Nullable)1