Search in sources :

Example 26 with ProcessAdapter

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

the class KarmaConsoleView method registerConsoleContent.

@NotNull
private Content registerConsoleContent(@NotNull final RunnerLayoutUi ui) {
    ui.getOptions().setMinimizeActionEnabled(false);
    final Content consoleContent = ui.createContent(ExecutionConsole.CONSOLE_CONTENT_ID, getComponent(), "Test Run", AllIcons.Debugger.Console, getPreferredFocusableComponent());
    ui.addContent(consoleContent, 1, PlaceInGrid.bottom, false);
    consoleContent.setCloseable(false);
    final KarmaRootTestProxyFormatter rootFormatter = new KarmaRootTestProxyFormatter(this, myServer);
    if (myServer.areBrowsersReady()) {
        KarmaUtil.selectAndFocusIfNotDisposed(ui, consoleContent, false, false);
    } else {
        myServer.onPortBound(() -> {
            KarmaUtil.selectAndFocusIfNotDisposed(ui, consoleContent, false, false);
            scheduleBrowserCapturingSuggestion();
        });
    }
    final ProcessAdapter listener = new ProcessAdapter() {

        @Override
        public void processTerminated(ProcessEvent event) {
            if (myServer.getProcessHandler().isProcessTerminated()) {
                rootFormatter.onServerProcessTerminated();
                printServerFinishedInfo();
            }
            rootFormatter.onTestRunProcessTerminated();
        }
    };
    myExecutionSession.getProcessHandler().addProcessListener(listener);
    Disposer.register(this, new Disposable() {

        @Override
        public void dispose() {
            myExecutionSession.getProcessHandler().removeProcessListener(listener);
        }
    });
    return consoleContent;
}
Also used : Disposable(com.intellij.openapi.Disposable) ProcessAdapter(com.intellij.execution.process.ProcessAdapter) ProcessEvent(com.intellij.execution.process.ProcessEvent) Content(com.intellij.ui.content.Content) NotNull(org.jetbrains.annotations.NotNull)

Example 27 with ProcessAdapter

use of com.intellij.execution.process.ProcessAdapter in project intellij-leiningen-plugin by derkork.

the class LeiningenRunConfigurationType method runConfiguration.

public static void runConfiguration(Project project, LeiningenRunnerParameters params, DataContext context) {
    RunnerAndConfigurationSettings configSettings = createRunnerAndConfigurationSettings(params, project);
    ProgramRunner runner = RunnerRegistry.getInstance().findRunnerById(DefaultRunExecutor.EXECUTOR_ID);
    Executor executor = DefaultRunExecutor.getRunExecutorInstance();
    ExecutionEnvironment env = new ExecutionEnvironment(executor, runner, configSettings, project);
    try {
        runner.execute(env, new ProgramRunner.Callback() {

            public void processStarted(RunContentDescriptor runContentDescriptor) {
                final ProcessHandler runContentDescriptorProcessHandler = runContentDescriptor.getProcessHandler();
                if (runContentDescriptorProcessHandler != null) {
                    runContentDescriptorProcessHandler.addProcessListener(new ProcessAdapter() {

                        @Override
                        public void processTerminated(ProcessEvent event) {
                            LocalFileSystem.getInstance().refreshWithoutFileWatcher(true);
                        }
                    });
                }
            }
        });
    } catch (ExecutionException e) {
    }
}
Also used : ExecutionEnvironment(com.intellij.execution.runners.ExecutionEnvironment) DefaultRunExecutor(com.intellij.execution.executors.DefaultRunExecutor) RunContentDescriptor(com.intellij.execution.ui.RunContentDescriptor) ProcessAdapter(com.intellij.execution.process.ProcessAdapter) ProcessEvent(com.intellij.execution.process.ProcessEvent) ProcessHandler(com.intellij.execution.process.ProcessHandler) ProgramRunner(com.intellij.execution.runners.ProgramRunner)

Example 28 with ProcessAdapter

use of com.intellij.execution.process.ProcessAdapter in project buck by facebook.

the class BuckToGeneralTestEventsConverter method onStartTesting.

@Override
public void onStartTesting() {
    mConnection = mProject.getMessageBus().connect();
    mConnection.subscribe(TestResultsAvailableConsumer.BUCK_TEST_RESULTS_AVAILABLE, this);
    mConnection.subscribe(TestRunCompleteConsumer.BUCK_TEST_RUN_COMPLETE, this);
    mConnection.subscribe(TestRunStartedConsumer.BUCK_TEST_RUN_STARTED, this);
    mConnection.subscribe(BuckBuildStartConsumer.BUCK_BUILD_START, this);
    mConnection.subscribe(BuckBuildEndConsumer.BUCK_BUILD_END, this);
    mConnection.subscribe(CompilerErrorConsumer.COMPILER_ERROR_CONSUMER, this);
    myHandler.addProcessListener(new ProcessAdapter() {

        @Override
        public void processTerminated(ProcessEvent event) {
            mConnection.disconnect();
        }
    });
}
Also used : ProcessAdapter(com.intellij.execution.process.ProcessAdapter) ProcessEvent(com.intellij.execution.process.ProcessEvent)

Example 29 with ProcessAdapter

use of com.intellij.execution.process.ProcessAdapter in project go-lang-idea-plugin by go-lang-plugin-org.

the class GoBeforeRunTaskProvider method executeTask.

@Override
public boolean executeTask(DataContext context, RunConfiguration configuration, ExecutionEnvironment env, GoCommandBeforeRunTask task) {
    Semaphore done = new Semaphore();
    Ref<Boolean> result = Ref.create(false);
    GoRunConfigurationBase goRunConfiguration = (GoRunConfigurationBase) configuration;
    Module module = goRunConfiguration.getConfigurationModule().getModule();
    Project project = configuration.getProject();
    String workingDirectory = goRunConfiguration.getWorkingDirectory();
    UIUtil.invokeAndWaitIfNeeded(new Runnable() {

        @Override
        public void run() {
            if (StringUtil.isEmpty(task.getCommand()))
                return;
            if (project == null || project.isDisposed())
                return;
            GoSdkService sdkService = GoSdkService.getInstance(project);
            if (!sdkService.isGoModule(module))
                return;
            done.down();
            GoExecutor.in(module).withParameterString(task.getCommand()).withWorkDirectory(workingDirectory).showOutputOnError().showNotifications(false, true).withPresentableName("Executing `" + task + "`").withProcessListener(new ProcessAdapter() {

                @Override
                public void processTerminated(ProcessEvent event) {
                    done.up();
                    result.set(event.getExitCode() == 0);
                }
            }).executeWithProgress(false, result1 -> VirtualFileManager.getInstance().asyncRefresh(null));
        }
    });
    done.waitFor();
    return result.get();
}
Also used : UIUtil(com.intellij.util.ui.UIUtil) GoRunConfigurationBase(com.goide.runconfig.GoRunConfigurationBase) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) DataContext(com.intellij.openapi.actionSystem.DataContext) GoIcons(com.goide.GoIcons) StringUtil(com.intellij.openapi.util.text.StringUtil) GoExecutor(com.goide.util.GoExecutor) ProcessAdapter(com.intellij.execution.process.ProcessAdapter) Key(com.intellij.openapi.util.Key) VirtualFileManager(com.intellij.openapi.vfs.VirtualFileManager) GoSdkService(com.goide.sdk.GoSdkService) Nullable(org.jetbrains.annotations.Nullable) ExecutionEnvironment(com.intellij.execution.runners.ExecutionEnvironment) Semaphore(com.intellij.util.concurrency.Semaphore) BeforeRunTaskProvider(com.intellij.execution.BeforeRunTaskProvider) Project(com.intellij.openapi.project.Project) ProcessEvent(com.intellij.execution.process.ProcessEvent) Messages(com.intellij.openapi.ui.Messages) Module(com.intellij.openapi.module.Module) Ref(com.intellij.openapi.util.Ref) javax.swing(javax.swing) ProcessAdapter(com.intellij.execution.process.ProcessAdapter) ProcessEvent(com.intellij.execution.process.ProcessEvent) Semaphore(com.intellij.util.concurrency.Semaphore) GoSdkService(com.goide.sdk.GoSdkService) GoRunConfigurationBase(com.goide.runconfig.GoRunConfigurationBase) Project(com.intellij.openapi.project.Project) Module(com.intellij.openapi.module.Module)

Example 30 with ProcessAdapter

use of com.intellij.execution.process.ProcessAdapter in project intellij-elixir by KronicDeth.

the class ElixirBuilder method runMix.

private static void runMix(@NotNull ElixirTarget target, @NotNull String elixirPath, @NotNull String mixPath, @Nullable String contentRootPath, @NotNull ElixirCompilerOptions compilerOptions, @NotNull CompileContext context) throws ProjectBuildException {
    GeneralCommandLine commandLine = new GeneralCommandLine();
    commandLine.withWorkDirectory(contentRootPath);
    commandLine.setExePath(elixirPath);
    commandLine.addParameter(mixPath);
    commandLine.addParameter(target.isTests() ? "test" : "compile");
    addCompileOptions(commandLine, compilerOptions);
    Process process;
    try {
        process = commandLine.createProcess();
    } catch (ExecutionException e) {
        throw new ProjectBuildException("Failed to run mix.", e);
    }
    BaseOSProcessHandler handler = new BaseOSProcessHandler(process, commandLine.getCommandLineString(), Charset.defaultCharset());
    ProcessAdapter adapter = new ElixirCompilerProcessAdapter(context, MIX_NAME, commandLine.getWorkDirectory().getPath());
    handler.addProcessListener(adapter);
    handler.startNotify();
    handler.waitFor();
}
Also used : ProjectBuildException(org.jetbrains.jps.incremental.ProjectBuildException) ProcessAdapter(com.intellij.execution.process.ProcessAdapter) BaseOSProcessHandler(com.intellij.execution.process.BaseOSProcessHandler)

Aggregations

ProcessAdapter (com.intellij.execution.process.ProcessAdapter)62 ProcessEvent (com.intellij.execution.process.ProcessEvent)59 Key (com.intellij.openapi.util.Key)19 NotNull (org.jetbrains.annotations.NotNull)15 ProcessHandler (com.intellij.execution.process.ProcessHandler)12 OSProcessHandler (com.intellij.execution.process.OSProcessHandler)10 ExecutionEnvironment (com.intellij.execution.runners.ExecutionEnvironment)10 ExecutionException (com.intellij.execution.ExecutionException)9 IOException (java.io.IOException)8 BaseOSProcessHandler (com.intellij.execution.process.BaseOSProcessHandler)7 Nullable (org.jetbrains.annotations.Nullable)7 Project (com.intellij.openapi.project.Project)5 ExecutionEnvironmentBuilder (com.intellij.execution.runners.ExecutionEnvironmentBuilder)4 RunContentDescriptor (com.intellij.execution.ui.RunContentDescriptor)4 File (java.io.File)4 ExecutionResult (com.intellij.execution.ExecutionResult)3 GeneralCommandLine (com.intellij.execution.configurations.GeneralCommandLine)3 Disposable (com.intellij.openapi.Disposable)3 Semaphore (com.intellij.util.concurrency.Semaphore)3 RunProfile (com.intellij.execution.configurations.RunProfile)2