Search in sources :

Example 11 with ConfigurationType

use of com.intellij.execution.configurations.ConfigurationType 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 12 with ConfigurationType

use of com.intellij.execution.configurations.ConfigurationType 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 13 with ConfigurationType

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

the class ConfigurationTypeDashboardGroupingRule method getGroup.

@Nullable
@Override
public DashboardGroup getGroup(AbstractTreeNode<?> node) {
    if (node instanceof DashboardRunConfigurationNode) {
        RunnerAndConfigurationSettings configurationSettings = ((DashboardRunConfigurationNode) node).getConfigurationSettings();
        ConfigurationType type = configurationSettings.getType();
        if (type != null) {
            return new DashboardGroupImpl<>(type, type.getDisplayName(), type.getIcon());
        }
    }
    return null;
}
Also used : ConfigurationType(com.intellij.execution.configurations.ConfigurationType) DashboardRunConfigurationNode(com.intellij.execution.dashboard.DashboardRunConfigurationNode) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) Nullable(org.jetbrains.annotations.Nullable)

Example 14 with ConfigurationType

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

the class PluginProjectWizardTest method testPluginProject.

public void testPluginProject() throws Exception {
    createSdk("devkit", IdeaJdk.getInstance());
    Project project = createProjectFromTemplate(PluginModuleType.getInstance().getName(), null, null);
    VirtualFile virtualFile = project.getBaseDir().findFileByRelativePath("resources/META-INF/plugin.xml");
    assertNotNull(virtualFile);
    RunnerAndConfigurationSettings configuration = RunManager.getInstance(project).getSelectedConfiguration();
    assertNotNull(configuration);
    ConfigurationType type = configuration.getType();
    assertNotNull(type);
    assertEquals(DevKitBundle.message("run.configuration.title"), type.getDisplayName());
    VirtualFile[] files = FileEditorManager.getInstance(project).getOpenFiles();
    assertEquals(1, files.length);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ConfigurationType(com.intellij.execution.configurations.ConfigurationType) Project(com.intellij.openapi.project.Project) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings)

Example 15 with ConfigurationType

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

the class RecentTestsListProvider method initRunConfigurationsMap.

private void initRunConfigurationsMap() {
    RunManagerEx manager = RunManagerEx.getInstanceEx(myProject);
    ConfigurationType[] types = manager.getConfigurationFactories();
    for (ConfigurationType type : types) {
        Map<String, List<RunnerAndConfigurationSettings>> structure = manager.getStructure(type);
        for (Map.Entry<String, List<RunnerAndConfigurationSettings>> e : structure.entrySet()) {
            for (RunnerAndConfigurationSettings settings : e.getValue()) {
                myConfigurationsMap.put(settings.getName().hashCode(), settings);
            }
        }
    }
}
Also used : ConfigurationType(com.intellij.execution.configurations.ConfigurationType) RunManagerEx(com.intellij.execution.RunManagerEx) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) List(java.util.List) Map(java.util.Map)

Aggregations

ConfigurationType (com.intellij.execution.configurations.ConfigurationType)15 RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)7 RunConfiguration (com.intellij.execution.configurations.RunConfiguration)6 Project (com.intellij.openapi.project.Project)6 NotNull (org.jetbrains.annotations.NotNull)5 ConfigurationFactory (com.intellij.execution.configurations.ConfigurationFactory)4 List (java.util.List)4 UnknownConfigurationType (com.intellij.execution.configurations.UnknownConfigurationType)3 RunManagerImpl (com.intellij.execution.impl.RunManagerImpl)3 AndroidJUnitConfigurationType (com.android.tools.idea.testartifacts.junit.AndroidJUnitConfigurationType)2 EditConfigurationsDialog (com.intellij.execution.impl.EditConfigurationsDialog)2 DataContext (com.intellij.openapi.actionSystem.DataContext)2 Map (java.util.Map)2 MakeBeforeRunTaskProvider (com.android.tools.idea.gradle.run.MakeBeforeRunTaskProvider)1 AndroidJUnitConfigurationProducer (com.android.tools.idea.testartifacts.junit.AndroidJUnitConfigurationProducer)1 BeforeRunTaskProvider (com.intellij.execution.BeforeRunTaskProvider)1 RunManager (com.intellij.execution.RunManager)1 RunManagerEx (com.intellij.execution.RunManagerEx)1 RunConfigurationProducer (com.intellij.execution.actions.RunConfigurationProducer)1 DashboardRunConfigurationNode (com.intellij.execution.dashboard.DashboardRunConfigurationNode)1