use of com.intellij.openapi.ui.popup.MultiSelectionListPopupStep 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