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);
}
}
}
}
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());
}
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));
}
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;
}
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);
}
}
}
}
}
}
Aggregations