use of com.intellij.execution.configurations.UnknownConfigurationType in project intellij-community by JetBrains.
the class ChooseRunConfigurationPopup method createSettingsList.
public static ItemWrapper[] createSettingsList(@NotNull Project project, @NotNull ExecutorProvider executorProvider, boolean createEditAction) {
List<ItemWrapper> result = new ArrayList<>();
if (createEditAction) {
ItemWrapper<Void> edit = new ItemWrapper<Void>(null) {
@Override
public Icon getIcon() {
return AllIcons.Actions.EditSource;
}
@Override
public String getText() {
return UIUtil.removeMnemonic(ActionsBundle.message("action.editRunConfigurations.text"));
}
@Override
public void perform(@NotNull final Project project, @NotNull final Executor executor, @NotNull DataContext context) {
if (new EditConfigurationsDialog(project) {
@Override
protected void init() {
setOKButtonText(executor.getStartActionText());
setOKButtonIcon(executor.getIcon());
myExecutor = executor;
super.init();
}
}.showAndGet()) {
ApplicationManager.getApplication().invokeLater(() -> {
RunnerAndConfigurationSettings configuration = RunManager.getInstance(project).getSelectedConfiguration();
if (configuration != null) {
ExecutionUtil.runConfiguration(configuration, executor);
}
}, project.getDisposed());
}
}
@Override
public boolean available(Executor executor) {
return true;
}
};
edit.setMnemonic(0);
result.add(edit);
}
RunManagerEx manager = RunManagerEx.getInstanceEx(project);
final RunnerAndConfigurationSettings selectedConfiguration = manager.getSelectedConfiguration();
if (selectedConfiguration != null) {
boolean isFirst = true;
final ExecutionTarget activeTarget = ExecutionTargetManager.getActiveTarget(project);
for (ExecutionTarget eachTarget : ExecutionTargetManager.getTargetsToChooseFor(project, selectedConfiguration)) {
result.add(new ItemWrapper<ExecutionTarget>(eachTarget, isFirst) {
{
setChecked(getValue().equals(activeTarget));
}
@Override
public Icon getIcon() {
return getValue().getIcon();
}
@Override
public String getText() {
return getValue().getDisplayName();
}
@Override
public void perform(@NotNull final Project project, @NotNull final Executor executor, @NotNull DataContext context) {
ExecutionTargetManager.setActiveTarget(project, getValue());
ExecutionUtil.runConfiguration(selectedConfiguration, executor);
}
@Override
public boolean available(Executor executor) {
return true;
}
});
isFirst = false;
}
}
Map<RunnerAndConfigurationSettings, ItemWrapper> wrappedExisting = new LinkedHashMap<>();
for (ConfigurationType type : manager.getConfigurationFactories()) {
if (!(type instanceof UnknownConfigurationType)) {
Map<String, List<RunnerAndConfigurationSettings>> structure = manager.getStructure(type);
for (Map.Entry<String, List<RunnerAndConfigurationSettings>> entry : structure.entrySet()) {
if (entry.getValue().isEmpty()) {
continue;
}
final String key = entry.getKey();
if (key != null) {
boolean isSelected = entry.getValue().contains(selectedConfiguration);
if (isSelected) {
assert selectedConfiguration != null;
}
FolderWrapper folderWrapper = new FolderWrapper(project, executorProvider, key + (isSelected ? " (mnemonic is to \"" + selectedConfiguration.getName() + "\")" : ""), entry.getValue());
if (isSelected) {
folderWrapper.setMnemonic(1);
}
result.add(folderWrapper);
} else {
for (RunnerAndConfigurationSettings configuration : entry.getValue()) {
final ItemWrapper wrapped = ItemWrapper.wrap(project, configuration);
if (configuration == selectedConfiguration) {
wrapped.setMnemonic(1);
}
wrappedExisting.put(configuration, wrapped);
}
}
}
}
}
if (!DumbService.isDumb(project)) {
populateWithDynamicRunners(result, wrappedExisting, project, manager, selectedConfiguration);
}
result.addAll(wrappedExisting.values());
return result.toArray(new ItemWrapper[result.size()]);
}
use of com.intellij.execution.configurations.UnknownConfigurationType 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();
}
Aggregations