commit 94c6459bf51b934d2b0101f32382c09960f642ae
Author: Katja Luther <k.luther@bgbm.org>
Date:   Fri Aug 16 12:49:52 2019 +0200

    fix search dialog default handling

diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/preferencePage/SearchDialogAdminPreferences.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/preferencePage/SearchDialogAdminPreferences.java
index 59434c518..3bd90f8d1 100755
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/preferencePage/SearchDialogAdminPreferences.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/preferencePage/SearchDialogAdminPreferences.java
@@ -70,7 +70,7 @@ public class SearchDialogAdminPreferences extends SearchDialogPreferences implem
             IPreferenceService service = controller.getPreferenceService();
             CdmPreference pref;
             if (showIdInSelectionDialog != null || !showIdInSelectionDialogPref.isAllowOverride()) {
-                pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowIdInSelectionDialog, showIdInSelectionDialog != null? showIdInSelectionDialog.toString():null);
+                pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowIdInSelectionDialog, showIdInSelectionDialog != null? showIdInSelectionDialog.toString():PreferencePredicate.ShowIdInSelectionDialog.getDefaultValue().toString());
                 pref.setAllowOverride(showIdInSelectionDialogPref.isAllowOverride());
                 service.set(pref);
             }else{
@@ -79,7 +79,7 @@ public class SearchDialogAdminPreferences extends SearchDialogPreferences implem
 
 
             if(searchForIdentifierAsDefault != null || !searchForIdentifierAsDefaultPref.isAllowOverride()){
-                pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.SearchForIdentifierAsDefault, searchForIdentifierAsDefault!= null? searchForIdentifierAsDefault.toString():null);
+                pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.SearchForIdentifierAsDefault, searchForIdentifierAsDefault!= null? searchForIdentifierAsDefault.toString():PreferencePredicate.SearchForIdentifierAsDefault.getDefaultValue().toString());
                 pref.setAllowOverride(searchForIdentifierAsDefaultPref.isAllowOverride());
                 service.set(pref);
             }else{
@@ -87,17 +87,17 @@ public class SearchDialogAdminPreferences extends SearchDialogPreferences implem
             }
 
 
-            if(searchForIdentifierAndTitleCache != null){
-                pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.SearchForIdentifierAndTitleCache, searchForIdentifierAndTitleCache!= null? searchForIdentifierAndTitleCache.toString():null);
+            if(searchForIdentifierAndTitleCache != null || !searchForIdentifierAndTitleCachePref.isAllowOverride()){
+                pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.SearchForIdentifierAndTitleCache, searchForIdentifierAndTitleCache!= null? searchForIdentifierAndTitleCache.toString():PreferencePredicate.SearchForIdentifierAndTitleCache.getDefaultValue().toString());
                 pref.setAllowOverride(searchForIdentifierAndTitleCachePref.isAllowOverride());
                 service.set(pref);
             }else{
                 service.remove(searchForIdentifierAndTitleCachePref.getKey());
             }
 
-            if(sortTaxaByRankAndName != null){
+            if(sortTaxaByRankAndName != null || !sortTaxaByRankAndNamePref.isAllowOverride()){
 
-                pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.SortTaxaByRankAndName, sortTaxaByRankAndName!= null? sortTaxaByRankAndName.toString():null);
+                pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.SortTaxaByRankAndName, sortTaxaByRankAndName!= null? sortTaxaByRankAndName.toString():PreferencePredicate.SortTaxaByRankAndName.getDefaultValue().toString());
                 pref.setAllowOverride(sortTaxaByRankAndNamePref.isAllowOverride());
                 service.set(pref);
             }else{
@@ -106,8 +106,8 @@ public class SearchDialogAdminPreferences extends SearchDialogPreferences implem
 
 
 
-            if(filterCommonNameReferences != null){
-                pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.CommonNameReferencesWithMarker, filterCommonNameReferences!= null? filterCommonNameReferences.toString():null);
+            if(filterCommonNameReferences != null || !filterCommonNameReferencesPref.isAllowOverride()){
+                pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.CommonNameReferencesWithMarker, filterCommonNameReferences!= null? filterCommonNameReferences.toString():PreferencePredicate.CommonNameReferencesWithMarker.getDefaultValue().toString());
                 pref.setAllowOverride(filterCommonNameReferencesPref.isAllowOverride());
                 service.set(pref);
             }else{
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/SearchDialogPreferences.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/SearchDialogPreferences.java
index 0485406bb..ee4385ccb 100755
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/SearchDialogPreferences.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/SearchDialogPreferences.java
@@ -267,7 +267,7 @@ public class SearchDialogPreferences extends CdmPreferencePage implements Select
                 @Override
                 public void widgetSelected(SelectionEvent e) {
                     setApply(true);
-                    if (searchForIdentifierAsDefaultPref == null){
+                    if (searchForIdentifierAsDefaultPref == null && !allowOverrideSearchForIdentifierAsDefaultButton.getSelection()){
                         searchForIdentifierAsDefaultPref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.SearchForIdentifierAsDefault, null);
                     }
                     searchForIdentifierAsDefaultPref.setAllowOverride(allowOverrideSearchForIdentifierAsDefaultButton.getSelection());
@@ -307,7 +307,7 @@ public class SearchDialogPreferences extends CdmPreferencePage implements Select
                 @Override
                 public void widgetSelected(SelectionEvent e) {
                     setApply(true);
-                    if (searchForIdentifierAndTitleCachePref == null){
+                    if (searchForIdentifierAndTitleCachePref == null && !allowOverridesSearchForIdentifierAndTitleCacheButton.getSelection()){
                         searchForIdentifierAndTitleCachePref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.SearchForIdentifierAndTitleCache, null);
                     }
                     searchForIdentifierAndTitleCachePref.setAllowOverride(allowOverridesSearchForIdentifierAndTitleCacheButton.getSelection());
@@ -346,7 +346,7 @@ public class SearchDialogPreferences extends CdmPreferencePage implements Select
                 @Override
                 public void widgetSelected(SelectionEvent e) {
                     setApply(true);
-                    if (sortTaxaByRankAndNamePref == null){
+                    if (sortTaxaByRankAndNamePref == null && !allowOverrideIsSortTaxaByRankAndNameButton.getSelection()){
                         sortTaxaByRankAndNamePref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.SortTaxaByRankAndName, null);
                     }
                     sortTaxaByRankAndNamePref.setAllowOverride(allowOverrideIsSortTaxaByRankAndNameButton.getSelection());
@@ -384,7 +384,7 @@ public class SearchDialogPreferences extends CdmPreferencePage implements Select
                 @Override
                 public void widgetSelected(SelectionEvent e) {
                     setApply(true);
-                    if (filterCommonNameReferencesPref == null){
+                    if (filterCommonNameReferencesPref == null && !allowOverrideFilterCommonNameReferencesButton.getSelection()){
                         filterCommonNameReferencesPref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.CommonNameReferencesWithMarker, null);
                     }
                     filterCommonNameReferencesPref.setAllowOverride(allowOverrideFilterCommonNameReferencesButton.getSelection());
@@ -399,8 +399,37 @@ public class SearchDialogPreferences extends CdmPreferencePage implements Select
 
     @Override
     protected void performDefaults() {
-        //TODO
-        super.performDefaults();
+        showIdInSelectionDialogButton.select(0);
+        showIdInSelectionDialog = null;
+        if (isAdminPreference){
+            allowOverrideIsShowIdInSelectionDialogButton.setSelection(true);
+            showIdInSelectionDialogPref.setAllowOverride(true);
+        }
+        searchForIdentifierAsDefaultButton.select(0);
+        searchForIdentifierAsDefault = null;
+        if (isAdminPreference){
+            allowOverrideSearchForIdentifierAsDefaultButton.setSelection(true);
+            searchForIdentifierAsDefaultPref.setAllowOverride(true);
+        }
+        searchForIdentifierAndTitleCacheButton.select(0);
+        searchForIdentifierAndTitleCache = null;
+        if (isAdminPreference){
+            allowOverridesSearchForIdentifierAndTitleCacheButton.setSelection(true);
+            searchForIdentifierAndTitleCachePref.setAllowOverride(true);
+        }
+        sortTaxaByRankAndNameButton.select(0);
+        sortTaxaByRankAndName = null;
+        if (isAdminPreference){
+            allowOverrideIsSortTaxaByRankAndNameButton.setSelection(true);
+            sortTaxaByRankAndNamePref.setAllowOverride(true);
+        }
+        filterCommonNameReferenceButton.select(0);
+        filterCommonNameReferences = null;
+        if (isAdminPreference){
+            allowOverrideFilterCommonNameReferencesButton.setSelection(true);
+            filterCommonNameReferencesPref.setAllowOverride(true);
+        }
+        setApply(true);
     }
 
     @Override
