1 package org.codehaus.mojo.gwt.reports;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 import java.util.List;
24 import java.util.Locale;
25
26 import org.apache.commons.lang.StringUtils;
27 import org.apache.maven.doxia.sink.Sink;
28 import org.apache.maven.plugin.logging.Log;
29 import org.apache.maven.reporting.AbstractMavenReportRenderer;
30 import org.codehaus.mojo.gwt.GwtModule;
31 import org.codehaus.plexus.i18n.I18N;
32
33
34
35
36
37
38
39 public class CompilationReportRenderer
40 extends AbstractMavenReportRenderer
41 {
42 private final List<GwtModule> gwtModules;
43
44 private final Log log;
45
46 private boolean reportsAvailable;
47
48 private String compilerReportsPath;
49
50 private boolean compilerReport;
51
52 private final I18N i18n;
53
54 private final Locale locale;
55
56 public CompilationReportRenderer( final Sink sink, final List<GwtModule> gwtModules, Log log,
57 boolean reportsAvailable, String compilerReportsPath, boolean compilerReport,
58 I18N i18n, Locale locale )
59 {
60 super( sink );
61
62 this.gwtModules = gwtModules;
63 this.log = log;
64 this.reportsAvailable = reportsAvailable;
65 this.compilerReportsPath = compilerReportsPath;
66 this.compilerReport = compilerReport;
67 this.i18n = i18n;
68 this.locale = locale;
69 }
70
71
72
73
74 @Override
75 public String getTitle()
76 {
77
78 return "GWT Compilation Reports";
79 }
80
81
82
83
84 @Override
85 protected void renderBody()
86 {
87
88 log.debug( "start renderBody" );
89 startSection( getI18nString( locale, "compiler.report.section.title" ) );
90
91 if ( !compilerReport )
92 {
93 sink.paragraph();
94 sink.bold();
95 sink.text( getI18nString( locale, "soyc.report.warning" ) );
96 sink.bold_();
97 sink.paragraph_();
98
99 }
100 if ( !this.reportsAvailable )
101 {
102 sink.paragraph();
103 sink.bold();
104 if ( compilerReport )
105 {
106 sink.text( getI18nString( locale, "compiler.report.none.warning" ) );
107 }
108 else
109 {
110 sink.text( getI18nString( locale, "compiler.report.soyc.warning" ) );
111 }
112 sink.bold_();
113 sink.paragraph_();
114 }
115 else
116 {
117 sink.list();
118 for ( GwtModule gwtModule : this.gwtModules )
119 {
120 sink.listItem();
121 if ( StringUtils.isNotBlank( compilerReportsPath ) )
122 {
123 sink.link( "./" + compilerReportsPath + "/" + gwtModule.getPath() + "/index.html" );
124 }
125 else
126 {
127 sink.link( "./" + gwtModule.getPath() + "/index.html" );
128 }
129 sink.text( gwtModule.getName() );
130 sink.link_();
131 sink.listItem_();
132 }
133 sink.list_();
134 }
135 endSection();
136 log.debug( "end renderBody" );
137 }
138
139 protected String getI18nString( Locale locale, String key )
140 {
141 return i18n.getString( "compile-report", locale, key );
142 }
143 }