7474import org .jabref .model .groups .GroupHierarchyType ;
7575import org .jabref .model .metadata .SaveOrder ;
7676import org .jabref .model .metadata .SelfContainedSaveOrder ;
77-
77+ import org . jabref . model . entry . types . EntryTypeFactory ;
7878import com .airhacks .afterburner .injection .Injector ;
7979import com .tobiasdiez .easybind .EasyBind ;
8080import org .slf4j .Logger ;
@@ -368,16 +368,7 @@ private JabRefGuiPreferences() {
368368 defaults .put (DONATION_LAST_SHOWN_EPOCH_DAY , -1 );
369369 // endregion
370370
371- // region NewEntryUnifierPreferences
372- defaults .put (CREATE_ENTRY_APPROACH , List .of (NewEntryDialogTab .values ()).indexOf (NewEntryDialogTab .CHOOSE_ENTRY_TYPE ));
373- defaults .put (CREATE_ENTRY_EXPAND_RECOMMENDED , true );
374- defaults .put (CREATE_ENTRY_EXPAND_OTHER , false );
375- defaults .put (CREATE_ENTRY_EXPAND_CUSTOM , true );
376- defaults .put (CREATE_ENTRY_IMMEDIATE_TYPE , StandardEntryType .Article .getDisplayName ());
377- defaults .put (CREATE_ENTRY_ID_LOOKUP_GUESSING , true );
378- defaults .put (CREATE_ENTRY_ID_FETCHER_NAME , DoiFetcher .NAME );
379- defaults .put (CREATE_ENTRY_INTERPRET_PARSER_NAME , PlainCitationParserChoice .RULE_BASED_GENERAL .getLocalizedName ());
380- // endregion
371+
381372 }
382373
383374 /**
@@ -414,6 +405,8 @@ public void clear() throws BackingStoreException {
414405
415406 getWorkspacePreferences ().setAll (WorkspacePreferences .getDefault ());
416407 getGuiPreferences ().setAll (CoreGuiPreferences .getDefault ());
408+ getNewEntryPreferences ().setAll (NewEntryPreferences .getDefault ());
409+
417410 }
418411
419412 @ Override
@@ -423,6 +416,8 @@ public void importPreferences(Path file) throws JabRefException {
423416 // in case of incomplete or corrupt xml fall back to current preferences
424417 getWorkspacePreferences ().setAll (getWorkspacePreferencesFromBackingStore (getWorkspacePreferences ()));
425418 getGuiPreferences ().setAll (getCoreGuiPreferencesFromBackingStore (getGuiPreferences ()));
419+ getNewEntryPreferences ().setAll (getNewEntryPreferencesFromLowLevelApi (getNewEntryPreferences ()));
420+
426421 }
427422
428423 // region EntryEditorPreferences
@@ -686,6 +681,30 @@ private WorkspacePreferences getWorkspacePreferencesFromBackingStore(WorkspacePr
686681 getStringList (SELECTED_SLR_CATALOGS ));
687682 }
688683
684+ private NewEntryPreferences getNewEntryPreferencesFromLowLevelApi (NewEntryPreferences defaults ) {
685+ int approachIndex = getInt ("createEntryApproach" , defaults .getLatestApproach ().ordinal ());
686+ NewEntryDialogTab approach ;
687+ if (approachIndex >= 0 && approachIndex < NewEntryDialogTab .values ().length ) {
688+ approach = NewEntryDialogTab .values ()[approachIndex ];
689+ } else {
690+ approach = defaults .getLatestApproach ();
691+ }
692+
693+ String typeName = get ("createEntryImmediateType" , defaults .getLatestImmediateType ().getDisplayName ());
694+ EntryType immediateType = EntryTypeFactory .parse (typeName );
695+
696+ return new NewEntryPreferences (
697+ approach ,
698+ getBoolean ("createEntryExpandRecommended" , defaults .getTypesRecommendedExpanded ()),
699+ getBoolean ("createEntryExpandOther" , defaults .getTypesOtherExpanded ()),
700+ getBoolean ("createEntryExpandCustom" , defaults .getTypesCustomExpanded ()),
701+ immediateType ,
702+ getBoolean ("createEntryIdLookupGuessing" , defaults .getIdLookupGuessing ()),
703+ get ("createEntryIdFetcherName" , defaults .getLatestIdFetcher ()),
704+ get ("createEntryInterpretParserName" , defaults .getLatestInterpretParser ())
705+ );
706+ }
707+
689708 @ Override
690709 public UnlinkedFilesDialogPreferences getUnlinkedFilesDialogPreferences () {
691710 if (unlinkedFilesDialogPreferences != null ) {
@@ -1190,15 +1209,8 @@ public NewEntryPreferences getNewEntryPreferences() {
11901209 }
11911210 }
11921211
1193- newEntryPreferences = new NewEntryPreferences (
1194- approach ,
1195- getBoolean (CREATE_ENTRY_EXPAND_RECOMMENDED ),
1196- getBoolean (CREATE_ENTRY_EXPAND_OTHER ),
1197- getBoolean (CREATE_ENTRY_EXPAND_CUSTOM ),
1198- immediateType ,
1199- getBoolean (CREATE_ENTRY_ID_LOOKUP_GUESSING ),
1200- get (CREATE_ENTRY_ID_FETCHER_NAME ),
1201- get (CREATE_ENTRY_INTERPRET_PARSER_NAME ));
1212+ newEntryPreferences = getNewEntryPreferencesFromLowLevelApi (NewEntryPreferences .getDefault ());
1213+
12021214
12031215 EasyBind .listen (newEntryPreferences .latestApproachProperty (), (_ , _ , newValue ) -> putInt (CREATE_ENTRY_APPROACH , List .of (NewEntryDialogTab .values ()).indexOf (newValue )));
12041216 EasyBind .listen (newEntryPreferences .typesRecommendedExpandedProperty (), (_ , _ , newValue ) -> putBoolean (CREATE_ENTRY_EXPAND_RECOMMENDED , newValue ));
0 commit comments