@Override
  protected Action @NotNull [] createActions() {
    DialogWrapperAction reloadAction = new DialogWrapperAction(IdeBundle.message("button.reload")) {
      @Override
      protected void doAction(ActionEvent e) {
        if (safeToReload == EncodingUtil.Magic8.NO_WAY) {
          Ref<Charset> current = Ref.create();
          EncodingUtil.FailReason failReason = EncodingUtil.checkCanReload(virtualFile, current);
          int res;
          byte[] bom = virtualFile.getBOM();
          String explanation = "<br><br>" +
                               (failReason == null ? "" : "Why: " + EncodingUtil.reasonToString(failReason, virtualFile) + "<br>") +
                               (current.isNull() ? "" : "Current encoding: '" + current.get().displayName() + "'");
          if (bom != null) {
            Messages.showErrorDialog(XmlStringUtil.wrapInHtml(
              IdeBundle.message("dialog.title.file.0.can.t.be.reloaded", virtualFile.getName(), charset.displayName(), explanation)),
                                     IdeBundle.message("incompatible.encoding.dialog.title", charset.displayName()));
            res = -1;
          }
          else {
            res = Messages.showDialog(XmlStringUtil.wrapInHtml(
              IdeBundle.message("dialog.title.file.0.most.likely.isn.t.stored", virtualFile.getName(), charset.displayName(), explanation)),
                                      IdeBundle.message("incompatible.encoding.dialog.title", charset.displayName()),
                                      new String[]{IdeBundle.message("button.reload.anyway"), CommonBundle.getCancelButtonText()}, 1,
                                      AllIcons.General.WarningDialog);
          }
          if (res != 0) {
            doCancelAction();
            return;
          }
        }
        close(RELOAD_EXIT_CODE);
      }
    };
    if (!SystemInfo.isMac && safeToReload == EncodingUtil.Magic8.NO_WAY) {
      reloadAction.putValue(Action.SMALL_ICON, AllIcons.General.Warning);
    }
    DialogWrapperAction convertAction = new DialogWrapperAction(IdeBundle.message("button.convert")) {
      @Override
      protected void doAction(ActionEvent e) {
        if (safeToConvert == EncodingUtil.Magic8.NO_WAY) {
          EncodingUtil.FailReason error = EncodingUtil.checkCanConvert(virtualFile);
          int res = Messages.showDialog(
            XmlStringUtil.wrapInHtml(
              IdeBundle.message("encoding.do.not.convert.message", charset.displayName()) + "<br><br>" +
              (error == null
               ? IdeBundle.message("encoding.unsupported.characters.message", charset.displayName())
               : EncodingUtil.reasonToString(error, virtualFile))),
            IdeBundle.message("incompatible.encoding.dialog.title", charset.displayName()),
            new String[]{IdeBundle.message("button.convert.anyway"), CommonBundle.getCancelButtonText()}, 1,
            AllIcons.General.WarningDialog);
          if (res != 0) {
            doCancelAction();
            return;
          }
        }
        close(CONVERT_EXIT_CODE);
      }

      @Override
      public boolean isEnabled() {
        return !FileUtilRt.isTooLarge(virtualFile.getLength());
      }
    };
    if (!SystemInfo.isMac && safeToConvert == EncodingUtil.Magic8.NO_WAY) {
      convertAction.putValue(Action.SMALL_ICON, AllIcons.General.Warning);
    }
    Action cancelAction = getCancelAction();
    cancelAction.putValue(DEFAULT_ACTION, Boolean.TRUE);
    return new Action[]{reloadAction, convertAction, cancelAction};
  }
@Override
  protected Action @NotNull [] createActions()