Search in sources :

Example 91 with ProcessHandler

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

the class HotswapAction method getActiveProcessHandler.

@Nullable
private static ProcessHandler getActiveProcessHandler(@Nullable Project project, @Nullable RunnerAndConfigurationSettings settings) {
    if (project == null || settings == null) {
        return null;
    }
    AndroidSessionInfo session = getAndroidSessionInfo(project, settings);
    if (session == null) {
        return null;
    }
    ProcessHandler processHandler = session.getProcessHandler();
    if (processHandler.isProcessTerminated() || processHandler.isProcessTerminating()) {
        return null;
    }
    return processHandler;
}
Also used : AndroidSessionInfo(com.android.tools.idea.run.AndroidSessionInfo) ProcessHandler(com.intellij.execution.process.ProcessHandler) Nullable(org.jetbrains.annotations.Nullable)

Example 92 with ProcessHandler

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

the class HotswapAction method doUpdate.

@Override
protected void doUpdate(@NotNull AnActionEvent e, @NotNull Project project) {
    Presentation presentation = e.getPresentation();
    presentation.setEnabled(false);
    if (!InstantRunSettings.isInstantRunEnabled()) {
        presentation.setText("Apply Changes: Instant Run has been disabled");
        return;
    }
    RunnerAndConfigurationSettings settings = RunManager.getInstance(project).getSelectedConfiguration();
    if (settings == null) {
        presentation.setText("Apply Changes: No run configuration selected");
        return;
    }
    AndroidSessionInfo session = getAndroidSessionInfo(project, settings);
    if (session == null) {
        presentation.setText(String.format("Apply Changes: No active '%1$s' launch", settings.getName()));
        return;
    }
    ProcessHandler processHandler = getActiveProcessHandler(project, settings);
    if (processHandler == null) {
        presentation.setText(String.format("Apply Changes: No active '%1$s' launch", settings.getName()));
        return;
    }
    RunConfiguration configuration = settings.getConfiguration();
    if (!(configuration instanceof ModuleBasedConfiguration)) {
        presentation.setText(String.format("Apply Changes: '%1$s' is not a module based configuration", settings.getName()));
        return;
    }
    Module module = ((ModuleBasedConfiguration) configuration).getConfigurationModule().getModule();
    if (module == null) {
        presentation.setText(String.format("Apply Changes: No module specified in '%1$s'", settings.getName()));
        return;
    }
    if (!(configuration instanceof AndroidRunConfigurationBase)) {
        presentation.setText(String.format("Apply Changes: '%1$s' is not an Android launch configuration", settings.getName()));
        return;
    }
    if (!((AndroidRunConfigurationBase) configuration).supportsInstantRun()) {
        presentation.setText(String.format("Apply Changes: Configuration '%1$s' does not support instant run", settings.getName()));
        return;
    }
    AndroidVersion androidVersion = InstantRunManager.getMinDeviceApiLevel(processHandler);
    if (androidVersion == null) {
        presentation.setText(String.format("Apply Changes: Cannot locate device from '%1$s'", settings.getName()));
        return;
    }
    if (!InstantRunManager.isInstantRunCapableDeviceVersion(androidVersion)) {
        presentation.setText(String.format("Apply Changes: Target device API level (%1$s) too low for Instant Run", androidVersion));
        return;
    }
    InstantRunGradleSupport status = InstantRunGradleUtils.getIrSupportStatus(InstantRunGradleUtils.getAppModel(module), androidVersion);
    if (status != SUPPORTED) {
        String notification = status.getUserNotification();
        if (notification == null) {
            notification = status.toString();
        }
        presentation.setText("Apply Changes: " + notification);
        return;
    }
    presentation.setText("Apply Changes" + getShortcutText());
    presentation.setEnabled(true);
}
Also used : RunConfiguration(com.intellij.execution.configurations.RunConfiguration) AndroidRunConfigurationBase(com.android.tools.idea.run.AndroidRunConfigurationBase) AndroidSessionInfo(com.android.tools.idea.run.AndroidSessionInfo) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) ProcessHandler(com.intellij.execution.process.ProcessHandler) InstantRunGradleSupport(com.android.tools.idea.fd.gradle.InstantRunGradleSupport) Presentation(com.intellij.openapi.actionSystem.Presentation) ModuleBasedConfiguration(com.intellij.execution.configurations.ModuleBasedConfiguration) Module(com.intellij.openapi.module.Module) AndroidVersion(com.android.sdklib.AndroidVersion)

Example 93 with ProcessHandler

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

the class AndroidRunConfiguration method getConsoleProvider.

@NotNull
@Override
protected ConsoleProvider getConsoleProvider() {
    return new ConsoleProvider() {

        @NotNull
        @Override
        public ConsoleView createAndAttach(@NotNull Disposable parent, @NotNull ProcessHandler handler, @NotNull Executor executor) throws ExecutionException {
            Project project = getConfigurationModule().getProject();
            final TextConsoleBuilder builder = TextConsoleBuilderFactory.getInstance().createBuilder(project);
            ConsoleView console = builder.getConsole();
            console.attachToProcess(handler);
            return console;
        }
    };
}
Also used : Disposable(com.intellij.openapi.Disposable) Project(com.intellij.openapi.project.Project) Executor(com.intellij.execution.Executor) TextConsoleBuilder(com.intellij.execution.filters.TextConsoleBuilder) ConsoleView(com.intellij.execution.ui.ConsoleView) ProcessHandler(com.intellij.execution.process.ProcessHandler) NotNull(org.jetbrains.annotations.NotNull) NotNull(org.jetbrains.annotations.NotNull)

Example 94 with ProcessHandler

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

the class CfmlUnitRunConfiguration method getState.

@Override
public RunProfileState getState(@NotNull Executor executor, @NotNull final ExecutionEnvironment env) throws ExecutionException {
    return new RunProfileState() {

        @Override
        public ExecutionResult execute(Executor executor, @NotNull ProgramRunner runner) throws ExecutionException {
            final ProcessHandler processHandler = new MyProcessHandler();
            final ConsoleView console = createConsole(getProject(), processHandler, env, executor);
            console.addMessageFilter(new CfmlStackTraceFilterProvider(getProject()));
            // processHandler.startNotify();
            runTests(processHandler);
            return new DefaultExecutionResult(console, processHandler);
        }
    };
}
Also used : Executor(com.intellij.execution.Executor) DefaultExecutionResult(com.intellij.execution.DefaultExecutionResult) BaseTestsOutputConsoleView(com.intellij.execution.testframework.ui.BaseTestsOutputConsoleView) ConsoleView(com.intellij.execution.ui.ConsoleView) ProcessHandler(com.intellij.execution.process.ProcessHandler) ProgramRunner(com.intellij.execution.runners.ProgramRunner) NotNull(org.jetbrains.annotations.NotNull)

Example 95 with ProcessHandler

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

the class FlexRunner method doExecute.

@Override
protected RunContentDescriptor doExecute(@NotNull final RunProfileState state, @NotNull ExecutionEnvironment env) throws ExecutionException {
    final BCBasedRunnerParameters parameters = ((RemoteFlashRunConfiguration) env.getRunProfile()).getRunnerParameters();
    RunContentDescriptor runContentDescriptor = XDebuggerManager.getInstance(env.getProject()).startSession(env, new XDebugProcessStarter() {

        @Override
        @NotNull
        public XDebugProcess start(@NotNull final XDebugSession session) throws ExecutionException {
            try {
                return DebugPathManager.IS_DEV ? new MyFlexDebugProcessAbleToResolveFileDebugId(callback, session, buildConfiguration, parameters) : new MyFlexDebugProcess(callback, session, buildConfiguration, parameters);
            } catch (IOException e) {
                throw new ExecutionException(e.getMessage(), e);
            } finally {
                buildConfiguration = null;
            }
        }
    }).getRunContentDescriptor();
    ProcessHandler processHandler = runContentDescriptor.getProcessHandler();
    assert processHandler != null;
    //noinspection deprecation
    processHandler.putUserData(ProcessHandler.SILENTLY_DESTROY_ON_CLOSE, true);
    return runContentDescriptor;
}
Also used : XDebugSession(com.intellij.xdebugger.XDebugSession) BCBasedRunnerParameters(com.intellij.lang.javascript.flex.run.BCBasedRunnerParameters) RunContentDescriptor(com.intellij.execution.ui.RunContentDescriptor) XDebugProcessStarter(com.intellij.xdebugger.XDebugProcessStarter) RemoteFlashRunConfiguration(com.intellij.lang.javascript.flex.run.RemoteFlashRunConfiguration) ProcessHandler(com.intellij.execution.process.ProcessHandler) IOException(java.io.IOException) ExecutionException(com.intellij.execution.ExecutionException) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

ProcessHandler (com.intellij.execution.process.ProcessHandler)99 NotNull (org.jetbrains.annotations.NotNull)30 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)15 DefaultExecutionResult (com.intellij.execution.DefaultExecutionResult)14 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 File (java.io.File)6 DefaultRunExecutor (com.intellij.execution.executors.DefaultRunExecutor)5 ToggleAutoTestAction (com.intellij.execution.testframework.autotest.ToggleAutoTestAction)5