\n
").append(reportDirectory.getName()).append("
\n"); // NON-NLS
- wrapper.append("
.append(reportDirectory.getName()).append(REPORT_IMAGE_EXTENSION)
"); // NON-NLS
- wrapper.append("
\n"); // NON-NLS
- for (Pair pair : reportMetaData) {
- wrapper.append("").append(pair.getKey()).append(": | ").append(pair.getValue()).append(" |
\n"); // NON-NLS
- }
- wrapper.append("
\n"); // NON-NLS
- wrapper.append("
\n\n"); // NON-NLS
- File reportHTMLFIle = new File(reportDirectory, reportName + HTML_EXT);
+ //take snapshot and save in report directory
+ ImageIO.write(SwingFXUtils.fromFXImage(node.snapshot(null, null), null), "png", // NON-NLS
+ reportPath.resolve(reportName + REPORT_IMAGE_EXTENSION).toFile()); // NON-NLS
- //write html wrapper
- try (Writer htmlWriter = new FileWriter(reportHTMLFIle)) {
- htmlWriter.write(wrapper.toString());
- } catch (FileNotFoundException ex) {
- LOGGER.log(Level.WARNING, "failed to open html wrapper file for writing ", ex); // NON-NLS
- return;
- } catch (IOException ex) {
- LOGGER.log(Level.WARNING, "failed to write html wrapper file", ex); // NON-NLS
- return;
- }
+ //copy report css
+ try (InputStream resource = this.getClass().getResourceAsStream("/org/sleuthkit/autopsy/timeline/index.css")) { // NON-NLS
+ Files.copy(resource, reportPath.resolve("index.css")); // NON-NLS
+ }
- //copy css
- try (InputStream resource = this.getClass().getResourceAsStream("/org/sleuthkit/autopsy/timeline/index.css")) { // NON-NLS
- Files.copy(resource, Paths.get(reportPath, "index.css")); // NON-NLS
- } catch (IOException ex) {
- LOGGER.log(Level.WARNING, "failed to copy css file", ex); // NON-NLS
- }
+ //add html file as report to case
+ try {
+ Case.getCurrentCase().addReport(reportHTMLFIle.getPath(), Bundle.Timeline_ModuleName(), reportName + HTML_EXT); // NON-NLS
+ } catch (TskCoreException ex) {
+ LOGGER.log(Level.WARNING, "failed to add html wrapper as a report", ex); // NON-NLS
+ new Alert(Alert.AlertType.ERROR, Bundle.SaveSnapShotAsReport_FailedToAddReport()).showAndWait();
+ }
- //add html file as report to case
- try {
- Case.getCurrentCase().addReport(reportHTMLFIle.getPath(), "Timeline", reportName + HTML_EXT); // NON-NLS
- } catch (TskCoreException ex) {
- LOGGER.log(Level.WARNING, "failed add html wrapper as a report", ex); // NON-NLS
+ //create alert to notify user of report location
+ final Alert alert = new Alert(Alert.AlertType.INFORMATION, null, open, ok);
+ alert.setTitle(Bundle.SaveSnapshot_action_name_text());
+ alert.setHeaderText(Bundle.SaveSnapShotAsReport_Success());
+ alert.initStyle(StageStyle.UTILITY);
+ alert.initOwner(node.getScene().getWindow());
+ alert.initModality(Modality.APPLICATION_MODAL);
+
+ //make action to open report, and hyperlinklable to invoke action
+ final OpenReportAction openReportAction = new OpenReportAction(reportHTMLFIle);
+ HyperlinkLabel hyperlinkLabel = new HyperlinkLabel(Bundle.SaveSnapShotAsReport_ReportSavedAt(reportHTMLFIle.getPath()));
+ hyperlinkLabel.setOnAction(openReportAction);
+ alert.getDialogPane().setContent(hyperlinkLabel);
+
+ alert.showAndWait().ifPresent(buttonType -> {
+ if (buttonType == open) {
+ openReportAction.handle(null);
+ }
+ });
+
+ } catch (IOException e) {
+ LOGGER.log(Level.SEVERE, "Error writing report " + reportPath + " to disk", e); // NON-NLS
+ new Alert(Alert.AlertType.ERROR, Bundle.SaveSnapShotAsReport_ErrorWritingReport(reportPath)).showAndWait();
}
}
});
}
+
+ private static void writeHTMLFile(String reportName, final Writer htmlWriter, ZoomParams zoomParams) throws IOException {
+
+ //write html wrapper file
+ htmlWriter.write("\n\n\t\n
" + reportName + "
\n"); // NON-NLS
+ //embed snapshot
+ htmlWriter.write("

"); // NON-NLS
+ //write view paramaters
+ htmlWriter.write("
\n"); // NON-NLS
+ writeTableRow(htmlWriter, "Case", Case.getCurrentCase().getName()); // NON-NLS
+ writeTableRow(htmlWriter, "Time Range", zoomParams.getTimeRange().toString()); // NON-NLS
+ writeTableRow(htmlWriter, "Description Level of Detail", zoomParams.getDescriptionLOD().getDisplayName()); // NON-NLS
+ writeTableRow(htmlWriter, "Event Type Zoom Level", zoomParams.getTypeZoomLevel().getDisplayName()); // NON-NLS
+ writeTableRow(htmlWriter, "Filters", zoomParams.getFilter().getHTMLReportString()); // NON-NLS
+ //end table and html
+ htmlWriter.write("
\n"); // NON-NLS
+ htmlWriter.write("
\n\n"); // NON-NLS
+ }
+
+ /**
+ *
+ * @param htmlWriter the value of htmlWriter
+ * @param key the value of Key
+ * @param value the value of value
+ *
+ * @throws IOException
+ */
+ private static void writeTableRow(final Writer htmlWriter, final String key, final String value) throws IOException {
+ htmlWriter.write("