Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.jabref.gui.entryeditor;

import java.util.Collections;
import java.util.Map;
import java.util.Set;

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

/// Creates Object with default values
private EntryEditorPreferences() {
this(
Collections.emptyMap(), // Default entryEditorTabList
Collections.emptyMap(), // Default defaultEntryEditorTabList
true, // Open editor when a new entry is created
true, // Show related articles tab
true, // Show AI summary tab
true, // Show AI chat tab
true, // Show Latex Citations tab
true, // Show File Annotations tab
false, // Show BibTex source
true, // Show validation messages
false, // Allow integers in edition in Bibtex
true, // Auto search and show unlinked files in entry editor
JournalPopupEnabled.DISABLED, // JournalPopupEnabled
true, // Show citation info tab
true, // Show user comments field
0.5 // previewWidthDividerPosition
);
}

public static EntryEditorPreferences getDefault() {
return new EntryEditorPreferences();
}

public void setAll(EntryEditorPreferences preferences) {
setEntryEditorTabList(preferences.getEntryEditorTabs());
this.defaultEntryEditorTabList.set(preferences.getDefaultEntryEditorTabs());
this.shouldOpenOnNewEntry.set(preferences.shouldOpenOnNewEntry());
this.shouldShowRecommendationsTab.set(preferences.shouldShowRecommendationsTab());
this.shouldShowAiSummaryTab.set(preferences.shouldShowAiSummaryTab());
this.shouldShowAiChatTab.set(preferences.shouldShowAiChatTab());
this.shouldShowLatexCitationsTab.set(preferences.shouldShowLatexCitationsTab());
this.shouldShowFileAnnotationsTab.set(preferences.shouldShowFileAnnotationsTab());
this.showSourceTabByDefault.set(preferences.showSourceTabByDefault());
this.enableValidation.set(preferences.shouldEnableValidation());
this.allowIntegerEditionBibtex.set(preferences.shouldAllowIntegerEditionBibtex());
this.autoLinkFiles.set(preferences.autoLinkFilesEnabled());
this.enablementStatus.set(preferences.shouldEnableJournalPopup());
this.shouldShowSciteTab.set(preferences.shouldShowSciteTab());
this.showUserCommentsFields.set(preferences.shouldShowUserCommentsFields());
this.previewWidthDividerPosition.set(preferences.getPreviewDividerPos());
}

public ObservableMap<String, Set<Field>> getEntryEditorTabs() {
return entryEditorTabList.get();
}
Expand Down Expand Up @@ -274,4 +320,12 @@ public DoubleProperty previewWidthDividerPositionProperty() {
public Double getPreviewWidthDividerPosition() {
return previewWidthDividerPosition.get();
}

public double getPreviewDividerPos() {
return previewWidthDividerPosition.get();
}

public String getJournalPopUp() {
return enablementStatus.get().toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,6 @@ public class JabRefGuiPreferences extends JabRefCliPreferences implements GuiPre
private JabRefGuiPreferences() {
super();

defaults.put(JOURNAL_POPUP, EntryEditorPreferences.JournalPopupEnabled.FIRST_START.toString());

defaults.put(ENTRY_EDITOR_PREVIEW_DIVIDER_POS, 0.5);

// region mergeDialogPreferences
defaults.put(MERGE_ENTRIES_DIFF_MODE, DiffMode.WORD.name());
defaults.put(MERGE_ENTRIES_SHOULD_SHOW_DIFF, Boolean.TRUE);
Expand Down Expand Up @@ -413,6 +409,7 @@ public void clear() throws BackingStoreException {
super.clear();

getWorkspacePreferences().setAll(WorkspacePreferences.getDefault());
getEntryEditorPreferences().setAll(EntryEditorPreferences.getDefault());
getGuiPreferences().setAll(CoreGuiPreferences.getDefault());
}

Expand All @@ -422,6 +419,7 @@ public void importPreferences(Path file) throws JabRefException {

// in case of incomplete or corrupt xml fall back to current preferences
getWorkspacePreferences().setAll(getWorkspacePreferencesFromBackingStore(getWorkspacePreferences()));
getEntryEditorPreferences().setAll(getEntryEditorPreferencesFromBackingStore(getEntryEditorPreferences()));
getGuiPreferences().setAll(getCoreGuiPreferencesFromBackingStore(getGuiPreferences()));
}

Expand All @@ -431,23 +429,7 @@ public EntryEditorPreferences getEntryEditorPreferences() {
return entryEditorPreferences;
}

entryEditorPreferences = new EntryEditorPreferences(
getEntryEditorTabs(),
getDefaultEntryEditorTabs(),
getBoolean(AUTO_OPEN_FORM),
getBoolean(SHOW_RECOMMENDATIONS),
getBoolean(SHOW_AI_SUMMARY),
getBoolean(SHOW_AI_CHAT),
getBoolean(SHOW_LATEX_CITATIONS),
getBoolean(SMART_FILE_ANNOTATIONS),
getBoolean(DEFAULT_SHOW_SOURCE),
getBoolean(VALIDATE_IN_ENTRY_EDITOR),
getBoolean(ALLOW_INTEGER_EDITION_BIBTEX),
getBoolean(AUTOLINK_FILES_ENABLED),
EntryEditorPreferences.JournalPopupEnabled.fromString(get(JOURNAL_POPUP)),
getBoolean(SHOW_SCITE_TAB),
getBoolean(SHOW_USER_COMMENTS_FIELDS),
getDouble(ENTRY_EDITOR_PREVIEW_DIVIDER_POS));
entryEditorPreferences = getEntryEditorPreferencesFromBackingStore(EntryEditorPreferences.getDefault());

EasyBind.listen(entryEditorPreferences.entryEditorTabs(), (_, _, newValue) -> storeEntryEditorTabs(newValue));
// defaultEntryEditorTabs are read-only
Expand All @@ -468,6 +450,26 @@ public EntryEditorPreferences getEntryEditorPreferences() {
return entryEditorPreferences;
}

public EntryEditorPreferences getEntryEditorPreferencesFromBackingStore(EntryEditorPreferences defaults) {
return new EntryEditorPreferences(
getEntryEditorTabs(),
getDefaultEntryEditorTabs(),
getBoolean(AUTO_OPEN_FORM),
getBoolean(SHOW_RECOMMENDATIONS),
getBoolean(SHOW_AI_SUMMARY),
getBoolean(SHOW_AI_CHAT),
getBoolean(SHOW_LATEX_CITATIONS),
getBoolean(SMART_FILE_ANNOTATIONS),
getBoolean(DEFAULT_SHOW_SOURCE),
getBoolean(VALIDATE_IN_ENTRY_EDITOR),
getBoolean(ALLOW_INTEGER_EDITION_BIBTEX),
getBoolean(AUTOLINK_FILES_ENABLED),
EntryEditorPreferences.JournalPopupEnabled.fromString(get(JOURNAL_POPUP, defaults.getJournalPopUp())),
getBoolean(SHOW_SCITE_TAB),
getBoolean(SHOW_USER_COMMENTS_FIELDS),
getDouble(ENTRY_EDITOR_PREVIEW_DIVIDER_POS, defaults.getPreviewDividerPos()));
}

/**
* Get a Map of defined tab names to default tab fields.
*
Expand Down