Skip to content

Commit 6bbbd36

Browse files
committed
fix for issue 14401
1 parent 5678922 commit 6bbbd36

File tree

3 files changed

+81
-20
lines changed

3 files changed

+81
-20
lines changed

jabgui/src/main/java/org/jabref/gui/entryeditor/EntryEditorPreferences.java

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.jabref.gui.entryeditor;
22

3+
import java.util.Collections;
34
import java.util.Map;
45
import java.util.Set;
56

@@ -88,6 +89,51 @@ public EntryEditorPreferences(Map<String, Set<Field>> entryEditorTabList,
8889
this.previewWidthDividerPosition = new SimpleDoubleProperty(previewWidthDividerPosition);
8990
}
9091

92+
/// Creates Object with default values
93+
private EntryEditorPreferences() {
94+
this(
95+
Collections.emptyMap(), // Default entryEditorTabList
96+
Collections.emptyMap(), // Default defaultEntryEditorTabList
97+
true, // shouldOpenOnNewEntry
98+
false, // shouldShowRecommendationsTab
99+
true, // shouldShowAiSummaryTab
100+
true, // shouldShowAiChatTab
101+
true, // shouldShowLatexCitationsTab
102+
true, // shouldShowFileAnnotationsTab
103+
false, // showSourceTabByDefault
104+
true, // enableValidation
105+
false, // allowIntegerEditionBibtex
106+
true, // autolinkFilesEnabled
107+
JournalPopupEnabled.ENABLED, // JournalPopupEnabled
108+
false, // showSciteTab
109+
false, // showUserCommentsFields
110+
0.5 // previewWidthDividerPosition
111+
);
112+
}
113+
114+
public void setAll(EntryEditorPreferences preferences) {
115+
setEntryEditorTabList(preferences.getEntryEditorTabs());
116+
this.defaultEntryEditorTabList.set(preferences.getDefaultEntryEditorTabs());
117+
this.shouldOpenOnNewEntry.set(preferences.shouldOpenOnNewEntry());
118+
this.shouldShowRecommendationsTab.set(preferences.shouldShowRecommendationsTab());
119+
this.shouldShowAiSummaryTab.set(preferences.shouldShowAiSummaryTab());
120+
this.shouldShowAiChatTab.set(preferences.shouldShowAiChatTab());
121+
this.shouldShowLatexCitationsTab.set(preferences.shouldShowLatexCitationsTab());
122+
this.shouldShowFileAnnotationsTab.set(preferences.shouldShowFileAnnotationsTab());
123+
this.showSourceTabByDefault.set(preferences.showSourceTabByDefault());
124+
this.enableValidation.set(preferences.shouldEnableValidation());
125+
this.allowIntegerEditionBibtex.set(preferences.shouldAllowIntegerEditionBibtex());
126+
this.autoLinkFiles.set(preferences.autoLinkFilesEnabled());
127+
this.enablementStatus.set(preferences.shouldEnableJournalPopup());
128+
this.shouldShowSciteTab.set(preferences.shouldShowSciteTab());
129+
this.showUserCommentsFields.set(preferences.shouldShowUserCommentsFields());
130+
this.previewWidthDividerPosition.set(preferences.getPreviewDividerPos());
131+
}
132+
133+
public static EntryEditorPreferences getDefault() {
134+
return new EntryEditorPreferences();
135+
}
136+
91137
public ObservableMap<String, Set<Field>> getEntryEditorTabs() {
92138
return entryEditorTabList.get();
93139
}
@@ -274,4 +320,12 @@ public DoubleProperty previewWidthDividerPositionProperty() {
274320
public Double getPreviewWidthDividerPosition() {
275321
return previewWidthDividerPosition.get();
276322
}
323+
324+
public double getPreviewDividerPos() {
325+
return previewWidthDividerPosition.get();
326+
}
327+
328+
public String getJournalPopUp() {
329+
return enablementStatus.get().toString();
330+
}
277331
}

jabgui/src/main/java/org/jabref/gui/preferences/JabRefGuiPreferences.java

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,7 @@ public class JabRefGuiPreferences extends JabRefCliPreferences implements GuiPre
248248
private JabRefGuiPreferences() {
249249
super();
250250

251-
defaults.put(JOURNAL_POPUP, EntryEditorPreferences.JournalPopupEnabled.FIRST_START.toString());
252-
253251
defaults.put(ENTRY_EDITOR_HEIGHT, 0.65);
254-
defaults.put(ENTRY_EDITOR_PREVIEW_DIVIDER_POS, 0.5);
255252

256253
// region mergeDialogPreferences
257254
defaults.put(MERGE_ENTRIES_DIFF_MODE, DiffMode.WORD.name());
@@ -425,6 +422,7 @@ public void clear() throws BackingStoreException {
425422
super.clear();
426423

427424
getWorkspacePreferences().setAll(WorkspacePreferences.getDefault());
425+
getEntryEditorPreferences().setAll(EntryEditorPreferences.getDefault());
428426
}
429427

430428
@Override
@@ -433,6 +431,7 @@ public void importPreferences(Path file) throws JabRefException {
433431

434432
// in case of incomplete or corrupt xml fall back to current preferences
435433
getWorkspacePreferences().setAll(getWorkspacePreferencesFromBackingStore(getWorkspacePreferences()));
434+
getEntryEditorPreferences().setAll(getEntryEditorPreferencesFromBackingStore(getEntryEditorPreferences()));
436435
}
437436

438437
// region EntryEditorPreferences
@@ -441,23 +440,7 @@ public EntryEditorPreferences getEntryEditorPreferences() {
441440
return entryEditorPreferences;
442441
}
443442

444-
entryEditorPreferences = new EntryEditorPreferences(
445-
getEntryEditorTabs(),
446-
getDefaultEntryEditorTabs(),
447-
getBoolean(AUTO_OPEN_FORM),
448-
getBoolean(SHOW_RECOMMENDATIONS),
449-
getBoolean(SHOW_AI_SUMMARY),
450-
getBoolean(SHOW_AI_CHAT),
451-
getBoolean(SHOW_LATEX_CITATIONS),
452-
getBoolean(SMART_FILE_ANNOTATIONS),
453-
getBoolean(DEFAULT_SHOW_SOURCE),
454-
getBoolean(VALIDATE_IN_ENTRY_EDITOR),
455-
getBoolean(ALLOW_INTEGER_EDITION_BIBTEX),
456-
getBoolean(AUTOLINK_FILES_ENABLED),
457-
EntryEditorPreferences.JournalPopupEnabled.fromString(get(JOURNAL_POPUP)),
458-
getBoolean(SHOW_SCITE_TAB),
459-
getBoolean(SHOW_USER_COMMENTS_FIELDS),
460-
getDouble(ENTRY_EDITOR_PREVIEW_DIVIDER_POS));
443+
entryEditorPreferences = getEntryEditorPreferencesFromBackingStore(EntryEditorPreferences.getDefault());
461444

462445
EasyBind.listen(entryEditorPreferences.entryEditorTabs(), (_, _, newValue) -> storeEntryEditorTabs(newValue));
463446
// defaultEntryEditorTabs are read-only
@@ -478,6 +461,26 @@ public EntryEditorPreferences getEntryEditorPreferences() {
478461
return entryEditorPreferences;
479462
}
480463

464+
public EntryEditorPreferences getEntryEditorPreferencesFromBackingStore(EntryEditorPreferences defaults) {
465+
return new EntryEditorPreferences(
466+
getEntryEditorTabs(),
467+
getDefaultEntryEditorTabs(),
468+
getBoolean(AUTO_OPEN_FORM),
469+
getBoolean(SHOW_RECOMMENDATIONS),
470+
getBoolean(SHOW_AI_SUMMARY),
471+
getBoolean(SHOW_AI_CHAT),
472+
getBoolean(SHOW_LATEX_CITATIONS),
473+
getBoolean(SMART_FILE_ANNOTATIONS),
474+
getBoolean(DEFAULT_SHOW_SOURCE),
475+
getBoolean(VALIDATE_IN_ENTRY_EDITOR),
476+
getBoolean(ALLOW_INTEGER_EDITION_BIBTEX),
477+
getBoolean(AUTOLINK_FILES_ENABLED),
478+
EntryEditorPreferences.JournalPopupEnabled.fromString(get(JOURNAL_POPUP, defaults.getJournalPopUp())),
479+
getBoolean(SHOW_SCITE_TAB),
480+
getBoolean(SHOW_USER_COMMENTS_FIELDS),
481+
getDouble(ENTRY_EDITOR_PREVIEW_DIVIDER_POS, defaults.getPreviewDividerPos()));
482+
}
483+
481484
/**
482485
* Get a Map of defined tab names to default tab fields.
483486
*

jablib/src/main/java/org/jabref/logic/preferences/JabRefCliPreferences.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -969,6 +969,10 @@ public double getDouble(String key) {
969969
return prefs.getDouble(key, getDoubleDefault(key));
970970
}
971971

972+
public double getDouble(String key, double def) {
973+
return prefs.getDouble(key, def);
974+
}
975+
972976
private double getDoubleDefault(String key) {
973977
return ((Number) defaults.get(key)).doubleValue();
974978
}

0 commit comments

Comments
 (0)