Search in sources :

Example 46 with RunConfiguration

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

the class BeforeRunStepsPanel method getAllRunBeforeRuns.

private void getAllRunBeforeRuns(BeforeRunTask task, Set<RunConfiguration> configurationSet) {
    if (task instanceof RunConfigurationBeforeRunProvider.RunConfigurableBeforeRunTask) {
        RunConfigurationBeforeRunProvider.RunConfigurableBeforeRunTask runTask = (RunConfigurationBeforeRunProvider.RunConfigurableBeforeRunTask) task;
        RunConfiguration configuration = runTask.getSettings().getConfiguration();
        List<BeforeRunTask> tasks = RunManagerImpl.getInstanceImpl(configuration.getProject()).getBeforeRunTasks(configuration);
        for (BeforeRunTask beforeRunTask : tasks) {
            if (beforeRunTask instanceof RunConfigurationBeforeRunProvider.RunConfigurableBeforeRunTask) {
                if (configurationSet.add(((RunConfigurationBeforeRunProvider.RunConfigurableBeforeRunTask) beforeRunTask).getSettings().getConfiguration()))
                    getAllRunBeforeRuns(beforeRunTask, configurationSet);
            }
        }
    }
}
Also used : BeforeRunTask(com.intellij.execution.BeforeRunTask) UnknownRunConfiguration(com.intellij.execution.configurations.UnknownRunConfiguration) RunConfiguration(com.intellij.execution.configurations.RunConfiguration)

Example 47 with RunConfiguration

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

the class BeforeRunStepsPanel method doAddAction.

void doAddAction(AnActionButton button) {
    if (isUnknown()) {
        return;
    }
    final JBPopupFactory popupFactory = JBPopupFactory.getInstance();
    final BeforeRunTaskProvider<BeforeRunTask>[] providers = Extensions.getExtensions(BeforeRunTaskProvider.EXTENSION_POINT_NAME, myRunConfiguration.getProject());
    Set<Key> activeProviderKeys = getActiveProviderKeys();
    DefaultActionGroup actionGroup = new DefaultActionGroup(null, false);
    for (final BeforeRunTaskProvider<BeforeRunTask> provider : providers) {
        if (provider.createTask(myRunConfiguration) == null)
            continue;
        if (activeProviderKeys.contains(provider.getId()) && provider.isSingleton())
            continue;
        AnAction providerAction = new AnAction(provider.getName(), null, provider.getIcon()) {

            @Override
            public void actionPerformed(AnActionEvent e) {
                BeforeRunTask task = provider.createTask(myRunConfiguration);
                if (task != null) {
                    provider.configureTask(myRunConfiguration, task);
                    if (!provider.canExecuteTask(myRunConfiguration, task))
                        return;
                } else {
                    return;
                }
                task.setEnabled(true);
                Set<RunConfiguration> configurationSet = new HashSet<>();
                getAllRunBeforeRuns(task, configurationSet);
                if (configurationSet.contains(myRunConfiguration)) {
                    JOptionPane.showMessageDialog(BeforeRunStepsPanel.this, ExecutionBundle.message("before.launch.panel.cyclic_dependency_warning", myRunConfiguration.getName(), provider.getDescription(task)), ExecutionBundle.message("warning.common.title"), JOptionPane.WARNING_MESSAGE);
                    return;
                }
                addTask(task);
                myListener.fireStepsBeforeRunChanged();
            }
        };
        actionGroup.add(providerAction);
    }
    final ListPopup popup = popupFactory.createActionGroupPopup(ExecutionBundle.message("add.new.run.configuration.acrtion.name"), actionGroup, SimpleDataContext.getProjectContext(myRunConfiguration.getProject()), false, false, false, null, -1, Conditions.<AnAction>alwaysTrue());
    popup.show(button.getPreferredPopupPoint());
}
Also used : ListPopup(com.intellij.openapi.ui.popup.ListPopup) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup) AnAction(com.intellij.openapi.actionSystem.AnAction) BeforeRunTask(com.intellij.execution.BeforeRunTask) UnknownRunConfiguration(com.intellij.execution.configurations.UnknownRunConfiguration) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) JBPopupFactory(com.intellij.openapi.ui.popup.JBPopupFactory) BeforeRunTaskProvider(com.intellij.execution.BeforeRunTaskProvider) Key(com.intellij.openapi.util.Key) HashSet(com.intellij.util.containers.hash.HashSet)

Example 48 with RunConfiguration

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

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

the class AbstractAddToTestsPatternAction method collectPatternConfigurations.

private List<T> collectPatternConfigurations(Collection<PsiElement> foundClasses, Project project) {
    final List<RunConfiguration> configurations = RunManager.getInstance(project).getConfigurationsList(getConfigurationType());
    final List<T> foundConfigurations = new ArrayList<>();
    for (RunConfiguration configuration : configurations) {
        if (isPatternBasedConfiguration((T) configuration)) {
            if (foundClasses.size() > 1 || foundClasses.size() == 1 && !getPatterns((T) configuration).contains(getPatternBasedProducer().getQName(ContainerUtil.getFirstItem(foundClasses)))) {
                foundConfigurations.add((T) configuration);
            }
        }
    }
    return foundConfigurations;
}
Also used : RunConfiguration(com.intellij.execution.configurations.RunConfiguration)

Example 50 with RunConfiguration

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

the class AbstractExcludeFromRunAction method update.

@Override
public void update(AnActionEvent e) {
    final Presentation presentation = e.getPresentation();
    presentation.setVisible(false);
    final DataContext dataContext = e.getDataContext();
    final Project project = CommonDataKeys.PROJECT.getData(dataContext);
    if (project != null) {
        final RunConfiguration configuration = RunConfiguration.DATA_KEY.getData(dataContext);
        if (isPatternBasedConfiguration(configuration)) {
            final AbstractTestProxy testProxy = AbstractTestProxy.DATA_KEY.getData(dataContext);
            if (testProxy != null) {
                final Location location = testProxy.getLocation(project, ((T) configuration).getConfigurationModule().getSearchScope());
                if (location != null) {
                    final PsiElement psiElement = location.getPsiElement();
                    if (psiElement instanceof PsiClass && getPattern((T) configuration).contains(((PsiClass) psiElement).getQualifiedName())) {
                        presentation.setVisible(true);
                    }
                }
            }
        }
    }
}
Also used : Project(com.intellij.openapi.project.Project) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) PsiClass(com.intellij.psi.PsiClass) AbstractTestProxy(com.intellij.execution.testframework.AbstractTestProxy) PsiElement(com.intellij.psi.PsiElement) Location(com.intellij.execution.Location)

Aggregations

RunConfiguration (com.intellij.execution.configurations.RunConfiguration)59 RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)16 Module (com.intellij.openapi.module.Module)13 Nullable (org.jetbrains.annotations.Nullable)12 Project (com.intellij.openapi.project.Project)10 PsiElement (com.intellij.psi.PsiElement)7 ConfigurationFactory (com.intellij.execution.configurations.ConfigurationFactory)6 ConfigurationType (com.intellij.execution.configurations.ConfigurationType)6 Pair (com.intellij.openapi.util.Pair)6 NotNull (org.jetbrains.annotations.NotNull)6 AndroidTestRunConfiguration (com.android.tools.idea.testartifacts.instrumented.AndroidTestRunConfiguration)5 FlexBuildConfiguration (com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration)5 BeforeRunTask (com.intellij.execution.BeforeRunTask)4 FlashRunConfiguration (com.intellij.lang.javascript.flex.run.FlashRunConfiguration)4 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 ArrayList (java.util.ArrayList)4 AndroidJUnitConfiguration (com.android.tools.idea.testartifacts.junit.AndroidJUnitConfiguration)3 BeforeRunTaskProvider (com.intellij.execution.BeforeRunTaskProvider)3 Location (com.intellij.execution.Location)3 RunManager (com.intellij.execution.RunManager)3