String (AWTEvent e, AnAction action) { Object src = e.getSource(); ArrayList<String> items = new ArrayList<>(); while (src instanceof MenuItem) { items.add(0, ((MenuItem)src).getLabel()); src = ((MenuItem)src).getParent(); } if (items.size() > 1) { items.set(items.size() - 1, getActionText(action)); } return convertMenuItemsToKey(items); }