From b84470368920263784ee2eeb264cf37ee75eecf4 Mon Sep 17 00:00:00 2001 From: Carl Christian Snethlage <50491877+calixtus@users.noreply.github.com> Date: Mon, 18 Oct 2021 21:26:18 +0200 Subject: [PATCH 1/2] Removed two unused preference options (#8164) --- CHANGELOG.md | 2 +- .../linkedfiles/LinkedFilesTabViewModel.java | 6 +-- .../jabref/preferences/FilePreferences.java | 16 +------- .../jabref/preferences/JabRefPreferences.java | 10 +---- .../preferences/FilePreferenceTest.java | 39 +++++++++---------- 5 files changed, 22 insertions(+), 51 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 59eea617342..82ff46b4e4d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,7 +52,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve ### Removed - +- We removed two orphaned preferences options [#8164](https://github.com/JabRef/jabref/pull/8164) diff --git a/src/main/java/org/jabref/gui/preferences/linkedfiles/LinkedFilesTabViewModel.java b/src/main/java/org/jabref/gui/preferences/linkedfiles/LinkedFilesTabViewModel.java index 80e54e42fba..6bd07120ddb 100644 --- a/src/main/java/org/jabref/gui/preferences/linkedfiles/LinkedFilesTabViewModel.java +++ b/src/main/java/org/jabref/gui/preferences/linkedfiles/LinkedFilesTabViewModel.java @@ -78,8 +78,6 @@ public void setValues() { // External files preferences / Attached files preferences / File preferences mainFileDirectoryProperty.setValue(initialFilePreferences.getFileDirectory().orElse(Path.of("")).toString()); useBibLocationAsPrimaryProperty.setValue(initialFilePreferences.shouldStoreFilesRelativeToBib()); - searchFilesOnOpenProperty.setValue(initialFilePreferences.shouldSearchFilesOnOpen()); - openBrowseOnCreateProperty.setValue(initialFilePreferences.shouldOpenBrowseOnCreate()); fileNamePatternProperty.setValue(initialFilePreferences.getFileNamePattern()); fileDirectoryPatternProperty.setValue(initialFilePreferences.getFileDirectoryPattern()); @@ -102,9 +100,7 @@ public void storeSettings() { useBibLocationAsPrimaryProperty.getValue(), fileNamePatternProperty.getValue(), fileDirectoryPatternProperty.getValue(), - initialFilePreferences.shouldDownloadLinkedFiles(), // set in ImportEntriesViewModel - searchFilesOnOpenProperty.getValue(), - openBrowseOnCreateProperty.getValue())); + initialFilePreferences.shouldDownloadLinkedFiles())); // set in ImportEntriesViewModel // Autolink preferences AutoLinkPreferences.CitationKeyDependency citationKeyDependency = AutoLinkPreferences.CitationKeyDependency.START; diff --git a/src/main/java/org/jabref/preferences/FilePreferences.java b/src/main/java/org/jabref/preferences/FilePreferences.java index 28ca322e925..9ecd65b14e9 100644 --- a/src/main/java/org/jabref/preferences/FilePreferences.java +++ b/src/main/java/org/jabref/preferences/FilePreferences.java @@ -15,25 +15,19 @@ public class FilePreferences { private final String fileNamePattern; private final String fileDirPattern; private boolean shouldDownloadLinkedFiles; - private final boolean shouldSearchFilesOnOpen; - private final boolean shouldOpenBrowseOnCreate; public FilePreferences(String user, String mainFileDirectory, boolean shouldStoreFilesRelativeToBibFile, String fileNamePattern, String fileDirPattern, - boolean shouldDownloadLinkedFiles, - boolean shouldSearchFilesOnOpen, - boolean shouldOpenBrowseOnCreate) { + boolean shouldDownloadLinkedFiles) { this.user = user; this.mainFileDirectory = mainFileDirectory; this.shouldStoreFilesRelativeToBibFile = shouldStoreFilesRelativeToBibFile; this.fileNamePattern = fileNamePattern; this.fileDirPattern = fileDirPattern; this.shouldDownloadLinkedFiles = shouldDownloadLinkedFiles; - this.shouldSearchFilesOnOpen = shouldSearchFilesOnOpen; - this.shouldOpenBrowseOnCreate = shouldOpenBrowseOnCreate; } public String getUser() { @@ -68,12 +62,4 @@ public FilePreferences withShouldDownloadLinkedFiles(boolean newShouldDownloadLi this.shouldDownloadLinkedFiles = newShouldDownloadLinkedFiles; return this; } - - public boolean shouldSearchFilesOnOpen() { - return shouldSearchFilesOnOpen; - } - - public boolean shouldOpenBrowseOnCreate() { - return shouldOpenBrowseOnCreate; - } } diff --git a/src/main/java/org/jabref/preferences/JabRefPreferences.java b/src/main/java/org/jabref/preferences/JabRefPreferences.java index 080dc7c65b0..6cd446ff5dd 100644 --- a/src/main/java/org/jabref/preferences/JabRefPreferences.java +++ b/src/main/java/org/jabref/preferences/JabRefPreferences.java @@ -260,7 +260,6 @@ public class JabRefPreferences implements PreferencesService { public static final String KEY_GEN_FIRST_LETTER_A = "keyGenFirstLetterA"; public static final String ALLOW_INTEGER_EDITION_BIBTEX = "allowIntegerEditionBibtex"; public static final String LOCAL_AUTO_SAVE = "localAutoSave"; - public static final String RUN_AUTOMATIC_FILE_SEARCH = "runAutomaticFileSearch"; public static final String AUTOLINK_REG_EXP_SEARCH_EXPRESSION_KEY = "regExpSearchExpression"; public static final String AUTOLINK_USE_REG_EXP_SEARCH_KEY = "useRegExpSearch"; // bibLocAsPrimaryDir is a misleading antique variable name, we keep it for reason of compatibility @@ -268,7 +267,6 @@ public class JabRefPreferences implements PreferencesService { public static final String SELECTED_FETCHER_INDEX = "selectedFetcherIndex"; public static final String WEB_SEARCH_VISIBLE = "webSearchVisible"; public static final String GROUP_SIDEPANE_VISIBLE = "groupSidepaneVisible"; - public static final String ALLOW_FILE_AUTO_OPEN_BROWSE = "allowFileAutoOpenBrowse"; public static final String CUSTOM_TAB_NAME = "customTabName_"; public static final String CUSTOM_TAB_FIELDS = "customTabFields_"; public static final String ASK_AUTO_NAMING_PDFS_AGAIN = "AskAutoNamingPDFsAgain"; @@ -641,7 +639,6 @@ private JabRefPreferences() { defaults.put(OVERRIDE_DEFAULT_FONT_SIZE, false); defaults.put(AUTOLINK_EXACT_KEY_ONLY, Boolean.FALSE); - defaults.put(RUN_AUTOMATIC_FILE_SEARCH, Boolean.FALSE); defaults.put(LOCAL_AUTO_SAVE, Boolean.FALSE); defaults.put(ALLOW_INTEGER_EDITION_BIBTEX, Boolean.FALSE); // Curly brackets ({}) are the default delimiters, not quotes (") as these cause trouble when they appear within the field value: @@ -650,7 +647,6 @@ private JabRefPreferences() { defaults.put(KEY_GEN_ALWAYS_ADD_LETTER, Boolean.FALSE); defaults.put(EMAIL_SUBJECT, Localization.lang("References")); defaults.put(OPEN_FOLDERS_OF_ATTACHED_FILES, Boolean.FALSE); - defaults.put(ALLOW_FILE_AUTO_OPEN_BROWSE, Boolean.TRUE); defaults.put(WEB_SEARCH_VISIBLE, Boolean.TRUE); defaults.put(GROUP_SIDEPANE_VISIBLE, Boolean.TRUE); defaults.put(SELECTED_FETCHER_INDEX, 0); @@ -2189,9 +2185,7 @@ public FilePreferences getFilePreferences() { getBoolean(STORE_RELATIVE_TO_BIB), get(IMPORT_FILENAMEPATTERN), get(IMPORT_FILEDIRPATTERN), - getBoolean(DOWNLOAD_LINKED_FILES), - getBoolean(RUN_AUTOMATIC_FILE_SEARCH), - getBoolean(ALLOW_FILE_AUTO_OPEN_BROWSE)); + getBoolean(DOWNLOAD_LINKED_FILES)); } @Override @@ -2201,8 +2195,6 @@ public void storeFilePreferences(FilePreferences preferences) { put(IMPORT_FILENAMEPATTERN, preferences.getFileNamePattern()); put(IMPORT_FILEDIRPATTERN, preferences.getFileDirectoryPattern()); putBoolean(DOWNLOAD_LINKED_FILES, preferences.shouldDownloadLinkedFiles()); - putBoolean(RUN_AUTOMATIC_FILE_SEARCH, preferences.shouldSearchFilesOnOpen()); - putBoolean(ALLOW_FILE_AUTO_OPEN_BROWSE, preferences.shouldOpenBrowseOnCreate()); } @Override diff --git a/src/test/java/org/jabref/preferences/FilePreferenceTest.java b/src/test/java/org/jabref/preferences/FilePreferenceTest.java index d97efe91c86..2f8c814054f 100644 --- a/src/test/java/org/jabref/preferences/FilePreferenceTest.java +++ b/src/test/java/org/jabref/preferences/FilePreferenceTest.java @@ -19,14 +19,15 @@ public class FilePreferenceTest { private final String testFileNamePattern = "test"; private final String testFileDirPattern = "test"; private final boolean shouldDownloadLinkedFiles = false; - private final boolean shouldSearchFilesOnOpen = false; - private final boolean shouldOpenBrowseOnCreate = false; @BeforeEach public void setup() { - filePreferences = new FilePreferences(testUser, testMainFileDirectory, shouldStoreFilesRelativeToBibFile, - testFileNamePattern, testFileDirPattern, shouldDownloadLinkedFiles, shouldSearchFilesOnOpen, - shouldOpenBrowseOnCreate); + filePreferences = new FilePreferences(testUser, + testMainFileDirectory, + shouldStoreFilesRelativeToBibFile, + testFileNamePattern, + testFileDirPattern, + shouldDownloadLinkedFiles); } @Test @@ -41,9 +42,12 @@ public void getFileDirectoryNonEmptyTest() { @Test public void getFileDirectoryEmptyTest() { - filePreferences = new FilePreferences(testUser, "", shouldStoreFilesRelativeToBibFile, - testFileNamePattern, testFileDirPattern, shouldDownloadLinkedFiles, shouldSearchFilesOnOpen, - shouldOpenBrowseOnCreate); + filePreferences = new FilePreferences(testUser, + "", + shouldStoreFilesRelativeToBibFile, + testFileNamePattern, + testFileDirPattern, + shouldDownloadLinkedFiles); assertEquals(Optional.empty(), filePreferences.getFileDirectory()); } @@ -71,21 +75,14 @@ public void shouldDownloadLinkedFilesTest() { @ParameterizedTest @ValueSource(booleans = {true, false}) public void withShouldDownloadLinkedFilesTest(boolean newShouldDownloadLinkedFiles) { - FilePreferences expected = new FilePreferences(testUser, testMainFileDirectory, shouldStoreFilesRelativeToBibFile, - testFileNamePattern, testFileDirPattern, newShouldDownloadLinkedFiles, shouldSearchFilesOnOpen, - shouldOpenBrowseOnCreate); + FilePreferences expected = new FilePreferences(testUser, + testMainFileDirectory, + shouldStoreFilesRelativeToBibFile, + testFileNamePattern, + testFileDirPattern, + newShouldDownloadLinkedFiles); assertEquals(expected.shouldDownloadLinkedFiles(), filePreferences.withShouldDownloadLinkedFiles(newShouldDownloadLinkedFiles).shouldDownloadLinkedFiles()); } - - @Test - public void shouldSearchFilesOnOpenTest() { - assertEquals(shouldSearchFilesOnOpen, filePreferences.shouldSearchFilesOnOpen()); - } - - @Test - public void shouldOpenBrowseOnCreateTest() { - assertEquals(shouldOpenBrowseOnCreate, filePreferences.shouldOpenBrowseOnCreate()); - } } From 71327b86e597ca565bae3700b0117f396f418b9b Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Mon, 18 Oct 2021 21:38:31 +0200 Subject: [PATCH 2/2] Fix some typos (#8157) --- src/main/java/org/jabref/gui/EntryTypeView.java | 2 +- src/main/java/org/jabref/gui/EntryTypeViewModel.java | 8 +++----- src/main/java/org/jabref/gui/JabRefGUI.java | 1 - src/main/java/org/jabref/gui/JabRefMain.java | 4 ++-- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/jabref/gui/EntryTypeView.java b/src/main/java/org/jabref/gui/EntryTypeView.java index b82df361511..10a95f3a5d0 100644 --- a/src/main/java/org/jabref/gui/EntryTypeView.java +++ b/src/main/java/org/jabref/gui/EntryTypeView.java @@ -79,7 +79,7 @@ public EntryTypeView(LibraryTab libraryTab, DialogService dialogService, Prefere ControlHelper.setAction(generateButton, this.getDialogPane(), event -> viewModel.runFetcherWorker()); setResultConverter(button -> { - // The buttonType will always be cancel, even if we pressed one of the entry type buttons + // The buttonType will always be "cancel", even if we pressed one of the entry type buttons return type; }); diff --git a/src/main/java/org/jabref/gui/EntryTypeViewModel.java b/src/main/java/org/jabref/gui/EntryTypeViewModel.java index d8221b328e6..c6981fb2e8d 100644 --- a/src/main/java/org/jabref/gui/EntryTypeViewModel.java +++ b/src/main/java/org/jabref/gui/EntryTypeViewModel.java @@ -113,16 +113,14 @@ private class FetcherWorker extends Task> { @Override protected Optional call() throws InterruptedException, FetcherException { - Optional bibEntry = Optional.empty(); - searchingProperty().setValue(true); storeSelectedFetcher(); fetcher = selectedItemProperty().getValue(); searchID = idText.getValue(); - if (!searchID.isEmpty()) { - bibEntry = fetcher.performSearchById(searchID); + if (searchID.isEmpty()) { + return Optional.empty(); } - return bibEntry; + return fetcher.performSearchById(searchID); } } diff --git a/src/main/java/org/jabref/gui/JabRefGUI.java b/src/main/java/org/jabref/gui/JabRefGUI.java index e7ec1aaf010..32bbfddeb51 100644 --- a/src/main/java/org/jabref/gui/JabRefGUI.java +++ b/src/main/java/org/jabref/gui/JabRefGUI.java @@ -66,7 +66,6 @@ public JabRefGUI(Stage mainStage, List databases, boolean isBlank, } private void openWindow(Stage mainStage) { - LOGGER.debug("Initializing frame"); mainFrame.init(); diff --git a/src/main/java/org/jabref/gui/JabRefMain.java b/src/main/java/org/jabref/gui/JabRefMain.java index 0c0abc0a31d..effcfc55731 100644 --- a/src/main/java/org/jabref/gui/JabRefMain.java +++ b/src/main/java/org/jabref/gui/JabRefMain.java @@ -141,8 +141,8 @@ private static void applyPreferences(PreferencesService preferences) { // Initialize protected terms loader Globals.protectedTermsLoader = new ProtectedTermsLoader(preferences.getProtectedTermsPreferences()); - // Override used newline character with the one stored in the preferences - // The preferences return the system newline character sequence as default + // Override used newline character with the one stored in the preferences. + // The preferences return the system newline character sequence as default. OS.NEWLINE = preferences.getNewLineSeparator().toString(); }