use of jgnash.convert.exports.ofx.OfxExport in project jgnash by ccavanaugh.
the class ExportTransactionsAction method exportTransactions.
public static void exportTransactions(final Account account, final LocalDate startDate, final LocalDate endDate) {
final ResourceBundle rb = ResourceUtils.getBundle();
final Preferences pref = Preferences.userNodeForPackage(ExportTransactionsAction.class);
JFileChooser chooser = new JFileChooser(pref.get(CURRENT_DIR, null));
FileNameExtensionFilter csvFilter = new FileNameExtensionFilter(rb.getString("Label.CsvFiles") + " (*.csv)", "csv");
FileNameExtensionFilter ofxFilter = new FileNameExtensionFilter(rb.getString("Label.OfxFiles") + " (*.ofx)", OFX);
FileNameExtensionFilter ssFilter = new FileNameExtensionFilter(rb.getString("Label.SpreadsheetFiles") + " (*.xls, *.xlsx)", "xls", "xlsx");
chooser.addChoosableFileFilter(csvFilter);
chooser.addChoosableFileFilter(ofxFilter);
chooser.addChoosableFileFilter(ssFilter);
chooser.setAcceptAllFileFilterUsed(false);
chooser.setMultiSelectionEnabled(false);
chooser.setFileFilter(csvFilter);
if (chooser.showSaveDialog(UIApplication.getFrame()) == JFileChooser.APPROVE_OPTION) {
pref.put(CURRENT_DIR, chooser.getCurrentDirectory().getAbsolutePath());
final File file = chooser.getSelectedFile();
final class Export extends SwingWorker<Void, Void> {
@Override
protected Void doInBackground() throws Exception {
UIApplication.getFrame().displayWaitMessage(rb.getString("Message.PleaseWait"));
if (OFX.equals(FileUtils.getFileExtension(file.getName()))) {
OfxExport export = new OfxExport(account, startDate, endDate, file);
export.exportAccount();
} else if (FileUtils.getFileExtension(file.getName()).contains(XLS)) {
AccountExport.exportAccount(account, RegisterFactory.getColumnNames(account), startDate, endDate, file);
} else {
CsvExport.exportAccount(account, startDate, endDate, file);
}
return null;
}
@Override
protected void done() {
UIApplication.getFrame().stopWaitMessage();
}
}
new Export().execute();
}
}
Aggregations