Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into disableColumnFitToW…
Browse files Browse the repository at this point in the history
…idth

* upstream/main:
  Fix some typos (#8157)
  Removed two unused preference options (#8164)
  • Loading branch information
Siedlerchr committed Oct 18, 2021
2 parents 93f3bba + 71327b8 commit 374f8ba
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 60 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)



Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/gui/EntryTypeView.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});

Expand Down
8 changes: 3 additions & 5 deletions src/main/java/org/jabref/gui/EntryTypeViewModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,16 +113,14 @@ private class FetcherWorker extends Task<Optional<BibEntry>> {

@Override
protected Optional<BibEntry> call() throws InterruptedException, FetcherException {
Optional<BibEntry> 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);
}
}

Expand Down
1 change: 0 additions & 1 deletion src/main/java/org/jabref/gui/JabRefGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ public JabRefGUI(Stage mainStage, List<ParserResult> databases, boolean isBlank,
}

private void openWindow(Stage mainStage) {

LOGGER.debug("Initializing frame");
mainFrame.init();

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/jabref/gui/JabRefMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand All @@ -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;
Expand Down
16 changes: 1 addition & 15 deletions src/main/java/org/jabref/preferences/FilePreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -68,12 +62,4 @@ public FilePreferences withShouldDownloadLinkedFiles(boolean newShouldDownloadLi
this.shouldDownloadLinkedFiles = newShouldDownloadLinkedFiles;
return this;
}

public boolean shouldSearchFilesOnOpen() {
return shouldSearchFilesOnOpen;
}

public boolean shouldOpenBrowseOnCreate() {
return shouldOpenBrowseOnCreate;
}
}
10 changes: 1 addition & 9 deletions src/main/java/org/jabref/preferences/JabRefPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -260,15 +260,13 @@ 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
public static final String STORE_RELATIVE_TO_BIB = "bibLocAsPrimaryDir";
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";
Expand Down Expand Up @@ -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:
Expand All @@ -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);
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
39 changes: 18 additions & 21 deletions src/test/java/org/jabref/preferences/FilePreferenceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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());
}
Expand Down Expand Up @@ -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());
}
}

0 comments on commit 374f8ba

Please sign in to comment.