Search in sources :

Example 76 with ProcessEvent

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

the class KarmaServerRestarter method onRunnerExecutionStarted.

public void onRunnerExecutionStarted(@NotNull final OSProcessHandler processHandler) {
    myActiveRunners.incrementAndGet();
    processHandler.addProcessListener(new ProcessAdapter() {

        @Override
        public void processTerminated(ProcessEvent event) {
            myActiveRunners.decrementAndGet();
            processHandler.removeProcessListener(this);
        }
    });
}
Also used : ProcessAdapter(com.intellij.execution.process.ProcessAdapter) ProcessEvent(com.intellij.execution.process.ProcessEvent)

Example 77 with ProcessEvent

use of com.intellij.execution.process.ProcessEvent in project flutter-intellij by flutter.

the class OpenInAndroidStudioAction method openFileInStudio.

private static void openFileInStudio(@NotNull VirtualFile file, @NotNull String androidStudioPath) {
    try {
        final GeneralCommandLine cmd;
        if (SystemInfo.isMac) {
            cmd = new GeneralCommandLine().withExePath("open").withParameters("-a", androidStudioPath, file.getPath());
        } else {
            cmd = new GeneralCommandLine().withExePath(androidStudioPath).withParameters(file.getPath());
        }
        final OSProcessHandler handler = new OSProcessHandler(cmd);
        handler.addProcessListener(new ProcessAdapter() {

            @Override
            public void processTerminated(@NotNull final ProcessEvent event) {
                if (event.getExitCode() != 0) {
                    FlutterMessages.showError("Error Opening", file.getPath());
                }
            }
        });
        handler.startNotify();
    } catch (ExecutionException ex) {
        FlutterMessages.showError("Error Opening", "Exception: " + ex.getMessage());
    }
}
Also used : ProcessAdapter(com.intellij.execution.process.ProcessAdapter) ProcessEvent(com.intellij.execution.process.ProcessEvent) OSProcessHandler(com.intellij.execution.process.OSProcessHandler) GeneralCommandLine(com.intellij.execution.configurations.GeneralCommandLine) ExecutionException(com.intellij.execution.ExecutionException)

Example 78 with ProcessEvent

use of com.intellij.execution.process.ProcessEvent in project flutter-intellij by flutter.

the class OpenInXcodeAction method openFile.

private static void openFile(@NotNull VirtualFile file) {
    final Project project = ProjectUtil.guessProjectForFile(file);
    final FlutterSdk sdk = project != null ? FlutterSdk.getFlutterSdk(project) : null;
    if (sdk == null) {
        FlutterSdkAction.showMissingSdkDialog(project);
        return;
    }
    final PubRoot pubRoot = PubRoot.forFile(file);
    if (pubRoot == null) {
        FlutterMessages.showError("Error Opening Xcode", "Unable to run `flutter build` (no pub root found)");
        return;
    }
    // Trigger an iOS build if necessary.
    if (!hasBeenBuilt(pubRoot)) {
        final ProgressHelper progressHelper = new ProgressHelper(project);
        progressHelper.start("Building for iOS");
        sdk.flutterBuild(pubRoot, "ios", "--debug").start(null, new ProcessAdapter() {

            @Override
            public void processTerminated(@NotNull ProcessEvent event) {
                progressHelper.done();
                if (event.getExitCode() != 0) {
                    FlutterMessages.showError("Error Opening Xcode", "`flutter build` returned: " + event.getExitCode());
                    return;
                }
                openWithXcode(file.getPath());
            }
        });
    } else {
        openWithXcode(file.getPath());
    }
}
Also used : Project(com.intellij.openapi.project.Project) ProgressHelper(io.flutter.utils.ProgressHelper) ProcessAdapter(com.intellij.execution.process.ProcessAdapter) ProcessEvent(com.intellij.execution.process.ProcessEvent) FlutterSdk(io.flutter.sdk.FlutterSdk) PubRoot(io.flutter.pub.PubRoot)

Example 79 with ProcessEvent

use of com.intellij.execution.process.ProcessEvent in project flutter-intellij by flutter.

the class FlutterApp method start.

/**
 * Creates a process that will launch the flutter app.
 * <p>
 * (Assumes we are launching it in --machine mode.)
 */
@NotNull
public static FlutterApp start(@NotNull ExecutionEnvironment env, @NotNull Project project, @Nullable Module module, @NotNull RunMode mode, @NotNull FlutterDevice device, @NotNull GeneralCommandLine command, @NotNull String analyticsStart, @NotNull String analyticsStop) throws ExecutionException {
    LOG.info(analyticsStart + " " + project.getName() + " (" + mode.mode() + ")");
    LOG.info(command.toString());
    final ProcessHandler process = new OSProcessHandler(command);
    Disposer.register(project, process::destroyProcess);
    // Send analytics for the start and stop events.
    FlutterInitializer.sendAnalyticsAction(analyticsStart);
    final DaemonApi api = new DaemonApi(process);
    final FlutterApp app = new FlutterApp(project, module, mode, device, process, env, api);
    process.addProcessListener(new ProcessAdapter() {

        @Override
        public void processTerminated(@NotNull ProcessEvent event) {
            LOG.info(analyticsStop + " " + project.getName() + " (" + mode.mode() + ")");
            FlutterInitializer.sendAnalyticsAction(analyticsStop);
            // Send analytics about whether this session used the reload workflow, the restart workflow, or neither.
            final String workflowType = app.reloadCount > 0 ? "reload" : (app.restartCount > 0 ? "restart" : "none");
            FlutterInitializer.getAnalytics().sendEvent("workflow", workflowType);
        }
    });
    api.listen(process, new io.flutter.run.daemon.FlutterAppListener(app, project));
    return app;
}
Also used : ProcessAdapter(com.intellij.execution.process.ProcessAdapter) ProcessEvent(com.intellij.execution.process.ProcessEvent) OSProcessHandler(com.intellij.execution.process.OSProcessHandler) OSProcessHandler(com.intellij.execution.process.OSProcessHandler) ProcessHandler(com.intellij.execution.process.ProcessHandler) NotNull(org.jetbrains.annotations.NotNull)

Example 80 with ProcessEvent

use of com.intellij.execution.process.ProcessEvent in project ballerina by ballerina-lang.

the class BallerinaTestRunningState method startProcess.

@NotNull
@Override
protected ProcessHandler startProcess() throws ExecutionException {
    ProcessHandler processHandler = super.startProcess();
    processHandler.addProcessListener(new ProcessAdapter() {

        @Override
        public void startNotified(ProcessEvent event) {
            if (myHistoryProcessHandler != null) {
                myHistoryProcessHandler.apply(processHandler);
            }
        }
    });
    return processHandler;
}
Also used : ProcessAdapter(com.intellij.execution.process.ProcessAdapter) ProcessEvent(com.intellij.execution.process.ProcessEvent) ProcessHandler(com.intellij.execution.process.ProcessHandler) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

ProcessEvent (com.intellij.execution.process.ProcessEvent)90 ProcessAdapter (com.intellij.execution.process.ProcessAdapter)82 Key (com.intellij.openapi.util.Key)34 OSProcessHandler (com.intellij.execution.process.OSProcessHandler)25 NotNull (org.jetbrains.annotations.NotNull)24 ExecutionException (com.intellij.execution.ExecutionException)22 ProcessHandler (com.intellij.execution.process.ProcessHandler)18 GeneralCommandLine (com.intellij.execution.configurations.GeneralCommandLine)16 ExecutionEnvironment (com.intellij.execution.runners.ExecutionEnvironment)12 IOException (java.io.IOException)12 Nullable (org.jetbrains.annotations.Nullable)12 Project (com.intellij.openapi.project.Project)9 File (java.io.File)9 ProcessListener (com.intellij.execution.process.ProcessListener)8 RunContentDescriptor (com.intellij.execution.ui.RunContentDescriptor)7 ExecutionEnvironmentBuilder (com.intellij.execution.runners.ExecutionEnvironmentBuilder)5 ProgramRunner (com.intellij.execution.runners.ProgramRunner)5 VirtualFile (com.intellij.openapi.vfs.VirtualFile)5 DefaultRunExecutor (com.intellij.execution.executors.DefaultRunExecutor)4 Disposable (com.intellij.openapi.Disposable)4