use of com.intellij.execution.configurations.RunConfiguration in project intellij-community by JetBrains.
the class BaseRunConfigurationAction method getChildren.
private AnAction[] getChildren(DataContext dataContext) {
final ConfigurationContext context = ConfigurationContext.getFromContext(dataContext);
final RunnerAndConfigurationSettings existing = context.findExisting();
if (existing == null) {
final List<ConfigurationFromContext> producers = getConfigurationsFromContext(context);
if (producers.size() > 1) {
final AnAction[] children = new AnAction[producers.size()];
int childIdx = 0;
for (final ConfigurationFromContext fromContext : producers) {
final ConfigurationType configurationType = fromContext.getConfigurationType();
final RunConfiguration configuration = fromContext.getConfiguration();
final String actionName = childActionName(configurationType, configuration);
final AnAction anAction = new AnAction(actionName, configurationType.getDisplayName(), configuration.getIcon()) {
@Override
public void actionPerformed(AnActionEvent e) {
perform(fromContext, context);
}
};
anAction.getTemplatePresentation().setText(actionName, false);
children[childIdx++] = anAction;
}
return children;
}
}
return EMPTY_ARRAY;
}
use of com.intellij.execution.configurations.RunConfiguration in project intellij-community by JetBrains.
the class RunDashboardManagerImpl method getRunConfigurations.
@Override
public List<Pair<RunnerAndConfigurationSettings, RunContentDescriptor>> getRunConfigurations() {
List<Pair<RunnerAndConfigurationSettings, RunContentDescriptor>> result = new ArrayList<>();
List<RunnerAndConfigurationSettings> configurations = RunManager.getInstance(myProject).getAllSettings().stream().filter(runConfiguration -> RunDashboardContributor.isShowInDashboard(runConfiguration.getType())).collect(Collectors.toList());
//noinspection ConstantConditions ???
ExecutionManagerImpl executionManager = ExecutionManagerImpl.getInstance(myProject);
configurations.forEach(configurationSettings -> {
List<RunContentDescriptor> descriptors = executionManager.getDescriptors(settings -> Comparing.equal(settings.getConfiguration(), configurationSettings.getConfiguration()));
if (descriptors.isEmpty()) {
result.add(Pair.create(configurationSettings, null));
} else {
descriptors.forEach(descriptor -> result.add(Pair.create(configurationSettings, descriptor)));
}
});
// It is possible that run configuration was deleted, but there is running content descriptor for such run configuration.
// It should be shown in he dashboard tree.
List<RunConfiguration> storedConfigurations = configurations.stream().map(RunnerAndConfigurationSettings::getConfiguration).collect(Collectors.toList());
List<RunContentDescriptor> notStoredDescriptors = executionManager.getRunningDescriptors(settings -> {
RunConfiguration configuration = settings.getConfiguration();
return RunDashboardContributor.isShowInDashboard(settings.getType()) && !storedConfigurations.contains(configuration);
});
notStoredDescriptors.forEach(descriptor -> {
Set<RunnerAndConfigurationSettings> settings = executionManager.getConfigurations(descriptor);
settings.forEach(setting -> result.add(Pair.create(setting, descriptor)));
});
return result;
}
use of com.intellij.execution.configurations.RunConfiguration in project intellij-community by JetBrains.
the class CompoundRunConfigurationSettingsEditor method createEditor.
@NotNull
@Override
protected JComponent createEditor() {
final ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myList);
return decorator.disableUpDownActions().setAddAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
final List<RunConfiguration> all = new ArrayList<>();
for (ConfigurationType type : myRunManager.getConfigurationFactories()) {
if (!(type instanceof UnknownConfigurationType)) {
for (RunnerAndConfigurationSettings settings : myRunManager.getConfigurationSettingsList(type)) {
all.add(settings.getConfiguration());
}
}
}
final List<RunConfiguration> configurations = ContainerUtil.filter(all, configuration -> !mySnapshot.getSetToRun().contains(configuration) && canBeAdded(configuration, mySnapshot));
JBPopupFactory.getInstance().createListPopup(new MultiSelectionListPopupStep<RunConfiguration>(null, configurations) {
@Nullable
@Override
public ListSeparator getSeparatorAbove(RunConfiguration value) {
int i = configurations.indexOf(value);
if (i < 1)
return null;
RunConfiguration previous = configurations.get(i - 1);
return value.getType() != previous.getType() ? new ListSeparator() : null;
}
@Override
public Icon getIconFor(RunConfiguration value) {
return value.getType().getIcon();
}
@Override
public boolean isSpeedSearchEnabled() {
return true;
}
@NotNull
@Override
public String getTextFor(RunConfiguration value) {
return value.getName();
}
@Override
public PopupStep<?> onChosen(List<RunConfiguration> selectedValues, boolean finalChoice) {
myList.clearSelection();
myModel.addAll(selectedValues);
return FINAL_CHOICE;
}
}).showUnderneathOf(decorator.getActionsPanel());
}
}).setEditAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
int index = myList.getSelectedIndex();
if (index == -1)
return;
RunConfiguration configuration = myModel.get(index);
RunConfigurationSelector selector = RunConfigurationSelector.KEY.getData(DataManager.getInstance().getDataContext(button.getContextComponent()));
if (selector != null) {
selector.select(configuration);
}
}
}).setToolbarPosition(ActionToolbarPosition.TOP).createPanel();
}
use of com.intellij.execution.configurations.RunConfiguration in project intellij-community by JetBrains.
the class CompoundRunConfigurationSettingsEditor method applyEditorTo.
@Override
protected void applyEditorTo(@NotNull CompoundRunConfiguration s) throws ConfigurationException {
Set<RunConfiguration> checked = new HashSet<>();
for (int i = 0; i < myModel.getSize(); i++) {
RunConfiguration configuration = myModel.get(i);
String message = LangBundle.message("compound.run.configuration.cycle", configuration.getType().getDisplayName(), configuration.getName());
if (!canBeAdded(configuration, s))
throw new ConfigurationException(message);
checked.add(configuration);
}
Set<RunConfiguration> toRun = s.getSetToRun();
toRun.clear();
toRun.addAll(checked);
}
use of com.intellij.execution.configurations.RunConfiguration in project intellij-community by JetBrains.
the class RunConfigurationProducer method createLightConfiguration.
@Nullable
public RunConfiguration createLightConfiguration(@NotNull final ConfigurationContext context) {
RunConfiguration configuration = myConfigurationFactory.createTemplateConfiguration(context.getProject());
final Ref<PsiElement> ref = new Ref<>(context.getPsiLocation());
try {
if (!setupConfigurationFromContext((T) configuration, context, ref)) {
return null;
}
} catch (ClassCastException e) {
LOG.error(myConfigurationFactory + " produced wrong type", e);
return null;
}
return configuration;
}
Aggregations