Skip to content

Commit

Permalink
fix bug where main file directory is not set correctly (#5215)
Browse files Browse the repository at this point in the history
Use getName when storing the file directory key
  • Loading branch information
Siedlerchr authored Aug 24, 2019
1 parent 72dbfa7 commit dd0f304
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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);
Expand All @@ -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());
Expand All @@ -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());
Expand All @@ -133,6 +135,7 @@ ValidationStatus mainFileDirValidationStatus() {
return mainFileDirValidator.getValidationStatus();
}

@Override
public boolean validateSettings() {
ValidationStatus status = mainFileDirValidationStatus();
if (!status.isValid()) {
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/org/jabref/preferences/JabRefPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,7 @@ private static void insertDefaultCleanupPreset(Map<String, Object> storage) {
storage.put(CLEANUP_FORMATTERS, convertListToString(Cleanups.DEFAULT_SAVE_ACTIONS.getAsStringList(OS.NEWLINE)));
}

@Override
public EntryEditorPreferences getEntryEditorPreferences() {
return new EntryEditorPreferences(getEntryEditorTabList(),
getLatexFieldFormatterPreferences(),
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -2034,6 +2035,7 @@ public Map<String, SortType> getMainTableColumnSortTypes() {
return map;
}

@Override
public FileDragDropPreferenceType getEntryEditorFileLinkPreference() {
return FileDragDropPreferenceType.valueOf(get(ENTRY_EDITOR_DRAG_DROP_PREFERENCE_TYPE));
}
Expand Down

0 comments on commit dd0f304

Please sign in to comment.