Search in sources :

Example 6 with FileSaveSession

use of org.jabref.logic.exporter.FileSaveSession in project jabref by JabRef.

the class BackupManager method performBackup.

private void performBackup(Path backupPath) {
    try {
        Charset charset = bibDatabaseContext.getMetaData().getEncoding().orElse(preferences.getDefaultEncoding());
        SavePreferences savePreferences = SavePreferences.loadForSaveFromPreferences(preferences).withEncoding(charset).withMakeBackup(false);
        new BibtexDatabaseWriter<>(FileSaveSession::new).saveDatabase(bibDatabaseContext, savePreferences).commit(backupPath);
    } catch (SaveException e) {
        LOGGER.error("Error while saving file.", e);
    }
}
Also used : SaveException(org.jabref.logic.exporter.SaveException) BibtexDatabaseWriter(org.jabref.logic.exporter.BibtexDatabaseWriter) FileSaveSession(org.jabref.logic.exporter.FileSaveSession) SavePreferences(org.jabref.logic.exporter.SavePreferences) Charset(java.nio.charset.Charset)

Aggregations

BibtexDatabaseWriter (org.jabref.logic.exporter.BibtexDatabaseWriter)6 FileSaveSession (org.jabref.logic.exporter.FileSaveSession)6 SaveException (org.jabref.logic.exporter.SaveException)6 SavePreferences (org.jabref.logic.exporter.SavePreferences)6 SaveSession (org.jabref.logic.exporter.SaveSession)5 Charset (java.nio.charset.Charset)3 Defaults (org.jabref.model.Defaults)3 BibDatabaseContext (org.jabref.model.database.BibDatabaseContext)3 FormBuilder (com.jgoodies.forms.builder.FormBuilder)2 FormLayout (com.jgoodies.forms.layout.FormLayout)2 UnsupportedCharsetException (java.nio.charset.UnsupportedCharsetException)2 JTextArea (javax.swing.JTextArea)2 ParserResult (org.jabref.logic.importer.ParserResult)2 File (java.io.File)1 IOException (java.io.IOException)1 BackingStoreException (java.util.prefs.BackingStoreException)1 JabRefException (org.jabref.JabRefException)1 IExportFormat (org.jabref.logic.exporter.IExportFormat)1 ImportException (org.jabref.logic.importer.ImportException)1 BibDatabase (org.jabref.model.database.BibDatabase)1