AnAction (@NotNull List<? extends Producer> producers, @NotNull Consumer<? super Integer> onSelected, int defaultSelection) { return new PresentableGoToChangePopupAction<ProducerWrapper>() { @Override protected @NotNull ListSelection<? extends ProducerWrapper> getChanges() { List<ProducerWrapper> wrappers = new ArrayList<>(); for (int i = 0; i < producers.size(); i++) { wrappers.add(new ProducerWrapper(producers.get(i), i)); } return ListSelection.createAt(wrappers, defaultSelection); } @Override protected PresentableChange getPresentation(@NotNull ProducerWrapper change) { return change.producer; } @Override protected void onSelected(@NotNull ProducerWrapper change) { onSelected.consume(change.index); } }; }