/** Presents commit message as tooltips. */
  @Override
  public String getToolTipText(MouseEvent e) {
    if (editorUI == null) return null;
    int line = getLineFromMouseEvent(e);

    StringBuilder annotation = new StringBuilder();
    if (!elementAnnotations.isEmpty()) {
      AnnotateLine al = getAnnotateLine(line);

      if (al != null) {
        String escapedAuthor = NbBundle.getMessage(AnnotationBar.class, "TT_Annotation"); // NOI18N
        try {
          escapedAuthor = XMLUtil.toElementContent(al.getAuthor());
        } catch (CharConversionException e1) {
          Mercurial.LOG.log(Level.INFO, "HG.AB: can not HTML escape: ", al.getAuthor()); // NOI18N
        }

        // always return unique string to avoid tooltip sharing on mouse move over same revisions
        // -->
        annotation
            .append("<html><!-- line=")
            .append(line++)
            .append(" -->")
            .append(al.getRevision())
            .append(":")
            .append(al.getId())
            .append(" - <b>")
            .append(escapedAuthor)
            .append("</b>"); // NOI18N
        if (al.getDate() != null) {
          annotation
              .append(" ")
              .append(
                  DateFormat.getDateInstance().format(al.getDate())); // NOI18N
        }
        if (al.getCommitMessage() != null) {
          String escaped = null;
          try {
            escaped = XMLUtil.toElementContent(al.getCommitMessage());
          } catch (CharConversionException e1) {
            Mercurial.LOG.log(
                Level.INFO, "HG.AB: can not HTML escape: ", al.getCommitMessage()); // NOI18N
          }
          if (escaped != null) {
            String lined =
                escaped.replaceAll(System.getProperty("line.separator"), "<br>"); // NOI18N
            annotation.append("<p>").append(lined); // NOI18N
          }
        }
      }
    } else {
      annotation.append(elementAnnotationsSubstitute);
    }

    return annotation.toString();
  }