use of com.intellij.execution.actions.ExecutorProvider in project intellij-community by JetBrains.
the class ProjectStartupConfigurable method selectAndAddConfiguration.
private void selectAndAddConfiguration(final AnActionButton button) {
final Executor executor = DefaultRunExecutor.getRunExecutorInstance();
final List<ChooseRunConfigurationPopup.ItemWrapper> wrappers = new ArrayList<>();
wrappers.add(createNewWrapper(button));
final ChooseRunConfigurationPopup.ItemWrapper[] allSettings = ChooseRunConfigurationPopup.createSettingsList(myProject, new ExecutorProvider() {
@Override
public Executor getExecutor() {
return executor;
}
}, false);
final Set<RunnerAndConfigurationSettings> existing = new HashSet<>(myModel.getAllConfigurations());
for (ChooseRunConfigurationPopup.ItemWrapper setting : allSettings) {
if (setting.getValue() instanceof RunnerAndConfigurationSettings) {
final RunnerAndConfigurationSettings settings = (RunnerAndConfigurationSettings) setting.getValue();
if (!settings.isTemporary() && ProjectStartupRunner.canBeRun(settings) && !existing.contains(settings)) {
wrappers.add(setting);
}
}
}
final JBList list = new JBList(wrappers);
list.setCellRenderer(new ColoredListCellRenderer() {
@Override
protected void customizeCellRenderer(@NotNull JList list, Object value, int index, boolean selected, boolean hasFocus) {
if (value instanceof ChooseRunConfigurationPopup.ItemWrapper) {
setIcon(((ChooseRunConfigurationPopup.ItemWrapper) value).getIcon());
append(((ChooseRunConfigurationPopup.ItemWrapper) value).getText());
}
}
});
final JBPopup popup = JBPopupFactory.getInstance().createListPopupBuilder(list).setItemChoosenCallback(() -> {
final int index = list.getSelectedIndex();
if (index < 0)
return;
final ChooseRunConfigurationPopup.ItemWrapper at = (ChooseRunConfigurationPopup.ItemWrapper) list.getModel().getElementAt(index);
if (at.getValue() instanceof RunnerAndConfigurationSettings) {
final RunnerAndConfigurationSettings added = (RunnerAndConfigurationSettings) at.getValue();
addConfiguration(added);
} else {
at.perform(myProject, executor, button.getDataContext());
}
}).createPopup();
showPopup(button, popup);
}
Aggregations