void (@NotNull AnActionEvent e) { JComponent button = e.getPresentation().getClientProperty(CustomComponentAction.COMPONENT_KEY); if (button == null || !button.isValid()) return; ListCellRenderer<ScopeDescriptor> renderer = new ListCellRenderer<>() { final ListCellRenderer<ScopeDescriptor> delegate = ScopeChooserCombo.createDefaultRenderer(); @Override public Component getListCellRendererComponent(JList<? extends ScopeDescriptor> list, ScopeDescriptor value, int index, boolean isSelected, boolean cellHasFocus) { // copied from DarculaJBPopupComboPopup.customizeListRendererComponent() Component component = delegate.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); if (component instanceof JComponent && !(component instanceof JSeparator || component instanceof TitledSeparator)) { ((JComponent)component).setBorder(JBUI.Borders.empty(2, 8)); } return component; } }; List<ScopeDescriptor> items = new ArrayList<>(); JList<ScopeDescriptor> fakeList = new JBList<>(); processScopes(o -> { Component c = renderer.getListCellRendererComponent(fakeList, o, -1, false, false); if (c instanceof JSeparator || c instanceof TitledSeparator || !o.scopeEquals(null) && o.getScope() instanceof GlobalSearchScope) { items.add(o); } return true; }); BaseListPopupStep<ScopeDescriptor> step = new BaseListPopupStep<>("", items) { @Nullable @Override public PopupStep<?> onChosen(ScopeDescriptor selectedValue, boolean finalChoice) { onScopeSelected(selectedValue); ActionToolbar toolbar = ActionToolbar.findToolbarBy(button); if (toolbar != null) toolbar.updateActionsImmediately(); return FINAL_CHOICE; } @Override public boolean isSpeedSearchEnabled() { return true; } @NotNull @Override public String getTextFor(ScopeDescriptor value) { return value.getScope() instanceof GlobalSearchScope ? StringUtil.notNullize(value.getDisplayName()) : ""; } @Override public boolean isSelectable(ScopeDescriptor value) { return value.getScope() instanceof GlobalSearchScope; } }; ScopeDescriptor selection = getSelectedScope(); step.setDefaultOptionIndex(ContainerUtil.indexOf(items, o -> Objects.equals(o.getDisplayName(), selection.getDisplayName()))); ListPopupImpl popup = new ListPopupImpl(e.getProject(), step); popup.setMaxRowCount(10); //noinspection unchecked popup.getList().setCellRenderer(renderer); popup.showUnderneathOf(button); }