From 7cb1e75ecca9159a1565ebabeda61ddaa6cb4dab Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Fri, 26 Aug 2016 19:57:46 +0200 Subject: [PATCH] Moved some logic preference instantiation to JabRefPreferences (#1781) * Moved some logic preference instantiation to JabRefPreferences * Some fixes * And some removed Globals --- .../net/sf/jabref/benchmarks/Benchmarks.java | 3 +- src/main/java/net/sf/jabref/JabRefGUI.java | 3 +- src/main/java/net/sf/jabref/JabRefMain.java | 14 +-- .../net/sf/jabref/cli/ArgumentProcessor.java | 10 +- .../jabref/cli/CrossrefFetcherEvaluator.java | 5 +- .../java/net/sf/jabref/cli/XMPUtilMain.java | 7 +- .../net/sf/jabref/collab/ChangeScanner.java | 3 +- .../jabref/external/DownloadExternalFile.java | 3 +- .../jabref/external/DroppedFileHandler.java | 6 +- .../sf/jabref/external/MoveFileAction.java | 4 +- .../sf/jabref/external/WriteXMPAction.java | 3 +- .../external/WriteXMPEntryEditorAction.java | 4 +- .../java/net/sf/jabref/gui/BasePanel.java | 8 +- .../net/sf/jabref/gui/ClipBoardManager.java | 5 +- .../java/net/sf/jabref/gui/PreviewPanel.java | 7 +- .../java/net/sf/jabref/gui/StringDialog.java | 3 +- .../jabref/gui/TransferableBibtexEntry.java | 3 +- .../sf/jabref/gui/actions/CleanupAction.java | 3 +- .../SearchFixDuplicateLabels.java | 3 +- .../jabref/gui/entryeditor/EntryEditor.java | 13 +-- .../gui/entryeditor/FieldExtraComponents.java | 3 +- .../sf/jabref/gui/exporter/ExportAction.java | 3 +- .../exporter/ExportCustomizationDialog.java | 5 +- .../contextmenu/ProtectedTermsMenu.java | 3 +- .../gui/importer/EntryFromPDFCreator.java | 4 +- .../importer/ImportCustomizationDialog.java | 10 +- .../gui/importer/ImportInspectionDialog.java | 5 +- .../actions/AppendDatabaseAction.java | 3 +- .../importer/actions/OpenDatabaseAction.java | 3 +- .../importer/fetcher/ACMPortalFetcher.java | 3 +- .../gui/importer/fetcher/ADSFetcher.java | 3 +- .../gui/importer/fetcher/DBLPFetcher.java | 5 +- .../importer/fetcher/DOItoBibTeXFetcher.java | 3 +- .../importer/fetcher/DiVAtoBibTeXFetcher.java | 3 +- .../fetcher/GoogleScholarFetcher.java | 3 +- .../importer/fetcher/IEEEXploreFetcher.java | 6 +- .../gui/importer/fetcher/INSPIREFetcher.java | 3 +- .../importer/fetcher/ISBNtoBibTeXFetcher.java | 3 +- .../fetcher/ScienceDirectFetcher.java | 3 +- .../worker/AutosaveStartupPrompter.java | 3 +- .../jabref/gui/journals/AbbreviateAction.java | 3 +- .../gui/journals/ManageJournalsPanel.java | 5 +- .../gui/journals/UnabbreviateAction.java | 3 +- .../gui/mergeentries/FetchAndMergeEntry.java | 3 +- .../jabref/gui/mergeentries/MergeEntries.java | 3 +- .../gui/openoffice/OpenOfficePanel.java | 5 +- .../gui/plaintextimport/TextInputDialog.java | 6 +- .../sf/jabref/gui/preftabs/AdvancedTab.java | 3 +- .../gui/preftabs/PreferencesDialog.java | 4 +- .../protectedterms/ProtectedTermsDialog.java | 5 +- .../jabref/gui/worker/SendAsEMailAction.java | 3 +- .../AutoCompletePreferences.java | 2 +- .../bibtex/FieldContentParserPreferences.java | 6 -- .../LatexFieldFormatterPreferences.java | 8 -- .../BibtexKeyPatternPreferences.java | 11 --- .../logic/exporter/CustomExportList.java | 2 +- .../logic/exporter/SavePreferences.java | 6 +- .../importer/ImportFormatPreferences.java | 10 -- .../JournalAbbreviationPreferences.java | 9 -- .../layout/LayoutFormatterPreferences.java | 12 --- .../layout/format/FileLinkPreferences.java | 9 -- .../format/NameFormatterPreferences.java | 7 -- .../ProtectedTermsPreferences.java | 40 -------- .../sf/jabref/logic/xmp/XMPPreferences.java | 8 -- .../net/sf/jabref/pdfimport/PdfImporter.java | 11 +-- .../jabref/preferences/JabRefPreferences.java | 98 +++++++++++++++++++ src/test/java/net/sf/jabref/MetaDataTest.java | 2 - .../net/sf/jabref/cli/AuxCommandLineTest.java | 3 +- .../external/RegExpFileSearchTests.java | 4 +- .../EntryFromFileCreatorManagerTest.java | 3 +- .../jabref/logic/auxparser/AuxParserTest.java | 2 +- .../jabref/logic/bibtex/BibEntryAssert.java | 3 +- .../logic/bibtex/BibEntryWriterTest.java | 6 +- .../bibtex/LatexFieldFormatterTests.java | 3 +- .../BibtexKeyPatternUtilTest.java | 2 +- .../java/net/sf/jabref/logic/bst/TestVM.java | 3 +- .../logic/cleanup/RenamePdfCleanupTest.java | 2 +- .../exporter/BibtexDatabaseWriterTest.java | 2 +- .../logic/exporter/ExportFormatTest.java | 4 +- .../logic/exporter/HtmlExportFormatTest.java | 3 +- .../exporter/MSBibExportFormatTestFiles.java | 3 +- .../jabref/logic/groups/GroupsUtilTest.java | 3 +- .../importer/BibDatabaseTestsWithFiles.java | 2 +- .../importer/DatabaseFileLookupTest.java | 2 +- .../ImportFormatReaderIntegrationTest.java | 5 +- .../ImportFormatReaderTestParameterless.java | 5 +- .../logic/importer/OpenDatabaseTest.java | 2 +- .../logic/importer/ParsedBibEntryTests.java | 2 +- .../logic/importer/fetcher/DiVATest.java | 3 +- .../fileformat/BibtexImporterTest.java | 3 +- .../importer/fileformat/BibtexParserTest.java | 10 +- .../fileformat/EndnoteImporterTest.java | 3 +- .../fileformat/FreeCiteImporterTest.java | 3 +- .../importer/fileformat/ImportFormatTest.java | 5 +- .../fileformat/PdfContentImporterTest.java | 3 +- .../PdfContentImporterTestFiles.java | 3 +- .../fileformat/PdfXmpImporterTest.java | 3 +- .../fileformat/RepecNepImporterTest.java | 3 +- .../logic/journals/AbbreviationsTest.java | 18 ++-- .../jabref/logic/layout/LayoutEntryTest.java | 2 +- .../sf/jabref/logic/layout/LayoutTest.java | 6 +- .../logic/layout/format/FileLinkTest.java | 2 +- .../logic/openoffice/OOBibStyleTest.java | 9 +- .../logic/openoffice/StyleLoaderTest.java | 6 +- .../sf/jabref/logic/util/io/FileUtilTest.java | 4 +- .../net/sf/jabref/logic/xmp/XMPUtilTest.java | 15 ++- .../logic/exporter/MsBibExportFormatTest3.xml | 2 +- 107 files changed, 262 insertions(+), 376 deletions(-) diff --git a/src/jmh/java/net/sf/jabref/benchmarks/Benchmarks.java b/src/jmh/java/net/sf/jabref/benchmarks/Benchmarks.java index 1a0f6a869e7..ddefa68e5c2 100644 --- a/src/jmh/java/net/sf/jabref/benchmarks/Benchmarks.java +++ b/src/jmh/java/net/sf/jabref/benchmarks/Benchmarks.java @@ -17,7 +17,6 @@ import net.sf.jabref.logic.formatter.bibtexfields.HtmlToLatexFormatter; import net.sf.jabref.logic.groups.GroupHierarchyType; import net.sf.jabref.logic.groups.KeywordGroup; -import net.sf.jabref.logic.importer.ImportFormatPreferences; import net.sf.jabref.logic.importer.ParserResult; import net.sf.jabref.logic.importer.fileformat.BibtexParser; import net.sf.jabref.logic.importer.util.ParseException; @@ -76,7 +75,7 @@ public void init() throws Exception { public ParserResult parse() throws IOException { StringReader bibtexStringReader = new StringReader(bibtexString); BibtexParser parser = new BibtexParser(bibtexStringReader, - ImportFormatPreferences.fromPreferences(Globals.prefs)); + Globals.prefs.getImportFormatPreferences()); return parser.parse(); } diff --git a/src/main/java/net/sf/jabref/JabRefGUI.java b/src/main/java/net/sf/jabref/JabRefGUI.java index efec40a5eb0..159a8b42e5a 100644 --- a/src/main/java/net/sf/jabref/JabRefGUI.java +++ b/src/main/java/net/sf/jabref/JabRefGUI.java @@ -23,7 +23,6 @@ import net.sf.jabref.gui.importer.worker.AutosaveStartupPrompter; import net.sf.jabref.gui.util.FocusRequester; import net.sf.jabref.gui.worker.VersionWorker; -import net.sf.jabref.logic.importer.ImportFormatPreferences; import net.sf.jabref.logic.importer.OpenDatabase; import net.sf.jabref.logic.importer.ParserResult; import net.sf.jabref.logic.l10n.Localization; @@ -219,7 +218,7 @@ private void openLastEditedDatabases() { } ParserResult parsedDatabase = OpenDatabase.loadDatabaseOrAutoSave(fileName, false, - ImportFormatPreferences.fromPreferences(Globals.prefs)); + Globals.prefs.getImportFormatPreferences()); if (parsedDatabase.isNullResult()) { LOGGER.error(Localization.lang("Error opening file") + " '" + dbFile.getPath() + "'"); diff --git a/src/main/java/net/sf/jabref/JabRefMain.java b/src/main/java/net/sf/jabref/JabRefMain.java index b4665ca1634..ae56693b5f2 100644 --- a/src/main/java/net/sf/jabref/JabRefMain.java +++ b/src/main/java/net/sf/jabref/JabRefMain.java @@ -12,7 +12,6 @@ import net.sf.jabref.logic.exporter.ExportFormats; import net.sf.jabref.logic.exporter.SavePreferences; import net.sf.jabref.logic.formatter.casechanger.ProtectTermsFormatter; -import net.sf.jabref.logic.importer.ImportFormatPreferences; import net.sf.jabref.logic.journals.JournalAbbreviationLoader; import net.sf.jabref.logic.l10n.Localization; import net.sf.jabref.logic.layout.LayoutFormatterPreferences; @@ -20,11 +19,9 @@ import net.sf.jabref.logic.net.ProxyPreferences; import net.sf.jabref.logic.net.ProxyRegisterer; import net.sf.jabref.logic.protectedterms.ProtectedTermsLoader; -import net.sf.jabref.logic.protectedterms.ProtectedTermsPreferences; import net.sf.jabref.logic.remote.RemotePreferences; import net.sf.jabref.logic.remote.client.RemoteListenerClient; import net.sf.jabref.logic.util.OS; -import net.sf.jabref.logic.xmp.XMPPreferences; import net.sf.jabref.model.entry.InternalBibtexFields; import net.sf.jabref.preferences.JabRefPreferences; @@ -67,19 +64,18 @@ private static void start(String[] args) { Globals.journalAbbreviationLoader = new JournalAbbreviationLoader(); /* Build list of Import and Export formats */ - Globals.IMPORT_FORMAT_READER.resetImportFormats(ImportFormatPreferences.fromPreferences(Globals.prefs), - XMPPreferences.fromPreferences(Globals.prefs)); + Globals.IMPORT_FORMAT_READER.resetImportFormats(Globals.prefs.getImportFormatPreferences(), + Globals.prefs.getXMPPreferences()); CustomEntryTypesManager.loadCustomEntryTypes(preferences); Map customFormats = Globals.prefs.customExports.getCustomExportFormats(Globals.prefs, Globals.journalAbbreviationLoader); - LayoutFormatterPreferences layoutPreferences = LayoutFormatterPreferences.fromPreferences(Globals.prefs, - Globals.journalAbbreviationLoader); + LayoutFormatterPreferences layoutPreferences = Globals.prefs + .getLayoutFormatterPreferences(Globals.journalAbbreviationLoader); SavePreferences savePreferences = SavePreferences.loadForExportFromPreferences(Globals.prefs); ExportFormats.initAllExports(customFormats, layoutPreferences, savePreferences); // Initialize protected terms loader - Globals.protectedTermsLoader = new ProtectedTermsLoader( - ProtectedTermsPreferences.fromPreferences(Globals.prefs)); + Globals.protectedTermsLoader = new ProtectedTermsLoader(Globals.prefs.getProtectedTermsPreferences()); ProtectTermsFormatter.setProtectedTermsLoader(Globals.protectedTermsLoader); // Check for running JabRef diff --git a/src/main/java/net/sf/jabref/cli/ArgumentProcessor.java b/src/main/java/net/sf/jabref/cli/ArgumentProcessor.java index ce2e7e10e16..be82b58a8da 100644 --- a/src/main/java/net/sf/jabref/cli/ArgumentProcessor.java +++ b/src/main/java/net/sf/jabref/cli/ArgumentProcessor.java @@ -22,7 +22,6 @@ import net.sf.jabref.gui.importer.fetcher.EntryFetcher; import net.sf.jabref.gui.importer.fetcher.EntryFetchers; import net.sf.jabref.logic.CustomEntryTypesManager; -import net.sf.jabref.logic.bibtexkeypattern.BibtexKeyPatternPreferences; import net.sf.jabref.logic.bibtexkeypattern.BibtexKeyPatternUtil; import net.sf.jabref.logic.exporter.BibDatabaseWriter; import net.sf.jabref.logic.exporter.BibtexDatabaseWriter; @@ -33,7 +32,6 @@ import net.sf.jabref.logic.exporter.SaveException; import net.sf.jabref.logic.exporter.SavePreferences; import net.sf.jabref.logic.exporter.SaveSession; -import net.sf.jabref.logic.importer.ImportFormatPreferences; import net.sf.jabref.logic.importer.ImportFormatReader; import net.sf.jabref.logic.importer.OpenDatabase; import net.sf.jabref.logic.importer.OutputPrinter; @@ -242,7 +240,7 @@ private List importAndOpenFiles() { ParserResult pr = null; if (bibExtension) { pr = OpenDatabase.loadDatabaseOrAutoSave(aLeftOver, false, - ImportFormatPreferences.fromPreferences(Globals.prefs)); + Globals.prefs.getImportFormatPreferences()); } if (!bibExtension || (pr.isNullResult())) { @@ -400,8 +398,8 @@ private void importPreferences() { CustomEntryTypesManager.loadCustomEntryTypes(Globals.prefs); Map customFormats = Globals.prefs.customExports.getCustomExportFormats(Globals.prefs, Globals.journalAbbreviationLoader); - LayoutFormatterPreferences layoutPreferences = LayoutFormatterPreferences.fromPreferences(Globals.prefs, - Globals.journalAbbreviationLoader); + LayoutFormatterPreferences layoutPreferences = Globals.prefs + .getLayoutFormatterPreferences(Globals.journalAbbreviationLoader); SavePreferences savePreferences = SavePreferences.loadForExportFromPreferences(Globals.prefs); ExportFormats.initAllExports(customFormats, layoutPreferences, savePreferences); } catch (JabRefException ex) { @@ -449,7 +447,7 @@ private void regenerateBibtexKeys(List loaded) { for (BibEntry entry : database.getEntries()) { // try to make a new label BibtexKeyPatternUtil.makeLabel(metaData, database, entry, - BibtexKeyPatternPreferences.fromPreferences(Globals.prefs)); + Globals.prefs.getBibtexKeyPatternPreferences()); } } else { LOGGER.info(Localization.lang("No meta data present in BIB_file. Cannot regenerate BibTeX keys")); diff --git a/src/main/java/net/sf/jabref/cli/CrossrefFetcherEvaluator.java b/src/main/java/net/sf/jabref/cli/CrossrefFetcherEvaluator.java index 63e91f35889..3a9bd24e736 100644 --- a/src/main/java/net/sf/jabref/cli/CrossrefFetcherEvaluator.java +++ b/src/main/java/net/sf/jabref/cli/CrossrefFetcherEvaluator.java @@ -10,7 +10,6 @@ import java.util.concurrent.atomic.AtomicInteger; import net.sf.jabref.Globals; -import net.sf.jabref.logic.importer.ImportFormatPreferences; import net.sf.jabref.logic.importer.ParserResult; import net.sf.jabref.logic.importer.fetcher.CrossRef; import net.sf.jabref.logic.importer.fileformat.BibtexParser; @@ -28,11 +27,11 @@ public class CrossrefFetcherEvaluator { public static void main(String[] args) throws IOException, InterruptedException { Globals.prefs = JabRefPreferences.getInstance(); try (FileReader reader = new FileReader(args[0])) { - BibtexParser parser = new BibtexParser(reader, ImportFormatPreferences.fromPreferences(Globals.prefs)); + BibtexParser parser = new BibtexParser(new FileReader(args[0]), Globals.prefs.getImportFormatPreferences()); ParserResult result = parser.parse(); BibDatabase db = result.getDatabase(); - int total = result.getDatabase().getEntryCount(); + int total = db.getEntryCount(); AtomicInteger dois = new AtomicInteger(); AtomicInteger doiFound = new AtomicInteger(); diff --git a/src/main/java/net/sf/jabref/cli/XMPUtilMain.java b/src/main/java/net/sf/jabref/cli/XMPUtilMain.java index bb9c8912789..1c39ddc01b3 100644 --- a/src/main/java/net/sf/jabref/cli/XMPUtilMain.java +++ b/src/main/java/net/sf/jabref/cli/XMPUtilMain.java @@ -14,7 +14,6 @@ import net.sf.jabref.Globals; import net.sf.jabref.logic.bibtex.BibEntryWriter; import net.sf.jabref.logic.bibtex.LatexFieldFormatter; -import net.sf.jabref.logic.bibtex.LatexFieldFormatterPreferences; import net.sf.jabref.logic.importer.ImportFormatPreferences; import net.sf.jabref.logic.importer.ParserResult; import net.sf.jabref.logic.importer.fileformat.BibtexParser; @@ -60,8 +59,8 @@ public static void main(String[] args) throws IOException, TransformerException Globals.prefs = JabRefPreferences.getInstance(); } - XMPPreferences xmpPreferences = XMPPreferences.fromPreferences(Globals.prefs); - ImportFormatPreferences importFormatPreferences = ImportFormatPreferences.fromPreferences(Globals.prefs); + XMPPreferences xmpPreferences = Globals.prefs.getXMPPreferences(); + ImportFormatPreferences importFormatPreferences = Globals.prefs.getImportFormatPreferences(); switch (args.length) { case 0: @@ -74,7 +73,7 @@ public static void main(String[] args) throws IOException, TransformerException List l = XMPUtil.readXMP(new File(args[0]), xmpPreferences); BibEntryWriter bibtexEntryWriter = new BibEntryWriter( - new LatexFieldFormatter(LatexFieldFormatterPreferences.fromPreferences(Globals.prefs)), false); + new LatexFieldFormatter(Globals.prefs.getLatexFieldFormatterPreferences()), false); for (BibEntry entry : l) { StringWriter sw = new StringWriter(); diff --git a/src/main/java/net/sf/jabref/collab/ChangeScanner.java b/src/main/java/net/sf/jabref/collab/ChangeScanner.java index b6b00acf926..64eaebab76d 100644 --- a/src/main/java/net/sf/jabref/collab/ChangeScanner.java +++ b/src/main/java/net/sf/jabref/collab/ChangeScanner.java @@ -85,10 +85,11 @@ public void run() { // Parse the temporary file. Path tempFile = Globals.getFileUpdateMonitor().getTempFile(panel.fileMonitorHandle()); - ImportFormatPreferences importFormatPreferences = ImportFormatPreferences.fromPreferences(Globals.prefs); + ImportFormatPreferences importFormatPreferences = Globals.prefs.getImportFormatPreferences(); ParserResult result = OpenDatabase.loadDatabase(tempFile.toFile(), importFormatPreferences); databaseInTemp = result.getDatabase(); metadataInTemp = result.getMetaData(); + // Parse the modified file. result = OpenDatabase.loadDatabase(file, importFormatPreferences); BibDatabase databaseOnDisk = result.getDatabase(); diff --git a/src/main/java/net/sf/jabref/external/DownloadExternalFile.java b/src/main/java/net/sf/jabref/external/DownloadExternalFile.java index 7e706df26b4..c64fd598719 100644 --- a/src/main/java/net/sf/jabref/external/DownloadExternalFile.java +++ b/src/main/java/net/sf/jabref/external/DownloadExternalFile.java @@ -18,7 +18,6 @@ import net.sf.jabref.gui.JabRefFrame; import net.sf.jabref.gui.net.MonitoredURLDownload; import net.sf.jabref.logic.l10n.Localization; -import net.sf.jabref.logic.layout.LayoutFormatterPreferences; import net.sf.jabref.logic.net.URLDownload; import net.sf.jabref.logic.util.OS; import net.sf.jabref.logic.util.io.FileUtil; @@ -259,7 +258,7 @@ private String getSuggestedFileName(String suffix) { String plannedName = FileUtil.createFileNameFromPattern(databaseContext.getDatabase(), frame.getCurrentBasePanel().getSelectedEntries().get(0), Globals.prefs.get(JabRefPreferences.IMPORT_FILENAMEPATTERN), - LayoutFormatterPreferences.fromPreferences(Globals.prefs, Globals.journalAbbreviationLoader)); + Globals.prefs.getLayoutFormatterPreferences(Globals.journalAbbreviationLoader)); if (!suffix.isEmpty()) { plannedName += "." + suffix; diff --git a/src/main/java/net/sf/jabref/external/DroppedFileHandler.java b/src/main/java/net/sf/jabref/external/DroppedFileHandler.java index c3198246ca5..0270002bd6b 100644 --- a/src/main/java/net/sf/jabref/external/DroppedFileHandler.java +++ b/src/main/java/net/sf/jabref/external/DroppedFileHandler.java @@ -25,10 +25,8 @@ import net.sf.jabref.gui.undo.UndoableFieldChange; import net.sf.jabref.gui.undo.UndoableInsertEntry; import net.sf.jabref.logic.l10n.Localization; -import net.sf.jabref.logic.layout.LayoutFormatterPreferences; import net.sf.jabref.logic.util.OS; import net.sf.jabref.logic.util.io.FileUtil; -import net.sf.jabref.logic.xmp.XMPPreferences; import net.sf.jabref.logic.xmp.XMPUtil; import net.sf.jabref.model.database.BibDatabase; import net.sf.jabref.model.entry.BibEntry; @@ -224,7 +222,7 @@ private boolean tryXmpImport(String fileName, ExternalFileType fileType, NamedCo List xmpEntriesInFile; try { - xmpEntriesInFile = XMPUtil.readXMP(fileName, XMPPreferences.fromPreferences(Globals.prefs)); + xmpEntriesInFile = XMPUtil.readXMP(fileName, Globals.prefs.getXMPPreferences()); } catch (IOException e) { LOGGER.warn("Problem reading XMP", e); return false; @@ -346,7 +344,7 @@ private boolean showLinkMoveCopyRenameDialog(String linkFileName, ExternalFileTy // Determine which name to suggest: String targetName = FileUtil.createFileNameFromPattern(database, entry, Globals.prefs.get(JabRefPreferences.IMPORT_FILENAMEPATTERN), - LayoutFormatterPreferences.fromPreferences(Globals.prefs, Globals.journalAbbreviationLoader)); + Globals.prefs.getLayoutFormatterPreferences(Globals.journalAbbreviationLoader)); renameToTextBox.setText(targetName.concat(".").concat(fileType.getExtension())); diff --git a/src/main/java/net/sf/jabref/external/MoveFileAction.java b/src/main/java/net/sf/jabref/external/MoveFileAction.java index 75372c8b63d..4d2a10dae00 100644 --- a/src/main/java/net/sf/jabref/external/MoveFileAction.java +++ b/src/main/java/net/sf/jabref/external/MoveFileAction.java @@ -20,7 +20,6 @@ import net.sf.jabref.gui.fieldeditors.FileListEditor; import net.sf.jabref.gui.util.component.CheckBoxMessage; import net.sf.jabref.logic.l10n.Localization; -import net.sf.jabref.logic.layout.LayoutFormatterPreferences; import net.sf.jabref.logic.util.io.FileUtil; import net.sf.jabref.preferences.JabRefPreferences; @@ -100,8 +99,7 @@ public void actionPerformed(ActionEvent event) { String suggName = FileUtil .createFileNameFromPattern(eEditor.getDatabase(), eEditor.getEntry(), Globals.prefs.get(JabRefPreferences.IMPORT_FILENAMEPATTERN), - LayoutFormatterPreferences.fromPreferences(Globals.prefs, - Globals.journalAbbreviationLoader)) + Globals.prefs.getLayoutFormatterPreferences(Globals.journalAbbreviationLoader)) .concat(entry.type.isPresent() ? "." + entry.type.get().getExtension() : ""); CheckBoxMessage cbm = new CheckBoxMessage(Localization.lang("Move file to file directory?"), Localization.lang("Rename to '%0'", suggName), diff --git a/src/main/java/net/sf/jabref/external/WriteXMPAction.java b/src/main/java/net/sf/jabref/external/WriteXMPAction.java index de7021d607c..7420c45a479 100644 --- a/src/main/java/net/sf/jabref/external/WriteXMPAction.java +++ b/src/main/java/net/sf/jabref/external/WriteXMPAction.java @@ -32,7 +32,6 @@ import net.sf.jabref.gui.worker.AbstractWorker; import net.sf.jabref.logic.l10n.Localization; import net.sf.jabref.logic.util.io.FileUtil; -import net.sf.jabref.logic.xmp.XMPPreferences; import net.sf.jabref.logic.xmp.XMPUtil; import net.sf.jabref.model.database.BibDatabase; import net.sf.jabref.model.entry.BibEntry; @@ -153,7 +152,7 @@ public void run() { for (File file : files) { if (file.exists()) { try { - XMPUtil.writeXMP(file, entry, database, XMPPreferences.fromPreferences(Globals.prefs)); + XMPUtil.writeXMP(file, entry, database, Globals.prefs.getXMPPreferences()); SwingUtilities.invokeLater( () -> optDiag.getProgressArea().append(" " + Localization.lang("OK") + ".\n")); entriesChanged++; diff --git a/src/main/java/net/sf/jabref/external/WriteXMPEntryEditorAction.java b/src/main/java/net/sf/jabref/external/WriteXMPEntryEditorAction.java index 4866915b2be..ec22a36a630 100644 --- a/src/main/java/net/sf/jabref/external/WriteXMPEntryEditorAction.java +++ b/src/main/java/net/sf/jabref/external/WriteXMPEntryEditorAction.java @@ -19,7 +19,6 @@ import net.sf.jabref.gui.worker.AbstractWorker; import net.sf.jabref.logic.l10n.Localization; import net.sf.jabref.logic.util.io.FileUtil; -import net.sf.jabref.logic.xmp.XMPPreferences; import net.sf.jabref.logic.xmp.XMPUtil; import net.sf.jabref.model.entry.BibEntry; import net.sf.jabref.model.entry.FieldName; @@ -115,8 +114,7 @@ public void run() { } else { try { - XMPUtil.writeXMP(file, entry, panel.getDatabase(), - XMPPreferences.fromPreferences(Globals.prefs)); + XMPUtil.writeXMP(file, entry, panel.getDatabase(), Globals.prefs.getXMPPreferences()); if (files.size() == 1) { message = Localization.lang("Wrote XMP-metadata"); } diff --git a/src/main/java/net/sf/jabref/gui/BasePanel.java b/src/main/java/net/sf/jabref/gui/BasePanel.java index d93a1f58492..ff4a68a65d2 100644 --- a/src/main/java/net/sf/jabref/gui/BasePanel.java +++ b/src/main/java/net/sf/jabref/gui/BasePanel.java @@ -96,7 +96,6 @@ import net.sf.jabref.logic.autocompleter.AutoCompleter; import net.sf.jabref.logic.autocompleter.AutoCompleterFactory; import net.sf.jabref.logic.autocompleter.ContentAutoCompleters; -import net.sf.jabref.logic.bibtexkeypattern.BibtexKeyPatternPreferences; import net.sf.jabref.logic.bibtexkeypattern.BibtexKeyPatternUtil; import net.sf.jabref.logic.exporter.BibtexDatabaseWriter; import net.sf.jabref.logic.exporter.FileSaveSession; @@ -106,7 +105,6 @@ import net.sf.jabref.logic.l10n.Encodings; import net.sf.jabref.logic.l10n.Localization; import net.sf.jabref.logic.layout.Layout; -import net.sf.jabref.logic.layout.LayoutFormatterPreferences; import net.sf.jabref.logic.layout.LayoutHelper; import net.sf.jabref.logic.util.FileExtensions; import net.sf.jabref.logic.util.UpdateField; @@ -479,7 +477,7 @@ public void run() { for (BibEntry entry : entries) { bes = entry; BibtexKeyPatternUtil.makeLabel(bibDatabaseContext.getMetaData(), bibDatabaseContext.getDatabase(), - bes, BibtexKeyPatternPreferences.fromPreferences(Globals.prefs)); + bes, Globals.prefs.getBibtexKeyPatternPreferences()); ce.addEdit(new UndoableKeyChange(bibDatabaseContext.getDatabase(), bes, (String) oldvals.get(bes), bes.getCiteKeyOptional().orElse(null))); } @@ -912,7 +910,7 @@ private void copyKeyAndTitle() { Layout layout; try { layout = new LayoutHelper(sr, - LayoutFormatterPreferences.fromPreferences(Globals.prefs, Globals.journalAbbreviationLoader)) + Globals.prefs.getLayoutFormatterPreferences(Globals.journalAbbreviationLoader)) .getLayoutFromText(); } catch (IOException e) { LOGGER.info("Could not get layout", e); @@ -1939,7 +1937,7 @@ public void autoGenerateKeysBeforeSaving() { Optional oldKey = bes.getCiteKeyOptional(); if (!(oldKey.isPresent()) || oldKey.get().isEmpty()) { BibtexKeyPatternUtil.makeLabel(bibDatabaseContext.getMetaData(), bibDatabaseContext.getDatabase(), - bes, BibtexKeyPatternPreferences.fromPreferences(Globals.prefs)); + bes, Globals.prefs.getBibtexKeyPatternPreferences()); ce.addEdit(new UndoableKeyChange(bibDatabaseContext.getDatabase(), bes, null, bes.getCiteKeyOptional().get())); // Cite key is set here any = true; diff --git a/src/main/java/net/sf/jabref/gui/ClipBoardManager.java b/src/main/java/net/sf/jabref/gui/ClipBoardManager.java index 79712d07184..19ab6d7db14 100644 --- a/src/main/java/net/sf/jabref/gui/ClipBoardManager.java +++ b/src/main/java/net/sf/jabref/gui/ClipBoardManager.java @@ -14,7 +14,6 @@ import java.util.Optional; import net.sf.jabref.Globals; -import net.sf.jabref.logic.importer.ImportFormatPreferences; import net.sf.jabref.logic.importer.fetcher.DOItoBibTeX; import net.sf.jabref.logic.importer.fileformat.BibtexParser; import net.sf.jabref.logic.util.DOI; @@ -88,12 +87,12 @@ public List extractBibEntriesFromClipboard() { if (DOI.build(data).isPresent()) { LOGGER.info("Found DOI in clipboard"); Optional entry = DOItoBibTeX.getEntryFromDOI(new DOI(data).getDOI(), - ImportFormatPreferences.fromPreferences(Globals.prefs)); + Globals.prefs.getImportFormatPreferences()); entry.ifPresent(result::add); } else { // parse bibtex string BibtexParser bp = new BibtexParser(new StringReader(data), - ImportFormatPreferences.fromPreferences(Globals.prefs)); + Globals.prefs.getImportFormatPreferences()); BibDatabase db = bp.parse().getDatabase(); LOGGER.info("Parsed " + db.getEntryCount() + " entries from clipboard text"); if (db.hasEntries()) { diff --git a/src/main/java/net/sf/jabref/gui/PreviewPanel.java b/src/main/java/net/sf/jabref/gui/PreviewPanel.java index 06152640b97..d48405d68c6 100644 --- a/src/main/java/net/sf/jabref/gui/PreviewPanel.java +++ b/src/main/java/net/sf/jabref/gui/PreviewPanel.java @@ -38,7 +38,6 @@ import net.sf.jabref.logic.exporter.ExportFormats; import net.sf.jabref.logic.l10n.Localization; import net.sf.jabref.logic.layout.Layout; -import net.sf.jabref.logic.layout.LayoutFormatterPreferences; import net.sf.jabref.logic.layout.LayoutHelper; import net.sf.jabref.logic.search.SearchQueryHighlightListener; import net.sf.jabref.model.entry.BibEntry; @@ -212,9 +211,9 @@ public void updateLayout(String layoutFormat) { private void updateLayout() { StringReader sr = new StringReader(layoutFile.replace("__NEWLINE__", "\n")); try { - layout = Optional - .of(new LayoutHelper(sr, LayoutFormatterPreferences.fromPreferences(Globals.prefs, - Globals.journalAbbreviationLoader)).getLayoutFromText()); + layout = Optional.of( + new LayoutHelper(sr, Globals.prefs.getLayoutFormatterPreferences(Globals.journalAbbreviationLoader)) + .getLayoutFromText()); } catch (IOException e) { layout = Optional.empty(); LOGGER.debug("no layout could be set", e); diff --git a/src/main/java/net/sf/jabref/gui/StringDialog.java b/src/main/java/net/sf/jabref/gui/StringDialog.java index 19fbb304113..1d79981d6ff 100644 --- a/src/main/java/net/sf/jabref/gui/StringDialog.java +++ b/src/main/java/net/sf/jabref/gui/StringDialog.java @@ -41,7 +41,6 @@ import net.sf.jabref.gui.util.GUIUtil; import net.sf.jabref.gui.util.PositionWindow; import net.sf.jabref.logic.bibtex.LatexFieldFormatter; -import net.sf.jabref.logic.bibtex.LatexFieldFormatterPreferences; import net.sf.jabref.logic.bibtex.comparator.BibtexStringComparator; import net.sf.jabref.logic.help.HelpFile; import net.sf.jabref.logic.l10n.Localization; @@ -252,7 +251,7 @@ public void setValueAt(Object value, int row, int col) { if (!value.equals(subject.getContent())) { try { - new LatexFieldFormatter(LatexFieldFormatterPreferences.fromPreferences(Globals.prefs)) + new LatexFieldFormatter(Globals.prefs.getLatexFieldFormatterPreferences()) .format((String) value, "__dummy"); } catch (IllegalArgumentException ex) { return; diff --git a/src/main/java/net/sf/jabref/gui/TransferableBibtexEntry.java b/src/main/java/net/sf/jabref/gui/TransferableBibtexEntry.java index 9ac269684fa..906d5db3f06 100644 --- a/src/main/java/net/sf/jabref/gui/TransferableBibtexEntry.java +++ b/src/main/java/net/sf/jabref/gui/TransferableBibtexEntry.java @@ -12,7 +12,6 @@ import net.sf.jabref.Globals; import net.sf.jabref.logic.bibtex.BibEntryWriter; import net.sf.jabref.logic.bibtex.LatexFieldFormatter; -import net.sf.jabref.logic.bibtex.LatexFieldFormatterPreferences; import net.sf.jabref.logic.l10n.Localization; import net.sf.jabref.model.database.BibDatabaseMode; import net.sf.jabref.model.entry.BibEntry; @@ -51,7 +50,7 @@ public Object getTransferData(DataFlavor flavor) try { StringWriter sw = new StringWriter(); BibEntryWriter bibtexEntryWriter = new BibEntryWriter( - new LatexFieldFormatter(LatexFieldFormatterPreferences.fromPreferences(Globals.prefs)), false); + new LatexFieldFormatter(Globals.prefs.getLatexFieldFormatterPreferences()), false); for (BibEntry entry : data) { bibtexEntryWriter.write(entry, sw, BibDatabaseMode.BIBTEX); } diff --git a/src/main/java/net/sf/jabref/gui/actions/CleanupAction.java b/src/main/java/net/sf/jabref/gui/actions/CleanupAction.java index 48f55512ce8..a914f9749f7 100644 --- a/src/main/java/net/sf/jabref/gui/actions/CleanupAction.java +++ b/src/main/java/net/sf/jabref/gui/actions/CleanupAction.java @@ -17,7 +17,6 @@ import net.sf.jabref.logic.cleanup.CleanupPreset; import net.sf.jabref.logic.cleanup.CleanupWorker; import net.sf.jabref.logic.l10n.Localization; -import net.sf.jabref.logic.layout.LayoutFormatterPreferences; import net.sf.jabref.model.FieldChange; import net.sf.jabref.model.entry.BibEntry; import net.sf.jabref.preferences.JabRefPreferences; @@ -149,7 +148,7 @@ private void doCleanup(CleanupPreset preset, BibEntry entry, NamedCompound ce) { BibDatabaseContext bibDatabaseContext = panel.getBibDatabaseContext(); CleanupWorker cleaner = new CleanupWorker(bibDatabaseContext, Globals.prefs.get(JabRefPreferences.IMPORT_FILENAMEPATTERN), - LayoutFormatterPreferences.fromPreferences(Globals.prefs, Globals.journalAbbreviationLoader), + Globals.prefs.getLayoutFormatterPreferences(Globals.journalAbbreviationLoader), Globals.prefs.getFileDirectoryPreferences()); List changes = cleaner.cleanup(preset, entry); diff --git a/src/main/java/net/sf/jabref/gui/bibtexkeypattern/SearchFixDuplicateLabels.java b/src/main/java/net/sf/jabref/gui/bibtexkeypattern/SearchFixDuplicateLabels.java index dfce10e49c6..48f7a5d1672 100644 --- a/src/main/java/net/sf/jabref/gui/bibtexkeypattern/SearchFixDuplicateLabels.java +++ b/src/main/java/net/sf/jabref/gui/bibtexkeypattern/SearchFixDuplicateLabels.java @@ -12,7 +12,6 @@ import net.sf.jabref.gui.undo.NamedCompound; import net.sf.jabref.gui.undo.UndoableKeyChange; import net.sf.jabref.gui.worker.AbstractWorker; -import net.sf.jabref.logic.bibtexkeypattern.BibtexKeyPatternPreferences; import net.sf.jabref.logic.bibtexkeypattern.BibtexKeyPatternUtil; import net.sf.jabref.logic.l10n.Localization; import net.sf.jabref.model.database.BibDatabase; @@ -95,7 +94,7 @@ public void update() { for (BibEntry entry : toGenerateFor) { String oldKey = entry.getCiteKeyOptional().orElse(null); BibtexKeyPatternUtil.makeLabel(panel.getBibDatabaseContext().getMetaData(), panel.getDatabase(), entry, - BibtexKeyPatternPreferences.fromPreferences(Globals.prefs)); + Globals.prefs.getBibtexKeyPatternPreferences()); ce.addEdit(new UndoableKeyChange(panel.getDatabase(), entry, oldKey, entry.getCiteKeyOptional().get())); } ce.end(); diff --git a/src/main/java/net/sf/jabref/gui/entryeditor/EntryEditor.java b/src/main/java/net/sf/jabref/gui/entryeditor/EntryEditor.java index b9d06387b7c..f0a5d0bc939 100644 --- a/src/main/java/net/sf/jabref/gui/entryeditor/EntryEditor.java +++ b/src/main/java/net/sf/jabref/gui/entryeditor/EntryEditor.java @@ -79,11 +79,8 @@ import net.sf.jabref.logic.autocompleter.AutoCompleter; import net.sf.jabref.logic.bibtex.BibEntryWriter; import net.sf.jabref.logic.bibtex.LatexFieldFormatter; -import net.sf.jabref.logic.bibtex.LatexFieldFormatterPreferences; -import net.sf.jabref.logic.bibtexkeypattern.BibtexKeyPatternPreferences; import net.sf.jabref.logic.bibtexkeypattern.BibtexKeyPatternUtil; import net.sf.jabref.logic.help.HelpFile; -import net.sf.jabref.logic.importer.ImportFormatPreferences; import net.sf.jabref.logic.importer.ParserResult; import net.sf.jabref.logic.importer.fileformat.BibtexParser; import net.sf.jabref.logic.l10n.Localization; @@ -587,7 +584,7 @@ public void updateSource() { public static String getSourceString(BibEntry entry, BibDatabaseMode type) throws IOException { StringWriter stringWriter = new StringWriter(200); LatexFieldFormatter formatter = LatexFieldFormatter - .buildIgnoreHashes(LatexFieldFormatterPreferences.fromPreferences(Globals.prefs)); + .buildIgnoreHashes(Globals.prefs.getLatexFieldFormatterPreferences()); new BibEntryWriter(formatter, false).writeWithoutPrependedNewlines(entry, stringWriter, type); return stringWriter.getBuffer().toString(); @@ -764,7 +761,7 @@ public synchronized void switchTo(BibEntry switchEntry) { private boolean storeSource() { BibtexParser bibtexParser = new BibtexParser(new StringReader(source.getText()), - ImportFormatPreferences.fromPreferences(Globals.prefs)); + Globals.prefs.getImportFormatPreferences()); try { ParserResult parserResult = bibtexParser.parse(); @@ -814,7 +811,7 @@ private boolean storeSource() { String newValue = field.getValue(); if (!Objects.equals(oldValue, newValue)) { // Test if the field is legally set. - new LatexFieldFormatter(LatexFieldFormatterPreferences.fromPreferences(Globals.prefs)) + new LatexFieldFormatter(Globals.prefs.getLatexFieldFormatterPreferences()) .format(newValue, fieldName); compound.addEdit(new UndoableFieldChange(entry, fieldName, oldValue, newValue)); @@ -1173,7 +1170,7 @@ public void actionPerformed(ActionEvent event) { // properly formatted. If that happens, the field // is not stored and the textarea turns red. if (toSet != null) { - new LatexFieldFormatter(LatexFieldFormatterPreferences.fromPreferences(Globals.prefs)) + new LatexFieldFormatter(Globals.prefs.getLatexFieldFormatterPreferences()) .format(toSet, fieldEditor.getFieldName()); } @@ -1370,7 +1367,7 @@ public void actionPerformed(ActionEvent e) { } BibtexKeyPatternUtil.makeLabel(panel.getBibDatabaseContext().getMetaData(), panel.getDatabase(), entry, - BibtexKeyPatternPreferences.fromPreferences(Globals.prefs)); + Globals.prefs.getBibtexKeyPatternPreferences()); // Store undo information: panel.getUndoManager().addEdit( diff --git a/src/main/java/net/sf/jabref/gui/entryeditor/FieldExtraComponents.java b/src/main/java/net/sf/jabref/gui/entryeditor/FieldExtraComponents.java index 66ff1a7ad77..5fa56d0b6ec 100644 --- a/src/main/java/net/sf/jabref/gui/entryeditor/FieldExtraComponents.java +++ b/src/main/java/net/sf/jabref/gui/entryeditor/FieldExtraComponents.java @@ -27,7 +27,6 @@ import net.sf.jabref.gui.fieldeditors.FieldEditor; import net.sf.jabref.gui.mergeentries.FetchAndMergeEntry; import net.sf.jabref.gui.undo.UndoableFieldChange; -import net.sf.jabref.logic.journals.JournalAbbreviationPreferences; import net.sf.jabref.logic.journals.JournalAbbreviationRepository; import net.sf.jabref.logic.l10n.Localization; import net.sf.jabref.logic.net.URLUtil; @@ -79,7 +78,7 @@ public static Optional getJournalExtraComponent(JabRefFrame frame, B button.addActionListener(actionEvent -> { String text = editor.getText(); JournalAbbreviationRepository abbreviationRepository = Globals.journalAbbreviationLoader - .getRepository(JournalAbbreviationPreferences.fromPreferences(Globals.prefs)); + .getRepository(Globals.prefs.getJournalAbbreviationPreferences()); if (abbreviationRepository.isKnownName(text)) { String s = abbreviationRepository.getNextAbbreviation(text).orElse(text); diff --git a/src/main/java/net/sf/jabref/gui/exporter/ExportAction.java b/src/main/java/net/sf/jabref/gui/exporter/ExportAction.java index 0c942cf5102..5bdab9f44fd 100644 --- a/src/main/java/net/sf/jabref/gui/exporter/ExportAction.java +++ b/src/main/java/net/sf/jabref/gui/exporter/ExportAction.java @@ -64,7 +64,8 @@ public InternalExportAction(JabRefFrame frame, boolean selectedOnly) { public void actionPerformed(ActionEvent e) { Map customFormats = Globals.prefs.customExports.getCustomExportFormats(Globals.prefs, Globals.journalAbbreviationLoader); - LayoutFormatterPreferences layoutPreferences = LayoutFormatterPreferences.fromPreferences(Globals.prefs, Globals.journalAbbreviationLoader); + LayoutFormatterPreferences layoutPreferences = Globals.prefs + .getLayoutFormatterPreferences(Globals.journalAbbreviationLoader); SavePreferences savePreferences = SavePreferences.loadForExportFromPreferences(Globals.prefs); ExportFormats.initAllExports(customFormats, layoutPreferences, savePreferences); JFileChooser fc = ExportAction diff --git a/src/main/java/net/sf/jabref/gui/exporter/ExportCustomizationDialog.java b/src/main/java/net/sf/jabref/gui/exporter/ExportCustomizationDialog.java index 7ca4c6c2697..de9cde33776 100644 --- a/src/main/java/net/sf/jabref/gui/exporter/ExportCustomizationDialog.java +++ b/src/main/java/net/sf/jabref/gui/exporter/ExportCustomizationDialog.java @@ -80,7 +80,7 @@ public ExportCustomizationDialog(final JabRefFrame frame) { if (ecd.okPressed()) { List newFormat = Arrays.asList(ecd.name(), ecd.layoutFile(), ecd.extension()); Globals.prefs.customExports.addFormat(newFormat, - LayoutFormatterPreferences.fromPreferences(Globals.prefs, Globals.journalAbbreviationLoader), + Globals.prefs.getLayoutFormatterPreferences(Globals.journalAbbreviationLoader), SavePreferences.loadForExportFromPreferences(Globals.prefs)); Globals.prefs.customExports.store(Globals.prefs); } @@ -115,7 +115,8 @@ public ExportCustomizationDialog(final JabRefFrame frame) { for (int i = 0; i < rows.length; i++) { entries.add(Globals.prefs.customExports.getSortedList().get(rows[i])); } - LayoutFormatterPreferences layoutPreferences = LayoutFormatterPreferences.fromPreferences(Globals.prefs, Globals.journalAbbreviationLoader); + LayoutFormatterPreferences layoutPreferences = Globals.prefs + .getLayoutFormatterPreferences(Globals.journalAbbreviationLoader); SavePreferences savePreferences = SavePreferences.loadForExportFromPreferences(Globals.prefs); for (List list : entries) { Globals.prefs.customExports.remove(list, layoutPreferences, savePreferences); diff --git a/src/main/java/net/sf/jabref/gui/fieldeditors/contextmenu/ProtectedTermsMenu.java b/src/main/java/net/sf/jabref/gui/fieldeditors/contextmenu/ProtectedTermsMenu.java index 4798476f667..387eeced4ed 100644 --- a/src/main/java/net/sf/jabref/gui/fieldeditors/contextmenu/ProtectedTermsMenu.java +++ b/src/main/java/net/sf/jabref/gui/fieldeditors/contextmenu/ProtectedTermsMenu.java @@ -10,7 +10,6 @@ import net.sf.jabref.logic.formatter.casechanger.ProtectTermsFormatter; import net.sf.jabref.logic.l10n.Localization; import net.sf.jabref.logic.protectedterms.ProtectedTermsList; -import net.sf.jabref.logic.protectedterms.ProtectedTermsPreferences; public class ProtectedTermsMenu extends JMenu { @@ -64,7 +63,7 @@ public void updateFiles() { dialog.setVisible(true); if (dialog.isOKPressed()) { // Update preferences with new list - ProtectedTermsPreferences.toPreferences(Globals.prefs, Globals.protectedTermsLoader); + Globals.prefs.setProtectedTermsPreferences(Globals.protectedTermsLoader); } }); externalFiles.add(addToNewFileItem); diff --git a/src/main/java/net/sf/jabref/gui/importer/EntryFromPDFCreator.java b/src/main/java/net/sf/jabref/gui/importer/EntryFromPDFCreator.java index dca09b3b566..d9095f1c722 100644 --- a/src/main/java/net/sf/jabref/gui/importer/EntryFromPDFCreator.java +++ b/src/main/java/net/sf/jabref/gui/importer/EntryFromPDFCreator.java @@ -14,7 +14,6 @@ import net.sf.jabref.external.ExternalFileType; import net.sf.jabref.external.ExternalFileTypes; import net.sf.jabref.gui.IconTheme; -import net.sf.jabref.logic.xmp.XMPPreferences; import net.sf.jabref.logic.xmp.XMPUtil; import net.sf.jabref.model.entry.BibEntry; import net.sf.jabref.pdfimport.PdfImporter; @@ -123,8 +122,7 @@ private void addEntryDataFromPDDocumentInformation(File pdfFile, BibEntry entry) */ private void addEntryDataFromXMP(File aFile, BibEntry entry) { try { - List entrys = XMPUtil.readXMP(aFile.getAbsoluteFile(), - XMPPreferences.fromPreferences(Globals.prefs)); + List entrys = XMPUtil.readXMP(aFile.getAbsoluteFile(), Globals.prefs.getXMPPreferences()); addEntrysToEntry(entry, entrys); } catch (IOException e) { // no canceling here, just no data added. diff --git a/src/main/java/net/sf/jabref/gui/importer/ImportCustomizationDialog.java b/src/main/java/net/sf/jabref/gui/importer/ImportCustomizationDialog.java index ec3a367ffb6..cdd8dd37c60 100644 --- a/src/main/java/net/sf/jabref/gui/importer/ImportCustomizationDialog.java +++ b/src/main/java/net/sf/jabref/gui/importer/ImportCustomizationDialog.java @@ -34,12 +34,10 @@ import net.sf.jabref.gui.util.FocusRequester; import net.sf.jabref.gui.util.GUIUtil; import net.sf.jabref.logic.help.HelpFile; -import net.sf.jabref.logic.importer.ImportFormatPreferences; import net.sf.jabref.logic.importer.fileformat.CustomImporter; import net.sf.jabref.logic.importer.fileformat.ImportFormat; import net.sf.jabref.logic.l10n.Localization; import net.sf.jabref.logic.util.FileExtensions; -import net.sf.jabref.logic.xmp.XMPPreferences; import com.jgoodies.forms.builder.ButtonBarBuilder; import org.apache.commons.logging.Log; @@ -169,8 +167,8 @@ public ImportCustomizationDialog(final JabRefFrame frame) { customImporterTable.removeRowSelectionInterval(row, row); Globals.prefs.customImports .remove(((ImportTableModel) customImporterTable.getModel()).getImporter(row)); - Globals.IMPORT_FORMAT_READER.resetImportFormats(ImportFormatPreferences.fromPreferences(Globals.prefs), - XMPPreferences.fromPreferences(Globals.prefs)); + Globals.IMPORT_FORMAT_READER.resetImportFormats(Globals.prefs.getImportFormatPreferences(), + Globals.prefs.getXMPPreferences()); customImporterTable.revalidate(); customImporterTable.repaint(); } @@ -260,8 +258,8 @@ private static String pathToClass(File basePath, File path) { */ public void addOrReplaceImporter(CustomImporter importer) { Globals.prefs.customImports.replaceImporter(importer); - Globals.IMPORT_FORMAT_READER.resetImportFormats(ImportFormatPreferences.fromPreferences(Globals.prefs), - XMPPreferences.fromPreferences(Globals.prefs)); + Globals.IMPORT_FORMAT_READER.resetImportFormats(Globals.prefs.getImportFormatPreferences(), + Globals.prefs.getXMPPreferences()); ((ImportTableModel) customImporterTable.getModel()).fireTableDataChanged(); } diff --git a/src/main/java/net/sf/jabref/gui/importer/ImportInspectionDialog.java b/src/main/java/net/sf/jabref/gui/importer/ImportInspectionDialog.java index 76c0b108540..ffdf3107cea 100644 --- a/src/main/java/net/sf/jabref/gui/importer/ImportInspectionDialog.java +++ b/src/main/java/net/sf/jabref/gui/importer/ImportInspectionDialog.java @@ -80,7 +80,6 @@ import net.sf.jabref.gui.util.comparator.IconComparator; import net.sf.jabref.gui.util.component.CheckBoxMessage; import net.sf.jabref.logic.bibtex.comparator.FieldComparator; -import net.sf.jabref.logic.bibtexkeypattern.BibtexKeyPatternPreferences; import net.sf.jabref.logic.bibtexkeypattern.BibtexKeyPatternUtil; import net.sf.jabref.logic.groups.AllEntriesGroup; import net.sf.jabref.logic.groups.EntriesGroupChange; @@ -466,7 +465,7 @@ private void generateKeySelectedEntry() { // Generate a unique key: BibtexKeyPatternUtil.makeLabel(localMetaData, database, entry, - BibtexKeyPatternPreferences.fromPreferences(Globals.prefs)); + Globals.prefs.getBibtexKeyPatternPreferences()); // Remove the entry from the database again, since we only added it in // order to // make sure the key was unique: @@ -508,7 +507,7 @@ private void generateKeys() { database.insertEntry(entry); BibtexKeyPatternUtil.makeLabel(localMetaData, database, entry, - BibtexKeyPatternPreferences.fromPreferences(Globals.prefs)); + Globals.prefs.getBibtexKeyPatternPreferences()); // Add the generated key to our list: -- TODO: Why?? keys.add(entry.getCiteKeyOptional()); } diff --git a/src/main/java/net/sf/jabref/gui/importer/actions/AppendDatabaseAction.java b/src/main/java/net/sf/jabref/gui/importer/actions/AppendDatabaseAction.java index a949dd912d5..26d50f5cf73 100644 --- a/src/main/java/net/sf/jabref/gui/importer/actions/AppendDatabaseAction.java +++ b/src/main/java/net/sf/jabref/gui/importer/actions/AppendDatabaseAction.java @@ -21,7 +21,6 @@ import net.sf.jabref.logic.groups.AllEntriesGroup; import net.sf.jabref.logic.groups.ExplicitGroup; import net.sf.jabref.logic.groups.GroupHierarchyType; -import net.sf.jabref.logic.importer.ImportFormatPreferences; import net.sf.jabref.logic.importer.OpenDatabase; import net.sf.jabref.logic.importer.ParserResult; import net.sf.jabref.logic.importer.util.ParseException; @@ -87,7 +86,7 @@ private void openIt(boolean importEntries, boolean importStrings, boolean import Globals.prefs.put(JabRefPreferences.WORKING_DIRECTORY, file.getParent()); // Should this be done _after_ we know it was successfully opened? ParserResult pr = OpenDatabase.loadDatabase(file, - ImportFormatPreferences.fromPreferences(Globals.prefs)); + Globals.prefs.getImportFormatPreferences()); AppendDatabaseAction.mergeFromBibtex(frame, panel, pr, importEntries, importStrings, importGroups, importSelectorWords); panel.output(Localization.lang("Imported from database") + " '" + file.getPath() + "'"); diff --git a/src/main/java/net/sf/jabref/gui/importer/actions/OpenDatabaseAction.java b/src/main/java/net/sf/jabref/gui/importer/actions/OpenDatabaseAction.java index becbf26b1a2..f4348bef785 100644 --- a/src/main/java/net/sf/jabref/gui/importer/actions/OpenDatabaseAction.java +++ b/src/main/java/net/sf/jabref/gui/importer/actions/OpenDatabaseAction.java @@ -27,7 +27,6 @@ import net.sf.jabref.gui.actions.MnemonicAwareAction; import net.sf.jabref.gui.importer.ParserResultWarningDialog; import net.sf.jabref.gui.keyboard.KeyBinding; -import net.sf.jabref.logic.importer.ImportFormatPreferences; import net.sf.jabref.logic.importer.OpenDatabase; import net.sf.jabref.logic.importer.ParserResult; import net.sf.jabref.logic.l10n.Localization; @@ -234,7 +233,7 @@ private void openTheFile(File file, boolean raisePanel) { String errorMessage = null; try { result = OpenDatabase.loadDatabase(fileToLoad, - ImportFormatPreferences.fromPreferences(Globals.prefs)); + Globals.prefs.getImportFormatPreferences()); } catch (IOException ex) { LOGGER.error("Error loading database " + fileToLoad, ex); result = ParserResult.getNullResult(); diff --git a/src/main/java/net/sf/jabref/gui/importer/fetcher/ACMPortalFetcher.java b/src/main/java/net/sf/jabref/gui/importer/fetcher/ACMPortalFetcher.java index f51186c4dbc..ffb8cbba8c9 100644 --- a/src/main/java/net/sf/jabref/gui/importer/fetcher/ACMPortalFetcher.java +++ b/src/main/java/net/sf/jabref/gui/importer/fetcher/ACMPortalFetcher.java @@ -31,7 +31,6 @@ import net.sf.jabref.logic.formatter.bibtexfields.UnitsToLatexFormatter; import net.sf.jabref.logic.formatter.casechanger.ProtectTermsFormatter; import net.sf.jabref.logic.help.HelpFile; -import net.sf.jabref.logic.importer.ImportFormatPreferences; import net.sf.jabref.logic.importer.ImportInspector; import net.sf.jabref.logic.importer.OutputPrinter; import net.sf.jabref.logic.importer.fileformat.BibtexParser; @@ -324,7 +323,7 @@ private static Optional downloadEntryBibTeX(String id, boolean downloa Collection items = null; try (BufferedReader in = new BufferedReader( new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8))) { - items = BibtexParser.parse(in, ImportFormatPreferences.fromPreferences(Globals.prefs)).getDatabase() + items = BibtexParser.parse(in, Globals.prefs.getImportFormatPreferences()).getDatabase() .getEntries(); } catch (IOException e) { LOGGER.info("Download of BibTeX information from ACM Portal failed.", e); diff --git a/src/main/java/net/sf/jabref/gui/importer/fetcher/ADSFetcher.java b/src/main/java/net/sf/jabref/gui/importer/fetcher/ADSFetcher.java index 79d2740c9bf..dd124b576bd 100644 --- a/src/main/java/net/sf/jabref/gui/importer/fetcher/ADSFetcher.java +++ b/src/main/java/net/sf/jabref/gui/importer/fetcher/ADSFetcher.java @@ -17,7 +17,6 @@ import net.sf.jabref.Globals; import net.sf.jabref.logic.help.HelpFile; -import net.sf.jabref.logic.importer.ImportFormatPreferences; import net.sf.jabref.logic.importer.ImportInspector; import net.sf.jabref.logic.importer.OutputPrinter; import net.sf.jabref.logic.importer.ParserResult; @@ -96,7 +95,7 @@ private BibDatabase importADSEntries(String key, OutputPrinter status) { ADSConnection.setRequestProperty("User-Agent", "JabRef"); try (BufferedReader reader = new BufferedReader( new InputStreamReader(ADSConnection.getInputStream(), Charset.forName("ISO-8859-1")))) { - ParserResult pr = BibtexParser.parse(reader, ImportFormatPreferences.fromPreferences(Globals.prefs)); + ParserResult pr = BibtexParser.parse(reader, Globals.prefs.getImportFormatPreferences()); return pr.getDatabase(); } } catch (FileNotFoundException e) { diff --git a/src/main/java/net/sf/jabref/gui/importer/fetcher/DBLPFetcher.java b/src/main/java/net/sf/jabref/gui/importer/fetcher/DBLPFetcher.java index 2a640a6b68b..33d69781298 100644 --- a/src/main/java/net/sf/jabref/gui/importer/fetcher/DBLPFetcher.java +++ b/src/main/java/net/sf/jabref/gui/importer/fetcher/DBLPFetcher.java @@ -10,7 +10,6 @@ import net.sf.jabref.Globals; import net.sf.jabref.logic.help.HelpFile; -import net.sf.jabref.logic.importer.ImportFormatPreferences; import net.sf.jabref.logic.importer.ImportInspector; import net.sf.jabref.logic.importer.OutputPrinter; import net.sf.jabref.logic.importer.fileformat.BibtexParser; @@ -32,7 +31,7 @@ public class DBLPFetcher implements EntryFetcher { private volatile boolean shouldContinue; private String query; - private final DBLPHelper helper = new DBLPHelper(ImportFormatPreferences.fromPreferences(Globals.prefs)); + private final DBLPHelper helper = new DBLPHelper(Globals.prefs.getImportFormatPreferences()); @Override @@ -106,7 +105,7 @@ public boolean processQuery(String newQuery, ImportInspector inspector, .downloadToString(Globals.prefs.getDefaultEncoding()); Collection bibtexEntries = BibtexParser.fromString(bibtexPage, - ImportFormatPreferences.fromPreferences(Globals.prefs)); + Globals.prefs.getImportFormatPreferences()); for (BibEntry be : bibtexEntries) { diff --git a/src/main/java/net/sf/jabref/gui/importer/fetcher/DOItoBibTeXFetcher.java b/src/main/java/net/sf/jabref/gui/importer/fetcher/DOItoBibTeXFetcher.java index e3aa02fbef5..eee8a9b1ffe 100644 --- a/src/main/java/net/sf/jabref/gui/importer/fetcher/DOItoBibTeXFetcher.java +++ b/src/main/java/net/sf/jabref/gui/importer/fetcher/DOItoBibTeXFetcher.java @@ -6,7 +6,6 @@ import net.sf.jabref.Globals; import net.sf.jabref.logic.help.HelpFile; -import net.sf.jabref.logic.importer.ImportFormatPreferences; import net.sf.jabref.logic.importer.ImportInspector; import net.sf.jabref.logic.importer.OutputPrinter; import net.sf.jabref.logic.importer.ParserResult; @@ -25,7 +24,7 @@ public void stopFetching() { public boolean processQuery(String query, ImportInspector inspector, OutputPrinter status) { ParserResult parserResult = new ParserResult(); Optional entry = DOItoBibTeX.getEntryFromDOI(query, parserResult, - ImportFormatPreferences.fromPreferences(Globals.prefs)); + Globals.prefs.getImportFormatPreferences()); if (parserResult.hasWarnings()) { status.showMessage(parserResult.getErrorMessage()); } diff --git a/src/main/java/net/sf/jabref/gui/importer/fetcher/DiVAtoBibTeXFetcher.java b/src/main/java/net/sf/jabref/gui/importer/fetcher/DiVAtoBibTeXFetcher.java index ba844e5a570..84738a2562a 100644 --- a/src/main/java/net/sf/jabref/gui/importer/fetcher/DiVAtoBibTeXFetcher.java +++ b/src/main/java/net/sf/jabref/gui/importer/fetcher/DiVAtoBibTeXFetcher.java @@ -17,7 +17,6 @@ import net.sf.jabref.logic.formatter.bibtexfields.UnitsToLatexFormatter; import net.sf.jabref.logic.formatter.casechanger.ProtectTermsFormatter; import net.sf.jabref.logic.help.HelpFile; -import net.sf.jabref.logic.importer.ImportFormatPreferences; import net.sf.jabref.logic.importer.ImportInspector; import net.sf.jabref.logic.importer.OutputPrinter; import net.sf.jabref.logic.importer.fileformat.BibtexParser; @@ -82,7 +81,7 @@ public boolean processQuery(String query, ImportInspector inspector, OutputPrint } Optional entry = BibtexParser.singleFromString(bibtexString, - ImportFormatPreferences.fromPreferences(Globals.prefs)); + Globals.prefs.getImportFormatPreferences()); if (entry.isPresent()) { // Optionally add curly brackets around key words to keep the case entry.get().getFieldOptional(FieldName.TITLE).ifPresent(title -> { diff --git a/src/main/java/net/sf/jabref/gui/importer/fetcher/GoogleScholarFetcher.java b/src/main/java/net/sf/jabref/gui/importer/fetcher/GoogleScholarFetcher.java index 1effe29d1b1..3ab5980c535 100644 --- a/src/main/java/net/sf/jabref/gui/importer/fetcher/GoogleScholarFetcher.java +++ b/src/main/java/net/sf/jabref/gui/importer/fetcher/GoogleScholarFetcher.java @@ -20,7 +20,6 @@ import net.sf.jabref.Globals; import net.sf.jabref.gui.importer.FetcherPreviewDialog; import net.sf.jabref.logic.help.HelpFile; -import net.sf.jabref.logic.importer.ImportFormatPreferences; import net.sf.jabref.logic.importer.ImportInspector; import net.sf.jabref.logic.importer.OutputPrinter; import net.sf.jabref.logic.importer.ParserResult; @@ -244,7 +243,7 @@ private BibEntry downloadEntry(String link) throws IOException { try { String s = new URLDownload(link).downloadToString(StandardCharsets.UTF_8); BibtexParser bp = new BibtexParser(new StringReader(s), - ImportFormatPreferences.fromPreferences(Globals.prefs)); + Globals.prefs.getImportFormatPreferences()); ParserResult pr = bp.parse(); if ((pr != null) && (pr.getDatabase() != null)) { Collection entries = pr.getDatabase().getEntries(); diff --git a/src/main/java/net/sf/jabref/gui/importer/fetcher/IEEEXploreFetcher.java b/src/main/java/net/sf/jabref/gui/importer/fetcher/IEEEXploreFetcher.java index f84b5946490..8261dd732f0 100644 --- a/src/main/java/net/sf/jabref/gui/importer/fetcher/IEEEXploreFetcher.java +++ b/src/main/java/net/sf/jabref/gui/importer/fetcher/IEEEXploreFetcher.java @@ -26,12 +26,10 @@ import net.sf.jabref.logic.formatter.bibtexfields.UnitsToLatexFormatter; import net.sf.jabref.logic.formatter.casechanger.ProtectTermsFormatter; import net.sf.jabref.logic.help.HelpFile; -import net.sf.jabref.logic.importer.ImportFormatPreferences; import net.sf.jabref.logic.importer.ImportInspector; import net.sf.jabref.logic.importer.OutputPrinter; import net.sf.jabref.logic.importer.fileformat.BibtexParser; import net.sf.jabref.logic.journals.JournalAbbreviationLoader; -import net.sf.jabref.logic.journals.JournalAbbreviationPreferences; import net.sf.jabref.logic.l10n.Localization; import net.sf.jabref.logic.net.URLDownload; import net.sf.jabref.model.entry.BibEntry; @@ -151,7 +149,7 @@ public boolean processQuery(String query, ImportInspector dialog, OutputPrinter //parse the page into Bibtex entries Collection parsedBibtexCollection = BibtexParser.fromString(bibtexPage, - ImportFormatPreferences.fromPreferences(Globals.prefs)); + Globals.prefs.getImportFormatPreferences()); if (parsedBibtexCollection == null) { status.showMessage(Localization.lang("Error while fetching from %0", getTitle()), DIALOG_TITLE, JOptionPane.INFORMATION_MESSAGE); @@ -421,7 +419,7 @@ private BibEntry cleanup(BibEntry entry) { fullName = fullName.trim(); if (Globals.prefs.getBoolean(JabRefPreferences.USE_IEEE_ABRV)) { fullName = abbreviationLoader - .getRepository(JournalAbbreviationPreferences.fromPreferences(Globals.prefs)) + .getRepository(Globals.prefs.getJournalAbbreviationPreferences()) .getMedlineAbbreviation(fullName) .orElse(fullName); } diff --git a/src/main/java/net/sf/jabref/gui/importer/fetcher/INSPIREFetcher.java b/src/main/java/net/sf/jabref/gui/importer/fetcher/INSPIREFetcher.java index 7ff94593ea5..4bc6203c812 100644 --- a/src/main/java/net/sf/jabref/gui/importer/fetcher/INSPIREFetcher.java +++ b/src/main/java/net/sf/jabref/gui/importer/fetcher/INSPIREFetcher.java @@ -15,7 +15,6 @@ import net.sf.jabref.Globals; import net.sf.jabref.logic.help.HelpFile; -import net.sf.jabref.logic.importer.ImportFormatPreferences; import net.sf.jabref.logic.importer.ImportInspector; import net.sf.jabref.logic.importer.OutputPrinter; import net.sf.jabref.logic.importer.ParserResult; @@ -111,7 +110,7 @@ private BibDatabase importInspireEntries(String key, OutputPrinter frame) { try (INSPIREBibtexFilterReader reader = new INSPIREBibtexFilterReader( new InputStreamReader(inputStream, Charset.forName("UTF-8")))) { - ParserResult pr = BibtexParser.parse(reader, ImportFormatPreferences.fromPreferences(Globals.prefs)); + ParserResult pr = BibtexParser.parse(reader, Globals.prefs.getImportFormatPreferences()); return pr.getDatabase(); } diff --git a/src/main/java/net/sf/jabref/gui/importer/fetcher/ISBNtoBibTeXFetcher.java b/src/main/java/net/sf/jabref/gui/importer/fetcher/ISBNtoBibTeXFetcher.java index 5158fc34878..9feb0fbc9c2 100644 --- a/src/main/java/net/sf/jabref/gui/importer/fetcher/ISBNtoBibTeXFetcher.java +++ b/src/main/java/net/sf/jabref/gui/importer/fetcher/ISBNtoBibTeXFetcher.java @@ -17,7 +17,6 @@ import net.sf.jabref.logic.formatter.bibtexfields.UnitsToLatexFormatter; import net.sf.jabref.logic.formatter.casechanger.ProtectTermsFormatter; import net.sf.jabref.logic.help.HelpFile; -import net.sf.jabref.logic.importer.ImportFormatPreferences; import net.sf.jabref.logic.importer.ImportInspector; import net.sf.jabref.logic.importer.OutputPrinter; import net.sf.jabref.logic.importer.fileformat.BibtexParser; @@ -89,7 +88,7 @@ public Optional getEntryFromISBN(String query, OutputPrinter status) { } Optional bibEntry = BibtexParser.singleFromString(bibtexString, - ImportFormatPreferences.fromPreferences(Globals.prefs)); + Globals.prefs.getImportFormatPreferences()); bibEntry.ifPresent(entry -> { // Remove the added " Seiten" from the "pagetotal" field entry.getFieldOptional(FieldName.PAGETOTAL) diff --git a/src/main/java/net/sf/jabref/gui/importer/fetcher/ScienceDirectFetcher.java b/src/main/java/net/sf/jabref/gui/importer/fetcher/ScienceDirectFetcher.java index 7f4019a24dd..a51a386e619 100644 --- a/src/main/java/net/sf/jabref/gui/importer/fetcher/ScienceDirectFetcher.java +++ b/src/main/java/net/sf/jabref/gui/importer/fetcher/ScienceDirectFetcher.java @@ -13,7 +13,6 @@ import net.sf.jabref.Globals; import net.sf.jabref.logic.help.HelpFile; -import net.sf.jabref.logic.importer.ImportFormatPreferences; import net.sf.jabref.logic.importer.ImportInspector; import net.sf.jabref.logic.importer.OutputPrinter; import net.sf.jabref.logic.importer.fetcher.BibsonomyScraper; @@ -87,7 +86,7 @@ public boolean processQuery(String query, ImportInspector dialog, OutputPrinter if (stopFetching) { break; } - BibsonomyScraper.getEntry(cit, ImportFormatPreferences.fromPreferences(Globals.prefs)) + BibsonomyScraper.getEntry(cit, Globals.prefs.getImportFormatPreferences()) .ifPresent(dialog::addEntry); dialog.setProgress(++i, citations.size()); } diff --git a/src/main/java/net/sf/jabref/gui/importer/worker/AutosaveStartupPrompter.java b/src/main/java/net/sf/jabref/gui/importer/worker/AutosaveStartupPrompter.java index 2891dea6f82..d5ec184d1cb 100644 --- a/src/main/java/net/sf/jabref/gui/importer/worker/AutosaveStartupPrompter.java +++ b/src/main/java/net/sf/jabref/gui/importer/worker/AutosaveStartupPrompter.java @@ -13,7 +13,6 @@ import net.sf.jabref.gui.BasePanel; import net.sf.jabref.gui.JabRefFrame; import net.sf.jabref.gui.importer.ParserResultWarningDialog; -import net.sf.jabref.logic.importer.ImportFormatPreferences; import net.sf.jabref.logic.importer.OpenDatabase; import net.sf.jabref.logic.importer.ParserResult; import net.sf.jabref.logic.l10n.Localization; @@ -62,7 +61,7 @@ public void run() { ParserResult pr; do { pr = OpenDatabase.loadDatabaseOrAutoSave(fileToLoad.getPath(), true, - ImportFormatPreferences.fromPreferences(Globals.prefs)); + Globals.prefs.getImportFormatPreferences()); if (pr.isInvalid()) { loaded.add(pr); BibDatabaseContext databaseContext = pr.getDatabaseContext(); diff --git a/src/main/java/net/sf/jabref/gui/journals/AbbreviateAction.java b/src/main/java/net/sf/jabref/gui/journals/AbbreviateAction.java index 489bd0dfd64..1e5e78b72be 100644 --- a/src/main/java/net/sf/jabref/gui/journals/AbbreviateAction.java +++ b/src/main/java/net/sf/jabref/gui/journals/AbbreviateAction.java @@ -6,7 +6,6 @@ import net.sf.jabref.gui.BasePanel; import net.sf.jabref.gui.undo.NamedCompound; import net.sf.jabref.gui.worker.AbstractWorker; -import net.sf.jabref.logic.journals.JournalAbbreviationPreferences; import net.sf.jabref.logic.l10n.Localization; import net.sf.jabref.model.entry.BibEntry; import net.sf.jabref.model.entry.InternalBibtexFields; @@ -39,7 +38,7 @@ public void run() { } UndoableAbbreviator undoableAbbreviator = new UndoableAbbreviator(Globals.journalAbbreviationLoader - .getRepository(JournalAbbreviationPreferences.fromPreferences(Globals.prefs)), iso); + .getRepository(Globals.prefs.getJournalAbbreviationPreferences()), iso); NamedCompound ce = new NamedCompound(Localization.lang("Abbreviate journal names")); int count = 0; diff --git a/src/main/java/net/sf/jabref/gui/journals/ManageJournalsPanel.java b/src/main/java/net/sf/jabref/gui/journals/ManageJournalsPanel.java index 907b06e26e2..de6bb333af2 100644 --- a/src/main/java/net/sf/jabref/gui/journals/ManageJournalsPanel.java +++ b/src/main/java/net/sf/jabref/gui/journals/ManageJournalsPanel.java @@ -54,7 +54,6 @@ import net.sf.jabref.logic.help.HelpFile; import net.sf.jabref.logic.journals.Abbreviation; import net.sf.jabref.logic.journals.JournalAbbreviationLoader; -import net.sf.jabref.logic.journals.JournalAbbreviationPreferences; import net.sf.jabref.logic.l10n.Localization; import net.sf.jabref.logic.util.OS; import net.sf.jabref.preferences.JabRefPreferences; @@ -175,7 +174,7 @@ public ManageJournalsPanel(final JabRefFrame frame) { viewBuiltin.addActionListener(e -> { JTable table = new JTable(JournalAbbreviationsUtil.getTableModel(Globals.journalAbbreviationLoader - .getRepository(JournalAbbreviationPreferences.fromPreferences(Globals.prefs)).getAbbreviations())); + .getRepository(Globals.prefs.getJournalAbbreviationPreferences()).getAbbreviations())); GUIUtil.correctRowHeight(table); JScrollPane pane = new JScrollPane(table); @@ -379,7 +378,7 @@ private void storeSettings() { Globals.prefs.putStringList(JabRefPreferences.EXTERNAL_JOURNAL_LISTS, extFiles); // Update journal abbreviation loader - Globals.journalAbbreviationLoader.update(JournalAbbreviationPreferences.fromPreferences(Globals.prefs)); + Globals.journalAbbreviationLoader.update(Globals.prefs.getJournalAbbreviationPreferences()); } diff --git a/src/main/java/net/sf/jabref/gui/journals/UnabbreviateAction.java b/src/main/java/net/sf/jabref/gui/journals/UnabbreviateAction.java index 9486ac3455f..1e8c12992b1 100644 --- a/src/main/java/net/sf/jabref/gui/journals/UnabbreviateAction.java +++ b/src/main/java/net/sf/jabref/gui/journals/UnabbreviateAction.java @@ -6,7 +6,6 @@ import net.sf.jabref.gui.BasePanel; import net.sf.jabref.gui.undo.NamedCompound; import net.sf.jabref.gui.worker.AbstractWorker; -import net.sf.jabref.logic.journals.JournalAbbreviationPreferences; import net.sf.jabref.logic.l10n.Localization; import net.sf.jabref.model.entry.BibEntry; import net.sf.jabref.model.entry.InternalBibtexFields; @@ -37,7 +36,7 @@ public void run() { } UndoableUnabbreviator undoableAbbreviator = new UndoableUnabbreviator(Globals.journalAbbreviationLoader - .getRepository(JournalAbbreviationPreferences.fromPreferences(Globals.prefs))); + .getRepository(Globals.prefs.getJournalAbbreviationPreferences())); NamedCompound ce = new NamedCompound(Localization.lang("Unabbreviate journal names")); int count = 0; diff --git a/src/main/java/net/sf/jabref/gui/mergeentries/FetchAndMergeEntry.java b/src/main/java/net/sf/jabref/gui/mergeentries/FetchAndMergeEntry.java index a66b536e0a5..e579e80e2fc 100644 --- a/src/main/java/net/sf/jabref/gui/mergeentries/FetchAndMergeEntry.java +++ b/src/main/java/net/sf/jabref/gui/mergeentries/FetchAndMergeEntry.java @@ -9,7 +9,6 @@ import net.sf.jabref.gui.BasePanel; import net.sf.jabref.gui.importer.fetcher.ISBNtoBibTeXFetcher; import net.sf.jabref.logic.importer.FetcherException; -import net.sf.jabref.logic.importer.ImportFormatPreferences; import net.sf.jabref.logic.importer.fetcher.ArXiv; import net.sf.jabref.logic.importer.fetcher.DOItoBibTeX; import net.sf.jabref.logic.l10n.Localization; @@ -56,7 +55,7 @@ public FetchAndMergeEntry(BibEntry entry, BasePanel panel, List fields) // Get entry based on field if (FieldName.DOI.equals(field)) { fetchedEntry = new DOItoBibTeX().getEntryFromDOI(fieldContent.get(), - ImportFormatPreferences.fromPreferences(Globals.prefs)); + Globals.prefs.getImportFormatPreferences()); } else if (FieldName.ISBN.equals(field)) { fetchedEntry = new ISBNtoBibTeXFetcher().getEntryFromISBN(fieldContent.get(), null); } else if (FieldName.EPRINT.equals(field)) { diff --git a/src/main/java/net/sf/jabref/gui/mergeentries/MergeEntries.java b/src/main/java/net/sf/jabref/gui/mergeentries/MergeEntries.java index 5eeb83ec8d0..0c8dc2ff0fd 100644 --- a/src/main/java/net/sf/jabref/gui/mergeentries/MergeEntries.java +++ b/src/main/java/net/sf/jabref/gui/mergeentries/MergeEntries.java @@ -31,7 +31,6 @@ import net.sf.jabref.gui.util.component.DiffHighlightingTextPane; import net.sf.jabref.logic.bibtex.BibEntryWriter; import net.sf.jabref.logic.bibtex.LatexFieldFormatter; -import net.sf.jabref.logic.bibtex.LatexFieldFormatterPreferences; import net.sf.jabref.logic.formatter.casechanger.SentenceCaseFormatter; import net.sf.jabref.logic.l10n.Localization; import net.sf.jabref.logic.util.strings.DiffHighlighting; @@ -442,7 +441,7 @@ private void updateAll() { // Update the BibTeX source view StringWriter writer = new StringWriter(); try { - new BibEntryWriter(new LatexFieldFormatter(LatexFieldFormatterPreferences.fromPreferences(Globals.prefs)), + new BibEntryWriter(new LatexFieldFormatter(Globals.prefs.getLatexFieldFormatterPreferences()), false).write(mergedEntry, writer, databaseType); } catch (IOException ex) { LOGGER.error("Error in entry", ex); diff --git a/src/main/java/net/sf/jabref/gui/openoffice/OpenOfficePanel.java b/src/main/java/net/sf/jabref/gui/openoffice/OpenOfficePanel.java index fc5d266fccc..d2e5fd9b8d4 100644 --- a/src/main/java/net/sf/jabref/gui/openoffice/OpenOfficePanel.java +++ b/src/main/java/net/sf/jabref/gui/openoffice/OpenOfficePanel.java @@ -49,7 +49,6 @@ import net.sf.jabref.logic.bibtexkeypattern.BibtexKeyPatternUtil; import net.sf.jabref.logic.help.HelpFile; import net.sf.jabref.logic.l10n.Localization; -import net.sf.jabref.logic.layout.LayoutFormatterPreferences; import net.sf.jabref.logic.openoffice.OOBibStyle; import net.sf.jabref.logic.openoffice.OpenOfficePreferences; import net.sf.jabref.logic.openoffice.StyleLoader; @@ -133,7 +132,7 @@ private OpenOfficePanel() { update.setPreferredSize(new Dimension(24, 24)); preferences = new OpenOfficePreferences(Globals.prefs); loader = new StyleLoader(preferences, - LayoutFormatterPreferences.fromPreferences(Globals.prefs, Globals.journalAbbreviationLoader), + Globals.prefs.getLayoutFormatterPreferences(Globals.journalAbbreviationLoader), Globals.prefs.getDefaultEncoding()); } @@ -700,7 +699,7 @@ private boolean checkThatEntriesHaveKeys(List entries) { BasePanel panel = frame.getCurrentBasePanel(); if ((answer == JOptionPane.OK_OPTION) && (panel != null)) { // Generate keys - BibtexKeyPatternPreferences prefs = BibtexKeyPatternPreferences.fromPreferences(Globals.prefs); + BibtexKeyPatternPreferences prefs = Globals.prefs.getBibtexKeyPatternPreferences(); NamedCompound undoCompound = new NamedCompound(Localization.lang("Cite")); for (BibEntry entry : entries) { if (!entry.getCiteKeyOptional().isPresent()) { diff --git a/src/main/java/net/sf/jabref/gui/plaintextimport/TextInputDialog.java b/src/main/java/net/sf/jabref/gui/plaintextimport/TextInputDialog.java index e292ae47605..e63d4f4e571 100644 --- a/src/main/java/net/sf/jabref/gui/plaintextimport/TextInputDialog.java +++ b/src/main/java/net/sf/jabref/gui/plaintextimport/TextInputDialog.java @@ -70,8 +70,6 @@ import net.sf.jabref.gui.util.component.OverlayPanel; import net.sf.jabref.logic.bibtex.BibEntryWriter; import net.sf.jabref.logic.bibtex.LatexFieldFormatter; -import net.sf.jabref.logic.bibtex.LatexFieldFormatterPreferences; -import net.sf.jabref.logic.importer.ImportFormatPreferences; import net.sf.jabref.logic.importer.ParserResult; import net.sf.jabref.logic.importer.fileformat.FreeCiteImporter; import net.sf.jabref.logic.l10n.Localization; @@ -456,7 +454,7 @@ public boolean okPressed() { * @return true if successful, false otherwise */ private boolean parseWithFreeCiteAndAddEntries() { - FreeCiteImporter fimp = new FreeCiteImporter(ImportFormatPreferences.fromPreferences(Globals.prefs)); + FreeCiteImporter fimp = new FreeCiteImporter(Globals.prefs.getImportFormatPreferences()); String text = textPane.getText(); // we have to remove line breaks (but keep empty lines) @@ -493,7 +491,7 @@ private boolean parseWithFreeCiteAndAddEntries() { private void updateSourceView() { StringWriter sw = new StringWriter(200); try { - new BibEntryWriter(new LatexFieldFormatter(LatexFieldFormatterPreferences.fromPreferences(Globals.prefs)), + new BibEntryWriter(new LatexFieldFormatter(Globals.prefs.getLatexFieldFormatterPreferences()), false).write(entry, sw, frame.getCurrentBasePanel().getBibDatabaseContext().getMode()); sourcePreview.setText(sw.getBuffer().toString()); } catch (IOException ex) { diff --git a/src/main/java/net/sf/jabref/gui/preftabs/AdvancedTab.java b/src/main/java/net/sf/jabref/gui/preftabs/AdvancedTab.java index ff003d0d8f2..d9673afb07c 100644 --- a/src/main/java/net/sf/jabref/gui/preftabs/AdvancedTab.java +++ b/src/main/java/net/sf/jabref/gui/preftabs/AdvancedTab.java @@ -14,7 +14,6 @@ import net.sf.jabref.gui.help.HelpAction; import net.sf.jabref.gui.remote.JabRefMessageHandler; import net.sf.jabref.logic.help.HelpFile; -import net.sf.jabref.logic.journals.JournalAbbreviationPreferences; import net.sf.jabref.logic.l10n.Localization; import net.sf.jabref.logic.remote.RemotePreferences; import net.sf.jabref.logic.remote.RemoteUtil; @@ -105,7 +104,7 @@ public void setValues() { public void storeSettings() { if (preferences.getBoolean(JabRefPreferences.USE_IEEE_ABRV) != useIEEEAbrv.isSelected()) { preferences.putBoolean(JabRefPreferences.USE_IEEE_ABRV, useIEEEAbrv.isSelected()); - Globals.journalAbbreviationLoader.update(JournalAbbreviationPreferences.fromPreferences(preferences)); + Globals.journalAbbreviationLoader.update(Globals.prefs.getJournalAbbreviationPreferences()); } storeRemoteSettings(); diff --git a/src/main/java/net/sf/jabref/gui/preftabs/PreferencesDialog.java b/src/main/java/net/sf/jabref/gui/preftabs/PreferencesDialog.java index 340abaf18f3..3cf06359c1d 100644 --- a/src/main/java/net/sf/jabref/gui/preftabs/PreferencesDialog.java +++ b/src/main/java/net/sf/jabref/gui/preftabs/PreferencesDialog.java @@ -219,8 +219,8 @@ private void updateAfterPreferenceChanges() { setValues(); Map customFormats = Globals.prefs.customExports.getCustomExportFormats(Globals.prefs, Globals.journalAbbreviationLoader); - LayoutFormatterPreferences layoutPreferences = LayoutFormatterPreferences.fromPreferences(Globals.prefs, - Globals.journalAbbreviationLoader); + LayoutFormatterPreferences layoutPreferences = Globals.prefs + .getLayoutFormatterPreferences(Globals.journalAbbreviationLoader); SavePreferences savePreferences = SavePreferences.loadForExportFromPreferences(Globals.prefs); ExportFormats.initAllExports(customFormats, layoutPreferences, savePreferences); diff --git a/src/main/java/net/sf/jabref/gui/protectedterms/ProtectedTermsDialog.java b/src/main/java/net/sf/jabref/gui/protectedterms/ProtectedTermsDialog.java index b52b3d2301b..c867e2c76b3 100644 --- a/src/main/java/net/sf/jabref/gui/protectedterms/ProtectedTermsDialog.java +++ b/src/main/java/net/sf/jabref/gui/protectedterms/ProtectedTermsDialog.java @@ -49,7 +49,6 @@ import net.sf.jabref.logic.l10n.Localization; import net.sf.jabref.logic.protectedterms.ProtectedTermsList; import net.sf.jabref.logic.protectedterms.ProtectedTermsLoader; -import net.sf.jabref.logic.protectedterms.ProtectedTermsPreferences; import net.sf.jabref.logic.util.FileExtensions; import net.sf.jabref.model.entry.BibEntry; import net.sf.jabref.preferences.JabRefPreferences; @@ -152,7 +151,7 @@ public void actionPerformed(ActionEvent event) { @Override public void actionPerformed(ActionEvent event) { // Restore from preferences - loader.update(ProtectedTermsPreferences.fromPreferences(Globals.prefs)); + loader.update(Globals.prefs.getProtectedTermsPreferences()); diag.dispose(); } }; @@ -496,6 +495,6 @@ public Optional getFileName() { private void storePreferences() { - ProtectedTermsPreferences.toPreferences(Globals.prefs, loader); + Globals.prefs.setProtectedTermsPreferences(loader); } } diff --git a/src/main/java/net/sf/jabref/gui/worker/SendAsEMailAction.java b/src/main/java/net/sf/jabref/gui/worker/SendAsEMailAction.java index f2b18863d11..5e8144634af 100644 --- a/src/main/java/net/sf/jabref/gui/worker/SendAsEMailAction.java +++ b/src/main/java/net/sf/jabref/gui/worker/SendAsEMailAction.java @@ -15,7 +15,6 @@ import net.sf.jabref.gui.desktop.JabRefDesktop; import net.sf.jabref.logic.bibtex.BibEntryWriter; import net.sf.jabref.logic.bibtex.LatexFieldFormatter; -import net.sf.jabref.logic.bibtex.LatexFieldFormatterPreferences; import net.sf.jabref.logic.l10n.Localization; import net.sf.jabref.logic.util.io.FileUtil; import net.sf.jabref.model.entry.BibEntry; @@ -67,7 +66,7 @@ public void run() { // write the entries using sw, which is used later to form the email content BibEntryWriter bibtexEntryWriter = new BibEntryWriter( - new LatexFieldFormatter(LatexFieldFormatterPreferences.fromPreferences(Globals.prefs)), true); + new LatexFieldFormatter(Globals.prefs.getLatexFieldFormatterPreferences()), true); for (BibEntry entry : bes) { try { diff --git a/src/main/java/net/sf/jabref/logic/autocompleter/AutoCompletePreferences.java b/src/main/java/net/sf/jabref/logic/autocompleter/AutoCompletePreferences.java index 45ec40fd713..c567c48dec1 100644 --- a/src/main/java/net/sf/jabref/logic/autocompleter/AutoCompletePreferences.java +++ b/src/main/java/net/sf/jabref/logic/autocompleter/AutoCompletePreferences.java @@ -86,6 +86,6 @@ public void setCompleteNames(String value) { } public JournalAbbreviationPreferences getJournalAbbreviationPreferences() { - return JournalAbbreviationPreferences.fromPreferences(preferences); + return preferences.getJournalAbbreviationPreferences(); } } \ No newline at end of file diff --git a/src/main/java/net/sf/jabref/logic/bibtex/FieldContentParserPreferences.java b/src/main/java/net/sf/jabref/logic/bibtex/FieldContentParserPreferences.java index 486d2583340..d434082d288 100644 --- a/src/main/java/net/sf/jabref/logic/bibtex/FieldContentParserPreferences.java +++ b/src/main/java/net/sf/jabref/logic/bibtex/FieldContentParserPreferences.java @@ -3,8 +3,6 @@ import java.util.Collections; import java.util.List; -import net.sf.jabref.preferences.JabRefPreferences; - public class FieldContentParserPreferences { private final List nonWrappableFields; @@ -23,8 +21,4 @@ public List getNonWrappableFields() { return nonWrappableFields; } - public static FieldContentParserPreferences fromPreferences(JabRefPreferences jabRefPreferences) { - return new FieldContentParserPreferences( - jabRefPreferences.getStringList(JabRefPreferences.NON_WRAPPABLE_FIELDS)); - } } diff --git a/src/main/java/net/sf/jabref/logic/bibtex/LatexFieldFormatterPreferences.java b/src/main/java/net/sf/jabref/logic/bibtex/LatexFieldFormatterPreferences.java index 1cfa74979bd..57bd42adda2 100644 --- a/src/main/java/net/sf/jabref/logic/bibtex/LatexFieldFormatterPreferences.java +++ b/src/main/java/net/sf/jabref/logic/bibtex/LatexFieldFormatterPreferences.java @@ -3,8 +3,6 @@ import java.util.Collections; import java.util.List; -import net.sf.jabref.preferences.JabRefPreferences; - public class LatexFieldFormatterPreferences { private final boolean resolveStringsAllFields; @@ -25,12 +23,6 @@ public LatexFieldFormatterPreferences() { this(true, Collections.emptyList(), new FieldContentParserPreferences()); } - public static LatexFieldFormatterPreferences fromPreferences(JabRefPreferences prefs) { - return new LatexFieldFormatterPreferences(prefs.getBoolean(JabRefPreferences.RESOLVE_STRINGS_ALL_FIELDS), - prefs.getStringList(JabRefPreferences.DO_NOT_RESOLVE_STRINGS_FOR), - FieldContentParserPreferences.fromPreferences(prefs)); - } - public boolean isResolveStringsAllFields() { return resolveStringsAllFields; } diff --git a/src/main/java/net/sf/jabref/logic/bibtexkeypattern/BibtexKeyPatternPreferences.java b/src/main/java/net/sf/jabref/logic/bibtexkeypattern/BibtexKeyPatternPreferences.java index c158a08127c..d0027663c3f 100644 --- a/src/main/java/net/sf/jabref/logic/bibtexkeypattern/BibtexKeyPatternPreferences.java +++ b/src/main/java/net/sf/jabref/logic/bibtexkeypattern/BibtexKeyPatternPreferences.java @@ -1,7 +1,6 @@ package net.sf.jabref.logic.bibtexkeypattern; import net.sf.jabref.model.bibtexkeypattern.GlobalBibtexKeyPattern; -import net.sf.jabref.preferences.JabRefPreferences; public class BibtexKeyPatternPreferences { @@ -25,16 +24,6 @@ public BibtexKeyPatternPreferences(String defaultBibtexKeyPattern, String keyPat this.keyPattern = keyPattern; } - public static BibtexKeyPatternPreferences fromPreferences(JabRefPreferences jabRefPreferences) { - return new BibtexKeyPatternPreferences(jabRefPreferences.get(JabRefPreferences.DEFAULT_BIBTEX_KEY_PATTERN), - jabRefPreferences.get(JabRefPreferences.KEY_PATTERN_REGEX), - jabRefPreferences.get(JabRefPreferences.KEY_PATTERN_REPLACEMENT), - jabRefPreferences.getBoolean(JabRefPreferences.KEY_GEN_ALWAYS_ADD_LETTER), - jabRefPreferences.getBoolean(JabRefPreferences.KEY_GEN_FIRST_LETTER_A), - jabRefPreferences.getBoolean(JabRefPreferences.ENFORCE_LEGAL_BIBTEX_KEY), - jabRefPreferences.getKeyPattern()); - } - public String getKeyPatternRegex() { return keyPatternRegex; } diff --git a/src/main/java/net/sf/jabref/logic/exporter/CustomExportList.java b/src/main/java/net/sf/jabref/logic/exporter/CustomExportList.java index 8a6ce5c415e..aad6d7c0488 100644 --- a/src/main/java/net/sf/jabref/logic/exporter/CustomExportList.java +++ b/src/main/java/net/sf/jabref/logic/exporter/CustomExportList.java @@ -63,7 +63,7 @@ private void readPrefs(JabRefPreferences prefs, JournalAbbreviationLoader loader list.clear(); int i = 0; List s; - LayoutFormatterPreferences layoutPreferences = LayoutFormatterPreferences.fromPreferences(prefs, loader); + LayoutFormatterPreferences layoutPreferences = prefs.getLayoutFormatterPreferences(loader); SavePreferences savePreferences = SavePreferences.loadForExportFromPreferences(prefs); while (!((s = prefs.getStringList(JabRefPreferences.CUSTOM_EXPORT_FORMAT + i)).isEmpty())) { Optional format = createFormat(s, layoutPreferences, savePreferences); diff --git a/src/main/java/net/sf/jabref/logic/exporter/SavePreferences.java b/src/main/java/net/sf/jabref/logic/exporter/SavePreferences.java index 507aafa0783..854e7c15072 100644 --- a/src/main/java/net/sf/jabref/logic/exporter/SavePreferences.java +++ b/src/main/java/net/sf/jabref/logic/exporter/SavePreferences.java @@ -52,8 +52,7 @@ public static SavePreferences loadForExportFromPreferences(JabRefPreferences pre DatabaseSaveType saveType = DatabaseSaveType.ALL; Boolean takeMetadataSaveOrderInAccount = false; Boolean reformatFile = preferences.getBoolean(JabRefPreferences.REFORMAT_FILE_ON_SAVE_AND_EXPORT); - LatexFieldFormatterPreferences latexFieldFormatterPreferences = LatexFieldFormatterPreferences - .fromPreferences(preferences); + LatexFieldFormatterPreferences latexFieldFormatterPreferences = preferences.getLatexFieldFormatterPreferences(); return new SavePreferences(saveInOriginalOrder, saveOrder, encoding, makeBackup, saveType, takeMetadataSaveOrderInAccount, reformatFile, latexFieldFormatterPreferences); } @@ -66,8 +65,7 @@ public static SavePreferences loadForSaveFromPreferences(JabRefPreferences prefe DatabaseSaveType saveType = DatabaseSaveType.ALL; Boolean takeMetadataSaveOrderInAccount = true; Boolean reformatFile = preferences.getBoolean(JabRefPreferences.REFORMAT_FILE_ON_SAVE_AND_EXPORT); - LatexFieldFormatterPreferences latexFieldFormatterPreferences = LatexFieldFormatterPreferences - .fromPreferences(preferences); + LatexFieldFormatterPreferences latexFieldFormatterPreferences = preferences.getLatexFieldFormatterPreferences(); return new SavePreferences(saveInOriginalOrder, saveOrder, encoding, makeBackup, saveType, takeMetadataSaveOrderInAccount, reformatFile, latexFieldFormatterPreferences); } diff --git a/src/main/java/net/sf/jabref/logic/importer/ImportFormatPreferences.java b/src/main/java/net/sf/jabref/logic/importer/ImportFormatPreferences.java index 97c9debe070..a3810a0e993 100644 --- a/src/main/java/net/sf/jabref/logic/importer/ImportFormatPreferences.java +++ b/src/main/java/net/sf/jabref/logic/importer/ImportFormatPreferences.java @@ -6,7 +6,6 @@ import net.sf.jabref.logic.bibtex.FieldContentParserPreferences; import net.sf.jabref.logic.bibtexkeypattern.BibtexKeyPatternPreferences; import net.sf.jabref.logic.importer.fileformat.CustomImporter; -import net.sf.jabref.preferences.JabRefPreferences; public class ImportFormatPreferences { @@ -69,13 +68,4 @@ public ImportFormatPreferences withEncoding(Charset newEncoding) { return new ImportFormatPreferences(customImportList, newEncoding, keywordSeparator, bibtexKeyPatternPreferences, fieldContentParserPreferences, convertUnitsOnSearch, useCaseKeeperOnSearch); } - - static public ImportFormatPreferences fromPreferences(JabRefPreferences jabRefPreferences) { - return new ImportFormatPreferences(jabRefPreferences.customImports, jabRefPreferences.getDefaultEncoding(), - jabRefPreferences.get(JabRefPreferences.KEYWORD_SEPARATOR), - BibtexKeyPatternPreferences.fromPreferences(jabRefPreferences), - FieldContentParserPreferences.fromPreferences(jabRefPreferences), - jabRefPreferences.getBoolean(JabRefPreferences.USE_UNIT_FORMATTER_ON_SEARCH), - jabRefPreferences.getBoolean(JabRefPreferences.USE_CASE_KEEPER_ON_SEARCH)); - } } diff --git a/src/main/java/net/sf/jabref/logic/journals/JournalAbbreviationPreferences.java b/src/main/java/net/sf/jabref/logic/journals/JournalAbbreviationPreferences.java index 3ba35a8b3b2..d79d3e6d4e7 100644 --- a/src/main/java/net/sf/jabref/logic/journals/JournalAbbreviationPreferences.java +++ b/src/main/java/net/sf/jabref/logic/journals/JournalAbbreviationPreferences.java @@ -3,8 +3,6 @@ import java.nio.charset.Charset; import java.util.List; -import net.sf.jabref.preferences.JabRefPreferences; - public class JournalAbbreviationPreferences { private final List externalJournalLists; @@ -21,13 +19,6 @@ public JournalAbbreviationPreferences(List externalJournalLists, String this.defaultEncoding = defaultEncoding; } - public static JournalAbbreviationPreferences fromPreferences(JabRefPreferences jabRefPreferences) { - return new JournalAbbreviationPreferences( - jabRefPreferences.getStringList(JabRefPreferences.EXTERNAL_JOURNAL_LISTS), - jabRefPreferences.get(JabRefPreferences.PERSONAL_JOURNAL_LIST), - jabRefPreferences.getBoolean(JabRefPreferences.USE_IEEE_ABRV), jabRefPreferences.getDefaultEncoding()); - } - public List getExternalJournalLists() { return externalJournalLists; } diff --git a/src/main/java/net/sf/jabref/logic/layout/LayoutFormatterPreferences.java b/src/main/java/net/sf/jabref/logic/layout/LayoutFormatterPreferences.java index f28dde68c06..a35362bf7d6 100644 --- a/src/main/java/net/sf/jabref/logic/layout/LayoutFormatterPreferences.java +++ b/src/main/java/net/sf/jabref/logic/layout/LayoutFormatterPreferences.java @@ -2,14 +2,12 @@ import java.util.HashMap; import java.util.Map; -import java.util.Objects; import java.util.Optional; import net.sf.jabref.logic.journals.JournalAbbreviationLoader; import net.sf.jabref.logic.journals.JournalAbbreviationPreferences; import net.sf.jabref.logic.layout.format.FileLinkPreferences; import net.sf.jabref.logic.layout.format.NameFormatterPreferences; -import net.sf.jabref.preferences.JabRefPreferences; public class LayoutFormatterPreferences { @@ -28,16 +26,6 @@ public LayoutFormatterPreferences(NameFormatterPreferences nameFormatterPreferen this.journalAbbreviationLoader = journalAbbreviationLoader; } - public static LayoutFormatterPreferences fromPreferences(JabRefPreferences jabRefPreferences, - JournalAbbreviationLoader journalAbbreviationLoader) { - Objects.requireNonNull(jabRefPreferences); - Objects.requireNonNull(journalAbbreviationLoader); - return new LayoutFormatterPreferences(NameFormatterPreferences.fromPreferences(jabRefPreferences), - JournalAbbreviationPreferences.fromPreferences(jabRefPreferences), - FileLinkPreferences.fromPreferences(jabRefPreferences), - journalAbbreviationLoader); - } - public NameFormatterPreferences getNameFormatterPreferences() { return nameFormatterPreferences; } diff --git a/src/main/java/net/sf/jabref/logic/layout/format/FileLinkPreferences.java b/src/main/java/net/sf/jabref/logic/layout/format/FileLinkPreferences.java index 3f87e1f56f6..9032934e782 100644 --- a/src/main/java/net/sf/jabref/logic/layout/format/FileLinkPreferences.java +++ b/src/main/java/net/sf/jabref/logic/layout/format/FileLinkPreferences.java @@ -1,11 +1,7 @@ package net.sf.jabref.logic.layout.format; -import java.util.Collections; import java.util.List; -import net.sf.jabref.model.entry.FieldName; -import net.sf.jabref.preferences.JabRefPreferences; - public class FileLinkPreferences { private final List generatedDirForDatabase; @@ -18,11 +14,6 @@ public FileLinkPreferences(List generatedDirForDatabase, List fi this.fileDirForDatabase = fileDirForDatabase; } - public static FileLinkPreferences fromPreferences(JabRefPreferences prefs) { - return new FileLinkPreferences(Collections.singletonList(prefs.get(FieldName.FILE + FileLinkPreferences.DIR_SUFFIX)), - prefs.fileDirForDatabase); - } - public List getGeneratedDirForDatabase() { return generatedDirForDatabase; } diff --git a/src/main/java/net/sf/jabref/logic/layout/format/NameFormatterPreferences.java b/src/main/java/net/sf/jabref/logic/layout/format/NameFormatterPreferences.java index 2c6a9b748b8..536fb418da2 100644 --- a/src/main/java/net/sf/jabref/logic/layout/format/NameFormatterPreferences.java +++ b/src/main/java/net/sf/jabref/logic/layout/format/NameFormatterPreferences.java @@ -2,8 +2,6 @@ import java.util.List; -import net.sf.jabref.preferences.JabRefPreferences; - public class NameFormatterPreferences { private final List nameFormatterKey; @@ -15,11 +13,6 @@ public NameFormatterPreferences(List nameFormatterKey, List name this.nameFormatterValue = nameFormatterValue; } - public static NameFormatterPreferences fromPreferences(JabRefPreferences jabRefPreferences) { - return new NameFormatterPreferences(jabRefPreferences.getStringList(NameFormatter.NAME_FORMATER_KEY), - jabRefPreferences.getStringList(NameFormatter.NAME_FORMATTER_VALUE)); - } - public List getNameFormatterKey() { return nameFormatterKey; } diff --git a/src/main/java/net/sf/jabref/logic/protectedterms/ProtectedTermsPreferences.java b/src/main/java/net/sf/jabref/logic/protectedterms/ProtectedTermsPreferences.java index e10fecc68c7..fe1c742b50e 100644 --- a/src/main/java/net/sf/jabref/logic/protectedterms/ProtectedTermsPreferences.java +++ b/src/main/java/net/sf/jabref/logic/protectedterms/ProtectedTermsPreferences.java @@ -1,10 +1,7 @@ package net.sf.jabref.logic.protectedterms; -import java.util.ArrayList; import java.util.List; -import net.sf.jabref.preferences.JabRefPreferences; - public class ProtectedTermsPreferences { private final List enabledInternalTermLists; @@ -21,15 +18,6 @@ public ProtectedTermsPreferences(List enabledInternalTermLists, List getEnabledInternalTermLists() { return enabledInternalTermLists; } @@ -46,32 +34,4 @@ public List getDisabledExternalTermLists() { return disabledExternalTermLists; } - public static void toPreferences(JabRefPreferences jabRefPreferences, ProtectedTermsLoader loader) { - List enabledExternalList = new ArrayList<>(); - List disabledExternalList = new ArrayList<>(); - List enabledInternalList = new ArrayList<>(); - List disabledInternalList = new ArrayList<>(); - - for (ProtectedTermsList list : loader.getProtectedTermsLists()) { - if (list.isInternalList()) { - if (list.isEnabled()) { - enabledInternalList.add(list.getLocation()); - } else { - disabledInternalList.add(list.getLocation()); - } - } else { - if (list.isEnabled()) { - enabledExternalList.add(list.getLocation()); - } else { - disabledExternalList.add(list.getLocation()); - } - } - } - - jabRefPreferences.putStringList(JabRefPreferences.PROTECTED_TERMS_ENABLED_EXTERNAL, enabledExternalList); - jabRefPreferences.putStringList(JabRefPreferences.PROTECTED_TERMS_DISABLED_EXTERNAL, disabledExternalList); - jabRefPreferences.putStringList(JabRefPreferences.PROTECTED_TERMS_ENABLED_INTERNAL, enabledInternalList); - jabRefPreferences.putStringList(JabRefPreferences.PROTECTED_TERMS_DISABLED_INTERNAL, disabledInternalList); - - } } diff --git a/src/main/java/net/sf/jabref/logic/xmp/XMPPreferences.java b/src/main/java/net/sf/jabref/logic/xmp/XMPPreferences.java index 96475459c60..0334fda0f51 100644 --- a/src/main/java/net/sf/jabref/logic/xmp/XMPPreferences.java +++ b/src/main/java/net/sf/jabref/logic/xmp/XMPPreferences.java @@ -2,8 +2,6 @@ import java.util.List; -import net.sf.jabref.preferences.JabRefPreferences; - public class XMPPreferences { private final boolean useXMPPrivacyFilter; @@ -17,12 +15,6 @@ public XMPPreferences(boolean useXMPPrivacyFilter, List xmpPrivacyFilter this.keywordSeparator = keywordSeparator; } - public static XMPPreferences fromPreferences(JabRefPreferences jabrefPreferences) { - return new XMPPreferences(jabrefPreferences.getBoolean(JabRefPreferences.USE_XMP_PRIVACY_FILTER), - jabrefPreferences.getStringList(JabRefPreferences.XMP_PRIVACY_FILTERS), - jabrefPreferences.get(JabRefPreferences.KEYWORD_SEPARATOR)); - } - public boolean isUseXMPPrivacyFilter() { return useXMPPrivacyFilter; } diff --git a/src/main/java/net/sf/jabref/pdfimport/PdfImporter.java b/src/main/java/net/sf/jabref/pdfimport/PdfImporter.java index 824474a8beb..37d7aab5e97 100644 --- a/src/main/java/net/sf/jabref/pdfimport/PdfImporter.java +++ b/src/main/java/net/sf/jabref/pdfimport/PdfImporter.java @@ -23,16 +23,13 @@ import net.sf.jabref.gui.entryeditor.EntryEditor; import net.sf.jabref.gui.maintable.MainTable; import net.sf.jabref.gui.undo.UndoableInsertEntry; -import net.sf.jabref.logic.bibtexkeypattern.BibtexKeyPatternPreferences; import net.sf.jabref.logic.bibtexkeypattern.BibtexKeyPatternUtil; -import net.sf.jabref.logic.importer.ImportFormatPreferences; import net.sf.jabref.logic.importer.ParserResult; import net.sf.jabref.logic.importer.fileformat.PdfContentImporter; import net.sf.jabref.logic.importer.fileformat.PdfXmpImporter; import net.sf.jabref.logic.l10n.Localization; import net.sf.jabref.logic.util.UpdateField; import net.sf.jabref.logic.util.io.FileUtil; -import net.sf.jabref.logic.xmp.XMPPreferences; import net.sf.jabref.logic.xmp.XMPUtil; import net.sf.jabref.model.database.KeyCollisionException; import net.sf.jabref.model.entry.BibEntry; @@ -139,7 +136,7 @@ private List importPdfFilesInternal(List fileNames) { for (String fileName : fileNames) { if (!neverShow && !doNotShowAgain) { importDialog = new ImportDialog(dropRow >= 0, fileName); - if (!XMPUtil.hasMetadata(Paths.get(fileName), XMPPreferences.fromPreferences(Globals.prefs))) { + if (!XMPUtil.hasMetadata(Paths.get(fileName), Globals.prefs.getXMPPreferences())) { importDialog.disableXMPChoice(); } importDialog.setLocationRelativeTo(frame); @@ -174,7 +171,7 @@ private List importPdfFilesInternal(List fileNames) { private void doXMPImport(String fileName, List res) { List localRes = new ArrayList<>(); - PdfXmpImporter importer = new PdfXmpImporter(XMPPreferences.fromPreferences(Globals.prefs)); + PdfXmpImporter importer = new PdfXmpImporter(Globals.prefs.getXMPPreferences()); Path filePath = Paths.get(fileName); ParserResult result = importer.importDatabase(filePath, Globals.prefs.getDefaultEncoding()); if (result.hasWarnings()) { @@ -221,7 +218,7 @@ private Optional createNewBlankEntry(String fileName) { private void doContentImport(String fileName, List res) { PdfContentImporter contentImporter = new PdfContentImporter( - ImportFormatPreferences.fromPreferences(Globals.prefs)); + Globals.prefs.getImportFormatPreferences()); Path filePath = Paths.get(fileName); ParserResult result = contentImporter.importDatabase(filePath, Globals.prefs.getDefaultEncoding()); if (result.hasWarnings()) { @@ -241,7 +238,7 @@ private void doContentImport(String fileName, List res) { panel.getDatabase().insertEntry(entry); panel.markBaseChanged(); BibtexKeyPatternUtil.makeLabel(panel.getBibDatabaseContext().getMetaData(), panel.getDatabase(), entry, - BibtexKeyPatternPreferences.fromPreferences(Globals.prefs)); + Globals.prefs.getBibtexKeyPatternPreferences()); DroppedFileHandler dfh = new DroppedFileHandler(frame, panel); dfh.linkPdfToEntry(fileName, entry); panel.highlightEntry(entry); diff --git a/src/main/java/net/sf/jabref/preferences/JabRefPreferences.java b/src/main/java/net/sf/jabref/preferences/JabRefPreferences.java index 733b2d1823b..f60ef40dce6 100644 --- a/src/main/java/net/sf/jabref/preferences/JabRefPreferences.java +++ b/src/main/java/net/sf/jabref/preferences/JabRefPreferences.java @@ -16,11 +16,13 @@ import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.EnumSet; import java.util.HashMap; import java.util.List; import java.util.Locale; import java.util.Map; +import java.util.Objects; import java.util.Optional; import java.util.Set; import java.util.prefs.BackingStoreException; @@ -38,6 +40,9 @@ import net.sf.jabref.gui.entryeditor.EntryEditorTabList; import net.sf.jabref.gui.preftabs.ImportSettingsTab; import net.sf.jabref.logic.autocompleter.AutoCompletePreferences; +import net.sf.jabref.logic.bibtex.FieldContentParserPreferences; +import net.sf.jabref.logic.bibtex.LatexFieldFormatterPreferences; +import net.sf.jabref.logic.bibtexkeypattern.BibtexKeyPatternPreferences; import net.sf.jabref.logic.cleanup.CleanupPreset; import net.sf.jabref.logic.cleanup.FieldFormatterCleanup; import net.sf.jabref.logic.exporter.CustomExportList; @@ -50,15 +55,24 @@ import net.sf.jabref.logic.formatter.bibtexfields.NormalizePagesFormatter; import net.sf.jabref.logic.formatter.bibtexfields.UnitsToLatexFormatter; import net.sf.jabref.logic.formatter.casechanger.ProtectTermsFormatter; +import net.sf.jabref.logic.importer.ImportFormatPreferences; +import net.sf.jabref.logic.journals.JournalAbbreviationLoader; +import net.sf.jabref.logic.journals.JournalAbbreviationPreferences; import net.sf.jabref.logic.l10n.Localization; +import net.sf.jabref.logic.layout.LayoutFormatterPreferences; import net.sf.jabref.logic.layout.format.FileLinkPreferences; +import net.sf.jabref.logic.layout.format.NameFormatter; +import net.sf.jabref.logic.layout.format.NameFormatterPreferences; import net.sf.jabref.logic.openoffice.OpenOfficePreferences; import net.sf.jabref.logic.openoffice.StyleLoader; +import net.sf.jabref.logic.protectedterms.ProtectedTermsList; import net.sf.jabref.logic.protectedterms.ProtectedTermsLoader; +import net.sf.jabref.logic.protectedterms.ProtectedTermsPreferences; import net.sf.jabref.logic.util.OS; import net.sf.jabref.logic.util.UpdateFieldPreferences; import net.sf.jabref.logic.util.io.FileHistory; import net.sf.jabref.logic.util.strings.StringUtil; +import net.sf.jabref.logic.xmp.XMPPreferences; import net.sf.jabref.model.bibtexkeypattern.AbstractBibtexKeyPattern; import net.sf.jabref.model.bibtexkeypattern.GlobalBibtexKeyPattern; import net.sf.jabref.model.database.BibDatabaseMode; @@ -1393,4 +1407,88 @@ public UpdateFieldPreferences getUpdateFieldPreferences() { get(TIME_STAMP_FORMAT)); } + public LatexFieldFormatterPreferences getLatexFieldFormatterPreferences() { + return new LatexFieldFormatterPreferences(getBoolean(RESOLVE_STRINGS_ALL_FIELDS), + getStringList(DO_NOT_RESOLVE_STRINGS_FOR), getFieldContentParserPreferences()); + } + + public FieldContentParserPreferences getFieldContentParserPreferences() { + return new FieldContentParserPreferences(getStringList(NON_WRAPPABLE_FIELDS)); + } + + public ImportFormatPreferences getImportFormatPreferences() { + return new ImportFormatPreferences(customImports, getDefaultEncoding(), get(KEYWORD_SEPARATOR), + getBibtexKeyPatternPreferences(), getFieldContentParserPreferences(), + getBoolean(USE_UNIT_FORMATTER_ON_SEARCH), getBoolean(USE_CASE_KEEPER_ON_SEARCH)); + } + + public BibtexKeyPatternPreferences getBibtexKeyPatternPreferences() { + return new BibtexKeyPatternPreferences(get(DEFAULT_BIBTEX_KEY_PATTERN), get(KEY_PATTERN_REGEX), + get(KEY_PATTERN_REPLACEMENT), getBoolean(KEY_GEN_ALWAYS_ADD_LETTER), getBoolean(KEY_GEN_FIRST_LETTER_A), + getBoolean(ENFORCE_LEGAL_BIBTEX_KEY), getKeyPattern()); + } + + public LayoutFormatterPreferences getLayoutFormatterPreferences( + JournalAbbreviationLoader journalAbbreviationLoader) { + Objects.requireNonNull(journalAbbreviationLoader); + return new LayoutFormatterPreferences(getNameFormatterPreferences(), getJournalAbbreviationPreferences(), + getFileLinkPreferences(), journalAbbreviationLoader); + } + + public XMPPreferences getXMPPreferences() { + return new XMPPreferences(getBoolean(USE_XMP_PRIVACY_FILTER), getStringList(XMP_PRIVACY_FILTERS), + get(KEYWORD_SEPARATOR)); + } + + private NameFormatterPreferences getNameFormatterPreferences() { + return new NameFormatterPreferences(getStringList(NameFormatter.NAME_FORMATER_KEY), + getStringList(NameFormatter.NAME_FORMATTER_VALUE)); + } + + public FileLinkPreferences getFileLinkPreferences() { + return new FileLinkPreferences(Collections.singletonList(get(FieldName.FILE + FileLinkPreferences.DIR_SUFFIX)), + fileDirForDatabase); + } + + public ProtectedTermsPreferences getProtectedTermsPreferences() { + return new ProtectedTermsPreferences( + getStringList(PROTECTED_TERMS_ENABLED_INTERNAL), getStringList(PROTECTED_TERMS_ENABLED_EXTERNAL), + getStringList(PROTECTED_TERMS_DISABLED_INTERNAL), getStringList(PROTECTED_TERMS_DISABLED_EXTERNAL)); + } + + public JournalAbbreviationPreferences getJournalAbbreviationPreferences() { + return new JournalAbbreviationPreferences( + getStringList(EXTERNAL_JOURNAL_LISTS), get(PERSONAL_JOURNAL_LIST), getBoolean(USE_IEEE_ABRV), + getDefaultEncoding()); + } + + public void setProtectedTermsPreferences(ProtectedTermsLoader loader) { + List enabledExternalList = new ArrayList<>(); + List disabledExternalList = new ArrayList<>(); + List enabledInternalList = new ArrayList<>(); + List disabledInternalList = new ArrayList<>(); + + for (ProtectedTermsList list : loader.getProtectedTermsLists()) { + if (list.isInternalList()) { + if (list.isEnabled()) { + enabledInternalList.add(list.getLocation()); + } else { + disabledInternalList.add(list.getLocation()); + } + } else { + if (list.isEnabled()) { + enabledExternalList.add(list.getLocation()); + } else { + disabledExternalList.add(list.getLocation()); + } + } + } + + putStringList(PROTECTED_TERMS_ENABLED_EXTERNAL, enabledExternalList); + putStringList(PROTECTED_TERMS_DISABLED_EXTERNAL, disabledExternalList); + putStringList(PROTECTED_TERMS_ENABLED_INTERNAL, enabledInternalList); + putStringList(PROTECTED_TERMS_DISABLED_INTERNAL, disabledInternalList); + + } + } diff --git a/src/test/java/net/sf/jabref/MetaDataTest.java b/src/test/java/net/sf/jabref/MetaDataTest.java index b6c754b4a17..b860bcd1d1f 100644 --- a/src/test/java/net/sf/jabref/MetaDataTest.java +++ b/src/test/java/net/sf/jabref/MetaDataTest.java @@ -9,7 +9,6 @@ import net.sf.jabref.logic.exporter.FieldFormatterCleanups; import net.sf.jabref.logic.formatter.casechanger.LowerCaseFormatter; import net.sf.jabref.logic.util.OS; -import net.sf.jabref.preferences.JabRefPreferences; import org.junit.Before; import org.junit.Test; @@ -22,7 +21,6 @@ public class MetaDataTest { @Before public void setUp() { - Globals.prefs = JabRefPreferences.getInstance(); metaData = new MetaData(); } diff --git a/src/test/java/net/sf/jabref/cli/AuxCommandLineTest.java b/src/test/java/net/sf/jabref/cli/AuxCommandLineTest.java index 9fad4fcc37c..be880e41379 100644 --- a/src/test/java/net/sf/jabref/cli/AuxCommandLineTest.java +++ b/src/test/java/net/sf/jabref/cli/AuxCommandLineTest.java @@ -8,7 +8,6 @@ import java.nio.charset.StandardCharsets; import java.nio.file.Paths; -import net.sf.jabref.logic.importer.ImportFormatPreferences; import net.sf.jabref.logic.importer.ParserResult; import net.sf.jabref.logic.importer.fileformat.BibtexParser; import net.sf.jabref.model.database.BibDatabase; @@ -26,7 +25,7 @@ public void test() throws URISyntaxException, IOException { File auxFile = Paths.get(AuxCommandLineTest.class.getResource("paper.aux").toURI()).toFile(); try (InputStreamReader originalReader = new InputStreamReader(originalStream, StandardCharsets.UTF_8)) { ParserResult result = BibtexParser.parse(originalReader, - ImportFormatPreferences.fromPreferences(JabRefPreferences.getInstance())); + JabRefPreferences.getInstance().getImportFormatPreferences()); AuxCommandLine auxCommandLine = new AuxCommandLine(auxFile.getAbsolutePath(), result.getDatabase()); BibDatabase newDB = auxCommandLine.perform(); diff --git a/src/test/java/net/sf/jabref/external/RegExpFileSearchTests.java b/src/test/java/net/sf/jabref/external/RegExpFileSearchTests.java index 02d5e3593da..7d1bc0ac5e6 100644 --- a/src/test/java/net/sf/jabref/external/RegExpFileSearchTests.java +++ b/src/test/java/net/sf/jabref/external/RegExpFileSearchTests.java @@ -10,7 +10,6 @@ import java.util.Map; import net.sf.jabref.Globals; -import net.sf.jabref.logic.importer.ImportFormatPreferences; import net.sf.jabref.logic.importer.ParserResult; import net.sf.jabref.logic.importer.fileformat.BibtexParser; import net.sf.jabref.logic.layout.format.NameFormatter; @@ -35,7 +34,6 @@ public class RegExpFileSearchTests { @Before public void setUp() throws IOException { - Globals.prefs = JabRefPreferences.getInstance(); StringReader reader = new StringReader( "@ARTICLE{HipKro03," + "\n" + " author = {Eric von Hippel and Georg von Krogh}," + "\n" @@ -46,7 +44,7 @@ public void setUp() throws IOException { + "\n" + " doi = {http://dx.doi.org/10.1287/orsc.14.2.209.14992}," + "\n" + " issn = {1526-5455}," + "\n" + " publisher = {INFORMS}" + "\n" + "}"); - BibtexParser parser = new BibtexParser(reader, ImportFormatPreferences.fromPreferences(Globals.prefs)); + BibtexParser parser = new BibtexParser(reader, JabRefPreferences.getInstance().getImportFormatPreferences()); ParserResult result = null; result = parser.parse(); diff --git a/src/test/java/net/sf/jabref/gui/importer/EntryFromFileCreatorManagerTest.java b/src/test/java/net/sf/jabref/gui/importer/EntryFromFileCreatorManagerTest.java index 02ee4f35181..0322e9516b6 100644 --- a/src/test/java/net/sf/jabref/gui/importer/EntryFromFileCreatorManagerTest.java +++ b/src/test/java/net/sf/jabref/gui/importer/EntryFromFileCreatorManagerTest.java @@ -11,7 +11,6 @@ import net.sf.jabref.Globals; import net.sf.jabref.logic.importer.ImportDataTest; -import net.sf.jabref.logic.importer.ImportFormatPreferences; import net.sf.jabref.logic.importer.ParserResult; import net.sf.jabref.logic.importer.fileformat.BibtexParser; import net.sf.jabref.model.database.BibDatabase; @@ -50,7 +49,7 @@ public void testGetCreator() { public void testAddEntrysFromFiles() throws FileNotFoundException, IOException { try (FileInputStream stream = new FileInputStream(ImportDataTest.UNLINKED_FILES_TEST_BIB); InputStreamReader reader = new InputStreamReader(stream, StandardCharsets.UTF_8)) { - ParserResult result = BibtexParser.parse(reader, ImportFormatPreferences.fromPreferences(Globals.prefs)); + ParserResult result = BibtexParser.parse(reader, Globals.prefs.getImportFormatPreferences()); BibDatabase database = result.getDatabase(); List files = new ArrayList<>(); diff --git a/src/test/java/net/sf/jabref/logic/auxparser/AuxParserTest.java b/src/test/java/net/sf/jabref/logic/auxparser/AuxParserTest.java index 6f7e6b887ce..fa4b4a3a0e4 100644 --- a/src/test/java/net/sf/jabref/logic/auxparser/AuxParserTest.java +++ b/src/test/java/net/sf/jabref/logic/auxparser/AuxParserTest.java @@ -28,7 +28,7 @@ public class AuxParserTest { @Before public void setUp() { - importFormatPreferences = ImportFormatPreferences.fromPreferences(JabRefPreferences.getInstance()); + importFormatPreferences = JabRefPreferences.getInstance().getImportFormatPreferences(); } @Test diff --git a/src/test/java/net/sf/jabref/logic/bibtex/BibEntryAssert.java b/src/test/java/net/sf/jabref/logic/bibtex/BibEntryAssert.java index 64d013ff614..e042e70a19b 100644 --- a/src/test/java/net/sf/jabref/logic/bibtex/BibEntryAssert.java +++ b/src/test/java/net/sf/jabref/logic/bibtex/BibEntryAssert.java @@ -13,7 +13,6 @@ import java.util.Collections; import java.util.List; -import net.sf.jabref.logic.importer.ImportFormatPreferences; import net.sf.jabref.logic.importer.ParserResult; import net.sf.jabref.logic.importer.fileformat.BibtexParser; import net.sf.jabref.logic.importer.fileformat.ImportFormat; @@ -64,7 +63,7 @@ private static List getListFromInputStream(InputStream is) throws IOEx ParserResult result; try (Reader reader = new InputStreamReader(is, StandardCharsets.UTF_8)) { BibtexParser parser = new BibtexParser(reader, - ImportFormatPreferences.fromPreferences(JabRefPreferences.getInstance())); + JabRefPreferences.getInstance().getImportFormatPreferences()); result = parser.parse(); } Assert.assertNotNull(result); diff --git a/src/test/java/net/sf/jabref/logic/bibtex/BibEntryWriterTest.java b/src/test/java/net/sf/jabref/logic/bibtex/BibEntryWriterTest.java index fe232ce627b..db746ffda43 100644 --- a/src/test/java/net/sf/jabref/logic/bibtex/BibEntryWriterTest.java +++ b/src/test/java/net/sf/jabref/logic/bibtex/BibEntryWriterTest.java @@ -28,9 +28,9 @@ public class BibEntryWriterTest { @Before public void setUpWriter() { - importFormatPreferences = ImportFormatPreferences.fromPreferences(JabRefPreferences.getInstance()); - writer = new BibEntryWriter(new LatexFieldFormatter( - LatexFieldFormatterPreferences.fromPreferences(JabRefPreferences.getInstance())), true); + importFormatPreferences = JabRefPreferences.getInstance().getImportFormatPreferences(); + writer = new BibEntryWriter( + new LatexFieldFormatter(JabRefPreferences.getInstance().getLatexFieldFormatterPreferences()), true); } @Test diff --git a/src/test/java/net/sf/jabref/logic/bibtex/LatexFieldFormatterTests.java b/src/test/java/net/sf/jabref/logic/bibtex/LatexFieldFormatterTests.java index 34ecef657ce..6d7dcbdb816 100644 --- a/src/test/java/net/sf/jabref/logic/bibtex/LatexFieldFormatterTests.java +++ b/src/test/java/net/sf/jabref/logic/bibtex/LatexFieldFormatterTests.java @@ -14,8 +14,7 @@ public class LatexFieldFormatterTests { @Before public void setUp() { - this.formatter = new LatexFieldFormatter( - LatexFieldFormatterPreferences.fromPreferences(JabRefPreferences.getInstance())); + this.formatter = new LatexFieldFormatter(JabRefPreferences.getInstance().getLatexFieldFormatterPreferences()); } @Test diff --git a/src/test/java/net/sf/jabref/logic/bibtexkeypattern/BibtexKeyPatternUtilTest.java b/src/test/java/net/sf/jabref/logic/bibtexkeypattern/BibtexKeyPatternUtilTest.java index ae0346b9aee..dacd18b9494 100644 --- a/src/test/java/net/sf/jabref/logic/bibtexkeypattern/BibtexKeyPatternUtilTest.java +++ b/src/test/java/net/sf/jabref/logic/bibtexkeypattern/BibtexKeyPatternUtilTest.java @@ -43,7 +43,7 @@ public class BibtexKeyPatternUtilTest { @Before public void setUp() { - importFormatPreferences = ImportFormatPreferences.fromPreferences(JabRefPreferences.getInstance()); + importFormatPreferences = JabRefPreferences.getInstance().getImportFormatPreferences(); BibtexKeyPatternUtil.setDataBase(new BibDatabase()); } diff --git a/src/test/java/net/sf/jabref/logic/bst/TestVM.java b/src/test/java/net/sf/jabref/logic/bst/TestVM.java index f29148061ca..1a3a39a5073 100644 --- a/src/test/java/net/sf/jabref/logic/bst/TestVM.java +++ b/src/test/java/net/sf/jabref/logic/bst/TestVM.java @@ -10,7 +10,6 @@ import net.sf.jabref.logic.bst.VM.BstEntry; import net.sf.jabref.logic.bst.VM.StackFunction; -import net.sf.jabref.logic.importer.ImportFormatPreferences; import net.sf.jabref.logic.importer.ParserResult; import net.sf.jabref.logic.importer.fileformat.BibtexParser; import net.sf.jabref.model.entry.BibEntry; @@ -642,7 +641,7 @@ public void testVMSwap() throws RecognitionException { private static BibEntry bibtexString2BibtexEntry(String s) throws IOException { ParserResult result = BibtexParser.parse(new StringReader(s), - ImportFormatPreferences.fromPreferences(JabRefPreferences.getInstance())); + JabRefPreferences.getInstance().getImportFormatPreferences()); Collection c = result.getDatabase().getEntries(); Assert.assertEquals(1, c.size()); return c.iterator().next(); diff --git a/src/test/java/net/sf/jabref/logic/cleanup/RenamePdfCleanupTest.java b/src/test/java/net/sf/jabref/logic/cleanup/RenamePdfCleanupTest.java index 03b27fcf131..28eea0fb278 100644 --- a/src/test/java/net/sf/jabref/logic/cleanup/RenamePdfCleanupTest.java +++ b/src/test/java/net/sf/jabref/logic/cleanup/RenamePdfCleanupTest.java @@ -105,7 +105,7 @@ public void cleanupRenamePdfRenamesFileInSameFolder() throws IOException { entry.setField("title", "test title"); RenamePdfCleanup cleanup = new RenamePdfCleanup(false, context, fileNamePattern, - LayoutFormatterPreferences.fromPreferences(prefs, mock(JournalAbbreviationLoader.class)), + prefs.getLayoutFormatterPreferences(mock(JournalAbbreviationLoader.class)), prefs.getFileDirectoryPreferences()); cleanup.cleanup(entry); diff --git a/src/test/java/net/sf/jabref/logic/exporter/BibtexDatabaseWriterTest.java b/src/test/java/net/sf/jabref/logic/exporter/BibtexDatabaseWriterTest.java index 762459a3a2c..11e3878c1d8 100644 --- a/src/test/java/net/sf/jabref/logic/exporter/BibtexDatabaseWriterTest.java +++ b/src/test/java/net/sf/jabref/logic/exporter/BibtexDatabaseWriterTest.java @@ -60,7 +60,7 @@ public void setUp() { database = new BibDatabase(); metaData = new MetaData(); bibtexContext = new BibDatabaseContext(database, metaData, new Defaults(BibDatabaseMode.BIBTEX)); - importFormatPreferences = ImportFormatPreferences.fromPreferences(prefs); + importFormatPreferences = prefs.getImportFormatPreferences(); } @Test(expected = NullPointerException.class) diff --git a/src/test/java/net/sf/jabref/logic/exporter/ExportFormatTest.java b/src/test/java/net/sf/jabref/logic/exporter/ExportFormatTest.java index dbebf6138ec..1a9bdb65206 100644 --- a/src/test/java/net/sf/jabref/logic/exporter/ExportFormatTest.java +++ b/src/test/java/net/sf/jabref/logic/exporter/ExportFormatTest.java @@ -80,8 +80,8 @@ public static Collection exportFormats() { Map customFormats = prefs.customExports.getCustomExportFormats(prefs, journalAbbreviationLoader); - LayoutFormatterPreferences layoutPreferences = LayoutFormatterPreferences.fromPreferences(prefs, - journalAbbreviationLoader); + LayoutFormatterPreferences layoutPreferences = prefs + .getLayoutFormatterPreferences(journalAbbreviationLoader); SavePreferences savePreferences = SavePreferences.loadForExportFromPreferences(prefs); ExportFormats.initAllExports(customFormats, layoutPreferences, savePreferences); diff --git a/src/test/java/net/sf/jabref/logic/exporter/HtmlExportFormatTest.java b/src/test/java/net/sf/jabref/logic/exporter/HtmlExportFormatTest.java index 7448730859a..938974538ee 100644 --- a/src/test/java/net/sf/jabref/logic/exporter/HtmlExportFormatTest.java +++ b/src/test/java/net/sf/jabref/logic/exporter/HtmlExportFormatTest.java @@ -37,8 +37,7 @@ public void setUp() { JournalAbbreviationLoader journalAbbreviationLoader = new JournalAbbreviationLoader(); Map customFormats = prefs.customExports.getCustomExportFormats(prefs, journalAbbreviationLoader); - LayoutFormatterPreferences layoutPreferences = LayoutFormatterPreferences.fromPreferences(prefs, - journalAbbreviationLoader); + LayoutFormatterPreferences layoutPreferences = prefs.getLayoutFormatterPreferences(journalAbbreviationLoader); SavePreferences savePreferences = SavePreferences.loadForExportFromPreferences(prefs); ExportFormats.initAllExports(customFormats, layoutPreferences, savePreferences); diff --git a/src/test/java/net/sf/jabref/logic/exporter/MSBibExportFormatTestFiles.java b/src/test/java/net/sf/jabref/logic/exporter/MSBibExportFormatTestFiles.java index 911b01ad133..ab1acb4a39f 100644 --- a/src/test/java/net/sf/jabref/logic/exporter/MSBibExportFormatTestFiles.java +++ b/src/test/java/net/sf/jabref/logic/exporter/MSBibExportFormatTestFiles.java @@ -15,7 +15,6 @@ import java.util.stream.Stream; import net.sf.jabref.BibDatabaseContext; -import net.sf.jabref.logic.importer.ImportFormatPreferences; import net.sf.jabref.logic.importer.fileformat.BibtexImporter; import net.sf.jabref.model.entry.BibEntry; import net.sf.jabref.preferences.JabRefPreferences; @@ -63,7 +62,7 @@ public void setUp() throws Exception { charset = StandardCharsets.UTF_8; msBibExportFormat = new MSBibExportFormat(); tempFile = testFolder.newFile(); - testImporter = new BibtexImporter(ImportFormatPreferences.fromPreferences(JabRefPreferences.getInstance())); + testImporter = new BibtexImporter(JabRefPreferences.getInstance().getImportFormatPreferences()); } @Test diff --git a/src/test/java/net/sf/jabref/logic/groups/GroupsUtilTest.java b/src/test/java/net/sf/jabref/logic/groups/GroupsUtilTest.java index 3da94fc56f6..82dee3115bc 100644 --- a/src/test/java/net/sf/jabref/logic/groups/GroupsUtilTest.java +++ b/src/test/java/net/sf/jabref/logic/groups/GroupsUtilTest.java @@ -9,7 +9,6 @@ import java.util.List; import java.util.Set; -import net.sf.jabref.logic.importer.ImportFormatPreferences; import net.sf.jabref.logic.importer.ParserResult; import net.sf.jabref.logic.importer.fileformat.BibtexParser; import net.sf.jabref.model.database.BibDatabase; @@ -29,7 +28,7 @@ public void test() throws IOException { StandardCharsets.UTF_8)) { ParserResult result = BibtexParser.parse(fr, - ImportFormatPreferences.fromPreferences(JabRefPreferences.getInstance())); + JabRefPreferences.getInstance().getImportFormatPreferences()); BibDatabase db = result.getDatabase(); diff --git a/src/test/java/net/sf/jabref/logic/importer/BibDatabaseTestsWithFiles.java b/src/test/java/net/sf/jabref/logic/importer/BibDatabaseTestsWithFiles.java index fcd75443047..d62a17f5c20 100644 --- a/src/test/java/net/sf/jabref/logic/importer/BibDatabaseTestsWithFiles.java +++ b/src/test/java/net/sf/jabref/logic/importer/BibDatabaseTestsWithFiles.java @@ -20,7 +20,7 @@ public class BibDatabaseTestsWithFiles { @Before public void setUp() { - importFormatPreferences = ImportFormatPreferences.fromPreferences(JabRefPreferences.getInstance()); + importFormatPreferences = JabRefPreferences.getInstance().getImportFormatPreferences(); } @Test diff --git a/src/test/java/net/sf/jabref/logic/importer/DatabaseFileLookupTest.java b/src/test/java/net/sf/jabref/logic/importer/DatabaseFileLookupTest.java index 109482063d2..249652d4f23 100644 --- a/src/test/java/net/sf/jabref/logic/importer/DatabaseFileLookupTest.java +++ b/src/test/java/net/sf/jabref/logic/importer/DatabaseFileLookupTest.java @@ -34,7 +34,7 @@ public void setUp() throws FileNotFoundException, IOException { try (FileInputStream stream = new FileInputStream(ImportDataTest.UNLINKED_FILES_TEST_BIB); InputStreamReader reader = new InputStreamReader(stream, StandardCharsets.UTF_8)) { ParserResult result = BibtexParser.parse(reader, - ImportFormatPreferences.fromPreferences(JabRefPreferences.getInstance())); + JabRefPreferences.getInstance().getImportFormatPreferences()); database = result.getDatabase(); entries = database.getEntries(); diff --git a/src/test/java/net/sf/jabref/logic/importer/ImportFormatReaderIntegrationTest.java b/src/test/java/net/sf/jabref/logic/importer/ImportFormatReaderIntegrationTest.java index 817b464e629..a64d9755eac 100644 --- a/src/test/java/net/sf/jabref/logic/importer/ImportFormatReaderIntegrationTest.java +++ b/src/test/java/net/sf/jabref/logic/importer/ImportFormatReaderIntegrationTest.java @@ -8,7 +8,6 @@ import java.util.Collection; import net.sf.jabref.Globals; -import net.sf.jabref.logic.xmp.XMPPreferences; import net.sf.jabref.preferences.JabRefPreferences; import org.junit.Before; @@ -39,8 +38,8 @@ public ImportFormatReaderIntegrationTest(String resource, String format, int cou public void setUp() { Globals.prefs = JabRefPreferences.getInstance(); // Needed for special fields reader = new ImportFormatReader(); - reader.resetImportFormats(ImportFormatPreferences.fromPreferences(Globals.prefs), - XMPPreferences.fromPreferences(JabRefPreferences.getInstance())); + reader.resetImportFormats(Globals.prefs.getImportFormatPreferences(), + Globals.prefs.getXMPPreferences()); } @Test diff --git a/src/test/java/net/sf/jabref/logic/importer/ImportFormatReaderTestParameterless.java b/src/test/java/net/sf/jabref/logic/importer/ImportFormatReaderTestParameterless.java index 96eb4635d5a..261dd17c66a 100644 --- a/src/test/java/net/sf/jabref/logic/importer/ImportFormatReaderTestParameterless.java +++ b/src/test/java/net/sf/jabref/logic/importer/ImportFormatReaderTestParameterless.java @@ -6,7 +6,6 @@ import java.nio.file.Paths; import net.sf.jabref.Globals; -import net.sf.jabref.logic.xmp.XMPPreferences; import net.sf.jabref.preferences.JabRefPreferences; import org.junit.Before; @@ -23,8 +22,8 @@ public class ImportFormatReaderTestParameterless { public void setUp() { Globals.prefs = JabRefPreferences.getInstance(); // Needed for special fields reader = new ImportFormatReader(); - reader.resetImportFormats(ImportFormatPreferences.fromPreferences(Globals.prefs), - XMPPreferences.fromPreferences(Globals.prefs)); + reader.resetImportFormats(Globals.prefs.getImportFormatPreferences(), + Globals.prefs.getXMPPreferences()); } @Test diff --git a/src/test/java/net/sf/jabref/logic/importer/OpenDatabaseTest.java b/src/test/java/net/sf/jabref/logic/importer/OpenDatabaseTest.java index ccd642e3d6e..e2f2d820d45 100644 --- a/src/test/java/net/sf/jabref/logic/importer/OpenDatabaseTest.java +++ b/src/test/java/net/sf/jabref/logic/importer/OpenDatabaseTest.java @@ -48,7 +48,7 @@ public static void setUpGlobalsPrefs() { @Before public void setUp() { - importFormatPreferences = ImportFormatPreferences.fromPreferences(JabRefPreferences.getInstance()); + importFormatPreferences = JabRefPreferences.getInstance().getImportFormatPreferences(); } @Test diff --git a/src/test/java/net/sf/jabref/logic/importer/ParsedBibEntryTests.java b/src/test/java/net/sf/jabref/logic/importer/ParsedBibEntryTests.java index 639461e5317..ecebc8b1f1f 100644 --- a/src/test/java/net/sf/jabref/logic/importer/ParsedBibEntryTests.java +++ b/src/test/java/net/sf/jabref/logic/importer/ParsedBibEntryTests.java @@ -17,7 +17,7 @@ public class ParsedBibEntryTests { @Before public void setUp() { - importFormatPreferences = ImportFormatPreferences.fromPreferences(JabRefPreferences.getInstance()); + importFormatPreferences = JabRefPreferences.getInstance().getImportFormatPreferences(); } @Test diff --git a/src/test/java/net/sf/jabref/logic/importer/fetcher/DiVATest.java b/src/test/java/net/sf/jabref/logic/importer/fetcher/DiVATest.java index 357e5fbba73..2809cc1411f 100644 --- a/src/test/java/net/sf/jabref/logic/importer/fetcher/DiVATest.java +++ b/src/test/java/net/sf/jabref/logic/importer/fetcher/DiVATest.java @@ -3,7 +3,6 @@ import java.util.Optional; import net.sf.jabref.logic.help.HelpFile; -import net.sf.jabref.logic.importer.ImportFormatPreferences; import net.sf.jabref.model.entry.BibEntry; import net.sf.jabref.preferences.JabRefPreferences; @@ -22,7 +21,7 @@ public class DiVATest { @Before public void setUp() { - fetcher = new DiVA(ImportFormatPreferences.fromPreferences(JabRefPreferences.getInstance())); + fetcher = new DiVA(JabRefPreferences.getInstance().getImportFormatPreferences()); } @Test diff --git a/src/test/java/net/sf/jabref/logic/importer/fileformat/BibtexImporterTest.java b/src/test/java/net/sf/jabref/logic/importer/fileformat/BibtexImporterTest.java index 782a31783a1..526137ed8ce 100644 --- a/src/test/java/net/sf/jabref/logic/importer/fileformat/BibtexImporterTest.java +++ b/src/test/java/net/sf/jabref/logic/importer/fileformat/BibtexImporterTest.java @@ -8,7 +8,6 @@ import java.util.List; import java.util.Optional; -import net.sf.jabref.logic.importer.ImportFormatPreferences; import net.sf.jabref.logic.util.FileExtensions; import net.sf.jabref.model.entry.BibEntry; import net.sf.jabref.preferences.JabRefPreferences; @@ -34,7 +33,7 @@ public class BibtexImporterTest { @Before public void setUp() { - importer = new BibtexImporter(ImportFormatPreferences.fromPreferences(JabRefPreferences.getInstance())); + importer = new BibtexImporter(JabRefPreferences.getInstance().getImportFormatPreferences()); } @Test diff --git a/src/test/java/net/sf/jabref/logic/importer/fileformat/BibtexParserTest.java b/src/test/java/net/sf/jabref/logic/importer/fileformat/BibtexParserTest.java index dac40f5909a..543e1c04f50 100644 --- a/src/test/java/net/sf/jabref/logic/importer/fileformat/BibtexParserTest.java +++ b/src/test/java/net/sf/jabref/logic/importer/fileformat/BibtexParserTest.java @@ -29,6 +29,7 @@ import net.sf.jabref.logic.util.OS; import net.sf.jabref.model.bibtexkeypattern.AbstractBibtexKeyPattern; import net.sf.jabref.model.bibtexkeypattern.DatabaseBibtexKeyPattern; +import net.sf.jabref.model.bibtexkeypattern.GlobalBibtexKeyPattern; import net.sf.jabref.model.database.BibDatabaseMode; import net.sf.jabref.model.entry.BibEntry; import net.sf.jabref.model.entry.BibtexString; @@ -55,8 +56,7 @@ public class BibtexParserTest { @BeforeClass public static void setUp() { - Globals.prefs = JabRefPreferences.getInstance(); - importFormatPreferences = ImportFormatPreferences.fromPreferences(JabRefPreferences.getInstance()); + importFormatPreferences = JabRefPreferences.getInstance().getImportFormatPreferences(); } @SuppressWarnings("unused") @@ -1465,10 +1465,10 @@ public void integrationTestCustomKeyPattern() throws IOException { .parse(new StringReader("@comment{jabref-meta: keypattern_article:articleTest;}" + OS.NEWLINE + "@comment{jabref-meta: keypatterndefault:test;}"), importFormatPreferences); - AbstractBibtexKeyPattern bibtexKeyPattern = result.getMetaData() - .getBibtexKeyPattern(Globals.prefs.getKeyPattern()); + GlobalBibtexKeyPattern pattern = JabRefPreferences.getInstance().getKeyPattern(); + AbstractBibtexKeyPattern bibtexKeyPattern = result.getMetaData().getBibtexKeyPattern(pattern); - AbstractBibtexKeyPattern expectedPattern = new DatabaseBibtexKeyPattern(Globals.prefs.getKeyPattern()); + AbstractBibtexKeyPattern expectedPattern = new DatabaseBibtexKeyPattern(pattern); expectedPattern.setDefaultValue("test"); expectedPattern.addBibtexKeyPattern("article", "articleTest"); diff --git a/src/test/java/net/sf/jabref/logic/importer/fileformat/EndnoteImporterTest.java b/src/test/java/net/sf/jabref/logic/importer/fileformat/EndnoteImporterTest.java index 49aeb5619cf..2c662a3a894 100644 --- a/src/test/java/net/sf/jabref/logic/importer/fileformat/EndnoteImporterTest.java +++ b/src/test/java/net/sf/jabref/logic/importer/fileformat/EndnoteImporterTest.java @@ -12,7 +12,6 @@ import java.util.List; import java.util.Optional; -import net.sf.jabref.logic.importer.ImportFormatPreferences; import net.sf.jabref.logic.util.FileExtensions; import net.sf.jabref.model.entry.BibEntry; import net.sf.jabref.preferences.JabRefPreferences; @@ -31,7 +30,7 @@ public class EndnoteImporterTest { @Before public void setUp() { - importer = new EndnoteImporter(ImportFormatPreferences.fromPreferences(JabRefPreferences.getInstance())); + importer = new EndnoteImporter(JabRefPreferences.getInstance().getImportFormatPreferences()); } @Test diff --git a/src/test/java/net/sf/jabref/logic/importer/fileformat/FreeCiteImporterTest.java b/src/test/java/net/sf/jabref/logic/importer/fileformat/FreeCiteImporterTest.java index 21265906907..afa5da23376 100644 --- a/src/test/java/net/sf/jabref/logic/importer/fileformat/FreeCiteImporterTest.java +++ b/src/test/java/net/sf/jabref/logic/importer/fileformat/FreeCiteImporterTest.java @@ -1,6 +1,5 @@ package net.sf.jabref.logic.importer.fileformat; -import net.sf.jabref.logic.importer.ImportFormatPreferences; import net.sf.jabref.logic.util.FileExtensions; import net.sf.jabref.preferences.JabRefPreferences; @@ -16,7 +15,7 @@ public class FreeCiteImporterTest { @Before public void setUp() { - importer = new FreeCiteImporter(ImportFormatPreferences.fromPreferences(JabRefPreferences.getInstance())); + importer = new FreeCiteImporter(JabRefPreferences.getInstance().getImportFormatPreferences()); } @Test diff --git a/src/test/java/net/sf/jabref/logic/importer/fileformat/ImportFormatTest.java b/src/test/java/net/sf/jabref/logic/importer/fileformat/ImportFormatTest.java index 0213315ee57..5e264dfc802 100644 --- a/src/test/java/net/sf/jabref/logic/importer/fileformat/ImportFormatTest.java +++ b/src/test/java/net/sf/jabref/logic/importer/fileformat/ImportFormatTest.java @@ -73,9 +73,8 @@ public static Collection instancesToTest() { // all classes implementing {@link ImportFormat} // sorted alphabetically - ImportFormatPreferences importFormatPreferences = ImportFormatPreferences - .fromPreferences(JabRefPreferences.getInstance()); - XMPPreferences xmpPreferences = XMPPreferences.fromPreferences(JabRefPreferences.getInstance()); + ImportFormatPreferences importFormatPreferences = JabRefPreferences.getInstance().getImportFormatPreferences(); + XMPPreferences xmpPreferences = JabRefPreferences.getInstance().getXMPPreferences(); // @formatter:off return Arrays.asList( new Object[]{new BiblioscapeImporter()}, diff --git a/src/test/java/net/sf/jabref/logic/importer/fileformat/PdfContentImporterTest.java b/src/test/java/net/sf/jabref/logic/importer/fileformat/PdfContentImporterTest.java index ff5fb2bf303..c5e89799471 100644 --- a/src/test/java/net/sf/jabref/logic/importer/fileformat/PdfContentImporterTest.java +++ b/src/test/java/net/sf/jabref/logic/importer/fileformat/PdfContentImporterTest.java @@ -7,7 +7,6 @@ import java.util.Collections; import java.util.List; -import net.sf.jabref.logic.importer.ImportFormatPreferences; import net.sf.jabref.logic.util.FileExtensions; import net.sf.jabref.model.entry.BibEntry; import net.sf.jabref.preferences.JabRefPreferences; @@ -24,7 +23,7 @@ public class PdfContentImporterTest { @Before public void setUp() { - importer = new PdfContentImporter(ImportFormatPreferences.fromPreferences(JabRefPreferences.getInstance())); + importer = new PdfContentImporter(JabRefPreferences.getInstance().getImportFormatPreferences()); } @Test diff --git a/src/test/java/net/sf/jabref/logic/importer/fileformat/PdfContentImporterTestFiles.java b/src/test/java/net/sf/jabref/logic/importer/fileformat/PdfContentImporterTestFiles.java index 730753d2c38..ab695d2df51 100644 --- a/src/test/java/net/sf/jabref/logic/importer/fileformat/PdfContentImporterTestFiles.java +++ b/src/test/java/net/sf/jabref/logic/importer/fileformat/PdfContentImporterTestFiles.java @@ -10,7 +10,6 @@ import java.util.List; import net.sf.jabref.logic.bibtex.BibEntryAssert; -import net.sf.jabref.logic.importer.ImportFormatPreferences; import net.sf.jabref.model.entry.BibEntry; import net.sf.jabref.preferences.JabRefPreferences; @@ -45,7 +44,7 @@ public void correctContent() throws IOException, URISyntaxException { String pdfFileName = fileName + ".pdf"; String bibFileName = fileName + ".bib"; PdfContentImporter importer = new PdfContentImporter( - ImportFormatPreferences.fromPreferences(JabRefPreferences.getInstance())); + JabRefPreferences.getInstance().getImportFormatPreferences()); Path pdfFile = Paths.get(PdfContentImporter.class.getResource(pdfFileName).toURI()); List result = importer.importDatabase(pdfFile, StandardCharsets.UTF_8).getDatabase().getEntries(); BibEntryAssert.assertEquals(PdfContentImporterTest.class, bibFileName, result); diff --git a/src/test/java/net/sf/jabref/logic/importer/fileformat/PdfXmpImporterTest.java b/src/test/java/net/sf/jabref/logic/importer/fileformat/PdfXmpImporterTest.java index 14ff113f525..4f98fd45af3 100644 --- a/src/test/java/net/sf/jabref/logic/importer/fileformat/PdfXmpImporterTest.java +++ b/src/test/java/net/sf/jabref/logic/importer/fileformat/PdfXmpImporterTest.java @@ -11,7 +11,6 @@ import net.sf.jabref.logic.importer.ParserResult; import net.sf.jabref.logic.util.FileExtensions; -import net.sf.jabref.logic.xmp.XMPPreferences; import net.sf.jabref.model.entry.BibEntry; import net.sf.jabref.preferences.JabRefPreferences; @@ -30,7 +29,7 @@ public class PdfXmpImporterTest { @Before public void setUp() { - importer = new PdfXmpImporter(XMPPreferences.fromPreferences(JabRefPreferences.getInstance())); + importer = new PdfXmpImporter(JabRefPreferences.getInstance().getXMPPreferences()); } @Test diff --git a/src/test/java/net/sf/jabref/logic/importer/fileformat/RepecNepImporterTest.java b/src/test/java/net/sf/jabref/logic/importer/fileformat/RepecNepImporterTest.java index 2310ef82c31..90efd592aac 100644 --- a/src/test/java/net/sf/jabref/logic/importer/fileformat/RepecNepImporterTest.java +++ b/src/test/java/net/sf/jabref/logic/importer/fileformat/RepecNepImporterTest.java @@ -10,7 +10,6 @@ import java.util.List; import net.sf.jabref.logic.bibtex.BibEntryAssert; -import net.sf.jabref.logic.importer.ImportFormatPreferences; import net.sf.jabref.logic.util.FileExtensions; import net.sf.jabref.model.entry.BibEntry; import net.sf.jabref.preferences.JabRefPreferences; @@ -26,7 +25,7 @@ public class RepecNepImporterTest { @Before public void setUp() { - testImporter = new RepecNepImporter(ImportFormatPreferences.fromPreferences(JabRefPreferences.getInstance())); + testImporter = new RepecNepImporter(JabRefPreferences.getInstance().getImportFormatPreferences()); } @Test diff --git a/src/test/java/net/sf/jabref/logic/journals/AbbreviationsTest.java b/src/test/java/net/sf/jabref/logic/journals/AbbreviationsTest.java index 73b609b0000..9726b466a37 100644 --- a/src/test/java/net/sf/jabref/logic/journals/AbbreviationsTest.java +++ b/src/test/java/net/sf/jabref/logic/journals/AbbreviationsTest.java @@ -1,7 +1,5 @@ package net.sf.jabref.logic.journals; -import net.sf.jabref.preferences.JabRefPreferences; - import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -15,7 +13,7 @@ public class AbbreviationsTest { @Mock - private JabRefPreferences prefs; + private JournalAbbreviationPreferences prefs; private JournalAbbreviationLoader abbreviations; @Before @@ -25,40 +23,40 @@ public void setUp() throws Exception { @Test public void getNextAbbreviationAbbreviatesIEEEJournalTitle() { - when(prefs.getBoolean(JabRefPreferences.USE_IEEE_ABRV)).thenReturn(true); + when(prefs.isUseIEEEAbbreviations()).thenReturn(true); assertEquals("#IEEE_J_PROC#", - abbreviations.getRepository(JournalAbbreviationPreferences.fromPreferences(prefs)) + abbreviations.getRepository(prefs) .getNextAbbreviation("Proceedings of the IEEE").get()); } @Test public void getNextAbbreviationExpandsIEEEAbbreviation() { - when(prefs.getBoolean(JabRefPreferences.USE_IEEE_ABRV)).thenReturn(true); + when(prefs.isUseIEEEAbbreviations()).thenReturn(true); assertEquals("Proceedings of the IEEE", - abbreviations.getRepository(JournalAbbreviationPreferences.fromPreferences(prefs)) + abbreviations.getRepository(prefs) .getNextAbbreviation("#IEEE_J_PROC#").get()); } @Test public void getNextAbbreviationAbbreviatesJournalTitle() { assertEquals("Proc. IEEE", - abbreviations.getRepository(JournalAbbreviationPreferences.fromPreferences(prefs)) + abbreviations.getRepository(prefs) .getNextAbbreviation("Proceedings of the IEEE").get()); } @Test public void getNextAbbreviationRemovesPoint() { assertEquals("Proc IEEE", - abbreviations.getRepository(JournalAbbreviationPreferences.fromPreferences(prefs)) + abbreviations.getRepository(prefs) .getNextAbbreviation("Proc. IEEE").get()); } @Test public void getNextAbbreviationExpandsAbbreviation() { assertEquals("Proceedings of the IEEE", - abbreviations.getRepository(JournalAbbreviationPreferences.fromPreferences(prefs)) + abbreviations.getRepository(prefs) .getNextAbbreviation("Proc IEEE").get()); } diff --git a/src/test/java/net/sf/jabref/logic/layout/LayoutEntryTest.java b/src/test/java/net/sf/jabref/logic/layout/LayoutEntryTest.java index a791adfce2b..c1553a7b73c 100644 --- a/src/test/java/net/sf/jabref/logic/layout/LayoutEntryTest.java +++ b/src/test/java/net/sf/jabref/logic/layout/LayoutEntryTest.java @@ -87,7 +87,7 @@ public void setUp() { public String layout(String layoutFile, BibEntry entry, Optional highlightPattern) throws IOException { StringReader sr = new StringReader(layoutFile.replace("__NEWLINE__", "\n")); Layout layout = new LayoutHelper(sr, - LayoutFormatterPreferences.fromPreferences(Globals.prefs, mock(JournalAbbreviationLoader.class))) + Globals.prefs.getLayoutFormatterPreferences(mock(JournalAbbreviationLoader.class))) .getLayoutFromText(); return layout.doLayout(entry, null, highlightPattern); diff --git a/src/test/java/net/sf/jabref/logic/layout/LayoutTest.java b/src/test/java/net/sf/jabref/logic/layout/LayoutTest.java index 6b52baa671a..0054d5e9f2f 100644 --- a/src/test/java/net/sf/jabref/logic/layout/LayoutTest.java +++ b/src/test/java/net/sf/jabref/logic/layout/LayoutTest.java @@ -4,7 +4,6 @@ import java.io.StringReader; import java.util.Collection; -import net.sf.jabref.logic.importer.ImportFormatPreferences; import net.sf.jabref.logic.importer.ParserResult; import net.sf.jabref.logic.importer.fileformat.BibtexParser; import net.sf.jabref.logic.journals.JournalAbbreviationLoader; @@ -28,8 +27,7 @@ public class LayoutTest { */ @Before public void setUp() { - prefs = LayoutFormatterPreferences.fromPreferences(JabRefPreferences.getInstance(), - mock(JournalAbbreviationLoader.class)); + prefs = JabRefPreferences.getInstance().getLayoutFormatterPreferences(mock(JournalAbbreviationLoader.class)); } /** @@ -46,7 +44,7 @@ public String t1BibtexString() { public static BibEntry bibtexString2BibtexEntry(String s) throws IOException { ParserResult result = BibtexParser.parse(new StringReader(s), - ImportFormatPreferences.fromPreferences(JabRefPreferences.getInstance())); +JabRefPreferences.getInstance().getImportFormatPreferences()); Collection c = result.getDatabase().getEntries(); Assert.assertEquals(1, c.size()); return c.iterator().next(); diff --git a/src/test/java/net/sf/jabref/logic/layout/format/FileLinkTest.java b/src/test/java/net/sf/jabref/logic/layout/format/FileLinkTest.java index e33e7d5e5d5..a0b24ff826b 100644 --- a/src/test/java/net/sf/jabref/logic/layout/format/FileLinkTest.java +++ b/src/test/java/net/sf/jabref/logic/layout/format/FileLinkTest.java @@ -14,7 +14,7 @@ public class FileLinkTest { private FileLinkPreferences prefs; @Before public void setUp() throws Exception { - prefs = FileLinkPreferences.fromPreferences(JabRefPreferences.getInstance()); + prefs = JabRefPreferences.getInstance().getFileLinkPreferences(); } @Test diff --git a/src/test/java/net/sf/jabref/logic/openoffice/OOBibStyleTest.java b/src/test/java/net/sf/jabref/logic/openoffice/OOBibStyleTest.java index bd24224e9a8..9197056d664 100644 --- a/src/test/java/net/sf/jabref/logic/openoffice/OOBibStyleTest.java +++ b/src/test/java/net/sf/jabref/logic/openoffice/OOBibStyleTest.java @@ -14,7 +14,6 @@ import java.util.Set; import net.sf.jabref.JabRefMain; -import net.sf.jabref.logic.importer.ImportFormatPreferences; import net.sf.jabref.logic.importer.ParserResult; import net.sf.jabref.logic.importer.fileformat.BibtexParser; import net.sf.jabref.logic.importer.fileformat.ImportFormat; @@ -42,8 +41,8 @@ public class OOBibStyleTest { @Before public void setUp() { - layoutFormatterPreferences = LayoutFormatterPreferences.fromPreferences(JabRefPreferences.getInstance(), - mock(JournalAbbreviationLoader.class)); + layoutFormatterPreferences = JabRefPreferences.getInstance() + .getLayoutFormatterPreferences(mock(JournalAbbreviationLoader.class)); } @Test @@ -144,7 +143,7 @@ public void testGetCitProperty() throws IOException { public void testGetCitationMarker() throws IOException { Path testBibtexFile = Paths.get("src/test/resources/testbib/complex.bib"); ParserResult result = BibtexParser.parse(ImportFormat.getReader(testBibtexFile, StandardCharsets.UTF_8), - ImportFormatPreferences.fromPreferences(JabRefPreferences.getInstance())); + JabRefPreferences.getInstance().getImportFormatPreferences()); OOBibStyle style = new OOBibStyle(StyleLoader.DEFAULT_NUMERICAL_STYLE_PATH, layoutFormatterPreferences); Map entryDBMap = new HashMap<>(); @@ -166,7 +165,7 @@ public void testGetCitationMarker() throws IOException { public void testLayout() throws IOException { Path testBibtexFile = Paths.get("src/test/resources/testbib/complex.bib"); ParserResult result = BibtexParser.parse(ImportFormat.getReader(testBibtexFile, StandardCharsets.UTF_8), - ImportFormatPreferences.fromPreferences(JabRefPreferences.getInstance())); + JabRefPreferences.getInstance().getImportFormatPreferences()); OOBibStyle style = new OOBibStyle(StyleLoader.DEFAULT_NUMERICAL_STYLE_PATH, layoutFormatterPreferences); BibDatabase db = result.getDatabase(); diff --git a/src/test/java/net/sf/jabref/logic/openoffice/StyleLoaderTest.java b/src/test/java/net/sf/jabref/logic/openoffice/StyleLoaderTest.java index cc4b0dd13e4..43c0b670769 100644 --- a/src/test/java/net/sf/jabref/logic/openoffice/StyleLoaderTest.java +++ b/src/test/java/net/sf/jabref/logic/openoffice/StyleLoaderTest.java @@ -33,8 +33,8 @@ public class StyleLoaderTest { @Before public void setUp() { preferences = new OpenOfficePreferences(JabRefPreferences.getInstance()); - layoutPreferences = LayoutFormatterPreferences.fromPreferences(JabRefPreferences.getInstance(), - mock(JournalAbbreviationLoader.class)); + layoutPreferences = JabRefPreferences.getInstance() + .getLayoutFormatterPreferences(mock(JournalAbbreviationLoader.class)); encoding = JabRefPreferences.getInstance().getDefaultEncoding(); } @@ -48,7 +48,7 @@ public void throwNPEWithNullPreferences() { @Test(expected = NullPointerException.class) public void throwNPEWithNullRepository() { loader = new StyleLoader(mock(OpenOfficePreferences.class), - LayoutFormatterPreferences.fromPreferences(JabRefPreferences.getInstance(), null), mock(Charset.class)); + JabRefPreferences.getInstance().getLayoutFormatterPreferences(null), mock(Charset.class)); fail(); } diff --git a/src/test/java/net/sf/jabref/logic/util/io/FileUtilTest.java b/src/test/java/net/sf/jabref/logic/util/io/FileUtilTest.java index 9f4242d198b..6d9bb50f8dc 100644 --- a/src/test/java/net/sf/jabref/logic/util/io/FileUtilTest.java +++ b/src/test/java/net/sf/jabref/logic/util/io/FileUtilTest.java @@ -27,8 +27,8 @@ public void testGetLinkedFileNameDefault() { entry.setField("title", "mytitle"); assertEquals("1234 - mytitle", - FileUtil.createFileNameFromPattern(null, entry, fileNamePattern, LayoutFormatterPreferences - .fromPreferences(JabRefPreferences.getInstance(), mock(JournalAbbreviationLoader.class)))); + FileUtil.createFileNameFromPattern(null, entry, fileNamePattern, JabRefPreferences.getInstance() + .getLayoutFormatterPreferences(mock(JournalAbbreviationLoader.class)))); } @Test diff --git a/src/test/java/net/sf/jabref/logic/xmp/XMPUtilTest.java b/src/test/java/net/sf/jabref/logic/xmp/XMPUtilTest.java index 2b08cbeb5c6..f52ebbe70d8 100644 --- a/src/test/java/net/sf/jabref/logic/xmp/XMPUtilTest.java +++ b/src/test/java/net/sf/jabref/logic/xmp/XMPUtilTest.java @@ -31,7 +31,6 @@ import net.sf.jabref.cli.XMPUtilMain; import net.sf.jabref.logic.bibtex.BibEntryWriter; import net.sf.jabref.logic.bibtex.LatexFieldFormatter; -import net.sf.jabref.logic.bibtex.LatexFieldFormatterPreferences; import net.sf.jabref.logic.importer.ImportFormatPreferences; import net.sf.jabref.logic.importer.ParserResult; import net.sf.jabref.logic.importer.fileformat.BibtexParser; @@ -149,7 +148,7 @@ public static BibEntry bibtexString2BibtexEntry(String s, ImportFormatPreference public static String bibtexEntry2BibtexString(BibEntry e, JabRefPreferences preferences) throws IOException { StringWriter sw = new StringWriter(); - new BibEntryWriter(new LatexFieldFormatter(LatexFieldFormatterPreferences.fromPreferences(preferences)), + new BibEntryWriter(new LatexFieldFormatter(preferences.getLatexFieldFormatterPreferences()), false).write(e, sw, BibDatabaseMode.BIBTEX); return sw.getBuffer().toString(); } @@ -250,8 +249,8 @@ public void setUp() throws IOException, COSVisitorException { // The code assumes privacy filters to be off prefs.putBoolean("useXmpPrivacyFilter", false); - importFormatPreferences = ImportFormatPreferences.fromPreferences(prefs); - xmpPreferences = XMPPreferences.fromPreferences(prefs); + importFormatPreferences = prefs.getImportFormatPreferences(); + xmpPreferences = prefs.getXMPPreferences(); } @After @@ -325,9 +324,9 @@ public void testPrivacyFilter() throws IOException, TransformerException { prefs.putBoolean("useXmpPrivacyFilter", true); prefs.putStringList(JabRefPreferences.XMP_PRIVACY_FILTERS, Arrays.asList("author", "title", "note")); - XMPUtil.writeXMP(pdfFile, e, null, XMPPreferences.fromPreferences(prefs)); + XMPUtil.writeXMP(pdfFile, e, null, prefs.getXMPPreferences()); - List l = XMPUtil.readXMP(pdfFile.getAbsoluteFile(), XMPPreferences.fromPreferences(prefs)); + List l = XMPUtil.readXMP(pdfFile.getAbsoluteFile(), prefs.getXMPPreferences()); Assert.assertEquals(1, l.size()); BibEntry x = l.get(0); @@ -343,9 +342,9 @@ public void testPrivacyFilter() throws IOException, TransformerException { BibEntry e = t1BibtexEntry(); - XMPUtil.writeXMP(pdfFile, e, null, XMPPreferences.fromPreferences(prefs)); + XMPUtil.writeXMP(pdfFile, e, null, prefs.getXMPPreferences()); - List l = XMPUtil.readXMP(pdfFile.getAbsoluteFile(), XMPPreferences.fromPreferences(prefs)); + List l = XMPUtil.readXMP(pdfFile.getAbsoluteFile(), prefs.getXMPPreferences()); Assert.assertEquals(1, l.size()); BibEntry x = l.get(0); Set ts = x.getFieldNames(); diff --git a/src/test/resources/net/sf/jabref/logic/exporter/MsBibExportFormatTest3.xml b/src/test/resources/net/sf/jabref/logic/exporter/MsBibExportFormatTest3.xml index b6855b785e1..4a4ac5d94c1 100644 --- a/src/test/resources/net/sf/jabref/logic/exporter/MsBibExportFormatTest3.xml +++ b/src/test/resources/net/sf/jabref/logic/exporter/MsBibExportFormatTest3.xml @@ -18,7 +18,7 @@ 237-248 44 - LCCN: 0937-6429 +LCCN: 0937-6429 Gabler Verlag Wirtschaftsinformatik http://dx.doi.org/10.1007/BF03250842