void (ListPopupImpl popup, Ref<Boolean> showAd, String... actionNames) { for (String name : actionNames) { KeyStroke stroke = KeymapUtil.getKeyStroke(ActionManager.getInstance().getAction(name).getShortcutSet()); if (stroke != null) { popup.registerAction("handleSelection " + stroke, stroke, new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { showAd.set(false); popup.handleSelect(true); } }); } } if (showAd.get()) { popup.setAdText(getSelectionShortcutsAdText(actionNames)); } }