@Override
  protected @NotNull WidgetState getWidgetState(@Nullable VirtualFile file) {
    if (file == null || file.isDirectory()) {
      return WidgetState.HIDDEN;
    }

    Pair<Charset, String> check = EncodingUtil.getCharsetAndTheReasonTooltip(file);
    String failReason = Pair.getSecond(check);
    Charset charset = ObjectUtils.notNull(Pair.getFirst(check), file.getCharset());
    String charsetName = ObjectUtils.notNull(charset.displayName(), IdeBundle.message("encoding.not.available"));
    String toolTipText = IdeBundle.message("status.bar.text.file.encoding", charsetName) + (failReason == null ? "" : " (" + failReason + ")");
    return new WidgetState(toolTipText, charsetName, failReason == null);
  }
@Override
  protected @NotNull WidgetState getWidgetState(@Nullable VirtualFile file)