Skip to content
Merged
13 changes: 4 additions & 9 deletions src/main/java/org/jabref/cli/ArgumentProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -291,13 +291,12 @@ private void writeMetadataToPdf(List<ParserResult> loaded,
}
ParserResult pr = loaded.get(loaded.size() - 1);
BibDatabaseContext databaseContext = pr.getDatabaseContext();
BibDatabase dataBase = pr.getDatabase();

XmpPdfExporter xmpPdfExporter = new XmpPdfExporter(xmpPreferences);
EmbeddedBibFilePdfExporter embeddedBibFilePdfExporter = new EmbeddedBibFilePdfExporter(databaseMode, entryTypesManager, fieldPreferences);

if ("all".equals(filesAndCitekeys)) {
for (BibEntry entry : dataBase.getEntries()) {
for (BibEntry entry : databaseContext.getEntries()) {
writeMetadataToPDFsOfEntry(
databaseContext,
entry.getCitationKey().orElse("<no cite key defined>"),
Expand All @@ -324,7 +323,6 @@ private void writeMetadataToPdf(List<ParserResult> loaded,

writeMetadataToPdfByCitekey(
databaseContext,
dataBase,
citeKeys,
filePreferences,
xmpPdfExporter,
Expand All @@ -334,7 +332,6 @@ private void writeMetadataToPdf(List<ParserResult> loaded,
embeddBibfile);
writeMetadataToPdfByFileNames(
databaseContext,
dataBase,
pdfs,
filePreferences,
xmpPdfExporter,
Expand Down Expand Up @@ -374,7 +371,6 @@ private void writeMetadataToPDFsOfEntry(BibDatabaseContext databaseContext,
}

private void writeMetadataToPdfByCitekey(BibDatabaseContext databaseContext,
BibDatabase dataBase,
List<String> citeKeys,
FilePreferences filePreferences,
XmpPdfExporter xmpPdfExporter,
Expand All @@ -383,7 +379,7 @@ private void writeMetadataToPdfByCitekey(BibDatabaseContext databaseContext,
boolean writeXMP,
boolean embeddBibfile) {
for (String citeKey : citeKeys) {
List<BibEntry> bibEntryList = dataBase.getEntriesByCitationKey(citeKey);
List<BibEntry> bibEntryList = databaseContext.getDatabase().getEntriesByCitationKey(citeKey);
if (bibEntryList.isEmpty()) {
System.err.printf("Skipped - Cannot find %s in library.%n", citeKey);
continue;
Expand All @@ -395,7 +391,6 @@ private void writeMetadataToPdfByCitekey(BibDatabaseContext databaseContext,
}

private void writeMetadataToPdfByFileNames(BibDatabaseContext databaseContext,
BibDatabase dataBase,
List<String> pdfs,
FilePreferences filePreferences,
XmpPdfExporter xmpPdfExporter,
Expand All @@ -411,14 +406,14 @@ private void writeMetadataToPdfByFileNames(BibDatabaseContext databaseContext,
if (Files.exists(filePath)) {
try {
if (writeXMP) {
if (xmpPdfExporter.exportToFileByPath(databaseContext, dataBase, filePreferences, filePath, abbreviationRepository)) {
if (xmpPdfExporter.exportToFileByPath(databaseContext, filePreferences, filePath, abbreviationRepository)) {
System.out.printf("Successfully written XMP metadata of at least one entry to %s%n", fileName);
} else {
System.out.printf("File %s is not linked to any entry in database.%n", fileName);
}
}
if (embeddBibfile) {
if (embeddedBibFilePdfExporter.exportToFileByPath(databaseContext, dataBase, filePreferences, filePath, abbreviationRepository)) {
if (embeddedBibFilePdfExporter.exportToFileByPath(databaseContext, filePreferences, filePath, abbreviationRepository)) {
System.out.printf("Successfully embedded XMP metadata of at least one entry to %s%n", fileName);
} else {
System.out.printf("File %s is not linked to any entry in database.%n", fileName);
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/org/jabref/cli/Launcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.jabref.logic.remote.client.RemoteClient;
import org.jabref.logic.util.OS;
import org.jabref.migrations.PreferencesMigrations;
import org.jabref.model.entry.BibEntryTypesManager;
import org.jabref.model.util.FileUpdateMonitor;
import org.jabref.preferences.JabRefPreferences;
import org.jabref.preferences.PreferencesService;
Expand Down Expand Up @@ -59,10 +60,12 @@ public static void main(String[] args) {

addLogToDisk();
try {
Globals.entryTypesManager = new BibEntryTypesManager();

// Init preferences
final JabRefPreferences preferences = JabRefPreferences.getInstance();
Globals.prefs = preferences;
PreferencesMigrations.runMigrations(preferences);
PreferencesMigrations.runMigrations(preferences, Globals.entryTypesManager);

// Early exit in case another instance is already running
if (!handleMultipleAppInstances(ARGUMENTS, preferences)) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/gui/Globals.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public class Globals {
public static ProtectedTermsLoader protectedTermsLoader;

public static CountingUndoManager undoManager = new CountingUndoManager();
public static BibEntryTypesManager entryTypesManager = new BibEntryTypesManager();
public static BibEntryTypesManager entryTypesManager;

private static ClipBoardManager clipBoardManager = null;
private static KeyBindingRepository keyBindingRepository;
Expand Down
45 changes: 24 additions & 21 deletions src/main/java/org/jabref/gui/JabRefFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
import org.jabref.logic.util.OS;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.BibEntryTypesManager;
import org.jabref.model.entry.field.SpecialField;
import org.jabref.model.entry.types.StandardEntryType;
import org.jabref.model.groups.GroupTreeNode;
Expand Down Expand Up @@ -173,6 +174,7 @@ public class JabRefFrame extends BorderPane {
private final CountingUndoManager undoManager;
private final DialogService dialogService;
private final FileUpdateMonitor fileUpdateMonitor;
private final BibEntryTypesManager entryTypesManager;
private final PushToApplicationCommand pushToApplicationCommand;
private SidePane sidePane;
private TabPane tabbedPane;
Expand All @@ -189,6 +191,7 @@ public JabRefFrame(Stage mainStage) {
this.dialogService = new JabRefDialogService(mainStage);
this.undoManager = Globals.undoManager;
this.fileUpdateMonitor = Globals.getFileUpdateMonitor();
this.entryTypesManager = Globals.entryTypesManager;
this.globalSearchBar = new GlobalSearchBar(this, stateManager, prefs, undoManager, dialogService);
this.pushToApplicationCommand = new PushToApplicationCommand(stateManager, dialogService, prefs);
this.fileHistory = new FileHistoryMenu(prefs.getGuiPreferences().getFileHistory(), dialogService, getOpenDatabaseAction());
Expand Down Expand Up @@ -413,7 +416,7 @@ public void openAction(String filePath) {
* The MacAdapter calls this method when "About" is selected from the application menu.
*/
public void about() {
new HelpAction(HelpFile.CONTENTS, dialogService).execute();
new HelpAction(HelpFile.CONTENTS, dialogService, prefs.getFilePreferences()).execute();
}

/**
Expand Down Expand Up @@ -562,7 +565,7 @@ private Node createToolbar() {
ToolBar toolBar = new ToolBar(
new HBox(
factory.createIconButton(StandardActions.NEW_LIBRARY, new NewDatabaseAction(this, prefs)),
factory.createIconButton(StandardActions.OPEN_LIBRARY, new OpenDatabaseAction(this, prefs, dialogService, stateManager, fileUpdateMonitor)),
factory.createIconButton(StandardActions.OPEN_LIBRARY, new OpenDatabaseAction(this, prefs, dialogService, stateManager, fileUpdateMonitor, entryTypesManager)),
factory.createIconButton(StandardActions.SAVE_LIBRARY, new SaveAction(SaveAction.SaveMethod.SAVE, this, prefs, stateManager))),

leftSpacer,
Expand Down Expand Up @@ -602,7 +605,7 @@ private Node createToolbar() {
new Separator(Orientation.VERTICAL),

new HBox(
factory.createIconButton(StandardActions.OPEN_GITHUB, new OpenBrowserAction("https://github.com/JabRef/jabref", dialogService))));
factory.createIconButton(StandardActions.OPEN_GITHUB, new OpenBrowserAction("https://github.com/JabRef/jabref", dialogService, prefs.getFilePreferences()))));

leftSpacer.setPrefWidth(50);
leftSpacer.setMinWidth(Region.USE_PREF_SIZE);
Expand Down Expand Up @@ -771,7 +774,7 @@ private MenuBar createMenu() {
factory.createMenuItem(StandardActions.SAVE_LIBRARY_AS, new SaveAction(SaveAction.SaveMethod.SAVE_AS, this, prefs, stateManager)),
factory.createMenuItem(StandardActions.SAVE_ALL, new SaveAllAction(this, prefs)),
factory.createMenuItem(StandardActions.CLOSE_LIBRARY, new CloseDatabaseAction()),

new SeparatorMenuItem(),

factory.createSubMenu(StandardActions.IMPORT,
Expand Down Expand Up @@ -861,8 +864,8 @@ private MenuBar createMenu() {

quality.getItems().addAll(
factory.createMenuItem(StandardActions.FIND_DUPLICATES, new DuplicateSearch(this, dialogService, stateManager, prefs)),
factory.createMenuItem(StandardActions.MERGE_ENTRIES, new MergeEntriesAction(dialogService, stateManager, prefs.getBibEntryPreferences())),
factory.createMenuItem(StandardActions.CHECK_INTEGRITY, new IntegrityCheckAction(this, stateManager, Globals.TASK_EXECUTOR)),
factory.createMenuItem(StandardActions.MERGE_ENTRIES, new MergeEntriesAction(dialogService, stateManager, prefs)),
factory.createMenuItem(StandardActions.CHECK_INTEGRITY, new IntegrityCheckAction(this, prefs, dialogService, stateManager, Globals.TASK_EXECUTOR, Globals.journalAbbreviationRepository)),
factory.createMenuItem(StandardActions.CLEANUP_ENTRIES, new CleanupAction(this, this.prefs, dialogService, stateManager)),

new SeparatorMenuItem(),
Expand Down Expand Up @@ -903,7 +906,7 @@ private MenuBar createMenu() {

new SeparatorMenuItem(),

factory.createMenuItem(StandardActions.WRITE_METADATA_TO_PDF, new WriteMetadataToPdfAction(stateManager, Globals.entryTypesManager, prefs.getFieldPreferences(), dialogService, taskExecutor, prefs.getFilePreferences(), prefs.getXmpPreferences())),
factory.createMenuItem(StandardActions.WRITE_METADATA_TO_PDF, new WriteMetadataToPdfAction(stateManager, Globals.entryTypesManager, prefs.getFieldPreferences(), dialogService, taskExecutor, prefs.getFilePreferences(), prefs.getXmpPreferences(), Globals.journalAbbreviationRepository)),
factory.createMenuItem(StandardActions.COPY_LINKED_FILES, new CopyFilesAction(dialogService, prefs, stateManager)),

new SeparatorMenuItem(),
Expand Down Expand Up @@ -943,28 +946,28 @@ private MenuBar createMenu() {
);

help.getItems().addAll(
factory.createMenuItem(StandardActions.HELP, new HelpAction(HelpFile.CONTENTS, dialogService)),
factory.createMenuItem(StandardActions.OPEN_FORUM, new OpenBrowserAction("http://discourse.jabref.org/", dialogService)),
factory.createMenuItem(StandardActions.HELP, new HelpAction(HelpFile.CONTENTS, dialogService, prefs.getFilePreferences())),
factory.createMenuItem(StandardActions.OPEN_FORUM, new OpenBrowserAction("http://discourse.jabref.org/", dialogService, prefs.getFilePreferences())),

new SeparatorMenuItem(),

factory.createMenuItem(StandardActions.ERROR_CONSOLE, new ErrorConsoleAction()),

new SeparatorMenuItem(),

factory.createMenuItem(StandardActions.DONATE, new OpenBrowserAction("https://donations.jabref.org", dialogService)),
factory.createMenuItem(StandardActions.SEARCH_FOR_UPDATES, new SearchForUpdateAction(Globals.BUILD_INFO, prefs.getInternalPreferences(), dialogService, Globals.TASK_EXECUTOR)),
factory.createMenuItem(StandardActions.DONATE, new OpenBrowserAction("https://donations.jabref.org", dialogService, prefs.getFilePreferences())),
factory.createMenuItem(StandardActions.SEARCH_FOR_UPDATES, new SearchForUpdateAction(Globals.BUILD_INFO, prefs, dialogService, Globals.TASK_EXECUTOR)),
factory.createSubMenu(StandardActions.WEB_MENU,
factory.createMenuItem(StandardActions.OPEN_WEBPAGE, new OpenBrowserAction("https://jabref.org/", dialogService)),
factory.createMenuItem(StandardActions.OPEN_BLOG, new OpenBrowserAction("https://blog.jabref.org/", dialogService)),
factory.createMenuItem(StandardActions.OPEN_FACEBOOK, new OpenBrowserAction("https://www.facebook.com/JabRef/", dialogService)),
factory.createMenuItem(StandardActions.OPEN_TWITTER, new OpenBrowserAction("https://twitter.com/jabref_org", dialogService)),
factory.createMenuItem(StandardActions.OPEN_GITHUB, new OpenBrowserAction("https://github.com/JabRef/jabref", dialogService)),
factory.createMenuItem(StandardActions.OPEN_WEBPAGE, new OpenBrowserAction("https://jabref.org/", dialogService, prefs.getFilePreferences())),
factory.createMenuItem(StandardActions.OPEN_BLOG, new OpenBrowserAction("https://blog.jabref.org/", dialogService, prefs.getFilePreferences())),
factory.createMenuItem(StandardActions.OPEN_FACEBOOK, new OpenBrowserAction("https://www.facebook.com/JabRef/", dialogService, prefs.getFilePreferences())),
factory.createMenuItem(StandardActions.OPEN_TWITTER, new OpenBrowserAction("https://twitter.com/jabref_org", dialogService, prefs.getFilePreferences())),
factory.createMenuItem(StandardActions.OPEN_GITHUB, new OpenBrowserAction("https://github.com/JabRef/jabref", dialogService, prefs.getFilePreferences())),

new SeparatorMenuItem(),

factory.createMenuItem(StandardActions.OPEN_DEV_VERSION_LINK, new OpenBrowserAction("https://builds.jabref.org/master/", dialogService)),
factory.createMenuItem(StandardActions.OPEN_CHANGELOG, new OpenBrowserAction("https://github.com/JabRef/jabref/blob/main/CHANGELOG.md", dialogService))
factory.createMenuItem(StandardActions.OPEN_DEV_VERSION_LINK, new OpenBrowserAction("https://builds.jabref.org/master/", dialogService, prefs.getFilePreferences())),
factory.createMenuItem(StandardActions.OPEN_CHANGELOG, new OpenBrowserAction("https://github.com/JabRef/jabref/blob/main/CHANGELOG.md", dialogService, prefs.getFilePreferences()))
),
factory.createMenuItem(StandardActions.ABOUT, new AboutAction())
);
Expand Down Expand Up @@ -1157,7 +1160,7 @@ public void addTab(LibraryTab libraryTab, boolean raisePanel) {
public LibraryTab addTab(BibDatabaseContext databaseContext, boolean raisePanel) {
Objects.requireNonNull(databaseContext);

LibraryTab libraryTab = new LibraryTab(databaseContext, this, prefs, stateManager, fileUpdateMonitor);
LibraryTab libraryTab = new LibraryTab(databaseContext, this, prefs, stateManager, fileUpdateMonitor, entryTypesManager);
addTab(libraryTab, raisePanel);
return libraryTab;
}
Expand Down Expand Up @@ -1275,7 +1278,7 @@ public void closeCurrentTab() {
}

public OpenDatabaseAction getOpenDatabaseAction() {
return new OpenDatabaseAction(this, prefs, dialogService, stateManager, fileUpdateMonitor);
return new OpenDatabaseAction(this, prefs, dialogService, stateManager, fileUpdateMonitor, entryTypesManager);
}

public GlobalSearchBar getGlobalSearchBar() {
Expand Down Expand Up @@ -1414,7 +1417,7 @@ public OpenDatabaseFolder(Supplier<BibDatabaseContext> databaseContext) {
public void execute() {
Optional.of(databaseContext.get()).flatMap(BibDatabaseContext::getDatabasePath).ifPresent(path -> {
try {
JabRefDesktop.openFolderAndSelectFile(path, prefs, dialogService);
JabRefDesktop.openFolderAndSelectFile(path, prefs.getExternalApplicationsPreferences(), dialogService);
} catch (IOException e) {
LOGGER.info("Could not open folder", e);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/gui/JabRefGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public JabRefGUI(Stage mainStage,
new VersionWorker(Globals.BUILD_INFO.version,
mainFrame.getDialogService(),
Globals.TASK_EXECUTOR,
preferencesService.getInternalPreferences())
preferencesService)
.checkForNewVersionDelayed();

setupProxy();
Expand Down
Loading