void () { // ask user whether she wants to highlight target exception usages or places that throws that exception String className = "'" + ((PsiClass)myResolved).getName() + "'"; String throwingPlacesMode = JavaBundle.message("highlight.throws.popup.throwing.places", className); String showUsagesMode = JavaBundle.message("highlight.throws.popup.usages", className); IPopupChooserBuilder<String> builder = JBPopupFactory.getInstance() .createPopupChooserBuilder(Arrays.asList(throwingPlacesMode, showUsagesMode)) .setRenderer(new SimpleListCellRenderer<>() { @Override public void customize(@NotNull JList<? extends String> list, @NlsContexts.Label String value, int index, boolean selected, boolean hasFocus) { setIcon(showUsagesMode.equals(value) ? AllIcons.Nodes.Class : AllIcons.Nodes.ExceptionClass); setText(value); } }) .setSelectionMode(ListSelectionModel.SINGLE_SELECTION) .setItemChosenCallback(selected -> { MODE mode = selected.equals(showUsagesMode) ? MODE.SHOW_USAGES : MODE.SHOW_THROWING_PLACES; if (mode == MODE.SHOW_THROWING_PLACES) { super.highlightUsages(); } else { new PsiElement2UsageTargetAdapter(myResolved).highlightUsages(myFile, myEditor, HighlightUsagesHandler.isClearHighlights(myEditor)); } }) .setTitle(JavaBundle.message("highlight.throws.class.name", className)); builder.createPopup().showInBestPositionFor(myEditor); }