View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.maven.plugins.changes.issues;
20  
21  import java.util.ResourceBundle;
22  
23  import org.apache.maven.doxia.sink.Sink;
24  import org.apache.maven.doxia.sink.SinkEventAttributes;
25  import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet;
26  import org.apache.maven.reporting.AbstractMavenReportRenderer;
27  
28  /**
29   * An abstract super class that helps when generating a report on issues.
30   *
31   * @author Dennis Lundberg
32   * @version $Id$
33   * @since 2.4
34   */
35  public abstract class AbstractIssuesReportRenderer extends AbstractMavenReportRenderer {
36  
37      protected final ResourceBundle bundle;
38  
39      protected AbstractIssuesReportRenderer(Sink sink, ResourceBundle bundle) {
40          super(sink);
41          this.bundle = bundle;
42      }
43  
44      public String getAuthor() {
45          return null;
46      }
47  
48      @Override
49      public String getTitle() {
50          return bundle.getString("report.issues.header");
51      }
52  
53      @Override
54      public void render() {
55  
56          String title = getTitle();
57          sink.head();
58          sink.title();
59          text(title);
60          sink.title_();
61  
62          String author = getAuthor();
63          if (author != null) {
64              sink.author();
65              text(author);
66              sink.author_();
67          }
68  
69          sink.head_();
70  
71          sink.body();
72          startSection(title);
73  
74          renderBody();
75  
76          endSection();
77          sink.body_();
78          sink.flush();
79          sink.close();
80      }
81  
82      protected void sinkCell(String text) {
83          sink.tableCell();
84  
85          if (text != null) {
86              text(text);
87          } else {
88              sink.nonBreakingSpace();
89          }
90  
91          sink.tableCell_();
92      }
93  
94      protected void sinkCellLink(String text, String link) {
95          sink.tableCell();
96          link(link, text);
97          sink.tableCell_();
98      }
99  
100     protected void sinkFigure(String image, String altText) {
101         SinkEventAttributes attributes = new SinkEventAttributeSet();
102         attributes.addAttribute("alt", altText);
103         attributes.addAttribute("title", altText);
104 
105         sink.figureGraphics(image, attributes);
106     }
107 
108     protected void sinkShowTypeIcon(String type) {
109         String image = "";
110         String altText = "";
111 
112         if (type == null) {
113             image = "images/icon_help_sml.gif";
114             altText = "Unknown";
115         } else if (type.equals("fix")) {
116             image = "images/fix.gif";
117             altText = "Fix";
118         } else if (type.equals("update")) {
119             image = "images/update.gif";
120             altText = "Update";
121         } else if (type.equals("add")) {
122             image = "images/add.gif";
123             altText = "Add";
124         } else if (type.equals("remove")) {
125             image = "images/remove.gif";
126             altText = "Remove";
127         }
128 
129         sink.tableCell();
130         sinkFigure(image, altText);
131         sink.tableCell_();
132     }
133 }