String (@NotNull AWTKeyStroke systemHotkey) { if (systemHotkey instanceof KeyStroke) { return myKeyStrokeCustomDescription.get(systemHotkey); } if (ourShkClass == null) { ourShkClass = ReflectionUtil.forName("java.awt.desktop.SystemHotkey"); } if (ourMethodGetDescription == null) { ourMethodGetDescription = ReflectionUtil.getMethod(ourShkClass, "getDescription"); } String result = null; try { result = (String)ourMethodGetDescription.invoke(systemHotkey); } catch (Throwable e) { Logger.getInstance(SystemShortcuts.class).error(e); } if (result == null) { return ourUnknownSysAction; } // shorten description when the result string looks like: // "com.apple.Safari - Search With %WebSearchProvider@ - searchWithWebSearchProvider" final String delimiter = " - "; final int pos0 = result.indexOf(delimiter); if (pos0 < 0) { return result; } final int pos1 = result.indexOf(delimiter, pos0 + delimiter.length()); if (pos1 < 0) { return result; } return result.substring(pos0 + delimiter.length(), pos1).replace("%", "").replace("@", ""); }