diff --git a/src/main/java/org/jabref/gui/importer/ImportEntriesViewModel.java b/src/main/java/org/jabref/gui/importer/ImportEntriesViewModel.java index 2c12cd4cda4..a41d4371d9b 100644 --- a/src/main/java/org/jabref/gui/importer/ImportEntriesViewModel.java +++ b/src/main/java/org/jabref/gui/importer/ImportEntriesViewModel.java @@ -61,7 +61,14 @@ public class ImportEntriesViewModel extends AbstractViewModel { * @param databaseContext the database to import into * @param task the task executed for parsing the selected files(s). */ - public ImportEntriesViewModel(BackgroundTask task, TaskExecutor taskExecutor, BibDatabaseContext databaseContext, DialogService dialogService, UndoManager undoManager, PreferencesService preferences, StateManager stateManager, FileUpdateMonitor fileUpdateMonitor) { + public ImportEntriesViewModel(BackgroundTask task, + TaskExecutor taskExecutor, + BibDatabaseContext databaseContext, + DialogService dialogService, + UndoManager undoManager, + PreferencesService preferences, + StateManager stateManager, + FileUpdateMonitor fileUpdateMonitor) { this.taskExecutor = taskExecutor; this.databaseContext = databaseContext; this.dialogService = dialogService; @@ -94,9 +101,9 @@ public ObservableList getEntries() { } public boolean hasDuplicate(BibEntry entry) { - return findInternalDuplicate(entry).isPresent() - || - new DuplicateCheck(Globals.entryTypesManager).containsDuplicate(databaseContext.getDatabase(), entry, databaseContext.getMode()).isPresent(); + return findInternalDuplicate(entry).isPresent() || + new DuplicateCheck(Globals.entryTypesManager) + .containsDuplicate(databaseContext.getDatabase(), entry, databaseContext.getMode()).isPresent(); } /** @@ -132,8 +139,8 @@ public void importEntries(List entriesToImport, boolean shouldDownload } // Remember the selection in the dialog - FilePreferences filePreferences = preferences.getFilePreferences(); - filePreferences.setShouldDownloadLinkedFiles(shouldDownloadFiles); + FilePreferences filePreferences = preferences.getFilePreferences() + .withShouldDownloadLinkedFiles(shouldDownloadFiles); preferences.storeFilePreferences(filePreferences); if (shouldDownloadFiles) { diff --git a/src/main/java/org/jabref/model/metadata/FilePreferences.java b/src/main/java/org/jabref/model/metadata/FilePreferences.java index 462fec70cdf..0d8d17f7e56 100644 --- a/src/main/java/org/jabref/model/metadata/FilePreferences.java +++ b/src/main/java/org/jabref/model/metadata/FilePreferences.java @@ -12,7 +12,7 @@ public class FilePreferences { private final boolean bibLocationAsPrimary; private final String fileNamePattern; private final String fileDirPattern; - private boolean shouldDownloadLinkedFiles; + private final boolean shouldDownloadLinkedFiles; public FilePreferences(String user, String mainFileDirectory, @@ -56,7 +56,13 @@ public boolean shouldDownloadLinkedFiles() { return shouldDownloadLinkedFiles; } - public void setShouldDownloadLinkedFiles(boolean shouldDownloadLinkedFiles) { - this.shouldDownloadLinkedFiles = shouldDownloadLinkedFiles; + public FilePreferences withShouldDownloadLinkedFiles(boolean newShouldDownloadLinkedFiles) { + return new FilePreferences( + this.user, + this.mainFileDirectory, + this.bibLocationAsPrimary, + this.fileNamePattern, + this.fileDirPattern, + newShouldDownloadLinkedFiles); } }