Search in sources :

Example 26 with ConfigurationFactory

use of com.intellij.execution.configurations.ConfigurationFactory in project android by JetBrains.

the class PostSyncProjectSetupTest method testJUnitRunConfigurationSetup.

public void testJUnitRunConfigurationSetup() {
    when(myIdeInfo.isAndroidStudio()).thenReturn(true);
    PostSyncProjectSetup.Request request = new PostSyncProjectSetup.Request();
    mySetup.setUpProject(request, myProgressIndicator);
    ConfigurationFactory configurationFactory = AndroidJUnitConfigurationType.getInstance().getConfigurationFactories()[0];
    AndroidJUnitConfiguration jUnitConfiguration = new AndroidJUnitConfiguration("", getProject(), configurationFactory);
    myRunManager.addConfiguration(myRunManager.createConfiguration(jUnitConfiguration, configurationFactory), true);
    List<RunConfiguration> junitRunConfigurations = myRunManager.getConfigurationsList(AndroidJUnitConfigurationType.getInstance());
    for (RunConfiguration runConfiguration : junitRunConfigurations) {
        assertSize(1, myRunManager.getBeforeRunTasks(runConfiguration));
        assertEquals(MakeBeforeRunTaskProvider.ID, myRunManager.getBeforeRunTasks(runConfiguration).get(0).getProviderId());
    }
    RunConfiguration runConfiguration = junitRunConfigurations.get(0);
    List<BeforeRunTask> tasks = new LinkedList<>(myRunManager.getBeforeRunTasks(runConfiguration));
    BeforeRunTask newTask = new MakeBeforeRunTaskProvider(getProject()).createTask(runConfiguration);
    newTask.setEnabled(true);
    tasks.add(newTask);
    myRunManager.setBeforeRunTasks(runConfiguration, tasks, false);
    mySetup.setUpProject(request, myProgressIndicator);
    assertSize(2, myRunManager.getBeforeRunTasks(runConfiguration));
}
Also used : BeforeRunTask(com.intellij.execution.BeforeRunTask) MakeBeforeRunTaskProvider(com.android.tools.idea.gradle.run.MakeBeforeRunTaskProvider) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) ConfigurationFactory(com.intellij.execution.configurations.ConfigurationFactory) AndroidJUnitConfiguration(com.android.tools.idea.testartifacts.junit.AndroidJUnitConfiguration) LinkedList(java.util.LinkedList)

Example 27 with ConfigurationFactory

use of com.intellij.execution.configurations.ConfigurationFactory in project intellij-community by JetBrains.

the class CloudRunConfigurationUtil method createRunConfiguration.

public static <SC extends ServerConfiguration, DC extends DeploymentConfiguration> DeployToServerRunConfiguration<SC, DC> createRunConfiguration(RemoteServer<SC> account, Module module, DeploymentSource deploymentSource, DC deploymentConfiguration) {
    Project project = module.getProject();
    String accountName = account.getName();
    String name = generateRunConfigurationName(accountName, module.getName());
    final RunManagerEx runManager = RunManagerEx.getInstanceEx(project);
    ConfigurationFactory configurationFactory = getRunConfigurationType(account.getType()).getConfigurationFactories()[0];
    final RunnerAndConfigurationSettings runSettings = runManager.createRunConfiguration(name, configurationFactory);
    final DeployToServerRunConfiguration<SC, DC> result = (DeployToServerRunConfiguration<SC, DC>) runSettings.getConfiguration();
    result.setServerName(accountName);
    result.setDeploymentSource(deploymentSource);
    result.setDeploymentConfiguration(deploymentConfiguration);
    ((ConfigurationFactoryEx) configurationFactory).onNewConfigurationCreated(runSettings.getConfiguration());
    runManager.addConfiguration(runSettings, false);
    runManager.setSelectedConfiguration(runSettings);
    return result;
}
Also used : Project(com.intellij.openapi.project.Project) RunManagerEx(com.intellij.execution.RunManagerEx) ConfigurationFactory(com.intellij.execution.configurations.ConfigurationFactory) ConfigurationFactoryEx(com.intellij.execution.configuration.ConfigurationFactoryEx) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) DeployToServerRunConfiguration(com.intellij.remoteServer.impl.configuration.deployment.DeployToServerRunConfiguration)

Example 28 with ConfigurationFactory

use of com.intellij.execution.configurations.ConfigurationFactory in project intellij-community by JetBrains.

the class AntConfigurationImpl method convertToBeforeRunTask.

private static void convertToBeforeRunTask(Project project, String buildFileUrl, String targetName, String configType, String configName) {
    if (buildFileUrl == null || targetName == null || configType == null) {
        return;
    }
    final RunManagerImpl runManager = (RunManagerImpl) RunManagerEx.getInstanceEx(project);
    final ConfigurationType type = runManager.getConfigurationType(configType);
    if (type == null) {
        return;
    }
    if (configName != null) {
        for (RunConfiguration configuration : runManager.getConfigurationsList(type)) {
            if (configName.equals(configuration.getName())) {
                final List<AntBeforeRunTask> tasks = runManager.getBeforeRunTasks(configuration, AntBeforeRunTaskProvider.ID);
                if (!tasks.isEmpty()) {
                    //This is legacy code, we had only one task that time
                    AntBeforeRunTask task = tasks.get(0);
                    task.setEnabled(true);
                    task.setTargetName(targetName);
                    task.setAntFileUrl(buildFileUrl);
                }
            }
        }
    } else {
        for (ConfigurationFactory factory : type.getConfigurationFactories()) {
            final RunConfiguration template = runManager.getConfigurationTemplate(factory).getConfiguration();
            final List<AntBeforeRunTask> tasks = runManager.getBeforeRunTasks(template, AntBeforeRunTaskProvider.ID);
            if (!tasks.isEmpty()) {
                //This is legacy code, we had only one task that time
                AntBeforeRunTask task = tasks.get(0);
                task.setEnabled(true);
                task.setTargetName(targetName);
                task.setAntFileUrl(buildFileUrl);
            }
        }
    }
}
Also used : ConfigurationType(com.intellij.execution.configurations.ConfigurationType) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) ConfigurationFactory(com.intellij.execution.configurations.ConfigurationFactory) RunManagerImpl(com.intellij.execution.impl.RunManagerImpl)

Example 29 with ConfigurationFactory

use of com.intellij.execution.configurations.ConfigurationFactory in project intellij-community by JetBrains.

the class AbstractRunConfigurationTypeUsagesCollector method getProjectUsages.

@NotNull
@Override
public final Set<UsageDescriptor> getProjectUsages(@NotNull final Project project) {
    final Set<String> runConfigurationTypes = new HashSet<>();
    UIUtil.invokeAndWaitIfNeeded(new Runnable() {

        @Override
        public void run() {
            if (project.isDisposed())
                return;
            final RunManager runManager = RunManager.getInstance(project);
            for (RunnerAndConfigurationSettings settings : runManager.getAllSettings()) {
                RunConfiguration runConfiguration = settings.getConfiguration();
                if (runConfiguration != null && isApplicable(runManager, settings)) {
                    final ConfigurationFactory configurationFactory = runConfiguration.getFactory();
                    final ConfigurationType configurationType = configurationFactory.getType();
                    final StringBuilder keyBuilder = new StringBuilder();
                    keyBuilder.append(configurationType.getId());
                    if (configurationType.getConfigurationFactories().length > 1) {
                        keyBuilder.append(".").append(configurationFactory.getName());
                    }
                    runConfigurationTypes.add(keyBuilder.toString());
                }
            }
        }
    });
    return ContainerUtil.map2Set(runConfigurationTypes, runConfigurationType -> new UsageDescriptor(runConfigurationType, 1));
}
Also used : ConfigurationType(com.intellij.execution.configurations.ConfigurationType) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) ConfigurationFactory(com.intellij.execution.configurations.ConfigurationFactory) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) UsageDescriptor(com.intellij.internal.statistic.beans.UsageDescriptor) RunManager(com.intellij.execution.RunManager) HashSet(com.intellij.util.containers.HashSet) NotNull(org.jetbrains.annotations.NotNull)

Example 30 with ConfigurationFactory

use of com.intellij.execution.configurations.ConfigurationFactory in project intellij-community by JetBrains.

the class ProgramRunnerUtil method getRawIcon.

@NotNull
public static Icon getRawIcon(RunnerAndConfigurationSettings settings) {
    RunConfiguration configuration = settings.getConfiguration();
    ConfigurationFactory factory = settings.getFactory();
    Icon icon = factory != null ? factory.getIcon(configuration) : null;
    if (icon == null)
        icon = AllIcons.RunConfigurations.Unknown;
    return icon;
}
Also used : RunConfiguration(com.intellij.execution.configurations.RunConfiguration) ConfigurationFactory(com.intellij.execution.configurations.ConfigurationFactory) LayeredIcon(com.intellij.ui.LayeredIcon) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

ConfigurationFactory (com.intellij.execution.configurations.ConfigurationFactory)38 RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)23 Project (com.intellij.openapi.project.Project)14 RunManagerEx (com.intellij.execution.RunManagerEx)11 RunConfiguration (com.intellij.execution.configurations.RunConfiguration)9 BeforeRunTask (com.intellij.execution.BeforeRunTask)7 RunManagerImpl (com.intellij.execution.impl.RunManagerImpl)6 ArrayList (java.util.ArrayList)6 NotNull (org.jetbrains.annotations.NotNull)6 ConfigurationType (com.intellij.execution.configurations.ConfigurationType)4 RemoteConfiguration (com.intellij.execution.remote.RemoteConfiguration)4 Module (com.intellij.openapi.module.Module)4 RunManager (com.intellij.execution.RunManager)3 DefaultDebugExecutor (com.intellij.execution.executors.DefaultDebugExecutor)3 RunnerAndConfigurationSettingsImpl (com.intellij.execution.impl.RunnerAndConfigurationSettingsImpl)3 ExecutionEnvironment (com.intellij.execution.runners.ExecutionEnvironment)3 MakeBeforeRunTaskProvider (com.android.tools.idea.gradle.run.MakeBeforeRunTaskProvider)2 DebuggerSession (com.intellij.debugger.impl.DebuggerSession)2 ExecutionException (com.intellij.execution.ExecutionException)2 ConfigurationFactoryEx (com.intellij.execution.configuration.ConfigurationFactoryEx)2