From dd0f3049027fc82f18dd5e8330e6e581aaeaa195 Mon Sep 17 00:00:00 2001 From: Christoph Date: Sat, 24 Aug 2019 15:34:20 +0200 Subject: [PATCH] fix bug where main file directory is not set correctly (#5215) Use getName when storing the file directory key --- .../java/org/jabref/gui/preferences/FileTabViewModel.java | 7 +++++-- .../java/org/jabref/preferences/JabRefPreferences.java | 4 +++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/jabref/gui/preferences/FileTabViewModel.java b/src/main/java/org/jabref/gui/preferences/FileTabViewModel.java index 990f65e8526..28047e8e9a3 100644 --- a/src/main/java/org/jabref/gui/preferences/FileTabViewModel.java +++ b/src/main/java/org/jabref/gui/preferences/FileTabViewModel.java @@ -77,6 +77,7 @@ public FileTabViewModel(DialogService dialogService, JabRefPreferences preferenc ); } + @Override public void setValues() { openLastStartupProperty.setValue(preferences.getBoolean(JabRefPreferences.OPEN_LAST_EDITED)); backupOldFileProperty.setValue(preferences.getBoolean(JabRefPreferences.BACKUP)); @@ -88,7 +89,7 @@ public void setValues() { selectedNewLineSeparatorProperty.setValue(preferences.getNewLineSeparator()); alwaysReformatBibProperty.setValue(preferences.getBoolean(JabRefPreferences.REFORMAT_FILE_ON_SAVE_AND_EXPORT)); - mainFileDirProperty.setValue(preferences.getAsOptional(StandardField.FILE + FilePreferences.DIR_SUFFIX).orElse("")); + mainFileDirProperty.setValue(preferences.getAsOptional(StandardField.FILE.getName() + FilePreferences.DIR_SUFFIX).orElse("")); useBibLocationAsPrimaryProperty.setValue(preferences.getBoolean(JabRefPreferences.BIB_LOC_AS_PRIMARY_DIR)); if (preferences.getBoolean(JabRefPreferences.AUTOLINK_USE_REG_EXP_SEARCH_KEY)) { // Flipped around autolinkUseRegexProperty.setValue(true); @@ -104,6 +105,7 @@ public void setValues() { autosaveLocalLibraries.setValue(preferences.getBoolean(JabRefPreferences.LOCAL_AUTO_SAVE)); } + @Override public void storeSettings() { preferences.putBoolean(JabRefPreferences.OPEN_LAST_EDITED, openLastStartupProperty.getValue()); preferences.putBoolean(JabRefPreferences.BACKUP, backupOldFileProperty.getValue()); @@ -119,7 +121,7 @@ public void storeSettings() { preferences.setNewLineSeparator(selectedNewLineSeparatorProperty.getValue()); preferences.putBoolean(JabRefPreferences.REFORMAT_FILE_ON_SAVE_AND_EXPORT, alwaysReformatBibProperty.getValue()); - preferences.put(StandardField.FILE + FilePreferences.DIR_SUFFIX, mainFileDirProperty.getValue()); + preferences.put(StandardField.FILE.getName() + FilePreferences.DIR_SUFFIX, mainFileDirProperty.getValue()); preferences.putBoolean(JabRefPreferences.BIB_LOC_AS_PRIMARY_DIR, useBibLocationAsPrimaryProperty.getValue()); preferences.putBoolean(JabRefPreferences.AUTOLINK_USE_REG_EXP_SEARCH_KEY, autolinkUseRegexProperty.getValue()); preferences.putBoolean(JabRefPreferences.AUTOLINK_EXACT_KEY_ONLY, autolinkFileExactBibtexProperty.getValue()); @@ -133,6 +135,7 @@ ValidationStatus mainFileDirValidationStatus() { return mainFileDirValidator.getValidationStatus(); } + @Override public boolean validateSettings() { ValidationStatus status = mainFileDirValidationStatus(); if (!status.isValid()) { diff --git a/src/main/java/org/jabref/preferences/JabRefPreferences.java b/src/main/java/org/jabref/preferences/JabRefPreferences.java index 8b14874da52..5d732e43703 100644 --- a/src/main/java/org/jabref/preferences/JabRefPreferences.java +++ b/src/main/java/org/jabref/preferences/JabRefPreferences.java @@ -896,6 +896,7 @@ private static void insertDefaultCleanupPreset(Map storage) { storage.put(CLEANUP_FORMATTERS, convertListToString(Cleanups.DEFAULT_SAVE_ACTIONS.getAsStringList(OS.NEWLINE))); } + @Override public EntryEditorPreferences getEntryEditorPreferences() { return new EntryEditorPreferences(getEntryEditorTabList(), getLatexFieldFormatterPreferences(), @@ -1589,7 +1590,7 @@ private NameFormatterPreferences getNameFormatterPreferences() { public FileLinkPreferences getFileLinkPreferences() { return new FileLinkPreferences( - Collections.singletonList(get(StandardField.FILE + FilePreferences.DIR_SUFFIX)), + Collections.singletonList(get(StandardField.FILE.getName() + FilePreferences.DIR_SUFFIX)), fileDirForDatabase); } @@ -2034,6 +2035,7 @@ public Map getMainTableColumnSortTypes() { return map; } + @Override public FileDragDropPreferenceType getEntryEditorFileLinkPreference() { return FileDragDropPreferenceType.valueOf(get(ENTRY_EDITOR_DRAG_DROP_PREFERENCE_TYPE)); }