Search in sources :

Example 11 with ProgramRunner

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

the class RunContextAction method isEnabledAndVisible.

private Pair<Boolean, Boolean> isEnabledAndVisible(ConfigurationContext context) {
    RunnerAndConfigurationSettings configuration = context.findExisting();
    if (configuration == null) {
        configuration = context.getConfiguration();
    }
    ProgramRunner runner = configuration == null ? null : getRunner(configuration.getConfiguration());
    if (runner == null) {
        return Pair.create(false, false);
    }
    return Pair.create(!ExecutorRegistry.getInstance().isStarting(context.getProject(), myExecutor.getId(), runner.getRunnerId()), true);
}
Also used : ProgramRunner(com.intellij.execution.runners.ProgramRunner)

Example 12 with ProgramRunner

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

the class ExecutionManagerImpl method createEnvironmentBuilder.

@NotNull
private static ExecutionEnvironmentBuilder createEnvironmentBuilder(@NotNull Project project, @NotNull Executor executor, @Nullable RunnerAndConfigurationSettings configuration) {
    ExecutionEnvironmentBuilder builder = new ExecutionEnvironmentBuilder(project, executor);
    ProgramRunner runner = RunnerRegistry.getInstance().getRunner(executor.getId(), configuration != null ? configuration.getConfiguration() : null);
    if (runner == null && configuration != null) {
        LOG.error("Cannot find runner for " + configuration.getName());
    } else if (runner != null) {
        assert configuration != null;
        builder.runnerAndSettings(runner, configuration);
    }
    return builder;
}
Also used : ExecutionEnvironmentBuilder(com.intellij.execution.runners.ExecutionEnvironmentBuilder) ProgramRunner(com.intellij.execution.runners.ProgramRunner) NotNull(org.jetbrains.annotations.NotNull)

Example 13 with ProgramRunner

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

the class RunConfigurationBeforeRunProvider method getAvailableConfigurations.

@NotNull
private static List<RunnerAndConfigurationSettings> getAvailableConfigurations(@NotNull RunConfiguration runConfiguration) {
    Project project = runConfiguration.getProject();
    if (project == null || !project.isInitialized()) {
        return Collections.emptyList();
    }
    List<RunnerAndConfigurationSettings> configurations = new ArrayList<>(RunManagerImpl.getInstanceImpl(project).getSortedConfigurations());
    String executorId = DefaultRunExecutor.getRunExecutorInstance().getId();
    for (Iterator<RunnerAndConfigurationSettings> iterator = configurations.iterator(); iterator.hasNext(); ) {
        RunnerAndConfigurationSettings settings = iterator.next();
        ProgramRunner runner = ProgramRunnerUtil.getRunner(executorId, settings);
        if (runner == null || settings.getConfiguration() == runConfiguration) {
            iterator.remove();
        }
    }
    return configurations;
}
Also used : Project(com.intellij.openapi.project.Project) ProgramRunner(com.intellij.execution.runners.ProgramRunner) NotNull(org.jetbrains.annotations.NotNull)

Example 14 with ProgramRunner

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

the class RunConfigurationBeforeRunProvider method canExecuteTask.

@Override
public boolean canExecuteTask(RunConfiguration configuration, RunConfigurableBeforeRunTask task) {
    RunnerAndConfigurationSettings settings = task.getSettings();
    if (settings == null) {
        return false;
    }
    String executorId = DefaultRunExecutor.getRunExecutorInstance().getId();
    final ProgramRunner runner = ProgramRunnerUtil.getRunner(executorId, settings);
    return runner != null && runner.canRun(executorId, settings.getConfiguration());
}
Also used : ProgramRunner(com.intellij.execution.runners.ProgramRunner)

Example 15 with ProgramRunner

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

the class ConfigurationSettingsEditor method init.

private void init() {
    if (myCompound == null) {
        myCompound = new SettingsEditorGroup<>();
        Disposer.register(this, myCompound);
        if (myConfigurationEditor instanceof SettingsEditorGroup) {
            SettingsEditorGroup<RunConfiguration> group = (SettingsEditorGroup<RunConfiguration>) myConfigurationEditor;
            List<Pair<String, SettingsEditor<RunConfiguration>>> editors = group.getEditors();
            for (Pair<String, SettingsEditor<RunConfiguration>> pair : editors) {
                myCompound.addEditor(pair.getFirst(), new ConfigToSettingsWrapper(pair.getSecond()));
            }
        } else {
            myCompound.addEditor(ExecutionBundle.message("run.configuration.configuration.tab.title"), new ConfigToSettingsWrapper(myConfigurationEditor));
        }
        myRunnersComponent = new RunnersEditorComponent();
        final Executor[] executors = ExecutorRegistry.getInstance().getRegisteredExecutors();
        for (final Executor executor : executors) {
            ProgramRunner runner = RunnerRegistry.getInstance().getRunner(executor.getId(), myConfiguration);
            if (runner != null) {
                JComponent perRunnerSettings = createCompositePerRunnerSettings(executor, runner);
                if (perRunnerSettings != null) {
                    myRunnersComponent.addExecutorComponent(executor, perRunnerSettings);
                }
            }
        }
        if (myRunnerEditors.size() > 0) {
            myCompound.addEditor(RUNNERS_TAB_NAME, new CompositeSettingsEditor<RunnerAndConfigurationSettings>(getFactory()) {

                @Override
                public CompositeSettingsBuilder<RunnerAndConfigurationSettings> getBuilder() {
                    return new CompositeSettingsBuilder<RunnerAndConfigurationSettings>() {

                        @Override
                        public Collection<SettingsEditor<RunnerAndConfigurationSettings>> getEditors() {
                            return myRunnerEditors;
                        }

                        @Override
                        public JComponent createCompoundEditor() {
                            return myRunnersComponent.getComponent();
                        }
                    };
                }
            });
        }
    }
}
Also used : AdjustingTabSettingsEditor(com.intellij.execution.ui.AdjustingTabSettingsEditor) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) ProgramRunner(com.intellij.execution.runners.ProgramRunner) Pair(com.intellij.openapi.util.Pair)

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