1   package com.stateofflow.eclipse.metrics.export.html;
2   
3   import java.io.IOException;
4   
5   import com.stateofflow.eclipse.metrics.collator.MetricsCollatorSet;
6   import com.stateofflow.eclipse.metrics.util.ProgressMonitor;
7   
8   final class ImageAndDashboardWriter implements ProgressMonitor.Runnable {
9       private final HtmlExportFactory factory;
10      private final MetricsCollatorSet collatorSet;
11  
12      public ImageAndDashboardWriter(final HtmlExportFactory factory, final MetricsCollatorSet collatorSet) {
13          this.factory = factory;
14          this.collatorSet = collatorSet;
15      }
16  
17      public void run(final ProgressMonitor progressMonitor) throws IOException {
18          progressMonitor.beginTask("Writing images and dashboard", 2);
19          createImages(progressMonitor.newChild(1));
20          createDashboard(progressMonitor.newChild(1));
21      }
22  
23      private void createDashboard(final ProgressMonitor progressMonitor) throws IOException {
24          progressMonitor.beginTask("Creating dashboard", 1);
25          factory.createDashboardWriter().write(collatorSet);
26      }
27  
28      private void createImages(final ProgressMonitor progressMonitor) throws IOException {
29          factory.createHistogramWriter().write(collatorSet, progressMonitor);
30      }
31  }
32