Search in sources :

Example 1 with RunManagerImpl

use of com.intellij.execution.impl.RunManagerImpl in project intellij-community by JetBrains.

the class CompoundRunConfiguration method hasRunningSingletones.

protected boolean hasRunningSingletones() {
    Project project = getProject();
    if (project.isDisposed())
        return false;
    final ExecutionManagerImpl executionManager = ExecutionManagerImpl.getInstance(project);
    return executionManager.getRunningDescriptors(s -> {
        RunManagerImpl manager = RunManagerImpl.getInstanceImpl(project);
        for (RunConfiguration runConfiguration : mySetToRun) {
            if (runConfiguration instanceof CompoundRunConfiguration && ((CompoundRunConfiguration) runConfiguration).hasRunningSingletones()) {
                return true;
            }
            RunnerAndConfigurationSettings settings = manager.findConfigurationByTypeAndName(runConfiguration.getType().getId(), runConfiguration.getName());
            if (settings != null && settings.isSingleton() && runConfiguration.equals(s.getConfiguration())) {
                return true;
            }
        }
        return false;
    }).size() > 0;
}
Also used : Project(com.intellij.openapi.project.Project) ExecutionManagerImpl(com.intellij.execution.impl.ExecutionManagerImpl) RunManagerImpl(com.intellij.execution.impl.RunManagerImpl)

Example 2 with RunManagerImpl

use of com.intellij.execution.impl.RunManagerImpl in project intellij-community by JetBrains.

the class CompoundRunConfiguration method getState.

@Nullable
@Override
public RunProfileState getState(@NotNull Executor executor, @NotNull final ExecutionEnvironment environment) throws ExecutionException {
    try {
        checkConfiguration();
    } catch (RuntimeConfigurationException e) {
        throw new ExecutionException(e.getMessage());
    }
    return new RunProfileState() {

        @Nullable
        @Override
        public ExecutionResult execute(final Executor executor, @NotNull ProgramRunner runner) throws ExecutionException {
            ApplicationManager.getApplication().invokeLater(() -> {
                RunManagerImpl manager = RunManagerImpl.getInstanceImpl(getProject());
                for (RunConfiguration configuration : getSetToRun()) {
                    RunnerAndConfigurationSettings settings = new RunnerAndConfigurationSettingsImpl(manager, configuration, false);
                    ExecutionEnvironmentBuilder builder = ExecutionEnvironmentBuilder.createOrNull(executor, settings);
                    if (builder != null) {
                        ExecutionManager.getInstance(getProject()).restartRunProfile(builder.activeTarget().dataContext(null).build());
                    }
                }
            });
            return null;
        }
    };
}
Also used : DefaultRunExecutor(com.intellij.execution.executors.DefaultRunExecutor) RunnerAndConfigurationSettingsImpl(com.intellij.execution.impl.RunnerAndConfigurationSettingsImpl) ProgramRunner(com.intellij.execution.runners.ProgramRunner) ExecutionEnvironmentBuilder(com.intellij.execution.runners.ExecutionEnvironmentBuilder) NotNull(org.jetbrains.annotations.NotNull) RunManagerImpl(com.intellij.execution.impl.RunManagerImpl) Nullable(org.jetbrains.annotations.Nullable)

Example 3 with RunManagerImpl

use of com.intellij.execution.impl.RunManagerImpl in project intellij-community by JetBrains.

the class ProjectStartupConfigurable method createNewWrapper.

private ChooseRunConfigurationPopup.ItemWrapper<Void> createNewWrapper(final AnActionButton button) {
    return new ChooseRunConfigurationPopup.ItemWrapper<Void>(null) {

        @Override
        public Icon getIcon() {
            return IconUtil.getAddIcon();
        }

        @Override
        public String getText() {
            return UIUtil.removeMnemonic(ExecutionBundle.message("add.new.run.configuration.acrtion.name"));
        }

        @Override
        public void perform(@NotNull final Project project, @NotNull final Executor executor, @NotNull DataContext context) {
            final RunManagerImpl runManager = RunManagerImpl.getInstanceImpl(project);
            final ConfigurationType[] factories = runManager.getConfigurationFactories();
            final Condition<ConfigurationType> filter = new Condition<ConfigurationType>() {

                private final RunnerRegistry myRegistry = RunnerRegistry.getInstance();

                @Override
                public boolean value(ConfigurationType configurationType) {
                    ConfigurationFactory factory;
                    return !UnknownConfigurationType.INSTANCE.equals(configurationType) && ((factory = runManager.getFactory(configurationType.getId(), null)) != null) && myRegistry.getRunner(executor.getId(), runManager.getConfigurationTemplate(factory).getConfiguration()) != null;
                }
            };
            final List<ConfigurationType> factoriesList = ContainerUtil.filter(Arrays.asList(factories), filter);
            final ListPopup popup = NewRunConfigurationPopup.createAddPopup(factoriesList, "", factory -> ApplicationManager.getApplication().invokeLater(() -> {
                final EditConfigurationsDialog dialog = new EditConfigurationsDialog(project, factory);
                if (dialog.showAndGet()) {
                    ApplicationManager.getApplication().invokeLater(() -> {
                        RunnerAndConfigurationSettings configuration = RunManager.getInstance(project).getSelectedConfiguration();
                        if (configuration != null) {
                            addConfiguration(configuration);
                        }
                    }, ModalityState.any(), project.getDisposed());
                }
            }, ModalityState.any(), project.getDisposed()), null, EmptyRunnable.getInstance(), false);
            showPopup(button, popup);
        }

        @Override
        public boolean available(Executor executor) {
            return true;
        }
    };
}
Also used : ConfigurationType(com.intellij.execution.configurations.ConfigurationType) UnknownConfigurationType(com.intellij.execution.configurations.UnknownConfigurationType) Condition(com.intellij.openapi.util.Condition) EditConfigurationsDialog(com.intellij.execution.impl.EditConfigurationsDialog) ListPopup(com.intellij.openapi.ui.popup.ListPopup) NotNull(org.jetbrains.annotations.NotNull) Project(com.intellij.openapi.project.Project) DataContext(com.intellij.openapi.actionSystem.DataContext) DefaultRunExecutor(com.intellij.execution.executors.DefaultRunExecutor) ConfigurationFactory(com.intellij.execution.configurations.ConfigurationFactory) RunManagerImpl(com.intellij.execution.impl.RunManagerImpl)

Example 4 with RunManagerImpl

use of com.intellij.execution.impl.RunManagerImpl in project intellij-community by JetBrains.

the class JavaRuntimeConfigurationProducerBase method setupConfigurationModule.

protected boolean setupConfigurationModule(@Nullable ConfigurationContext context, ModuleBasedConfiguration configuration) {
    if (context != null) {
        final RunnerAndConfigurationSettings template = ((RunManagerImpl) context.getRunManager()).getConfigurationTemplate(getConfigurationFactory());
        final Module contextModule = context.getModule();
        final Module predefinedModule = ((ModuleBasedConfiguration) template.getConfiguration()).getConfigurationModule().getModule();
        if (predefinedModule != null) {
            configuration.setModule(predefinedModule);
            return true;
        }
        final Module module = findModule(configuration, contextModule);
        if (module != null) {
            configuration.setModule(module);
            return true;
        }
    }
    return false;
}
Also used : RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) Module(com.intellij.openapi.module.Module) RunManagerImpl(com.intellij.execution.impl.RunManagerImpl)

Example 5 with RunManagerImpl

use of com.intellij.execution.impl.RunManagerImpl in project intellij-community by JetBrains.

the class AbstractAutoTestManager method loadConfigurations.

public static List<RunConfiguration> loadConfigurations(State state, Project project) {
    List<RunConfiguration> configurations = ContainerUtil.newArrayList();
    RunManagerImpl runManager = RunManagerImpl.getInstanceImpl(project);
    List<RunConfigurationDescriptor> descriptors = ContainerUtil.notNullize(state.myEnabledRunConfigurations);
    for (RunConfigurationDescriptor descriptor : descriptors) {
        if (descriptor.myType != null && descriptor.myName != null) {
            RunnerAndConfigurationSettings settings = runManager.findConfigurationByTypeAndName(descriptor.myType, descriptor.myName);
            RunConfiguration configuration = settings != null ? settings.getConfiguration() : null;
            if (configuration != null) {
                configurations.add(configuration);
            }
        }
    }
    return configurations;
}
Also used : RunConfiguration(com.intellij.execution.configurations.RunConfiguration) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) RunManagerImpl(com.intellij.execution.impl.RunManagerImpl)

Aggregations

RunManagerImpl (com.intellij.execution.impl.RunManagerImpl)12 RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)4 ConfigurationFactory (com.intellij.execution.configurations.ConfigurationFactory)3 ConfigurationType (com.intellij.execution.configurations.ConfigurationType)3 RunConfiguration (com.intellij.execution.configurations.RunConfiguration)3 DefaultRunExecutor (com.intellij.execution.executors.DefaultRunExecutor)2 RunnerAndConfigurationSettingsImpl (com.intellij.execution.impl.RunnerAndConfigurationSettingsImpl)2 Module (com.intellij.openapi.module.Module)2 Project (com.intellij.openapi.project.Project)2 NotNull (org.jetbrains.annotations.NotNull)2 MakeBeforeRunTaskProvider (com.android.tools.idea.gradle.run.MakeBeforeRunTaskProvider)1 AndroidJUnitConfigurationType (com.android.tools.idea.testartifacts.junit.AndroidJUnitConfigurationType)1 BeforeRunTask (com.intellij.execution.BeforeRunTask)1 BeforeRunTaskProvider (com.intellij.execution.BeforeRunTaskProvider)1 UnknownConfigurationType (com.intellij.execution.configurations.UnknownConfigurationType)1 EditConfigurationsDialog (com.intellij.execution.impl.EditConfigurationsDialog)1 ExecutionManagerImpl (com.intellij.execution.impl.ExecutionManagerImpl)1 ExecutionEnvironmentBuilder (com.intellij.execution.runners.ExecutionEnvironmentBuilder)1 ProgramRunner (com.intellij.execution.runners.ProgramRunner)1 AppPropertiesComponentImpl (com.intellij.ide.util.AppPropertiesComponentImpl)1