protected @NotNull DefaultActionGroup createCharsetsActionGroup(@Nullable @NlsActions.ActionText String clearItemText,
                                                                  @Nullable Charset alreadySelected,
                                                                  @NotNull Function<? super Charset, @NlsActions.ActionDescription String> descriptionSupplier) {
    DefaultActionGroup group = new DefaultActionGroup();
    List<Charset> favorites = new ArrayList<>(EncodingManager.getInstance().getFavorites());
    Collections.sort(favorites);
    Charset current = myVirtualFile == null ? null : myVirtualFile.getCharset();
    favorites.remove(current);
    favorites.remove(alreadySelected);

    if (clearItemText != null) {
      String description = myVirtualFile == null
                           ? IdeBundle.message("action.clear.encoding.description")
                           : IdeBundle.message("action.clear.encoding.description.file", myVirtualFile.getName());
      group.add(new DumbAwareAction(clearItemText, description, null) {
        @Override
        public void actionPerformed(@NotNull AnActionEvent e) {
          chosen(myVirtualFile, NO_ENCODING);
        }
      });
    }
    if (favorites.isEmpty() && clearItemText == null) {
      fillCharsetActions(group, myVirtualFile, Arrays.asList(CharsetToolkit.getAvailableCharsets()), descriptionSupplier);
    }
    else {
      fillCharsetActions(group, myVirtualFile, favorites, descriptionSupplier);

      DefaultActionGroup more = DefaultActionGroup.createPopupGroup(() -> IdeBundle.message("action.text.more"));
      group.add(more);
      fillCharsetActions(more, myVirtualFile, Arrays.asList(CharsetToolkit.getAvailableCharsets()), descriptionSupplier);
    }
    return group;
  }
protected @NotNull DefaultActionGroup createCharsetsActionGroup(@Nullable @NlsActions.ActionText String clearItemText,
                                                                  @Nullable Charset alreadySelected,
                                                                  @NotNull Function<? super Charset, @NlsActions.ActionDescription String> descriptionSupplier)