commit 2bd924ce9809391592c064c8ff581226c3728f5f
Author: Katja Luther <k.luther@bgbm.org>
Date:   Tue Apr 24 10:59:48 2018 +0200

    ref #6429: namedetails view configuration in admin preferences

diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/preferencePage/ChecklistEditorGeneralPreference.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/preferencePage/ChecklistEditorGeneralPreference.java
index ca9a2a683..561b607b8 100755
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/preferencePage/ChecklistEditorGeneralPreference.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/preferencePage/ChecklistEditorGeneralPreference.java
@@ -17,6 +17,10 @@ import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
 
+import eu.etaxonomy.cdm.api.application.ICdmRepository;
+import eu.etaxonomy.cdm.api.service.IPreferenceService;
+import eu.etaxonomy.cdm.model.metadata.CdmPreference;
+import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
 import eu.etaxonomy.taxeditor.l10n.Messages;
 import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
 import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
@@ -43,7 +47,12 @@ public class ChecklistEditorGeneralPreference extends CdmPreferencePage implemen
 
         Composite composite = new Composite(parent, SWT.NULL);
         composite.setLayout(new GridLayout());
-        isEditorActivated = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.DISTRIBUTION_AREA_PREFRENCES_ACTIVE);
+        CdmPreference pref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.DistributionEditorActivated);
+        if (pref != null){
+            isEditorActivated = Boolean.valueOf(pref.getValue());
+        }else{
+            isEditorActivated = false;
+        }
         final Button activateCheckButton = new Button(composite, SWT.CHECK);
         activateCheckButton.setText(Messages.ChecklistEditorGeneralPreference_enable);
         activateCheckButton.setSelection(isEditorActivated);
@@ -68,12 +77,17 @@ public class ChecklistEditorGeneralPreference extends CdmPreferencePage implemen
         child.setVisible(isEditorActivated);
         final CLabel label = new CLabel(child, SWT.NULL);
         label.setText(Messages.ChecklistEditorGeneralPreference_open_wizard + Messages.ChecklistEditorGeneralPreference_2);
-        final CommandHandlerButton button_openFeatureTree = new CommandHandlerButton(child, SWT.PUSH,
+        final CommandHandlerButton button_openWizard = new CommandHandlerButton(child, SWT.PUSH,
                 Messages.ChecklistEditorGeneralPreference_3);
 
-        button_openFeatureTree.setText(Messages.ChecklistEditorGeneralPreference_open_distribution_selection);
+        button_openWizard.setText(Messages.ChecklistEditorGeneralPreference_open_distribution_selection);
         final Button showIdInVocabulary = new Button(child, SWT.CHECK);
-        isShowIdInVocabulary = PreferencesUtil.isShowIdInVocabularyInChecklistEditor();
+        pref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.ShowIdInVocabulary);
+        if (pref != null){
+            isShowIdInVocabulary = Boolean.valueOf(pref.getValue());
+        }else{
+            isShowIdInVocabulary = false;
+        }
         showIdInVocabulary.setText(Messages.ChecklistEditorGeneralPreference_show_id_in_voc);
         showIdInVocabulary.setSelection(isShowIdInVocabulary);
         showIdInVocabulary.addSelectionListener(new SelectionAdapter(){
@@ -85,7 +99,13 @@ public class ChecklistEditorGeneralPreference extends CdmPreferencePage implemen
         });
 
         final Button showSymbol = new Button(child, SWT.CHECK);
-        isShowSymbol = PreferencesUtil.isShowSymbolInChecklistEditor();
+        pref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.ShowSymbol);
+        if (pref != null){
+            isShowSymbol = Boolean.valueOf(pref.getValue());
+        }else{
+            isShowSymbol = false;
+        }
+
         showSymbol.setText(Messages.ChecklistEditorGeneralPreference_show_symbol);
         showSymbol.setSelection(isShowSymbol);
         showSymbol.addSelectionListener(new SelectionAdapter(){
@@ -94,8 +114,14 @@ public class ChecklistEditorGeneralPreference extends CdmPreferencePage implemen
                 isShowSymbol = showSymbol.getSelection();
              }
         });
-        PreferencesUtil.recursiveSetEnabled(button_openFeatureTree, CdmStore.isActive());
-        isShowRank = PreferencesUtil.isShowRankInChecklistEditor();
+//        PreferencesUtil.recursiveSetEnabled(button_openWizard, CdmStore.isActive());
+        pref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.ShowRankInDistributionEditor);
+        if (pref != null){
+            isShowRank = Boolean.valueOf(pref.getValue());
+        }else{
+            isShowRank = false;
+        }
+
         final Button activateRankButton = new Button(child, SWT.CHECK);
         activateRankButton.setText(Messages.ChecklistEditorGeneralPreference_show_rank);
         activateRankButton.setSelection(isShowRank);
@@ -106,7 +132,14 @@ public class ChecklistEditorGeneralPreference extends CdmPreferencePage implemen
             }
         });
         final Button sortNamedAreaByVocabularyOrder = new Button(child, SWT.CHECK);
-        isSortByVocabularyOrder = PreferencesUtil.isSortNamedAreaByOrderInVocabulary();
+
+        pref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.AreasSortedByIdInVocabulary);
+        if (pref != null){
+            isSortByVocabularyOrder = Boolean.valueOf(pref.getValue());
+        }else{
+            isSortByVocabularyOrder = false;
+        }
+
         sortNamedAreaByVocabularyOrder.setText(Messages.ChecklistEditorGeneralPreference_sort_areas);
         sortNamedAreaByVocabularyOrder.setSelection(isSortByVocabularyOrder);
         sortNamedAreaByVocabularyOrder.addSelectionListener(new SelectionAdapter(){
@@ -127,6 +160,36 @@ public class ChecklistEditorGeneralPreference extends CdmPreferencePage implemen
 
     @Override
     public boolean performOk() {
+        ICdmRepository controller = CdmStore.getCurrentApplicationConfiguration();
+        if (controller == null){
+            return false;
+        }
+        IPreferenceService service = controller.getPreferenceService();
+
+        CdmPreference pref = CdmPreference.NewDatabaseInstance( PreferencePredicate.DistributionEditorActivated, Boolean.toString(isEditorActivated));
+        //ToDo
+        pref.setAllowOverride(false);
+        service.set(pref);
+
+        pref = CdmPreference.NewDatabaseInstance( PreferencePredicate.ShowIdInVocabulary, Boolean.toString(isShowIdInVocabulary));
+        //ToDo
+        pref.setAllowOverride(false);
+        service.set(pref);
+
+        pref = CdmPreference.NewDatabaseInstance( PreferencePredicate.ShowSymbol, Boolean.toString(isShowSymbol));
+        //ToDo
+        pref.setAllowOverride(false);
+        service.set(pref);
+
+        pref = CdmPreference.NewDatabaseInstance( PreferencePredicate.ShowRankInDistributionEditor, Boolean.toString(isShowRank));
+        //ToDo
+        pref.setAllowOverride(false);
+        service.set(pref);
+        pref = CdmPreference.NewDatabaseInstance( PreferencePredicate.AreasSortedByIdInVocabulary, Boolean.toString(isSortByVocabularyOrder));
+        //ToDo
+        pref.setAllowOverride(false);
+        service.set(pref);
+
         PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.DISTRIBUTION_AREA_PREFRENCES_ACTIVE, isEditorActivated);
         PreferencesUtil.setSortNamedAreasByOrderInVocabulary(isSortByVocabularyOrder);
         PreferencesUtil.setShowRankInChecklistEditor(isShowRank);
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/preferencePage/NameDetailsViewConfiguration.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/preferencePage/NameDetailsViewConfiguration.java
index 73133e068..3f465a016 100755
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/preferencePage/NameDetailsViewConfiguration.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/preferencePage/NameDetailsViewConfiguration.java
@@ -52,21 +52,13 @@ public class NameDetailsViewConfiguration extends CdmPreferencePage implements I
     protected Control createContents(Composite parent) {
         final CLabel description = new CLabel(parent, SWT.NULL);
         description.setText(Messages.NameDetailsViewConfiguration_description);
-        CdmPreference nameDetailsPref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.NameDetailsView);
-        isAllowOverride = false;
-        if (nameDetailsPref != null){
-            //TODO: create checkbox
+        NameDetailsConfigurator nameDetailsConfig = PreferencesUtil.setPreferredNameDetailsConfiguration(false);
 
-            isAllowOverride = nameDetailsPref.isAllowOverride();
-        }
-
-
-
-        isSimpleDetailsViewActivated = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION);
 
         final Button activateCheckButton = new Button(parent, SWT.CHECK);
         activateCheckButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, true, 1, 1));
         activateCheckButton.setText(Messages.NameDetailsViewConfiguration_activateSimpleDetailsView);
+        isSimpleDetailsViewActivated = nameDetailsConfig.isSimpleDetailsViewActivated();
         activateCheckButton.setSelection(isSimpleDetailsViewActivated);
         activateCheckButton.addSelectionListener(new SelectionAdapter(){
         @Override
@@ -98,6 +90,7 @@ public class NameDetailsViewConfiguration extends CdmPreferencePage implements I
         final Button allowLocalPreference = new Button(dbSettings, SWT.CHECK);
 //      boolean isUseLocalPreference = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ALLOW_OVERRIDE_NAME_DETAILS);
       allowLocalPreference.setText(Messages.DatabasePreferencesPage_UseLocalPreferences);
+      isAllowOverride = nameDetailsConfig.isAllowOverride();
       allowLocalPreference.setSelection(isAllowOverride);
       allowLocalPreference.addSelectionListener(new SelectionAdapter(){
            @Override
@@ -109,8 +102,8 @@ public class NameDetailsViewConfiguration extends CdmPreferencePage implements I
         Label separator= new Label(dbSettings, SWT.HORIZONTAL | SWT.SEPARATOR);
         separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
         final Button showTaxon = new Button(dbSettings, SWT.CHECK);
-        isShowTaxon = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_TAXON);
         showTaxon.setText(Messages.NameDetailsViewComposite_Show_Taxon);
+        isShowTaxon = nameDetailsConfig.isTaxonSectionActivated();
         showTaxon.setSelection(isShowTaxon);
         showTaxon.addSelectionListener(new SelectionAdapter(){
              @Override
@@ -121,8 +114,8 @@ public class NameDetailsViewConfiguration extends CdmPreferencePage implements I
          });
 
         final Button showLsid = new Button(dbSettings, SWT.CHECK);
-        isShowLSID = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_LSID);
         showLsid.setText(Messages.NameDetailsViewComposite_Show_LSID);
+        isShowLSID = nameDetailsConfig.isLSIDActivated();
         showLsid.setSelection(isShowLSID);
         showLsid.addSelectionListener(new SelectionAdapter(){
              @Override
@@ -133,8 +126,8 @@ public class NameDetailsViewConfiguration extends CdmPreferencePage implements I
          });
 
         final Button showNomenclaturalCode = new Button(dbSettings, SWT.CHECK);
-        isShowNomenclaturalCode = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE);
         showNomenclaturalCode.setText(Messages.NameDetailsViewComposite_Show_NomenclaturalCode);
+        isShowNomenclaturalCode = nameDetailsConfig.isNomenclaturalCodeActived();
         showNomenclaturalCode.setSelection(isShowNomenclaturalCode);
         showNomenclaturalCode.addSelectionListener(new SelectionAdapter(){
              @Override
@@ -145,8 +138,8 @@ public class NameDetailsViewConfiguration extends CdmPreferencePage implements I
          });
 
         final Button showNameCache = new Button(dbSettings, SWT.CHECK);
-        isShowNameCache = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAMECACHE);
         showNameCache.setText(Messages.NameDetailsViewComposite_Show_NameCache);
+        isShowNameCache = nameDetailsConfig.isNameCacheActivated();
         showNameCache.setSelection(isShowNameCache);
         showNameCache.addSelectionListener(new SelectionAdapter(){
              @Override
@@ -156,7 +149,7 @@ public class NameDetailsViewConfiguration extends CdmPreferencePage implements I
               }
          });
         final Button showAppendedPhrase = new Button(dbSettings, SWT.CHECK);
-        isShowAppendedPhrase= PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE);
+        isShowAppendedPhrase= nameDetailsConfig.isAppendedPhraseActivated();
         showAppendedPhrase.setText(Messages.NameDetailsViewComposite_Show_AppendedPhrase);
         showAppendedPhrase.setSelection(isShowAppendedPhrase);
         showAppendedPhrase.addSelectionListener(new SelectionAdapter(){
@@ -168,7 +161,7 @@ public class NameDetailsViewConfiguration extends CdmPreferencePage implements I
          });
 
         final Button showRank = new Button(dbSettings, SWT.CHECK);
-        isShowRank = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_RANK);
+        isShowRank = nameDetailsConfig.isRankActivated();
         showRank.setText(Messages.NameDetailsViewComposite_Show_Rank);
         showRank.setSelection(isShowRank);
         showRank.addSelectionListener(new SelectionAdapter(){
@@ -179,7 +172,7 @@ public class NameDetailsViewConfiguration extends CdmPreferencePage implements I
               }
          });
         final Button showEpithets = new Button(dbSettings, SWT.CHECK);
-        isShowEpithets = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS);
+        isShowEpithets = nameDetailsConfig.isAtomisedEpithetsActivated();
         showEpithets.setText(Messages.NameDetailsViewComposite_Show_AtomisedEpithets);
         showEpithets.setSelection(isShowEpithets);
         showEpithets.addSelectionListener(new SelectionAdapter(){
@@ -191,7 +184,7 @@ public class NameDetailsViewConfiguration extends CdmPreferencePage implements I
          });
 
         final Button showAuthorCache = new Button(dbSettings, SWT.CHECK);
-        isShowAuthorCache = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP_CACHE);
+        isShowAuthorCache = nameDetailsConfig.isAuthorCacheActivated();
         showAuthorCache.setText(Messages.NameDetailsViewComposite_Show_AuthorCache);
         showAuthorCache.setSelection(isShowAuthorCache);
         showAuthorCache.addSelectionListener(new SelectionAdapter(){
@@ -203,7 +196,7 @@ public class NameDetailsViewConfiguration extends CdmPreferencePage implements I
          });
 
         final Button showAuthorship = new Button(dbSettings, SWT.CHECK);
-        isShowAuthorship = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP);
+        isShowAuthorship = nameDetailsConfig.isAuthorshipSectionActivated();
         showAuthorship.setText(Messages.NameDetailsViewComposite_Show_Author);
         showAuthorship.setSelection(isShowAuthorship);
         showAuthorship.addSelectionListener(new SelectionAdapter(){
@@ -215,7 +208,7 @@ public class NameDetailsViewConfiguration extends CdmPreferencePage implements I
          });
 
         final Button showNomenclaturalRef = new Button(dbSettings, SWT.CHECK);
-        isShowNomenclaturalRef = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE);
+        isShowNomenclaturalRef = nameDetailsConfig.isNomenclaturalReferenceSectionActivated();
         showNomenclaturalRef.setText(Messages.NameDetailsViewComposite_Show_NomenclaturalReference);
         showNomenclaturalRef.setSelection(isShowNomenclaturalRef);
         showNomenclaturalRef.addSelectionListener(new SelectionAdapter(){
@@ -227,7 +220,7 @@ public class NameDetailsViewConfiguration extends CdmPreferencePage implements I
          });
 
         final Button showNomenclaturalStatus = new Button(dbSettings, SWT.CHECK);
-        isShowNomenclaturalStatus = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS);
+        isShowNomenclaturalStatus = nameDetailsConfig.isNomenclaturalStatusSectionActivated();
         showNomenclaturalStatus.setText(Messages.NameDetailsViewComposite_Show_NomenclaturalStatus);
         showNomenclaturalStatus.setSelection(isShowNomenclaturalStatus);
         showNomenclaturalStatus.addSelectionListener(new SelectionAdapter(){
@@ -239,7 +232,7 @@ public class NameDetailsViewConfiguration extends CdmPreferencePage implements I
          });
 
         final Button showProtologue = new Button(dbSettings, SWT.CHECK);
-        isShowProtologue = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_PROTOLOGUE);
+        isShowProtologue = nameDetailsConfig.isProtologueActivated();
         showProtologue.setText(Messages.NameDetailsViewComposite_Show_Protologue);
         showProtologue.setSelection(isShowProtologue);
         showProtologue.addSelectionListener(new SelectionAdapter(){
@@ -251,7 +244,7 @@ public class NameDetailsViewConfiguration extends CdmPreferencePage implements I
          });
 
         final Button showTypeDesignation = new Button(dbSettings, SWT.CHECK);
-        isShowTypeDesignation = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION);
+        isShowTypeDesignation = nameDetailsConfig.isTypeDesignationSectionActivated();
         showTypeDesignation.setText(Messages.NameDetailsViewComposite_Show_TypeDesignation);
         showTypeDesignation.setSelection(isShowTypeDesignation);
         showTypeDesignation.addSelectionListener(new SelectionAdapter(){
@@ -264,7 +257,7 @@ public class NameDetailsViewConfiguration extends CdmPreferencePage implements I
 
 
         final Button showNameRelationship = new Button(dbSettings, SWT.CHECK);
-        isShowNameRelationship = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP);
+        isShowNameRelationship = nameDetailsConfig.isNameRelationsSectionActivated();
         showNameRelationship.setText(Messages.NameDetailsViewComposite_Show_Namerelationships);
         showNameRelationship.setSelection(isShowNameRelationship);
         showNameRelationship.addSelectionListener(new SelectionAdapter(){
@@ -276,7 +269,7 @@ public class NameDetailsViewConfiguration extends CdmPreferencePage implements I
          });
 
         final Button showHybrid = new Button(dbSettings, SWT.CHECK);
-        isShowHybrid = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_HYBRID);
+        isShowHybrid = nameDetailsConfig.isHybridActivated();
         showHybrid.setText(Messages.NameDetailsViewComposite_Show_Hybrid);
         showHybrid.setSelection(isShowHybrid);
         showHybrid.addSelectionListener(new SelectionAdapter(){
@@ -287,7 +280,7 @@ public class NameDetailsViewConfiguration extends CdmPreferencePage implements I
               }
          });
         final Button showNameApprobiation = new Button(dbSettings, SWT.CHECK);
-        isShowNameApprobiation = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAME_APPROBATION);
+        isShowNameApprobiation = nameDetailsConfig.isNameApprobiationActivated();
         showNameApprobiation.setText(Messages.NameDetailsViewComposite_Show_NameApprobiation);
         showNameApprobiation.setSelection(isShowNameApprobiation);
         showNameApprobiation.addSelectionListener(new SelectionAdapter(){
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/preferencePage/PublishFlagPreference.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/preferencePage/PublishFlagPreference.java
index 22da8742c..ebebaf1e2 100755
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/preferencePage/PublishFlagPreference.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/preferencePage/PublishFlagPreference.java
@@ -33,14 +33,37 @@ import eu.etaxonomy.taxeditor.store.CdmStore;
  */
 public class PublishFlagPreference extends CdmPreferencePage implements IE4AdminPreferencePage{
 
-   boolean setPublish = true;
-   boolean setNotPublish = false;
-   boolean inheritFromParent = false;
+   boolean setPublish;
+   boolean setNotPublish;
+   boolean inheritFromParent;
 
    @Override
    public void init() {
        super.init();
        CdmPreference pref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.DefaultBehaviourForPublishFlag);
+       if (pref != null){
+           if (pref.getValue().equals(Messages.PublishFlagPreference_do_not_set)){
+               setNotPublish = true;
+               setPublish = false;
+               inheritFromParent = false;
+           }
+
+           if (pref.getValue().equals(Messages.PublishFlagPreference_inherit)){
+               setNotPublish = false;
+               setPublish = false;
+               inheritFromParent = true;
+           }
+
+           if (pref.getValue().equals(Messages.PublishFlagPreference_set)){
+               setNotPublish = false;
+               setPublish = true;
+               inheritFromParent = false;
+           }
+       }else{
+           setNotPublish = false;
+           setPublish = true;
+           inheritFromParent = false;
+       }
 
    }
     /**
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/NameDetailsConfigurator.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/NameDetailsConfigurator.java
index 0adb01aac..45191ab8e 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/NameDetailsConfigurator.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/NameDetailsConfigurator.java
@@ -15,6 +15,7 @@ package eu.etaxonomy.taxeditor.preference;
  */
 public class NameDetailsConfigurator {
 
+    private boolean isAllowOverride = true;
     private boolean isSimpleDetailsViewActivated = true;
 
     private boolean isTaxonSectionActivated = true;
@@ -227,7 +228,7 @@ public class NameDetailsConfigurator {
       return result.toString();
     }
 
-    
+
 
     /**
      * @return the isAuthorCacheActivated
@@ -253,11 +254,19 @@ public class NameDetailsConfigurator {
 
 	public void setNameApprobiationActivated(boolean isNameApprobiationActivated) {
 		this.isNameApprobiationActivated  = isNameApprobiationActivated;
-		
+
 	}
 	public boolean isNameApprobiationActivated() {
 		return isNameApprobiationActivated;
-		
+
 	}
 
+    public boolean isAllowOverride() {
+        return isAllowOverride;
+    }
+
+    public void setAllowOverride(boolean isAllowOverride) {
+        this.isAllowOverride = isAllowOverride;
+    }
+
 }
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/PreferencesUtil.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/PreferencesUtil.java
index 6a750fa18..489b5723a 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/PreferencesUtil.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/PreferencesUtil.java
@@ -276,6 +276,20 @@ public class PreferencesUtil implements IPreferenceKeys {
 
     }
 
+    public static void setPreferenceToDB(CdmPreference preference){
+        ICdmRepository controller;
+        try{
+            if(CdmStore.isActive()){
+                controller = CdmStore.getCurrentApplicationConfiguration();
+                controller.getPreferenceService().set(preference);
+            }
+        }catch(Exception e){
+            e.printStackTrace();
+        }
+
+    }
+
+
 
 	public static String getPreferredDefaultLangugae(){
 	    String preferredLanguage = getPreferenceStore().getString(DEFAULT_LANGUAGE_EDITOR);
@@ -1062,81 +1076,95 @@ public class PreferencesUtil implements IPreferenceKeys {
 
         if (!local) {
             preference = getPreferenceFromDB(PreferencePredicate.NameDetailsView);
-        }
-        if (preference == null){
-            return null;
-        }
+            if (preference == null){
+                return null;
+            }
 
-        getPreferenceStore().setValue(ALLOW_OVERRIDE_NAME_DETAILS, preference.isAllowOverride());
+            getPreferenceStore().setValue(ALLOW_OVERRIDE_NAME_DETAILS, preference.isAllowOverride());
 
-        //the preference value is build like this:
-        //<section1>:true;<section2>:false....
+            //the preference value is build like this:
+            //<section1>:true;<section2>:false....
 
-        String value = preference.getValue();
-        String [] sections = value.split(";");
-        Map<String, Boolean> sectionMap = new HashMap<String, Boolean>();
-        String[] sectionValues;
-        for (String sectionValue: sections){
-            sectionValues = sectionValue.split(":");
-            sectionMap.put(sectionValues[0], Boolean.valueOf(sectionValues[1]));
+            String value = preference.getValue();
+            String [] sections = value.split(";");
+            Map<String, Boolean> sectionMap = new HashMap<String, Boolean>();
+            String[] sectionValues;
+            for (String sectionValue: sections){
+                sectionValues = sectionValue.split(":");
+                sectionMap.put(sectionValues[0], Boolean.valueOf(sectionValues[1]));
+            }
+            config.setAllowOverride(preference.isAllowOverride());
+            config.setSimpleDetailsViewActivated(getValue(sectionMap, "simpleViewActivated"));
+
+    //        getPreferenceStore().setValue(SHOW_SIMPLE_NAME_DETAILS_TAXON,
+    //                (getValue(sectionMap, "taxon")));
+            config.setTaxonSectionActivated(getValue(sectionMap, "taxon"));
+
+    //        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_LSID,
+    //                (getValue(sectionMap, "lsid")));
+            config.setLSIDActivated(getValue(sectionMap, "lsid"));
+
+    //        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE,
+    //                (getValue(sectionMap, "nc")));
+            config.setNomenclaturalCodeActived(getValue(sectionMap, "nc"));
+
+    //        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE,
+    //                (getValue(sectionMap, "ap")));
+            config.setAppendedPhraseActivated(getValue(sectionMap, "ap"));
+
+    //        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_RANK,
+    //                (getValue(sectionMap, "rank")));
+            config.setRankActivated(getValue(sectionMap, "rank"));
+
+
+    //        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS,
+    //                (getValue(sectionMap, "atomisedEpithets")));
+            config.setAtomisedEpithetsActivated(getValue(sectionMap, "atomisedEpithets"));
+
+    //        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_AUTHORSHIP,
+    //                (getValue(sectionMap,"author")));
+            config.setAuthorshipSectionActivated(getValue(sectionMap,"author"));
+
+    //        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE,
+    //                (getValue(sectionMap, "nomRef")));
+            config.setNomenclaturalReferenceSectionActivated(sectionMap.get("nomRef"));
+
+    //        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS,
+    //                (getValue(sectionMap, "nomStat")));
+            config.setNomenclaturalStatusSectionActivated(getValue(sectionMap, "nomStat"));
+
+
+    //        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_PROTOLOGUE,
+    //                (getValue(sectionMap,"protologue")));
+            config.setProtologueActivated(getValue(sectionMap,"protologue"));
+
+    //        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION,
+    //                (getValue(sectionMap,"typeDes")));
+            config.setTypeDesignationSectionActivated(getValue(sectionMap,"typeDes"));
+
+    //        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP,
+    //                (getValue(sectionMap,"nameRelation")));
+            config.setNameRelationsSectionActivated(getValue(sectionMap,"nameRelation"));
+
+    //        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_HYBRID,
+    //                (getValue(sectionMap, "hybrid")));
+            config.setHybridActivated(getValue(sectionMap,"hybrid"));
+        }else{
+            config.setSimpleDetailsViewActivated(getPreferenceStore().getBoolean(SHOW_SIMPLE_NAME_DETAILS_SECTION));
+            config.setTaxonSectionActivated(getPreferenceStore().getBoolean(SHOW_SIMPLE_NAME_DETAILS_TAXON));
+            config.setLSIDActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_LSID));
+            config.setNomenclaturalCodeActived(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE));
+            config.setAppendedPhraseActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE));
+            config.setRankActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_RANK));
+            config.setAtomisedEpithetsActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS));
+            config.setAuthorshipSectionActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_AUTHORSHIP));
+            config.setNomenclaturalReferenceSectionActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE));
+            config.setNomenclaturalStatusSectionActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS));
+            config.setProtologueActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_PROTOLOGUE));
+            config.setTypeDesignationSectionActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION));
+            config.setNameRelationsSectionActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP));
+            config.setHybridActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_HYBRID));
         }
-
-        config.setSimpleDetailsViewActivated(getValue(sectionMap, "simpleViewActivated"));
-
-//        getPreferenceStore().setValue(SHOW_SIMPLE_NAME_DETAILS_TAXON,
-//                (getValue(sectionMap, "taxon")));
-        config.setTaxonSectionActivated(getValue(sectionMap, "taxon"));
-
-//        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_LSID,
-//                (getValue(sectionMap, "lsid")));
-        config.setLSIDActivated(getValue(sectionMap, "lsid"));
-
-//        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE,
-//                (getValue(sectionMap, "nc")));
-        config.setNomenclaturalCodeActived(getValue(sectionMap, "nc"));
-
-//        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE,
-//                (getValue(sectionMap, "ap")));
-        config.setAppendedPhraseActivated(getValue(sectionMap, "ap"));
-
-//        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_RANK,
-//                (getValue(sectionMap, "rank")));
-        config.setRankActivated(getValue(sectionMap, "rank"));
-
-
-//        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS,
-//                (getValue(sectionMap, "atomisedEpithets")));
-        config.setAtomisedEpithetsActivated(getValue(sectionMap, "atomisedEpithets"));
-
-//        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_AUTHORSHIP,
-//                (getValue(sectionMap,"author")));
-        config.setAuthorshipSectionActivated(getValue(sectionMap,"author"));
-
-//        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE,
-//                (getValue(sectionMap, "nomRef")));
-        config.setNomenclaturalReferenceSectionActivated(sectionMap.get("nomRef"));
-
-//        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS,
-//                (getValue(sectionMap, "nomStat")));
-        config.setNomenclaturalStatusSectionActivated(getValue(sectionMap, "nomStat"));
-
-
-//        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_PROTOLOGUE,
-//                (getValue(sectionMap,"protologue")));
-        config.setProtologueActivated(getValue(sectionMap,"protologue"));
-
-//        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION,
-//                (getValue(sectionMap,"typeDes")));
-        config.setTypeDesignationSectionActivated(getValue(sectionMap,"typeDes"));
-
-//        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP,
-//                (getValue(sectionMap,"nameRelation")));
-        config.setNameRelationsSectionActivated(getValue(sectionMap,"nameRelation"));
-
-//        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_HYBRID,
-//                (getValue(sectionMap, "hybrid")));
-        config.setHybridActivated(getValue(sectionMap,"hybrid"));
-
         return config;
     }
 
@@ -1391,4 +1419,5 @@ public static CdmPreference setPreferredNamedAreasForDistributionEditor(
 
 
 
+
 }
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/wizard/AvailableDistributionWizard.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/wizard/AvailableDistributionWizard.java
index bf21b8404..009909380 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/wizard/AvailableDistributionWizard.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/wizard/AvailableDistributionWizard.java
@@ -82,6 +82,7 @@ public class AvailableDistributionWizard extends Wizard implements IConversation
             String saveCheckedElements = StringUtils.join(listUIIDChecked, ",");
             String saveGrayedElements = StringUtils.join(listUIIDGrayed, ",");
             IPreferenceStore preferenceStore = PreferencesUtil.getPreferenceStore();
+            //ToDo, if whole vocabulary is selected, save the vocabulary not all areas
             PreferencesUtil.setPreferredNamedAreasForDistributionEditor(saveCheckedElements, saveGrayedElements, false);
 //            preferenceStore.setValue(PreferencesUtil.DISTRIBUTION_AREA_OCCURENCE_STATUS, saveCheckedElements);
             preferenceStore.setValue(PreferencesUtil.DISTRIBUTION_AREA_OCCURENCE_STATUS_GRAYED, saveGrayedElements);
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/NameDetailElement.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/NameDetailElement.java
index 25a659d8a..94a09c0aa 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/NameDetailElement.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/NameDetailElement.java
@@ -26,7 +26,7 @@ import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
 import eu.etaxonomy.cdm.model.name.Rank;
 import eu.etaxonomy.cdm.model.name.TaxonNameFactory;
 import eu.etaxonomy.cdm.strategy.parser.ParserProblem;
-import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
+import eu.etaxonomy.taxeditor.preference.NameDetailsConfigurator;
 import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
 import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
@@ -64,6 +64,7 @@ public class NameDetailElement extends AbstractIdentifiableEntityDetailElement<I
 	//private NumberWithLabelElement text_originalPublicationYear;
 	private int cursorPosition;
 
+	NameDetailsConfigurator config;
 
 	/**
 	 * <p>Constructor for NameDetailElement.</p>
@@ -77,12 +78,17 @@ public class NameDetailElement extends AbstractIdentifiableEntityDetailElement<I
 		super(cdmFormFactory, formElement);
 		// make this element selectable
 
+
 	}
 
 	/** {@inheritDoc} */
 	@Override
 	protected void createControls(ICdmFormElement formElement, INonViralName nonViralName, int style) {
 		Comparator<Rank> comparator = null;
+		config = PreferencesUtil.setPreferredNameDetailsConfiguration(false);
+        if ( PreferencesUtil.getPreferenceStore().getBoolean(PreferencesUtil.ALLOW_OVERRIDE_NAME_DETAILS)){
+            config = PreferencesUtil.setPreferredNameDetailsConfiguration(true);
+        }
 		if(PreferencesUtil.getSortRanksHierarchichally()){
 			comparator = new Comparator<Rank>(){
 
@@ -104,22 +110,22 @@ public class NameDetailElement extends AbstractIdentifiableEntityDetailElement<I
             createSpecificNameParts(this, nonViralName, style);
             text_appendedPhrase = formFactory.createTextWithLabelElement(formElement, "Appended Phrase", nonViralName.getAppendedPhrase(), style);
 	    }else{
-	    	if (PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAMECACHE)){
+	    	if (config.isNameCacheActivated()){
 	    		toggleable_cache = formFactory.createToggleableTextField(this, "Name Cache", nonViralName.getNameCache(), nonViralName.isProtectedNameCache(), style);
         	}
 
-    	    if (PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_RANK)){
+    	    if (config.isRankActivated()){
     	        combo_rank = formFactory.createDefinedTermComboElement(TermType.Rank, this, "Rank", nonViralName.getRank(), style, comparator);
     	    }
 
-    		if (PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS)){
+    		if (config.isAtomisedEpithetsActivated()){
     			createGenusOrUninomialControls(this, nonViralName, style);
     			createInfragenerericEpithetControls(this, nonViralName, style);
     			createSpecificEpithetControls(this, nonViralName, style);
     			createInfraSpecificEpithetControls(this, nonViralName, style);
     			createSpecificNameParts(this, nonViralName, style);
     		}
-    		if (PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE)){
+    		if (config.isAppendedPhraseActivated()){
     				text_appendedPhrase = formFactory.createTextWithLabelElement(formElement, "Appended Phrase", nonViralName.getAppendedPhrase(), style);
            	}
 	    }
