void (final @NotNull AnActionEvent e) { final DataContext dataContext = e.getDataContext(); Project project = CommonDataKeys.PROJECT.getData(dataContext); Component focusedComponent = e.getData(PlatformCoreDataKeys.CONTEXT_COMPONENT); Editor editor = CommonDataKeys.EDITOR.getData(dataContext); if (!(focusedComponent instanceof JComponent)) return; final ContentChooser<Transferable> chooser = new ClipboardContentChooser(project); if (!chooser.getAllContents().isEmpty()) { chooser.show(); } else { chooser.close(DialogWrapper.CANCEL_EXIT_CODE); } if (chooser.getExitCode() == DialogWrapper.OK_EXIT_CODE || chooser.getExitCode() == getPasteSimpleExitCode()) { List<Transferable> selectedContents = chooser.getSelectedContents(); CopyPasteManagerEx copyPasteManager = CopyPasteManagerEx.getInstanceEx(); if (selectedContents.size() == 1) { copyPasteManager.moveContentToStackTop(selectedContents.get(0)); } else { copyPasteManager.setContents(new StringSelection(chooser.getSelectedText())); } if (editor != null) { if (editor.isViewer()) return; final AnAction pasteAction = ActionManager.getInstance().getAction(chooser.getExitCode() == getPasteSimpleExitCode() ? IdeActions.ACTION_EDITOR_PASTE_SIMPLE : IdeActions.ACTION_PASTE); AnActionEvent newEvent = new AnActionEvent(e.getInputEvent(), DataManager.getInstance().getDataContext(focusedComponent), e.getPlace(), e.getPresentation(), ActionManager.getInstance(), e.getModifiers()); pasteAction.actionPerformed(newEvent); } else { final Action pasteAction = ((JComponent)focusedComponent).getActionMap().get(DefaultEditorKit.pasteAction); if (pasteAction != null) { pasteAction.actionPerformed(new ActionEvent(focusedComponent, ActionEvent.ACTION_PERFORMED, "")); } } } }