ActionGroup (@Nullable Object target, @NotNull Consumer<? super Charset> onChosen) { VirtualFile file = target instanceof VirtualFile ? (VirtualFile)target : null; byte[] b = null; try { b = file == null || file.isDirectory() ? null : file.contentsToByteArray(); } catch (IOException ignored) { } byte[] bytes = b; Document document = file == null ? null : FileDocumentManager.getInstance().getDocument(file); return new ChangeFileEncodingAction(true) { @Override protected boolean chosen(Document document, Editor editor, VirtualFile virtualFile, byte[] bytes, @NotNull Charset charset) { onChosen.consume(charset); return true; } }.createActionGroup(file, null, document, bytes, getClearValueText(target)); }