001    /**
002     * www.jcoverage.com
003     * Copyright (C)2003 jcoverage ltd.
004     *
005     * This file is part of jcoverage.
006     *
007     * jcoverage is free software; you can redistribute it and/or modify
008     * it under the terms of the GNU General Public License as published
009     * by the Free Software Foundation; either version 2 of the License,
010     * or (at your option) any later version.
011     *
012     * jcoverage is distributed in the hope that it will be useful, but
013     * WITHOUT ANY WARRANTY; without even the implied warranty of
014     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015     * General Public License for more details.
016     *
017     * You should have received a copy of the GNU General Public License
018     * along with jcoverage; if not, write to the Free Software
019     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
020     * USA
021     *
022     */
023    package com.jcoverage.coverage.reporting.html;
024    
025    import java.io.*;
026    import java.util.*;
027    
028    import org.apache.log4j.Logger;
029    
030    import com.jcoverage.coverage.reporting.collation.JavaFileLine;
031    import com.jcoverage.coverage.reporting.collation.PackageSummaryPage;
032    import com.jcoverage.coverage.reporting.collation.ReportSummaryPackageLine;
033    import com.jcoverage.coverage.reporting.collation.ReportSummaryPage;
034    import com.jcoverage.reporting.Column;
035    import com.jcoverage.reporting.FormattingContext;
036    import com.jcoverage.reporting.Line;
037    import com.jcoverage.reporting.MultiViewCollator;
038    import com.jcoverage.reporting.Page;
039    import com.jcoverage.reporting.ReportingException;
040    import com.jcoverage.reporting.View;
041    import com.jcoverage.reporting.ViewFormattingContext;
042    import com.jcoverage.reporting.html.ColumnRenderer;
043    import com.jcoverage.reporting.html.CssColumnRenderer;
044    import com.jcoverage.reporting.html.H1;
045    import com.jcoverage.reporting.html.H2;
046    import com.jcoverage.reporting.html.Html;
047    import com.jcoverage.reporting.html.RedGreenIndicator;
048    import com.jcoverage.reporting.html.ReportTable;
049    
050    /**
051     *
052     */
053    public class ReportSummaryFormat extends CommonFormat {
054      
055      static Logger logger=Logger.getLogger(ReportSummaryFormat.class);
056      
057      public void formatPage(FormattingContext ctx,Page page) throws ReportingException {
058        throw new IllegalStateException(getClass().getName()+" formatPage method must be given a ViewFormattingContext because views are involved");
059      }
060    
061      public void formatPage(ViewFormattingContext ctx,Page page) throws ReportingException {
062    
063        // Must cope with different orderings
064    
065        Html html=new Html();
066        html.setTitle("jcoverage report");
067        buildHeader(html);
068    
069        NavigationBar navbar=new NavigationBar(ctx,page);
070        html.add(navbar);
071    
072        html.add(new H1("Coverage Report"));
073    
074        Set lines=new HashSet();
075        lines.add(page.getMasterLine());
076        html.add(new OverallSummaryTable(page,lines,ctx));
077    
078        addViews(ctx,page,html);
079    
080        html.add(new H2("Packages"));
081    
082        lines=page.getLines(ReportSummaryPage.CATEGORY_PACKAGE_SUMMARY);
083        if (ctx.getCurrentView()!=null) {
084          lines=ctx.getCurrentView().orderLines(lines,ReportSummaryPage.CATEGORY_PACKAGE_SUMMARY);
085        }
086        html.add(new PackagesTable(page,lines,ctx));
087    
088        html.add(new H2("All Java™ files"));
089    
090        lines=page.getLines(PackageSummaryPage.CATEGORY_JAVAFILES);
091        if (ctx.getCurrentView()!=null) {
092          lines=ctx.getCurrentView().orderLines(lines,PackageSummaryPage.CATEGORY_JAVAFILES);
093        }
094        html.add(new JavaFilesTable(page,lines,ctx));
095    
096        html.add("<p>");
097        html.add(navbar);
098        buildFooter(html);
099        html.writeTo(getWriter(ctx,page));
100      }
101    
102    }