void (EditorEx editor) { editor.putUserData(TEXT_MODEL_KEY, myTextModel); AnAction restoreAction = ActionManager.getInstance().getAction(IdeActions.ACTION_RESTORE_FONT_PREVIEW_TEXT); AnAction toggleBoldFontAction = ActionManager.getInstance().getAction("fontEditorPreview.ToggleBoldFont"); if (restoreAction != null || toggleBoldFontAction != null) { String originalGroupId = editor.getContextMenuGroupId(); AnAction originalGroup = originalGroupId == null ? null : ActionManager.getInstance().getAction(originalGroupId); DefaultActionGroup group = new DefaultActionGroup(); if (originalGroup instanceof ActionGroup) { group.addAll(((ActionGroup)originalGroup).getChildren(null)); } if (restoreAction != null) { group.add(restoreAction); } if (toggleBoldFontAction != null) { group.add(toggleBoldFontAction); DumbAwareAction.create(event -> toggleBoldFont(editor)).registerCustomShortcutSet(TOGGLE_BOLD_SHORTCUT, editor.getComponent()); } editor.installPopupHandler(new ContextMenuPopupHandler.Simple(group)); } }