/**
   * Saves locations into a file.
   *
   * @param mainWindow Main window.
   */
  public SaveChartAction(final DaylightChartGui mainWindow) {

    super(
        Messages.getString("DaylightChartGui.Menu.File.SaveChart"), // $NON-NLS-1$
        "/icons/save.gif" //$NON-NLS-1$
        );
    setShortcutKey(KeyStroke.getKeyStroke("control S"));
    addActionListener(new GuiActionListener(mainWindow));
  }
 /**
  * {@inheritDoc}
  *
  * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
  */
 @Override
 public void actionPerformed(final ActionEvent actionevent) {
   final DaylightChartReport daylightChartReport =
       new DaylightChartReport(
           mainWindow.getSelectedLocation(), UserPreferences.optionsFile().getData());
   final List<ExtensionFileFilter<ChartFileType>> fileFilters =
       new ArrayList<ExtensionFileFilter<ChartFileType>>();
   for (final ChartFileType chartFileType : ChartFileType.values()) {
     fileFilters.add(new ExtensionFileFilter<ChartFileType>(chartFileType));
   }
   final String reportFilename = daylightChartReport.getReportFileName(ChartFileType.png);
   final Path chartFile =
       Paths.get(
           UserPreferences.optionsFile().getData().getWorkingDirectory().toString(),
           reportFilename);
   final SelectedFile<ChartFileType> selectedFile =
       Actions.showSaveDialog(
           mainWindow,
           Messages.getString("DaylightChartGui.Menu.File.SaveChart"),
           fileFilters,
           chartFile.toFile(),
           Messages.getString("DaylightChartGui.Message.Confirm.FileOverwrite")); // $NON-NLS-1$
   if (selectedFile.isSelected()) {
     try {
       daylightChartReport.write(selectedFile.getFile(), selectedFile.getFileType());
     } catch (final Exception e) {
       LOGGER.log(
           Level.WARNING,
           Messages.getString("DaylightChartGui.Message.Error.CannotSaveFile"), // $NON-NLS-1$
           e);
       JOptionPane.showMessageDialog(
           mainWindow,
           Messages.getString("DaylightChartGui.Message.Error.CannotSaveFile") // $NON-NLS-1$
               + "\n" //$NON-NLS-1$
               + selectedFile,
           Messages.getString("DaylightChartGui.Message.Error.CannotSaveFile"), // $NON-NLS-1$
           JOptionPane.ERROR_MESSAGE);
     }
   }
 }