ref #8294: add preference page for id in namespace and namespace in source
authorKatja Luther <k.luther@bgbm.org>
Fri, 28 Jun 2019 09:47:40 +0000 (11:47 +0200)
committerKatja Luther <k.luther@bgbm.org>
Fri, 28 Jun 2019 09:47:40 +0000 (11:47 +0200)
eu.etaxonomy.taxeditor.store/plugin.xml
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/preferencePage/SupplementalDataAdminPreference.java [new file with mode: 0755]
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/ChecklistEditorGeneralPreference.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/GeneralPreferencePage.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/NameDetailsViewConfiguration.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/PreferencesUtil.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/SpecimenOrObservationPreferences.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/SupplementalDataPreferences.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/TermManager.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/supplemental/AbstractOriginalSourceElement.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/supplemental/IdentifiableSourceElement.java

index fae546f1414c6cdb4521abf4b247588ff4f9c068..154d01b92444850313a989ca263c45db44cfd943 100755 (executable)
          id="eu.etaxonomy.taxeditor.preferences.nameFeature"
          name="%page.name.59">
    </page>
-   <page
+   <!--<page
          category="eu.etaxonomy.taxeditor.preferences.description"
          class="eu.etaxonomy.taxeditor.preference.menu.PresenceAbsenceMenuPreferences"
          id="eu.etaxonomy.taxeditor.preferences.distributionStatus"
          name="%page.name.2">
-   </page>
+   </page>-->
     <page
          category="eu.etaxonomy.taxeditor.preference.searchPreferences"
          class="eu.etaxonomy.taxeditor.preference.SearchDialogPreferences"
    </page>
    <page
          category="eu.etaxonomy.taxeditor.preferences.namePreferences"
-         class="eu.etaxonomy.taxeditor.preference.menu.RankMenuPreferences"
+         class="eu.etaxonomy.taxeditor.preference.RankPreference"
          id="eu.etaxonomy.taxeditor.preferences.ranks"
          name="%page.name.5">
    </page>
    <page
          category="eu.etaxonomy.taxeditor.preferences.namePreferences"
-         class="eu.etaxonomy.taxeditor.preference.menu.NomenclaturalStatusTypeMenuPreferences"
+         class="eu.etaxonomy.taxeditor.preference.NomenclaturalStatusTypePreferences"
          id="eu.etaxonomy.taxeditor.preferences.nomenclaturalStatusType"
          name="%page.name.6">
    </page>
          class="eu.etaxonomy.taxeditor.databaseAdmin.preferencePage.PublishFlagPreference"
          id="eu.etaxonomy.taxeditor.preferences.publishFlagPreference"
          name="%page.name.46">
+   </page>
+    <page
+        category="eu.etaxonomy.taxeditor.preferences.general"
+         class="eu.etaxonomy.taxeditor.databaseAdmin.preferencePage.RankAdminPreference"
+         id="eu.etaxonomy.taxeditor.preferences.adminRankPreference"
+         name="%page.name.5">
+   </page>
+   <page
+        category="eu.etaxonomy.taxeditor.preferences.general"
+         class="eu.etaxonomy.taxeditor.databaseAdmin.preferencePage.NomenclaturalStatusTypeAdminPreference"
+         id="eu.etaxonomy.taxeditor.preferences.adminNomenclaturalStatusTypePreference"
+         name="%page.name.6">
    </page>
    <page
          category="eu.etaxonomy.taxeditor.preferences.general"
          id="eu.etaxonomy.taxeditor.store.scientificNameDetails"
          name="%page.name.61">
    </page>
+   <page
+         category="eu.etaxonomy.taxeditor.preferences.general"
+         class="eu.etaxonomy.taxeditor.databaseAdmin.preferencePage.SupplementalDataAdminPreference"
+         id="eu.etaxonomy.taxeditor.store.supplementalDataPreferences"
+         name="%page.name.55">
+   </page>
 </extension>
 </plugin>
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/preferencePage/SupplementalDataAdminPreference.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/preferencePage/SupplementalDataAdminPreference.java
new file mode 100755 (executable)
index 0000000..eb1418a
--- /dev/null
@@ -0,0 +1,78 @@
+/**
+* Copyright (C) 2019 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.taxeditor.databaseAdmin.preferencePage;
+
+import eu.etaxonomy.cdm.model.metadata.CdmPreference;
+import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
+import eu.etaxonomy.taxeditor.preference.CdmPreferenceCache;
+import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
+import eu.etaxonomy.taxeditor.preference.SupplementalDataPreferences;
+
+/**
+ * @author k.luther
+ * @since 28.06.2019
+ *
+ */
+public class SupplementalDataAdminPreference extends SupplementalDataPreferences {
+
+    CdmPreference prefShowIdNamespace;
+    CdmPreference prefShowNamespace;
+
+
+    @Override
+    public boolean performOk() {
+        if (!isApply()){
+            return true;
+        }
+        boolean setToDefault = false;
+        if (isShowIDNamspace == null){
+           setToDefault = true;
+           isShowIDNamspace = true;
+        }
+        CdmPreference pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowIdInSource, Boolean.toString(this.isShowIDNamspace));
+        pref.setAllowOverride(isAllowOverrideShowIDNamspace);
+        PreferencesUtil.setPreferencesToDB(pref, setToDefault);
+
+        if (isShowNamespace == null){
+            setToDefault = true;
+            isShowNamespace = true;
+         }
+        pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowNamespaceInSource, Boolean.toString(this.isShowNamespace));
+        pref.setAllowOverride(isAllowOverrideShowNamspace);
+        PreferencesUtil.setPreferencesToDB(pref, setToDefault);
+
+        PreferencesUtil.updateDBPreferences();
+
+
+       return true;
+   }
+    @Override
+    protected void getValues(){
+        isAdminPreference = true;
+
+        CdmPreferenceCache cache = CdmPreferenceCache.instance();
+
+        prefShowIdNamespace = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.ShowIdInSource);
+        if (prefShowIdNamespace == null){
+            prefShowIdNamespace = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowIdInSource, null);
+            prefShowIdNamespace.setAllowOverride(true);
+        }
+        isShowIDNamspace = prefShowIdNamespace.getValue()!= null? Boolean.parseBoolean(prefShowIdNamespace.getValue()): null;
+        isAllowOverrideShowIDNamspace = prefShowIdNamespace.isAllowOverride();
+
+
+        prefShowNamespace = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.ShowNamespaceInSource);
+        if (prefShowNamespace == null){
+            prefShowNamespace = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowNamespaceInSource, null);
+            prefShowNamespace.setAllowOverride(true);
+        }
+        isShowNamespace = prefShowNamespace.getValue()!= null? Boolean.parseBoolean(prefShowNamespace.getValue()): null;
+        isAllowOverrideShowNamspace = prefShowNamespace.isAllowOverride();
+    }
+}
index 6f06d07b11b2f9871032fc9be6538b390b7e4ad3..7628c1dc9a9b463910186649cb4c1eabf8e6fc30 100644 (file)
@@ -656,7 +656,8 @@ public class ChecklistEditorGeneralPreference extends CdmPreferencePage implemen
         setPreferenceStore(PreferencesUtil.getPreferenceStore());\r
         distributionEditorPref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.DistributionEditorActivated);\r
         overrideActivated = PreferencesUtil.getBooleanValue(\r
-                PreferencesUtil.prefOverrideKey(PreferencePredicate.DistributionEditorActivated.getKey()), true);\r
+                PreferencesUtil.prefOverrideKey(PreferencePredicate.DistributionEditorActivated.getKey()), true) != null? PreferencesUtil.getBooleanValue(\r
+                        PreferencesUtil.prefOverrideKey(PreferencePredicate.DistributionEditorActivated.getKey()), true):false;\r
 \r
         if (distributionEditorPref != null) {\r
             if (distributionEditorPref.isAllowOverride() ) {\r
@@ -666,7 +667,6 @@ public class ChecklistEditorGeneralPreference extends CdmPreferencePage implemen
 \r
             } else {\r
                 isEditorActivated = Boolean.valueOf(distributionEditorPref.getValue());\r
-\r
             }\r
 \r
         } else {\r
@@ -692,7 +692,9 @@ public class ChecklistEditorGeneralPreference extends CdmPreferencePage implemen
 \r
         prefAreaDisplay = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.DisplayOfAreasInDistributionEditor);\r
         overrideAreaDisplay = PreferencesUtil.getBooleanValue(\r
-                PreferencesUtil.prefOverrideKey(PreferencePredicate.DisplayOfAreasInDistributionEditor.getKey()), true);\r
+                PreferencesUtil.prefOverrideKey(PreferencePredicate.DisplayOfAreasInDistributionEditor.getKey()), true) != null? PreferencesUtil.getBooleanValue(\r
+                        PreferencesUtil.prefOverrideKey(PreferencePredicate.DisplayOfAreasInDistributionEditor.getKey()), true): false;\r
+\r
         if (prefAreaDisplay != null) {\r
             if (prefAreaDisplay.isAllowOverride()){\r
                 if (overrideActivated) {\r
@@ -714,7 +716,8 @@ public class ChecklistEditorGeneralPreference extends CdmPreferencePage implemen
 \r
         prefStatusDisplay = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.DisplayOfStatus);\r
         overrideStatusDisplay = PreferencesUtil\r
-                .getBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.DisplayOfStatus.getKey()), true);\r
+                .getBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.DisplayOfStatus.getKey()), true) != null? PreferencesUtil\r
+                        .getBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.DisplayOfStatus.getKey()), true): false;\r
         if (prefStatusDisplay != null) {\r
             if (prefStatusDisplay.isAllowOverride()){\r
                 if (overrideStatusDisplay) {\r
@@ -736,7 +739,8 @@ public class ChecklistEditorGeneralPreference extends CdmPreferencePage implemen
 \r
         prefStatusDisplayInCombo = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.DisplayOfStatusInCombo);\r
         overrideStatusDisplayCombo = PreferencesUtil\r
-                .getBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.DisplayOfStatusInCombo.getKey()), true);\r
+                .getBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.DisplayOfStatusInCombo.getKey()), true) != null? PreferencesUtil\r
+                        .getBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.DisplayOfStatusInCombo.getKey()), true): false;\r
         if (prefStatusDisplayInCombo != null) {\r
             if (prefStatusDisplayInCombo.isAllowOverride()){\r
                 if (overrideStatusDisplayCombo) {\r
@@ -759,7 +763,8 @@ public class ChecklistEditorGeneralPreference extends CdmPreferencePage implemen
 \r
         prefAreaSort = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.AreasSortedInDistributionEditor);\r
         overrideOrderAreas = PreferencesUtil.getBooleanValue(\r
-                PreferencesUtil.prefOverrideKey(PreferencePredicate.AreasSortedInDistributionEditor.getKey()), true);\r
+                PreferencesUtil.prefOverrideKey(PreferencePredicate.AreasSortedInDistributionEditor.getKey()), true) != null? PreferencesUtil.getBooleanValue(\r
+                        PreferencesUtil.prefOverrideKey(PreferencePredicate.AreasSortedInDistributionEditor.getKey()), true): false;\r
         if (prefAreaSort != null) {\r
             if (prefAreaSort.isAllowOverride()){\r
                 if(overrideOrderAreas) {\r
@@ -787,7 +792,8 @@ public class ChecklistEditorGeneralPreference extends CdmPreferencePage implemen
 \r
         prefRank = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.ShowRankInDistributionEditor);\r
         overrideRank = PreferencesUtil.getBooleanValue(\r
-                PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowRankInDistributionEditor.getKey()), true);\r
+                PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowRankInDistributionEditor.getKey()), true) != null? PreferencesUtil.getBooleanValue(\r
+                        PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowRankInDistributionEditor.getKey()), true): false;\r
         if (prefRank != null) {\r
             if (prefRank.isAllowOverride()){\r
                 if(overrideRank) {\r
@@ -819,7 +825,8 @@ public class ChecklistEditorGeneralPreference extends CdmPreferencePage implemen
             ownDescriptionForDistributionEditor = PreferencesUtil.isShowRankInChecklistEditor();\r
             // allowOverrideOwnDescriptionForDistributionEditor = true;\r
             overrideOwnDescriptionForDistributionEditor = PreferencesUtil.getBooleanValue(\r
-                    PreferencesUtil.prefOverrideKey(PreferencePredicate.OwnDescriptionForDistributionEditor.getKey()), true);\r
+                    PreferencesUtil.prefOverrideKey(PreferencePredicate.OwnDescriptionForDistributionEditor.getKey()), true) != null? PreferencesUtil.getBooleanValue(\r
+                            PreferencesUtil.prefOverrideKey(PreferencePredicate.OwnDescriptionForDistributionEditor.getKey()), true): false;\r
             //prefOwnDescription = CdmPreference.NewTaxEditorInstance(PreferencePredicate.OwnDescriptionForDistributionEditor, PreferencePredicate.OwnDescriptionForDistributionEditor.getDefaultValue() != null ?  PreferencePredicate.OwnDescriptionForDistributionEditor.getDefaultValue().toString(): null);\r
         }\r
 \r
index 262ad92779266f2c282485c2376404461f4c35be..a9b7d77cccad5e1407e08ef5d3ef9326b05e8094 100755 (executable)
@@ -34,10 +34,10 @@ import eu.etaxonomy.taxeditor.preference.menu.CdmPreferencePage;
 public class GeneralPreferencePage extends CdmPreferencePage implements SelectionListener{
 
 
-    protected boolean isShowIOMenu;
+    protected Boolean isShowIOMenu;
 //    protected boolean isShowMediaView;
-    protected boolean isShowCheckListPerspective;
-    protected boolean isShowTaxonNodeWizard;
+    protected Boolean isShowCheckListPerspective;
+    protected Boolean isShowTaxonNodeWizard;
     protected boolean isAllowOverrideShowIOMenu;
     protected boolean isAllowOverrideShowMediaView;
     protected boolean isAllowOverrideShowCheckListPerspective;
@@ -73,10 +73,13 @@ public class GeneralPreferencePage extends CdmPreferencePage implements Selectio
                 isAdminPreference);
 
         showIOMenuButton.addSelectionListener(this);
-        if (isShowIOMenu){
+
+        if (isShowIOMenu == null || !isOverrideShowIOMenu){
             showIOMenuButton.select(0);
-        }else{
+        }else if (isShowIOMenu){
             showIOMenuButton.select(1);
+        }else{
+            showIOMenuButton.select(2);
         }
         if (isAdminPreference){
         allowOverrideShowIOMenuButton = createAllowOverrideButton(composite);
@@ -96,10 +99,12 @@ public class GeneralPreferencePage extends CdmPreferencePage implements Selectio
                 isAdminPreference);
 
         showChecklistPerspectiveButton.addSelectionListener(this);
-        if (isShowCheckListPerspective){
+        if (isShowCheckListPerspective == null || !isOverrideShowCheckListPerspective){
             showChecklistPerspectiveButton.select(0);
-        }else{
+        }else if (isShowCheckListPerspective){
             showChecklistPerspectiveButton.select(1);
+        }else{
+            showChecklistPerspectiveButton.select(2);
         }
 
         if (isAdminPreference){
@@ -124,7 +129,13 @@ public class GeneralPreferencePage extends CdmPreferencePage implements Selectio
         }else{
             showTaxonNodeWizardButton.select(1);
         }
-
+        if (isShowTaxonNodeWizard == null || !isOverrideShowTaxonNodeWizard){
+            showTaxonNodeWizardButton.select(0);
+        }else if (isShowTaxonNodeWizard){
+            showTaxonNodeWizardButton.select(1);
+        }else{
+            showTaxonNodeWizardButton.select(2);
+        }
         showTaxonNodeWizardButton.addSelectionListener(this);
 
 
@@ -184,7 +195,9 @@ public class GeneralPreferencePage extends CdmPreferencePage implements Selectio
 
         CdmPreferenceCache cache = CdmPreferenceCache.instance();
         isShowIOMenu = PreferencesUtil.getBooleanValue(PreferencePredicate.ShowImportExportMenu.getKey(), true);
-        isOverrideShowIOMenu = PreferencesUtil.getBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowImportExportMenu.getKey()), true);
+
+        isOverrideShowIOMenu = PreferencesUtil.getBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowImportExportMenu.getKey()), true) != null?
+                PreferencesUtil.getBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowImportExportMenu.getKey()), true): false;
         PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowImportExportMenu);
         CdmPreference pref = cache.findBestMatching(key);
         if (pref != null){
@@ -194,7 +207,8 @@ public class GeneralPreferencePage extends CdmPreferencePage implements Selectio
         }
 
         isShowCheckListPerspective = PreferencesUtil.getBooleanValue(PreferencePredicate.ShowChecklistPerspective.getKey(), true);
-        isOverrideShowCheckListPerspective = PreferencesUtil.getBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowChecklistPerspective.getKey()), true);
+
+        isOverrideShowCheckListPerspective = PreferencesUtil.getBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowChecklistPerspective.getKey()), true) != null? PreferencesUtil.getBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowChecklistPerspective.getKey()), true): false;
         key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowChecklistPerspective);
         pref = cache.findBestMatching(key);
         if (pref != null){
@@ -204,7 +218,7 @@ public class GeneralPreferencePage extends CdmPreferencePage implements Selectio
         }
 
         isShowTaxonNodeWizard = PreferencesUtil.getBooleanValue(PreferencePredicate.ShowTaxonNodeWizard.getKey(), true);
-        isOverrideShowTaxonNodeWizard = PreferencesUtil.getBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowTaxonNodeWizard.getKey()), true);
+        isOverrideShowTaxonNodeWizard = PreferencesUtil.getBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowTaxonNodeWizard.getKey()), true) != null? PreferencesUtil.getBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowTaxonNodeWizard.getKey()), true): false;
         key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowTaxonNodeWizard);
         pref = cache.findBestMatching(key);
         if (pref != null){
@@ -223,7 +237,11 @@ public class GeneralPreferencePage extends CdmPreferencePage implements Selectio
     public void widgetSelected(SelectionEvent e) {
         if (e.getSource().equals(this.showIOMenuButton)) {
             String text = showIOMenuButton.getText();
-            text = text.replace(Messages.Preference_Use_Default, "");
+            if (text.equals(Messages.Preference_Use_Default)){
+                isOverrideShowIOMenu = false;
+            }else{
+                isOverrideShowIOMenu = true;
+            }
             if (text.equals(SHOW)){
                 isShowIOMenu = true;
             }else{
@@ -232,7 +250,11 @@ public class GeneralPreferencePage extends CdmPreferencePage implements Selectio
         }
         if (e.getSource().equals(this.showChecklistPerspectiveButton)) {
             String text = showChecklistPerspectiveButton.getText();
-            text = text.replace(Messages.Preference_Use_Default, "");
+            if (text.equals(Messages.Preference_Use_Default)){
+                isOverrideShowCheckListPerspective = false;
+            }else{
+                isOverrideShowCheckListPerspective = true;
+            }
             if (text.equals(SHOW)){
                 isShowCheckListPerspective = true;
             }else{
@@ -241,7 +263,11 @@ public class GeneralPreferencePage extends CdmPreferencePage implements Selectio
         }
         if (e.getSource().equals(this.showTaxonNodeWizardButton)) {
             String text = showTaxonNodeWizardButton.getText();
-            text = text.replace(Messages.Preference_Use_Default, "");
+            if (text.equals(Messages.Preference_Use_Default)){
+                isOverrideShowTaxonNodeWizard = false;
+            }else{
+                isOverrideShowTaxonNodeWizard = true;
+            }
             if (text.equals(SHOW)){
                 isShowTaxonNodeWizard = true;
             }else{
index d21a8d7bdd14c173b7d191f99ab2cdc896f292c6..570e91cb26781909ffdfe948dad014c472ac7337 100644 (file)
@@ -432,7 +432,7 @@ public class NameDetailsViewConfiguration extends CdmPreferencePage implements S
                 isAllowOverride = nameDetailsPref.isAllowOverride();
 
             }
-            isOverride = PreferencesUtil.getBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.NameDetailsView.getKey()), true);
+            isOverride = PreferencesUtil.getBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.NameDetailsView.getKey()), true) != null? PreferencesUtil.getBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.NameDetailsView.getKey()), true): false;
             nameDetailsConfig = PreferencesUtil.getPreferredNameDetailsConfiguration(true);
         }
     }
index 7cf619fd494af57fabe46e86fb3bdca91185b594..7ffc1d1f40e8945e84f58dcb0c288c0e7c4dacce 100644 (file)
@@ -287,10 +287,16 @@ public class PreferencesUtil implements IPreferenceKeys {
     }
 
     public static boolean getBooleanValue(String name) {
-        return getBooleanValue(name, false);
+        Boolean result = getBooleanValue(name, false);
+        if (result == null){
+            return false;
+        }else{
+            return result;
+        }
+
     }
 
-    public static boolean getBooleanValue(String name, boolean local) {
+    public static Boolean getBooleanValue(String name, boolean local) {
         if (CdmStore.isActive()){
             CdmPreference pref = getDBPreferenceValue(name);
 
@@ -299,7 +305,11 @@ public class PreferencesUtil implements IPreferenceKeys {
 
             if (local || pref == null || (pref != null && pref.isAllowOverride() && override)){
                 String dbSpecific = prefKey(name);
-                return getPreferenceStore().getBoolean(dbSpecific);
+                if (getPreferenceStore().contains(dbSpecific)){
+                    return getPreferenceStore().getBoolean(dbSpecific);
+                }else{
+                    return null;
+                }
              }else{
                 return Boolean.valueOf(pref.getValue());
             }
@@ -539,8 +549,6 @@ public class PreferencesUtil implements IPreferenceKeys {
 
     public static void setPreferencesToDB(CdmPreference preference, boolean setDefault){
         ICdmRepository controller;
-
-
         try{
             if(CdmStore.isActive()){
                 controller = CdmStore.getCurrentApplicationConfiguration();
@@ -1685,7 +1693,11 @@ public class PreferencesUtil implements IPreferenceKeys {
     }
 
     public static boolean getFilterCommonNameReferences(){
-        return getBooleanValue(PreferencesUtil.FILTER_COMMON_NAME_REFERENCES);
+        Boolean result = getBooleanValue(PreferencesUtil.FILTER_COMMON_NAME_REFERENCES);
+        if (result == null){
+            return false;
+        }
+        return result;
     }
 
     public static void updateDBPreferences() {
index ea61ce8780171f7d4aab72cbd792dbe12e101140..950a37c33dbf9d5ba415a1822b99ea4268478ca7 100644 (file)
@@ -314,7 +314,8 @@ public class SpecimenOrObservationPreferences extends CdmPreferencePage implemen
 
 
         overrideShowSpecimenRelatedIssues = PreferencesUtil.getBooleanValue(
-                PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowSpecimen.getKey()), true);
+                PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowSpecimen.getKey()), true) != null? PreferencesUtil.getBooleanValue(
+                        PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowSpecimen.getKey()), true): false;
 
         PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowSpecimen);
         showSpecimenPref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.ShowSpecimen);
@@ -344,7 +345,8 @@ public class SpecimenOrObservationPreferences extends CdmPreferencePage implemen
         key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowCollectingAreasInGeneralSection);
         showCollectingAreaInGeneralSection = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.ShowCollectingAreasInGeneralSection);
         overrideShowCollectionAreaInGeneralSection = PreferencesUtil.getBooleanValue(
-                PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowCollectingAreasInGeneralSection.getKey()), true);
+                PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowCollectingAreasInGeneralSection.getKey()), true) != null? PreferencesUtil.getBooleanValue(
+                        PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowCollectingAreasInGeneralSection.getKey()), true): false;
         allowOverrideShowCollectingAreaInGeneralSection = showCollectingAreaInGeneralSection != null ? showCollectingAreaInGeneralSection.isAllowOverride():true;
         if (showCollectingAreaInGeneralSection != null) {
             if (showCollectingAreaInGeneralSection.isAllowOverride() ) {
@@ -370,7 +372,8 @@ public class SpecimenOrObservationPreferences extends CdmPreferencePage implemen
         key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.DeterminationOnlyForFieldUnits);
         showDeterminationOnlyForFieldUnits = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.DeterminationOnlyForFieldUnits);
         overrideDeterminationOnlyForFieldUnits = PreferencesUtil.getBooleanValue(
-                PreferencesUtil.prefOverrideKey(PreferencePredicate.DeterminationOnlyForFieldUnits.getKey()), true);
+                PreferencesUtil.prefOverrideKey(PreferencePredicate.DeterminationOnlyForFieldUnits.getKey()), true) != null? PreferencesUtil.getBooleanValue(
+                        PreferencesUtil.prefOverrideKey(PreferencePredicate.DeterminationOnlyForFieldUnits.getKey()), true): false;
         if (showDeterminationOnlyForFieldUnits != null) {
             if (showDeterminationOnlyForFieldUnits.isAllowOverride() ) {
                 if (overrideDeterminationOnlyForFieldUnits){
@@ -397,7 +400,8 @@ public class SpecimenOrObservationPreferences extends CdmPreferencePage implemen
         key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowTaxonAssociations);
         showTaxonAssociation = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.ShowTaxonAssociations);
         overrideShowTaxonAssociation =  PreferencesUtil.getBooleanValue(
-                PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowTaxonAssociations.getKey()), true);
+                PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowTaxonAssociations.getKey()), true) != null? PreferencesUtil.getBooleanValue(
+                        PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowTaxonAssociations.getKey()), true): false;
         if (showTaxonAssociation != null) {
             if (showTaxonAssociation.isAllowOverride() ) {
                 if (overrideShowTaxonAssociation){
@@ -424,7 +428,8 @@ public class SpecimenOrObservationPreferences extends CdmPreferencePage implemen
         key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowLifeForm);
         showLifeForm = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.ShowLifeForm);
         overrideShowLifeForm =  PreferencesUtil.getBooleanValue(
-                PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowLifeForm.getKey()), true);
+                PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowLifeForm.getKey()), true) != null? PreferencesUtil.getBooleanValue(
+                        PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowLifeForm.getKey()), true): false;
         if (showLifeForm != null) {
             if (showLifeForm.isAllowOverride() ) {
                 if (overrideShowLifeForm){
index b3831ff0f678c851c9da0a33fbbfdd0931608433..4ade914d4d1e0a30fb4cebe0855077cc5085ed6d 100755 (executable)
 */
 package eu.etaxonomy.taxeditor.preference;
 
-import org.eclipse.jface.preference.BooleanFieldEditor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
 
+import eu.etaxonomy.cdm.model.metadata.CdmPreference;
+import eu.etaxonomy.cdm.model.metadata.CdmPreference.PrefKey;
+import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
+import eu.etaxonomy.cdm.model.metadata.PreferenceSubject;
 import eu.etaxonomy.taxeditor.l10n.Messages;
-import eu.etaxonomy.taxeditor.preference.menu.FieldEditorPreferencePageE4;
+import eu.etaxonomy.taxeditor.preference.menu.CdmPreferencePage;
 
 /**
  * @author k.luther
  * @since 18.01.2019
  *
  */
-public class SupplementalDataPreferences extends FieldEditorPreferencePageE4 {
+public class SupplementalDataPreferences extends CdmPreferencePage implements SelectionListener{
 
+
+    protected Boolean isShowIDNamspace;
+    protected Boolean isShowNamespace;
+
+    protected boolean isAllowOverrideShowIDNamspace;
+    protected boolean isAllowOverrideShowNamspace;
+
+    protected boolean isOverrideShowIDNamspace;
+    protected boolean isOverrideShowNamspace;
+
+
+    protected Combo showIDNamspaceButton;
+    protected Button allowOverrideShowIDNamspaceButton;
+    protected Combo showNamspaceButton;
+    protected Button allowOverrideNamspaceButton;
+
+    final String SHOW = Messages.GeneralPreference_yes;
+    final String DO_NOT_SHOW = Messages.GeneralPreference_no;
     /**
      * {@inheritDoc}
      */
     @Override
-    protected void createFieldEditors() {
-        addField(new BooleanFieldEditor(PreferencesUtil.createPreferenceString(IPreferenceKeys.SHOW_DEBUG_INFORMATION),
-                Messages.SupplementalDataPreferences_0,
-                getFieldEditorParent()));
+    protected Control createContents(Composite parent) {
+        getValues();
+        final Composite composite = createComposite(parent);
+
+        GridData gridData = createTextGridData();
+
+        Label separator= new Label(composite, SWT.HORIZONTAL | SWT.SEPARATOR);
+        separator.setLayoutData(gridData);
+        separator.setVisible(false);
+
+        showIDNamspaceButton = createBooleanCombo(composite, SHOW, DO_NOT_SHOW, PreferencePredicate.ShowIdInSource, "Show ID in Namespace in Source",
+                isAdminPreference);
+
+        showIDNamspaceButton.addSelectionListener(this);
+
+        if (isShowIDNamspace == null || (!isOverrideShowIDNamspace && !isAdminPreference)){
+            showIDNamspaceButton.select(0);
+        }else if (isShowIDNamspace){
+            showIDNamspaceButton.select(1);
+        }else{
+            showIDNamspaceButton.select(2);
+        }
+        if (isAdminPreference){
+            allowOverrideShowIDNamspaceButton = createAllowOverrideButton(composite);
+
+            allowOverrideShowIDNamspaceButton.setSelection(isAllowOverrideShowIDNamspace);
+            allowOverrideShowIDNamspaceButton.addSelectionListener(new SelectionAdapter(){
+                @Override
+                public void widgetSelected(SelectionEvent e) {
+                    isAllowOverrideShowIDNamspace = allowOverrideShowIDNamspaceButton.getSelection();
+                    setApply(true);
+                }
+            });
+        }
+
+
+        showNamspaceButton = createBooleanCombo(composite, SHOW, DO_NOT_SHOW, PreferencePredicate.ShowNamespaceInSource, "Show Namespace in Source",
+                isAdminPreference);
+
+        showNamspaceButton.addSelectionListener(this);
+        if (isShowNamespace == null || (!isOverrideShowNamspace && !isAdminPreference)){
+            showNamspaceButton.select(0);
+        }else if (isShowNamespace){
+            showNamspaceButton.select(1);
+        }else{
+            showNamspaceButton.select(2);
+        }
+
+        if (isAdminPreference){
+            allowOverrideNamspaceButton = createAllowOverrideButton(composite);
+            allowOverrideNamspaceButton.setSelection(isAllowOverrideShowNamspace);
+            allowOverrideNamspaceButton.addSelectionListener(new SelectionAdapter(){
+                @Override
+                public void widgetSelected(SelectionEvent e) {
+                    isAllowOverrideShowNamspace = allowOverrideNamspaceButton.getSelection();
+                    setApply(true);
+                }
+            });
+        }
+        if (!isAllowOverrideShowIDNamspace && !isAdminPreference){
+            showIDNamspaceButton.setEnabled(false);
+        }
+        if (!isAllowOverrideShowNamspace && !isAdminPreference){
+            showNamspaceButton.setEnabled(false);
+        }
+
+
+        return composite;
+    }
+
+
+
+    @Override
+    public boolean performOk() {
+        if (isAllowOverrideShowIDNamspace){
+            PreferencesUtil.setBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowIdInSource.getKey()), isOverrideShowIDNamspace);
+            PreferencesUtil.setBooleanValue(PreferencePredicate.ShowIdInSource.getKey(), isShowIDNamspace);
+        }
+        if (isAllowOverrideShowNamspace){
+            PreferencesUtil.setBooleanValue(PreferencePredicate.ShowNamespaceInSource.getKey(), isShowNamespace);
+            PreferencesUtil.setBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowNamespaceInSource.getKey()), isOverrideShowNamspace);
+        }
+
+
+       return true;
+   }
+    @Override
+    protected void getValues(){
+        isAdminPreference = false;
+
+        CdmPreferenceCache cache = CdmPreferenceCache.instance();
+        isShowIDNamspace = PreferencesUtil.getBooleanValue(PreferencePredicate.ShowIdInSource.getKey(), true);
+        isOverrideShowIDNamspace = PreferencesUtil.getBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowIdInSource.getKey()), true) != null?PreferencesUtil.getBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowIdInSource.getKey()), true): false;
+        PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowIdInSource);
+        CdmPreference pref = cache.findBestMatching(key);
+        if (pref != null){
+            isAllowOverrideShowIDNamspace = pref.isAllowOverride();
+        }else{
+            isAllowOverrideShowIDNamspace = true;
+        }
+
+        isShowNamespace = PreferencesUtil.getBooleanValue(PreferencePredicate.ShowNamespaceInSource.getKey(), true);
+        isOverrideShowNamspace = PreferencesUtil.getBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowNamespaceInSource.getKey()), true) != null? PreferencesUtil.getBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowNamespaceInSource.getKey()), true):false;
+        key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowNamespaceInSource);
+        pref = cache.findBestMatching(key);
+        if (pref != null){
+            isAllowOverrideShowNamspace = pref.isAllowOverride();
+        }else{
+            isAllowOverrideShowNamspace = true;
+        }
+
+
+    }
+
+
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void widgetSelected(SelectionEvent e) {
+        if (e.getSource().equals(this.showIDNamspaceButton)) {
+            String text = showIDNamspaceButton.getText();
+           // text = text.replace(Messages.Preference_Use_Default, "");
+            if (text.equals(Messages.Preference_Use_Default)){
+                isOverrideShowIDNamspace = false;
+            }else{
+                isOverrideShowIDNamspace = true;
+            }
+            if (text.equals(SHOW)){
+                isShowIDNamspace = true;
+
+            }else{
+                isShowIDNamspace = false;
+            }
+        }
+        if (e.getSource().equals(this.showNamspaceButton)) {
+            String text = showNamspaceButton.getText();
+            if (text.equals(Messages.Preference_Use_Default)){
+                isOverrideShowNamspace = false;
+            }else{
+                isOverrideShowNamspace = true;
+            }
+            if (text.equals(SHOW)){
+                isShowNamespace = true;
+            }else{
+                isShowNamespace = false;
+            }
+        }
+
+        this.setApply(true);
+
+
+    }
+
+
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void widgetDefaultSelected(SelectionEvent e) {
+        // TODO Auto-generated method stub
+
     }
 
 }
index ea0a9a24f49e24cb972c91dc2f8f98fb1b955554..bc8a767f23b6515a88bfe1632d93a7339b9558e6 100644 (file)
@@ -198,7 +198,7 @@ public class TermManager {
 
         List<T> filteredTerms = new ArrayList<T>();
         List<T> terms = TermStore.getTerms(clazz);
-        if (uuidList.isEmpty()){
+        if (uuidList == null || uuidList.isEmpty()){
             return terms;
         }
         for (T term : terms){
index 2abac681abfced6abfa1ae558c1b847b3e5f84d3..945089ad7fb6a931b2eedb353290e155f806eb8c 100644 (file)
@@ -14,8 +14,10 @@ import java.util.Comparator;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.SelectionListener;
 
+import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
 import eu.etaxonomy.cdm.model.reference.OriginalSourceBase;
 import eu.etaxonomy.cdm.model.reference.OriginalSourceType;
+import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
 import eu.etaxonomy.taxeditor.ui.combo.EnumComboElement;
 import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
@@ -68,8 +70,12 @@ public abstract class AbstractOriginalSourceElement<T extends OriginalSourceBase
                                .createEnumComboElement(OriginalSourceType.class,
                                                formElement, new OriginalSourceTypeComparator(getEntity()), style);
                super.createControls(formElement, style);
-               text_idInSource = formFactory.createTextWithLabelElement(formElement, "ID in Source", null, style);
-               text_idNamespace = formFactory.createTextWithLabelElement(formElement, "ID Namespace", null, style);
+               if (PreferencesUtil.getBooleanValue(PreferencePredicate.ShowIdInSource.getKey())){
+                   text_idInSource = formFactory.createTextWithLabelElement(formElement, "ID in Source", null, style);
+               }
+               if (PreferencesUtil.getBooleanValue(PreferencePredicate.ShowNamespaceInSource.getKey())){
+                   text_idNamespace = formFactory.createTextWithLabelElement(formElement, "ID Namespace", null, style);
+               }
                text_originaleNameString = formFactory.createTextWithLabelElement(
                        formElement, "Original Information", null, SWT.NULL);
 
index fad623c8f7e2f7bf273b37fe8aa6336359282b71..803cb2861c17294d6de644a5ffe0f0a756e21e24 100644 (file)
@@ -6,6 +6,8 @@ package eu.etaxonomy.taxeditor.ui.section.supplemental;
 import org.eclipse.swt.events.SelectionListener;
 
 import eu.etaxonomy.cdm.model.common.IdentifiableSource;
+import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
+import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
 import eu.etaxonomy.taxeditor.store.StoreUtil;
 import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
@@ -37,8 +39,12 @@ public class IdentifiableSourceElement extends AbstractOriginalSourceElement<Ide
        @Override
        public void setEntity(IdentifiableSource entity) {
                super.setEntity(entity);
-               text_idInSource.setText(entity.getIdInSource());
-               text_idNamespace.setText(entity.getIdNamespace());
+               if (PreferencesUtil.getBooleanValue(PreferencePredicate.ShowIdInSource.getKey())){
+                   text_idInSource.setText(entity.getIdInSource());
+               }
+               if (PreferencesUtil.getBooleanValue(PreferencePredicate.ShowNamespaceInSource.getKey())){
+                   text_idNamespace.setText(entity.getIdNamespace());
+               }
 
                selection_reference.setEntity(entity.getCitation());
                text_referenceDetail.setText(entity.getCitationMicroReference());