Skip to content
Open
Show file tree
Hide file tree
Changes from all 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.getPreviewWidthDividerPosition());
}

public ObservableMap<String, Set<Field>> getEntryEditorTabs() {
return entryEditorTabList.get();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,6 @@ public class JabRefGuiPreferences extends JabRefCliPreferences implements GuiPre
/**
* Holds the horizontal divider position of the preview view when it is shown inside the entry editor
*/
private static final String ENTRY_EDITOR_PREVIEW_DIVIDER_POS = "entryEditorPreviewDividerPos";

private static final String JOURNAL_POPUP = "journalPopup";

// region Auto completion
private static final String AUTO_COMPLETE = "autoComplete";
Expand Down Expand Up @@ -221,6 +218,23 @@ public class JabRefGuiPreferences extends JabRefCliPreferences implements GuiPre
private static final String CREATE_ENTRY_INTERPRET_PARSER_NAME = "latestInterpretParserName";
// endregion

// region EntryEditorPreferences
private static final String AUTO_OPEN_FORM = "autoOpenForm";
private static final String SHOW_RECOMMENDATIONS = "showRecommendations";
private static final String SHOW_AI_SUMMARY = "showAiSummary";
private static final String SHOW_AI_CHAT = "showAiChat";
private static final String SHOW_LATEX_CITATIONS = "showLatexCitations";
private static final String SMART_FILE_ANNOTATIONS = "smartFileAnnotations";
private static final String DEFAULT_SHOW_SOURCE = "defaultShowSource";
private static final String VALIDATE_IN_ENTRY_EDITOR = "validateInEntryEditor";
private static final String ALLOW_INTEGER_EDITION_BIBTEX = "allowIntegerEditionBibtex";
private static final String AUTOLINK_FILES_ENABLED = "autoLinkFilesEnabled";
private static final String SHOW_SCITE_TAB = "showSciteTab";
private static final String SHOW_USER_COMMENTS_FIELDS = "showUserCommentsFields";
private static final String ENTRY_EDITOR_PREVIEW_DIVIDER_POS = "entryEditorPreviewDividerPos";
private static final String JOURNAL_POPUP = "journalPopup";
// endregion

private static JabRefGuiPreferences singleton;

private EntryEditorPreferences entryEditorPreferences;
Expand All @@ -246,10 +260,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 +423,7 @@ public void clear() throws BackingStoreException {
super.clear();

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

Expand All @@ -422,6 +433,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 +443,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 +464,26 @@ public EntryEditorPreferences getEntryEditorPreferences() {
return entryEditorPreferences;
}

public EntryEditorPreferences getEntryEditorPreferencesFromBackingStore(EntryEditorPreferences defaults) {
return new EntryEditorPreferences(
getEntryEditorTabs(),
getDefaultEntryEditorTabs(),
getBoolean(AUTO_OPEN_FORM, defaults.shouldOpenOnNewEntry()),
getBoolean(SHOW_RECOMMENDATIONS, defaults.shouldShowRecommendationsTab()),
getBoolean(SHOW_AI_SUMMARY, defaults.shouldShowAiSummaryTab()),
getBoolean(SHOW_AI_CHAT, defaults.shouldShowAiChatTab()),
getBoolean(SHOW_LATEX_CITATIONS, defaults.shouldShowLatexCitationsTab()),
getBoolean(SMART_FILE_ANNOTATIONS, defaults.shouldShowFileAnnotationsTab()),
getBoolean(DEFAULT_SHOW_SOURCE, defaults.showSourceTabByDefault()),
getBoolean(VALIDATE_IN_ENTRY_EDITOR, defaults.shouldEnableValidation()),
getBoolean(ALLOW_INTEGER_EDITION_BIBTEX, defaults.shouldAllowIntegerEditionBibtex()),
getBoolean(AUTOLINK_FILES_ENABLED, defaults.autoLinkFilesEnabled()),
EntryEditorPreferences.JournalPopupEnabled.fromString(get(JOURNAL_POPUP, defaults.shouldEnableJournalPopup().toString())),
getBoolean(SHOW_SCITE_TAB, defaults.shouldShowSciteTab()),
getBoolean(SHOW_USER_COMMENTS_FIELDS, defaults.shouldShowUserCommentsFields()),
getDouble(ENTRY_EDITOR_PREVIEW_DIVIDER_POS, defaults.getPreviewWidthDividerPosition()));
}

/**
* Get a Map of defined tab names to default tab fields.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,7 @@ public class JabRefCliPreferences implements CliPreferences {

public static final String XMP_PRIVACY_FILTERS = "xmpPrivacyFilters";
public static final String USE_XMP_PRIVACY_FILTER = "useXmpPrivacyFilter";
public static final String DEFAULT_SHOW_SOURCE = "defaultShowSource";

public static final String AUTO_OPEN_FORM = "autoOpenForm";
public static final String IMPORT_WORKING_DIRECTORY = "importWorkingDirectory";
public static final String LAST_USED_EXPORT = "lastUsedExport";
public static final String EXPORT_WORKING_DIRECTORY = "exportWorkingDirectory";
Expand Down Expand Up @@ -204,8 +202,6 @@ public class JabRefCliPreferences implements CliPreferences {

public static final String MERGE_SHOW_ONLY_CHANGED_FIELDS = "mergeShowOnlyChangedFields";

public static final String SHOW_USER_COMMENTS_FIELDS = "showUserCommentsFields";

public static final String MERGE_APPLY_TO_ALL_ENTRIES = "mergeApplyToAllEntries";

public static final String DUPLICATE_RESOLVER_DECISION_RESULT_ALL_ENTRIES = "duplicateResolverDecisionResult";
Expand Down Expand Up @@ -247,12 +243,10 @@ public class JabRefCliPreferences implements CliPreferences {
public static final String WARN_BEFORE_OVERWRITING_KEY = "warnBeforeOverwritingKey";
public static final String AVOID_OVERWRITING_KEY = "avoidOverwritingKey";
public static final String AUTOLINK_EXACT_KEY_ONLY = "autolinkExactKeyOnly";
public static final String AUTOLINK_FILES_ENABLED = "autoLinkFilesEnabled";

public static final String GENERATE_KEYS_BEFORE_SAVING = "generateKeysBeforeSaving";
public static final String KEY_GEN_ALWAYS_ADD_LETTER = "keyGenAlwaysAddLetter";
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 AUTOLINK_REG_EXP_SEARCH_EXPRESSION_KEY = "regExpSearchExpression";
public static final String AUTOLINK_USE_REG_EXP_SEARCH_KEY = "useRegExpSearch";
Expand All @@ -270,17 +264,10 @@ public class JabRefCliPreferences implements CliPreferences {
public static final String IMPORT_FILEDIRPATTERN = "importFileDirPattern";
public static final String NAME_FORMATTER_VALUE = "nameFormatterFormats";
public static final String NAME_FORMATER_KEY = "nameFormatterNames";
public static final String SHOW_RECOMMENDATIONS = "showRecommendations";
public static final String SHOW_AI_SUMMARY = "showAiSummary";
public static final String SMART_FILE_ANNOTATIONS = "smartFileAnnotations";
public static final String SHOW_AI_CHAT = "showAiChat";
public static final String ACCEPT_RECOMMENDATIONS = "acceptRecommendations";
public static final String SHOW_LATEX_CITATIONS = "showLatexCitations";
public static final String SEND_LANGUAGE_DATA = "sendLanguageData";
public static final String SEND_OS_DATA = "sendOSData";
public static final String SEND_TIMEZONE_DATA = "sendTimezoneData";
public static final String VALIDATE_IN_ENTRY_EDITOR = "validateInEntryEditor";
public static final String SHOW_SCITE_TAB = "showSciteTab";

/**
* The OpenOffice/LibreOffice connection preferences are: OO_PATH main directory for
Expand Down Expand Up @@ -603,22 +590,11 @@ public JabRefCliPreferences() {
// Remembers working directory of last import
defaults.put(IMPORT_WORKING_DIRECTORY, USER_HOME);
defaults.put(PREFS_EXPORT_PATH, USER_HOME);
defaults.put(AUTO_OPEN_FORM, Boolean.TRUE);
defaults.put(DEFAULT_SHOW_SOURCE, Boolean.FALSE);

defaults.put(SHOW_USER_COMMENTS_FIELDS, Boolean.TRUE);

defaults.put(SHOW_RECOMMENDATIONS, Boolean.TRUE);
defaults.put(SHOW_AI_CHAT, Boolean.TRUE);
defaults.put(SHOW_AI_SUMMARY, Boolean.TRUE);
defaults.put(SMART_FILE_ANNOTATIONS, Boolean.TRUE);
defaults.put(ACCEPT_RECOMMENDATIONS, Boolean.FALSE);
defaults.put(SHOW_LATEX_CITATIONS, Boolean.TRUE);
defaults.put(SHOW_SCITE_TAB, Boolean.TRUE);
defaults.put(SEND_LANGUAGE_DATA, Boolean.FALSE);
defaults.put(SEND_OS_DATA, Boolean.FALSE);
defaults.put(SEND_TIMEZONE_DATA, Boolean.FALSE);
defaults.put(VALIDATE_IN_ENTRY_EDITOR, Boolean.TRUE);
defaults.put(KEYWORD_SEPARATOR, ", ");
defaults.put(DEFAULT_ENCODING, StandardCharsets.UTF_8.name());
defaults.put(DEFAULT_OWNER, System.getProperty("user.name"));
Expand Down Expand Up @@ -698,9 +674,7 @@ public JabRefCliPreferences() {
defaults.put(STORE_RELATIVE_TO_BIB, Boolean.TRUE);

defaults.put(AUTOLINK_EXACT_KEY_ONLY, Boolean.FALSE);
defaults.put(AUTOLINK_FILES_ENABLED, Boolean.TRUE);
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:
// Currently, JabRef does not escape them
defaults.put(KEY_GEN_FIRST_LETTER_A, Boolean.TRUE);
Expand Down