Search in sources :

Example 16 with ProgramRunner

use of com.intellij.execution.runners.ProgramRunner in project intellij-community by JetBrains.

the class RunnerAndConfigurationSettingsImpl method checkSettings.

@Override
public void checkSettings(@Nullable Executor executor) throws RuntimeConfigurationException {
    myConfiguration.checkConfiguration();
    if (myConfiguration instanceof RunConfigurationBase) {
        final RunConfigurationBase runConfigurationBase = (RunConfigurationBase) myConfiguration;
        Set<ProgramRunner> runners = new THashSet<>();
        runners.addAll(myRunnerSettings.settings.keySet());
        runners.addAll(myConfigurationPerRunnerSettings.settings.keySet());
        for (ProgramRunner runner : runners) {
            if (executor == null || runner.canRun(executor.getId(), myConfiguration)) {
                runConfigurationBase.checkRunnerSettings(runner, myRunnerSettings.settings.get(runner), myConfigurationPerRunnerSettings.settings.get(runner));
            }
        }
        if (executor != null) {
            runConfigurationBase.checkSettingsBeforeRun();
        }
    }
}
Also used : ProgramRunner(com.intellij.execution.runners.ProgramRunner) THashSet(gnu.trove.THashSet)

Example 17 with ProgramRunner

use of com.intellij.execution.runners.ProgramRunner in project intellij-community by JetBrains.

the class RunnerAndConfigurationSettingsImpl method importFromTemplate.

@SuppressWarnings("deprecation")
private <T> void importFromTemplate(@NotNull RunnerItem<T> templateItem, @NotNull RunnerItem<T> item) {
    for (ProgramRunner runner : templateItem.settings.keySet()) {
        T data = item.createSettings(runner);
        item.settings.put(runner, data);
        if (data != null) {
            Element temp = new Element(DUMMY_ELEMENT_NAME);
            T templateSettings = templateItem.settings.get(runner);
            if (templateSettings != null) {
                try {
                    ((JDOMExternalizable) templateSettings).writeExternal(temp);
                    ((JDOMExternalizable) data).readExternal(temp);
                } catch (WriteExternalException | InvalidDataException e) {
                    LOG.error(e);
                }
            }
        }
    }
}
Also used : Element(org.jdom.Element) ProgramRunner(com.intellij.execution.runners.ProgramRunner)

Example 18 with ProgramRunner

use of com.intellij.execution.runners.ProgramRunner in project intellij-plugins by JetBrains.

the class FlexUnitRunConfiguration method getState.

@Override
public RunProfileState getState(@NotNull final Executor executor, @NotNull final ExecutionEnvironment env) throws ExecutionException {
    final FlexBuildConfiguration bc;
    try {
        bc = myRunnerParameters.checkAndGetModuleAndBC(getProject()).second;
    } catch (RuntimeConfigurationError e) {
        throw new ExecutionException(e.getMessage());
    }
    final BuildConfigurationNature nature = bc.getNature();
    if (nature.isDesktopPlatform() || nature.isMobilePlatform()) {
        return new FlashRunConfiguration.AirRunState(getProject(), env, myRunnerParameters) {

            @NotNull
            @Override
            public ExecutionResult execute(@NotNull Executor executor, @NotNull ProgramRunner runner) throws ExecutionException {
                final ProcessHandler processHandler = startProcess();
                final ExecutionConsole console = FlexBaseRunner.createFlexUnitRunnerConsole(getProject(), env, processHandler);
                return new DefaultExecutionResult(console, processHandler);
            }
        };
    }
    return EmptyRunProfileState.INSTANCE;
}
Also used : BuildConfigurationNature(com.intellij.flex.model.bc.BuildConfigurationNature) FlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration) ProcessHandler(com.intellij.execution.process.ProcessHandler) ExecutionConsole(com.intellij.execution.ui.ExecutionConsole) ProgramRunner(com.intellij.execution.runners.ProgramRunner) NotNull(org.jetbrains.annotations.NotNull)

Example 19 with ProgramRunner

use of com.intellij.execution.runners.ProgramRunner 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 20 with ProgramRunner

use of com.intellij.execution.runners.ProgramRunner 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)

Aggregations

ProgramRunner (com.intellij.execution.runners.ProgramRunner)30 NotNull (org.jetbrains.annotations.NotNull)13 DefaultRunExecutor (com.intellij.execution.executors.DefaultRunExecutor)10 ProcessHandler (com.intellij.execution.process.ProcessHandler)9 Executor (com.intellij.execution.Executor)8 ExecutionEnvironment (com.intellij.execution.runners.ExecutionEnvironment)7 Project (com.intellij.openapi.project.Project)5 ProcessEvent (com.intellij.execution.process.ProcessEvent)4 ExecutionEnvironmentBuilder (com.intellij.execution.runners.ExecutionEnvironmentBuilder)4 Nullable (org.jetbrains.annotations.Nullable)4 DefaultExecutionResult (com.intellij.execution.DefaultExecutionResult)3 DefaultDebugExecutor (com.intellij.execution.executors.DefaultDebugExecutor)3 OSProcessHandler (com.intellij.execution.process.OSProcessHandler)3 ProcessAdapter (com.intellij.execution.process.ProcessAdapter)3 RunContentDescriptor (com.intellij.execution.ui.RunContentDescriptor)3 File (java.io.File)3 ExecutionException (com.intellij.execution.ExecutionException)2 ExecutionResult (com.intellij.execution.ExecutionResult)2 CommandLineState (com.intellij.execution.configurations.CommandLineState)2 GeneralCommandLine (com.intellij.execution.configurations.GeneralCommandLine)2