1   package com.stateofflow.eclipse.metrics.export.html;
2   
3   import com.stateofflow.eclipse.metrics.configuration.MetricPresentations;
4   import com.stateofflow.eclipse.metrics.metric.MetricId;
5   
6   final class PageHeaderWriter {
7       private HtmlPageBuilder pageBuilder;
8       private MetricId[] metricIds;
9       private final MetricPresentations presentations;
10  
11      public PageHeaderWriter(final MetricPresentations presentations) {
12          this.presentations = presentations;
13      }
14  
15      public void write(final HtmlPageBuilder pageBuilder, final MetricId[] metricIds, final String imageFileName) {
16          this.pageBuilder = pageBuilder;
17          this.metricIds = metricIds;
18          pageBuilder.openElement("TABLE").openElement("TR").openElementAndNewline("TD");
19          pageBuilder.createImageFileLink(imageFileName);
20          pageBuilder.closeElement("TD").openElementAndNewline("TD");
21          writeAcronymList();
22          pageBuilder.closeElement("TD").closeElement("TR").closeElementAndNewline("TABLE");
23      }
24  
25      private void writeAcronymList() {
26          openMetricsAcronymListTable();
27          writeMetricsAcronymListTableRows();
28          closeMetricsAcronymListTable();
29      }
30  
31      private void writeMetricsAcronymListTableRows() {
32          for (int i = 0; i < metricIds.length; i++) {
33              pageBuilder.openElement("TR").createElement("TD", presentations.getShortPresentationName(metricIds[i])).createElement("TD", pageBuilder.getLink(presentations.getDescriptionUrl(metricIds[i]), presentations.getPresentationName(metricIds[i]))).closeElementAndNewline("TR");
34          }
35      }
36  
37      private void closeMetricsAcronymListTable() {
38          pageBuilder.closeElementAndNewline("TABLE").openElementAndNewline("P");
39      }
40  
41      private void openMetricsAcronymListTable() {
42          pageBuilder.openElementAndNewline("TABLE border=\"1\" cellpadding=\"2\"").openElement("TR").createElement("TH", "Short Name").createElement("TH", "Full Name").closeElementAndNewline("TR");
43      }
44  }
45