1 | |
package org.apache.maven.plugins.site; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
import org.apache.maven.doxia.module.xhtml.decoration.render.RenderingContext; |
23 | |
import org.apache.maven.doxia.siterenderer.DocumentRenderer; |
24 | |
import org.apache.maven.doxia.siterenderer.Renderer; |
25 | |
import org.apache.maven.doxia.siterenderer.RendererException; |
26 | |
import org.apache.maven.doxia.siterenderer.SiteRenderingContext; |
27 | |
import org.apache.maven.doxia.siterenderer.sink.SiteRendererSink; |
28 | |
import org.apache.maven.reporting.MavenReport; |
29 | |
import org.codehaus.plexus.i18n.I18N; |
30 | |
|
31 | |
import java.io.FileNotFoundException; |
32 | |
import java.io.Writer; |
33 | |
import java.util.Collections; |
34 | |
import java.util.Iterator; |
35 | |
import java.util.List; |
36 | |
import java.util.Locale; |
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | |
public class CategorySummaryDocumentRenderer |
44 | |
implements DocumentRenderer |
45 | |
{ |
46 | |
private RenderingContext renderingContext; |
47 | |
|
48 | |
private String title; |
49 | |
|
50 | |
private String desc1; |
51 | |
|
52 | |
private String desc2; |
53 | |
|
54 | |
private I18N i18n; |
55 | |
|
56 | |
private List categoryReports; |
57 | |
|
58 | |
public CategorySummaryDocumentRenderer( RenderingContext renderingContext, String title, String desc1, String desc2, |
59 | |
I18N i18n, List categoryReports ) |
60 | 0 | { |
61 | 0 | this.renderingContext = renderingContext; |
62 | 0 | this.title = title; |
63 | 0 | this.desc1 = desc1; |
64 | 0 | this.desc2 = desc2; |
65 | 0 | this.i18n = i18n; |
66 | 0 | this.categoryReports = Collections.unmodifiableList( categoryReports ); |
67 | 0 | } |
68 | |
|
69 | |
public void renderDocument( Writer writer, Renderer renderer, SiteRenderingContext siteRenderingContext ) |
70 | |
throws RendererException, FileNotFoundException |
71 | |
{ |
72 | 0 | SiteRendererSink sink = new SiteRendererSink( renderingContext ); |
73 | |
|
74 | 0 | sink.head(); |
75 | |
|
76 | 0 | sink.title(); |
77 | |
|
78 | 0 | sink.text( title ); |
79 | |
|
80 | 0 | sink.title_(); |
81 | |
|
82 | 0 | sink.head_(); |
83 | |
|
84 | 0 | sink.body(); |
85 | |
|
86 | 0 | sink.section1(); |
87 | 0 | sink.sectionTitle1(); |
88 | 0 | sink.text( title ); |
89 | 0 | sink.sectionTitle1_(); |
90 | |
|
91 | 0 | sink.paragraph(); |
92 | 0 | sink.text( desc1 + " " ); |
93 | 0 | sink.link( "http://maven.apache.org" ); |
94 | 0 | sink.text( "Maven" ); |
95 | 0 | sink.link_(); |
96 | 0 | sink.text( " " + desc2 ); |
97 | 0 | sink.paragraph_(); |
98 | |
|
99 | 0 | sink.section2(); |
100 | 0 | sink.sectionTitle2(); |
101 | 0 | Locale locale = siteRenderingContext.getLocale(); |
102 | 0 | sink.text( i18n.getString( "site-plugin", locale, "report.category.sectionTitle" ) ); |
103 | 0 | sink.sectionTitle2_(); |
104 | |
|
105 | 0 | sink.table(); |
106 | |
|
107 | 0 | String name = i18n.getString( "site-plugin", locale, "report.category.column.document" ); |
108 | 0 | String description = i18n.getString( "site-plugin", locale, "report.category.column.description" ); |
109 | |
|
110 | 0 | sink.tableRow(); |
111 | |
|
112 | 0 | sink.tableHeaderCell(); |
113 | |
|
114 | 0 | sink.text( name ); |
115 | |
|
116 | 0 | sink.tableHeaderCell_(); |
117 | |
|
118 | 0 | sink.tableHeaderCell(); |
119 | |
|
120 | 0 | sink.text( description ); |
121 | |
|
122 | 0 | sink.tableHeaderCell_(); |
123 | |
|
124 | 0 | sink.tableRow_(); |
125 | |
|
126 | 0 | if ( categoryReports != null ) |
127 | |
{ |
128 | 0 | for ( Iterator i1 = categoryReports.iterator(); i1.hasNext(); ) |
129 | |
{ |
130 | 0 | MavenReport report = (MavenReport) i1.next(); |
131 | |
|
132 | 0 | sink.tableRow(); |
133 | 0 | sink.tableCell(); |
134 | 0 | sink.link( report.getOutputName() + ".html" ); |
135 | 0 | sink.text( report.getName( locale ) ); |
136 | 0 | sink.link_(); |
137 | 0 | sink.tableCell_(); |
138 | 0 | sink.tableCell(); |
139 | 0 | sink.text( report.getDescription( locale ) ); |
140 | 0 | sink.tableCell_(); |
141 | 0 | sink.tableRow_(); |
142 | |
} |
143 | |
} |
144 | |
|
145 | 0 | sink.table_(); |
146 | |
|
147 | 0 | sink.section2_(); |
148 | |
|
149 | 0 | sink.section1_(); |
150 | |
|
151 | 0 | sink.body_(); |
152 | |
|
153 | 0 | sink.flush(); |
154 | |
|
155 | 0 | sink.close(); |
156 | |
|
157 | 0 | renderer.generateDocument( writer, sink, siteRenderingContext ); |
158 | 0 | } |
159 | |
|
160 | |
public String getOutputName() |
161 | |
{ |
162 | 0 | return renderingContext.getOutputName(); |
163 | |
} |
164 | |
|
165 | |
public RenderingContext getRenderingContext() |
166 | |
{ |
167 | 0 | return renderingContext; |
168 | |
} |
169 | |
|
170 | |
public boolean isOverwrite() |
171 | |
{ |
172 | 0 | return true; |
173 | |
} |
174 | |
} |