Search in sources :

Example 6 with ConfigurationType

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

the class DumpConfigurationTypesAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    final Project project = e.getProject();
    final ConfigurationType[] factories = RunManager.getInstance(project).getConfigurationFactories();
    for (ConfigurationType factory : factories) {
        System.out.println(factory.getDisplayName() + " : " + factory.getId());
    }
}
Also used : ConfigurationType(com.intellij.execution.configurations.ConfigurationType) Project(com.intellij.openapi.project.Project)

Example 7 with ConfigurationType

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

the class BaseExecuteBeforeRunDialog method buildNodes.

private DefaultMutableTreeNode buildNodes() {
    DefaultMutableTreeNode root = new DefaultMutableTreeNode(new Descriptor());
    RunManager runManager = RunManager.getInstance(myProject);
    final ConfigurationType[] configTypes = runManager.getConfigurationFactories();
    for (final ConfigurationType type : configTypes) {
        final Icon icon = type.getIcon();
        DefaultMutableTreeNode typeNode = new DefaultMutableTreeNode(new ConfigurationTypeDescriptor(type, icon, isConfigurationAssigned(type)));
        root.add(typeNode);
        final Set<String> addedNames = StringSetSpinAllocator.alloc();
        try {
            List<RunConfiguration> configurations = runManager.getConfigurationsList(type);
            for (final RunConfiguration configuration : configurations) {
                final String configurationName = configuration.getName();
                if (addedNames.contains(configurationName)) {
                    // add only the first configuration if more than one has the same name
                    continue;
                }
                addedNames.add(configurationName);
                typeNode.add(new DefaultMutableTreeNode(new ConfigurationDescriptor(configuration, isConfigurationAssigned(configuration))));
            }
        } finally {
            StringSetSpinAllocator.dispose(addedNames);
        }
    }
    return root;
}
Also used : ConfigurationType(com.intellij.execution.configurations.ConfigurationType) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) RunConfiguration(com.intellij.execution.configurations.RunConfiguration)

Example 8 with ConfigurationType

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

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

the class AndroidStudioInitializer method disableIdeaJUnitConfigurations.

// JUnit original Extension JUnitConfigurationType is disabled so it can be replaced by its child class AndroidJUnitConfigurationType
private static void disableIdeaJUnitConfigurations() {
    // First we unregister the ConfigurationProducers, and after the ConfigurationType
    ExtensionPoint<RunConfigurationProducer> configurationProducerExtensionPoint = Extensions.getRootArea().getExtensionPoint(RunConfigurationProducer.EP_NAME);
    for (RunConfigurationProducer runConfigurationProducer : configurationProducerExtensionPoint.getExtensions()) {
        if (runConfigurationProducer instanceof JUnitConfigurationProducer && !(runConfigurationProducer instanceof AndroidJUnitConfigurationProducer)) {
            // In AndroidStudio these ConfigurationProducer s are replaced
            configurationProducerExtensionPoint.unregisterExtension(runConfigurationProducer);
        }
    }
    ExtensionPoint<ConfigurationType> configurationTypeExtensionPoint = Extensions.getRootArea().getExtensionPoint(ConfigurationType.CONFIGURATION_TYPE_EP);
    for (ConfigurationType configurationType : configurationTypeExtensionPoint.getExtensions()) {
        if (configurationType instanceof JUnitConfigurationType && !(configurationType instanceof AndroidJUnitConfigurationType)) {
            // In Android Studio the user is forced to use AndroidJUnitConfigurationType instead of JUnitConfigurationType
            configurationTypeExtensionPoint.unregisterExtension(configurationType);
        }
    }
    // We hide actions registered by the JUnit plugin and instead we use those registered in android-junit.xml
    hideAction("excludeFromSuite");
    hideAction("AddToISuite");
}
Also used : ConfigurationType(com.intellij.execution.configurations.ConfigurationType) AndroidJUnitConfigurationType(com.android.tools.idea.testartifacts.junit.AndroidJUnitConfigurationType) JUnitConfigurationType(com.intellij.execution.junit.JUnitConfigurationType) RunConfigurationProducer(com.intellij.execution.actions.RunConfigurationProducer) AndroidJUnitConfigurationType(com.android.tools.idea.testartifacts.junit.AndroidJUnitConfigurationType) AndroidJUnitConfigurationProducer(com.android.tools.idea.testartifacts.junit.AndroidJUnitConfigurationProducer) AndroidJUnitConfigurationType(com.android.tools.idea.testartifacts.junit.AndroidJUnitConfigurationType) JUnitConfigurationType(com.intellij.execution.junit.JUnitConfigurationType) JUnitConfigurationProducer(com.intellij.execution.junit.JUnitConfigurationProducer) AndroidJUnitConfigurationProducer(com.android.tools.idea.testartifacts.junit.AndroidJUnitConfigurationProducer)

Example 10 with ConfigurationType

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

the class PostSyncProjectSetup method setMakeStepInJunitRunConfigurations.

private void setMakeStepInJunitRunConfigurations(@NotNull String makeTaskName) {
    ConfigurationType junitConfigurationType = AndroidJUnitConfigurationType.getInstance();
    BeforeRunTaskProvider<BeforeRunTask>[] taskProviders = Extensions.getExtensions(BeforeRunTaskProvider.EXTENSION_POINT_NAME, myProject);
    BeforeRunTaskProvider targetProvider = null;
    for (BeforeRunTaskProvider<? extends BeforeRunTask> provider : taskProviders) {
        if (makeTaskName.equals(provider.getName())) {
            targetProvider = provider;
            break;
        }
    }
    if (targetProvider != null) {
        RunManagerImpl runManager = RunManagerImpl.getInstanceImpl(myProject);
        // Set the correct "Make step" in the "JUnit Run Configuration" template.
        for (ConfigurationFactory configurationFactory : junitConfigurationType.getConfigurationFactories()) {
            RunnerAndConfigurationSettings template = runManager.getConfigurationTemplate(configurationFactory);
            RunConfiguration runConfiguration = template.getConfiguration();
            setMakeStepInJUnitConfiguration(targetProvider, runConfiguration);
        }
        // Set the correct "Make step" in existing JUnit Configurations.
        for (RunConfiguration runConfiguration : runManager.getConfigurationsList(junitConfigurationType)) {
            setMakeStepInJUnitConfiguration(targetProvider, runConfiguration);
        }
    }
}
Also used : ConfigurationType(com.intellij.execution.configurations.ConfigurationType) AndroidJUnitConfigurationType(com.android.tools.idea.testartifacts.junit.AndroidJUnitConfigurationType) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) ConfigurationFactory(com.intellij.execution.configurations.ConfigurationFactory) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) BeforeRunTaskProvider(com.intellij.execution.BeforeRunTaskProvider) MakeBeforeRunTaskProvider(com.android.tools.idea.gradle.run.MakeBeforeRunTaskProvider) RunManagerImpl(com.intellij.execution.impl.RunManagerImpl)

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