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