示例#1
0
  private int _writeHTML(PrintWriter out, int level, ReportData rd, int ndx)
      throws ReportException {
    RequestProperties reqState = rd.getRequestProperties();
    boolean isEMail = reqState.getEncodeEMailHTML();
    PrivateLabel privLabel = rd.getPrivateLabel();
    I18N i18n = privLabel.getI18N(ReportTable.class);

    out.print("<center>\n");
    out.print("<table cellspacing='0' cellpadding='0' border='0'>\n");

    /* report title row */
    {
      String rptTitle = rd.getReportTitle();
      out.print(
          "<tr><td colSpan='3'><H1 class=\"rptTitle\">"
              + FilterText(rptTitle)
              + "</H1></td></tr>\n");
    }

    /* report subtitle row */
    {
      out.print("<tr>\n");

      // "Refresh"
      out.print("<td>");
      StringBuffer linkSB_L = new StringBuffer();
      String refreshURL = (!isEMail && (ndx <= 0)) ? EncodeURL(reqState, rd.getRefreshURL()) : null;
      if (!StringTools.isBlank(refreshURL)) {
        String refreshDesc = i18n.getString("ReportTable.refreshReport", "Refresh");
        if (linkSB_L.length() > 0) {
          linkSB_L.append("&nbsp;&nbsp;");
        } // add space between links
        linkSB_L.append(
            "<a href='" + refreshURL + "' target='_self'>" + refreshDesc + "</a>"); // target='_top'
      }
      // ...
      if (linkSB_L.length() > 0) {
        out.print(linkSB_L.toString());
      } else {
        out.print("&nbsp;");
      }
      out.print("</td>\n");

      // Report subtitle
      out.print("<td width='100%'>");
      String rptSubtt = rd.getReportSubtitle();
      if (!StringTools.isBlank(rptSubtt)) {
        out.print("<H2 class=\"rptSubtitle\">" + FilterText(rptSubtt) + "</H2>");
      } else {
        out.print("&nbsp;");
      }
      out.print("</td>\n");

      // "Graph", "Map" links
      out.print("<td>");
      StringBuffer linkSB_R = new StringBuffer();
      String graphURL =
          (!isEMail && (ndx < 0) && rd.getSupportsGraphDisplay())
              ? EncodeURL(reqState, rd.getGraphURL())
              : null;
      if (!StringTools.isBlank(graphURL)) {
        MapDimension sz = rd.getGraphWindowSize();
        String desc = rd.getGraphLinkDescription();
        if (StringTools.isBlank(desc)) {
          desc = i18n.getString("ReportTable.displayGraph", "Graph");
        }
        if (linkSB_R.length() > 0) {
          linkSB_R.append("&nbsp;&nbsp;");
        } // add space between links
        linkSB_R.append(
            "<span class='spanLink' onclick=\"javascript:openResizableWindow('"
                + graphURL
                + "','ReportGraph',"
                + sz.getWidth()
                + ","
                + sz.getHeight()
                + ");\">"
                + desc
                + "</span>");
      }
      String mapURL =
          (!isEMail && (ndx < 0) && rd.getSupportsMapDisplay())
              ? EncodeURL(reqState, rd.getMapURL())
              : null;
      if (!StringTools.isBlank(mapURL)) {
        MapDimension sz = rd.getMapWindowSize();
        String desc = rd.getMapLinkDescription();
        if (StringTools.isBlank(desc)) {
          desc = i18n.getString("ReportTable.displayMap", "Map");
        }
        if (linkSB_R.length() > 0) {
          linkSB_R.append("&nbsp;&nbsp;");
        } // add space between links
        linkSB_R.append(
            "<span class='spanLink' onclick=\"javascript:openResizableWindow('"
                + mapURL
                + "','ReportMap',"
                + sz.getWidth()
                + ","
                + sz.getHeight()
                + ");\">"
                + desc
                + "</span>");
      }
      String kmlURL =
          (!isEMail
                  && (ndx < 0)
                  && rd.getSupportsKmlDisplay()
                  && privLabel.getBooleanProperty(
                      PrivateLabel.PROP_ReportDisplay_showGoogleKML, false))
              ? EncodeURL(reqState, rd.getKmlURL())
              : null;
      if (!StringTools.isBlank(kmlURL)) {
        String desc = rd.getKmlLinkDescription();
        if (StringTools.isBlank(desc)) {
          desc = i18n.getString("ReportTable.displayKML", "KML");
        }
        if (linkSB_R.length() > 0) {
          linkSB_R.append("&nbsp;&nbsp;");
        } // add space between links
        linkSB_R.append("<a href='" + kmlURL + "' target='_blank'>" + desc + "</a>");
      }
      // ...
      if (linkSB_R.length() > 0) {
        out.print(linkSB_R.toString());
      } else {
        out.print("&nbsp;");
      }
      out.print("</td>\n");

      out.print("</tr>\n");
    }

    /* start report */
    out.print("<tr>\n");
    out.print("<td colSpan='3'>\n");
    String tableClass =
        rd.getReportFactory().isTableSortable() ? CSS_CLASS_TABLE_SORT : CSS_CLASS_TABLE;
    out.print(
        "<table class='"
            + tableClass
            + "' width='100%' cellspacing='0' cellpadding='0' border='0'>\n");
    out.print("<!-- Report Header -->\n");
    this.rptHeader.writeHTML(out, level + 1, rd);
    out.print("<!-- Report Data -->\n");
    this.rptBody.writeHTML(out, level + 1, rd);
    out.print("</table>\n");
    out.print("</td>\n");
    out.print("</tr>\n");

    /* no/partial data indication */
    if (this.rptBody.getRecordCount() <= 0) {
      out.print("<tr>\n");
      out.print("<td colSpan='3'><H2 class=\"rptNoData\">");
      String t = i18n.getString("ReportTable.noData", "This report contains no data");
      out.print(FilterText(t));
      out.print("</H2></td>\n");
      out.print("</tr>\n");
    } else if (this.rptBody.isPartial()) {
      out.print("<tr>\n");
      out.print("<td colSpan='3'><H2 class=\"rptPartial\">");
      String t =
          i18n.getString(
              "ReportTable.partialData",
              "This report has reached it's record display limit and may only contain a portion of the possible data");
      out.print(FilterText(t));
      out.print("</H2></td>\n");
      out.print("</tr>\n");
    }

    out.print("</table>\n");
    out.print("</center>\n");
    return this.rptBody.getRecordCount();
  }