boolean (Editor editor, final Processor<? super Injectable> onChosen) { ColoredListCellRenderer<Injectable> renderer = new ColoredListCellRenderer<>() { @Override protected void customizeCellRenderer(@NotNull JList<? extends Injectable> list, Injectable language, int index, boolean selected, boolean hasFocus) { setIcon(language.getIcon()); append(language.getDisplayName()); String description = language.getAdditionalDescription(); if (description != null) { append(description, SimpleTextAttributes.GRAYED_ATTRIBUTES); } } }; final List<Injectable> injectables = getAllInjectables(); final String lastInjectedId = PropertiesComponent.getInstance().getValue(LAST_INJECTED_LANGUAGE); Injectable lastInjected = lastInjectedId != null ? ContainerUtil.find(injectables, injectable -> lastInjectedId.equals(injectable.getId())) : null; Dimension minSize = new JLabel(PlainTextLanguage.INSTANCE.getDisplayName(), EmptyIcon.ICON_16, SwingConstants.LEFT).getMinimumSize(); minSize.height *= 4; IPopupChooserBuilder<Injectable> builder = JBPopupFactory.getInstance() .createPopupChooserBuilder(injectables) .setRenderer(renderer) .setItemChosenCallback(injectable -> { onChosen.process(injectable); PropertiesComponent.getInstance().setValue(LAST_INJECTED_LANGUAGE, injectable.getId()); }) .setMinSize(minSize) .setNamerForFiltering(language -> language.getDisplayName()); if (lastInjected != null) { builder = builder.setSelectedValue(lastInjected, true); } builder.createPopup().showInBestPositionFor(editor); return true; }