001: /*
002: * @(#)SourceHtmlReportStyle.java
003: *
004: * Copyright (C) 2003-2004 Matt Albrecht
005: * groboclown@users.sourceforge.net
006: * http://groboutils.sourceforge.net
007: *
008: * Permission is hereby granted, free of charge, to any person obtaining a
009: * copy of this software and associated documentation files (the "Software"),
010: * to deal in the Software without restriction, including without limitation
011: * the rights to use, copy, modify, merge, publish, distribute, sublicense,
012: * and/or sell copies of the Software, and to permit persons to whom the
013: * Software is furnished to do so, subject to the following conditions:
014: *
015: * The above copyright notice and this permission notice shall be included in
016: * all copies or substantial portions of the Software.
017: *
018: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
019: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
020: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
021: * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
022: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
023: * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
024: * DEALINGS IN THE SOFTWARE.
025: */
026:
027: package net.sourceforge.groboutils.codecoverage.v2.ant;
028:
029: import java.io.File;
030: import java.io.IOException;
031:
032: import org.apache.tools.ant.BuildException;
033: import org.apache.tools.ant.Project;
034: import org.w3c.dom.Document;
035:
036: /**
037: * Describes a report style, used to generate readable reports from the
038: * XML output. This is a combo report, which means that it only works
039: * with the combined coverage file.
040: *
041: * @author Matt Albrecht <a href="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
042: * @version $Date: 2004/04/15 05:48:25 $
043: * @since November 22, 2003
044: */
045: public class SourceHtmlReportStyle extends SourceXslReportStyle {
046: private File stylesheet = null;
047: private String title = null;
048: private String footerText = null;
049: private String footerLink = null;
050:
051: private boolean hasSetup = false;
052:
053: public SourceHtmlReportStyle() {
054: SourceXslReportStyle.StyleType st;
055:
056: st = new SourceXslReportStyle.StyleType();
057: st.setUrl("xsl/1x1.png");
058: st.setDest("/1x1.png");
059: addFile(st);
060:
061: st = new SourceXslReportStyle.StyleType();
062: st.setUrl("xsl/source-frame-html.xsl");
063: st.setDest(".html");
064: addSourceStyle(st);
065:
066: st = new SourceXslReportStyle.StyleType();
067: st.setUrl("xsl/source-frame-html.xsl");
068: st.setDest("/package-frame.html");
069: addPackageStyle(st);
070:
071: st = new SourceXslReportStyle.StyleType();
072: st.setUrl("xsl/overview-frame.xsl");
073: st.setDest("/package-classes.html");
074: addPackageStyle(st);
075:
076: st = new SourceXslReportStyle.StyleType();
077: st.setUrl("xsl/index.xsl");
078: st.setDest("/index.html");
079: addRootStyle(st);
080:
081: st = new SourceXslReportStyle.StyleType();
082: st.setUrl("xsl/overview-frame.xsl");
083: st.setDest("/overview-frame.html");
084: addRootStyle(st);
085:
086: st = new SourceXslReportStyle.StyleType();
087: st.setUrl("xsl/allclasses-frame.xsl");
088: st.setDest("/allclasses-frame.html");
089: addRootStyle(st);
090:
091: st = new SourceXslReportStyle.StyleType();
092: st.setUrl("xsl/source-frame-html.xsl");
093: st.setDest("/overview-summary.html");
094: addRootStyle(st);
095: }
096:
097: /** Well-defined XSL parameters */
098: public void setTitle(String title) {
099: this .title = title;
100: }
101:
102: public void setFooterText(String t) {
103: this .footerText = t;
104: }
105:
106: public void setFooterHref(String t) {
107: this .footerLink = t;
108: }
109:
110: public void setStylesheet(File f) {
111: this .stylesheet = f;
112: }
113:
114: public void generateReport(Project project, Document doc,
115: String moduleName) throws BuildException, IOException {
116: if (!this .hasSetup) {
117: SourceXslReportStyle.StyleType st = new SourceXslReportStyle.StyleType();
118: st.setDest("stylesheet.css");
119: if (this .stylesheet == null) {
120: st.setUrl("xsl/stylesheet.css");
121: } else {
122: st.setFile(this .stylesheet);
123: }
124: addFile(st);
125: st = null;
126:
127: addMyParam("title", this .title);
128: addMyParam("footerText", this .footerText);
129: addMyParam("footerLink", this .footerLink);
130:
131: this .hasSetup = true;
132: }
133:
134: super .generateReport(project, doc, moduleName);
135: }
136:
137: private void addMyParam(String name, String value) {
138: if (value != null) {
139: SimpleXslReportStyle.ParamType pt = new SimpleXslReportStyle.ParamType();
140: pt.setName(name);
141: pt.setExpression(value);
142: addParam(pt);
143: }
144: }
145: }
|