2121import org .jabref .logic .bibtexkeypattern .BibtexKeyGenerator ;
2222import org .jabref .logic .exporter .BibDatabaseWriter ;
2323import org .jabref .logic .exporter .BibtexDatabaseWriter ;
24- import org .jabref .logic .exporter .ExportFormat ;
25- import org .jabref .logic .exporter .ExportFormats ;
24+ import org .jabref .logic .exporter .Exporter ;
25+ import org .jabref .logic .exporter .ExporterFactory ;
2626import org .jabref .logic .exporter .FileSaveSession ;
27- import org .jabref .logic .exporter .IExportFormat ;
2827import org .jabref .logic .exporter .SaveException ;
2928import org .jabref .logic .exporter .SavePreferences ;
3029import org .jabref .logic .exporter .SaveSession ;
30+ import org .jabref .logic .exporter .TemplateExporter ;
3131import org .jabref .logic .importer .ImportException ;
3232import org .jabref .logic .importer .ImportFormatReader ;
3333import org .jabref .logic .importer .OpenDatabase ;
@@ -249,7 +249,7 @@ private boolean exportMatches(List<ParserResult> loaded) {
249249 formatName = data [2 ];
250250 break ;
251251 case 2 :
252- //default ExportFormat : HTML table (with Abstract & BibTeX)
252+ //default exporter : HTML table (with Abstract & BibTeX)
253253 formatName = "tablerefsabsbib" ;
254254 break ;
255255 default :
@@ -260,14 +260,14 @@ private boolean exportMatches(List<ParserResult> loaded) {
260260 }
261261
262262 //export new database
263- IExportFormat format = ExportFormats . getExportFormat (formatName );
264- if (format == null ) {
263+ Optional < Exporter > exporter = Globals . exportFactory . getExporterByName (formatName );
264+ if (! exporter . isPresent () ) {
265265 System .err .println (Localization .lang ("Unknown export format" ) + ": " + formatName );
266266 } else {
267- // We have an ExportFormat instance:
267+ // We have an TemplateExporter instance:
268268 try {
269269 System .out .println (Localization .lang ("Exporting" ) + ": " + data [1 ]);
270- format . performExport ( databaseContext , data [1 ],
270+ exporter . get (). export ( databaseContext , Paths . get ( data [1 ]) ,
271271 databaseContext .getMetaData ().getEncoding ().orElse (Globals .prefs .getDefaultEncoding ()),
272272 matches );
273273 } catch (Exception ex ) {
@@ -437,18 +437,17 @@ private void exportFile(List<ParserResult> loaded, String[] data) {
437437 Globals .prefs .fileDirForDatabase = databaseContext
438438 .getFileDirectories (Globals .prefs .getFileDirectoryPreferences ());
439439 System .out .println (Localization .lang ("Exporting" ) + ": " + data [0 ]);
440- IExportFormat format = ExportFormats . getExportFormat (data [1 ]);
441- if (format == null ) {
440+ Optional < Exporter > exporter = Globals . exportFactory . getExporterByName (data [1 ]);
441+ if (! exporter . isPresent () ) {
442442 System .err .println (Localization .lang ("Unknown export format" ) + ": " + data [1 ]);
443443 } else {
444- // We have an ExportFormat instance :
444+ // We have an exporter :
445445 try {
446- format . performExport ( pr .getDatabaseContext (), data [0 ],
446+ exporter . get (). export ( pr .getDatabaseContext (), Paths . get ( data [0 ]) ,
447447 pr .getDatabaseContext ().getMetaData ().getEncoding ()
448448 .orElse (Globals .prefs .getDefaultEncoding ()),
449449 pr .getDatabaseContext ().getDatabase ().getEntries ());
450450 } catch (Exception ex ) {
451-
452451 System .err .println (Localization .lang ("Could not export file" ) + " '" + data [0 ] + "': "
453452 + Throwables .getStackTraceAsString (ex ));
454453 }
@@ -462,12 +461,12 @@ private void importPreferences() {
462461 Globals .prefs .importPreferences (cli .getPreferencesImport ());
463462 EntryTypes .loadCustomEntryTypes (Globals .prefs .loadCustomEntryTypes (BibDatabaseMode .BIBTEX ),
464463 Globals .prefs .loadCustomEntryTypes (BibDatabaseMode .BIBLATEX ));
465- Map <String , ExportFormat > customFormats = Globals .prefs .customExports .getCustomExportFormats (Globals .prefs ,
464+ Map <String , TemplateExporter > customExporters = Globals .prefs .customExports .getCustomExportFormats (Globals .prefs ,
466465 Globals .journalAbbreviationLoader );
467466 LayoutFormatterPreferences layoutPreferences = Globals .prefs
468467 .getLayoutFormatterPreferences (Globals .journalAbbreviationLoader );
469468 SavePreferences savePreferences = SavePreferences .loadForExportFromPreferences (Globals .prefs );
470- ExportFormats . initAllExports ( customFormats , layoutPreferences , savePreferences );
469+ Globals . exportFactory = ExporterFactory . create ( customExporters , layoutPreferences , savePreferences );
471470 } catch (JabRefException ex ) {
472471 LOGGER .error ("Cannot import preferences" , ex );
473472 }
0 commit comments