1 | |
package org.apache.maven.plugin.issues; |
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.sink.Sink; |
23 | |
import org.apache.maven.doxia.sink.SinkEventAttributeSet; |
24 | |
import org.apache.maven.doxia.sink.SinkEventAttributes; |
25 | |
import org.apache.maven.doxia.util.HtmlTools; |
26 | |
import org.codehaus.plexus.util.StringUtils; |
27 | |
|
28 | |
import java.util.ResourceBundle; |
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
public abstract class AbstractIssuesReportGenerator |
38 | |
{ |
39 | |
protected String author; |
40 | |
|
41 | |
protected String title; |
42 | |
|
43 | |
public AbstractIssuesReportGenerator() |
44 | 2 | { |
45 | 2 | } |
46 | |
|
47 | |
public String getAuthor() |
48 | |
{ |
49 | 0 | return author; |
50 | |
} |
51 | |
|
52 | |
public void setAuthor( String author ) |
53 | |
{ |
54 | 0 | this.author = author; |
55 | 0 | } |
56 | |
|
57 | |
public String getTitle() |
58 | |
{ |
59 | 0 | return title; |
60 | |
} |
61 | |
|
62 | |
public void setTitle( String title ) |
63 | |
{ |
64 | 0 | this.title = title; |
65 | 0 | } |
66 | |
|
67 | |
protected void sinkBeginReport( Sink sink, ResourceBundle bundle ) |
68 | |
{ |
69 | 2 | sink.head(); |
70 | |
|
71 | 2 | String title = null; |
72 | 2 | if ( this.title != null ) |
73 | |
{ |
74 | 0 | title = this.title; |
75 | |
} |
76 | |
else |
77 | |
{ |
78 | 2 | title = bundle.getString( "report.issues.header" ); |
79 | |
} |
80 | 2 | sink.title(); |
81 | 2 | sink.text( title ); |
82 | 2 | sink.title_(); |
83 | |
|
84 | 2 | if ( StringUtils.isNotEmpty( author ) ) |
85 | |
{ |
86 | 0 | sink.author(); |
87 | 0 | sink.text( author ); |
88 | 0 | sink.author_(); |
89 | |
} |
90 | |
|
91 | 2 | sink.head_(); |
92 | |
|
93 | 2 | sink.body(); |
94 | |
|
95 | 2 | sink.section1(); |
96 | |
|
97 | 2 | sinkSectionTitle1Anchor( sink, title, title ); |
98 | 2 | } |
99 | |
|
100 | |
protected void sinkCell( Sink sink, String text ) |
101 | |
{ |
102 | 16 | sink.tableCell(); |
103 | |
|
104 | 16 | if ( text != null ) |
105 | |
{ |
106 | 16 | sink.text( text ); |
107 | |
} |
108 | |
else |
109 | |
{ |
110 | 0 | sink.nonBreakingSpace(); |
111 | |
} |
112 | |
|
113 | 16 | sink.tableCell_(); |
114 | 16 | } |
115 | |
|
116 | |
protected void sinkCellLink( Sink sink, String text, String link ) |
117 | |
{ |
118 | 0 | sink.tableCell(); |
119 | |
|
120 | 0 | sinkLink( sink, text, link ); |
121 | |
|
122 | 0 | sink.tableCell_(); |
123 | 0 | } |
124 | |
|
125 | |
protected void sinkEndReport( Sink sink ) |
126 | |
{ |
127 | 2 | sink.section1_(); |
128 | |
|
129 | 2 | sink.body_(); |
130 | |
|
131 | 2 | sink.flush(); |
132 | |
|
133 | 2 | sink.close(); |
134 | 2 | } |
135 | |
|
136 | |
protected void sinkFigure( Sink sink, String image, String altText ) |
137 | |
{ |
138 | 0 | SinkEventAttributes attributes = new SinkEventAttributeSet(); |
139 | 0 | attributes.addAttribute( "alt", altText ); |
140 | 0 | attributes.addAttribute( "title", altText ); |
141 | |
|
142 | 0 | sink.figureGraphics( image, attributes ); |
143 | 0 | } |
144 | |
|
145 | |
protected void sinkHeader( Sink sink, String header ) |
146 | |
{ |
147 | 10 | sink.tableHeaderCell(); |
148 | |
|
149 | 10 | sink.text( header ); |
150 | |
|
151 | 10 | sink.tableHeaderCell_(); |
152 | 10 | } |
153 | |
|
154 | |
protected void sinkLink( Sink sink, String text, String link ) |
155 | |
{ |
156 | 0 | sink.link( link ); |
157 | |
|
158 | 0 | sink.text( text ); |
159 | |
|
160 | 0 | sink.link_(); |
161 | 0 | } |
162 | |
|
163 | |
protected void sinkSectionTitle1Anchor( Sink sink, String text, String anchor ) |
164 | |
{ |
165 | 2 | sink.sectionTitle1(); |
166 | |
|
167 | 2 | sink.text( text ); |
168 | |
|
169 | 2 | sink.sectionTitle1_(); |
170 | |
|
171 | 2 | sink.anchor( HtmlTools.encodeId( anchor ) ); |
172 | 2 | sink.anchor_(); |
173 | 2 | } |
174 | |
|
175 | |
protected void sinkSectionTitle2Anchor( Sink sink, String text, String anchor ) |
176 | |
{ |
177 | 0 | sink.sectionTitle2(); |
178 | 0 | sink.text( text ); |
179 | 0 | sink.sectionTitle2_(); |
180 | |
|
181 | 0 | sink.anchor( HtmlTools.encodeId( anchor ) ); |
182 | 0 | sink.anchor_(); |
183 | 0 | } |
184 | |
|
185 | |
protected void sinkShowTypeIcon( Sink sink, String type ) |
186 | |
{ |
187 | 0 | String image = ""; |
188 | 0 | String altText = ""; |
189 | |
|
190 | 0 | if ( type == null ) |
191 | |
{ |
192 | 0 | image = "images/icon_help_sml.gif"; |
193 | 0 | altText = "?"; |
194 | |
} |
195 | 0 | else if ( type.equals( "fix" ) ) |
196 | |
{ |
197 | 0 | image = "images/fix.gif"; |
198 | 0 | altText = "fix"; |
199 | |
} |
200 | 0 | else if ( type.equals( "update" ) ) |
201 | |
{ |
202 | 0 | image = "images/update.gif"; |
203 | 0 | altText = "update"; |
204 | |
} |
205 | 0 | else if ( type.equals( "add" ) ) |
206 | |
{ |
207 | 0 | image = "images/add.gif"; |
208 | 0 | altText = "add"; |
209 | |
} |
210 | 0 | else if ( type.equals( "remove" ) ) |
211 | |
{ |
212 | 0 | image = "images/remove.gif"; |
213 | 0 | altText = "remove"; |
214 | |
} |
215 | |
|
216 | 0 | sink.tableCell(); |
217 | |
|
218 | 0 | sinkFigure( sink, image, altText ); |
219 | |
|
220 | 0 | sink.tableCell_(); |
221 | 0 | } |
222 | |
} |