2 * Copyright (C) 2018 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
9 package eu
.etaxonomy
.taxeditor
.databaseAdmin
.preferencePage
;
11 import org
.eclipse
.swt
.widgets
.Composite
;
13 import eu
.etaxonomy
.cdm
.api
.application
.ICdmRepository
;
14 import eu
.etaxonomy
.cdm
.api
.service
.IPreferenceService
;
15 import eu
.etaxonomy
.cdm
.model
.metadata
.CdmPreference
;
16 import eu
.etaxonomy
.cdm
.model
.metadata
.CdmPreference
.PrefKey
;
17 import eu
.etaxonomy
.cdm
.model
.metadata
.PreferencePredicate
;
18 import eu
.etaxonomy
.cdm
.model
.metadata
.PreferenceSubject
;
19 import eu
.etaxonomy
.taxeditor
.preference
.PreferencesUtil
;
20 import eu
.etaxonomy
.taxeditor
.preference
.SpecimenOrObservationPreferences
;
21 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
28 public class SpecimenAdminPreferences
extends SpecimenOrObservationPreferences
implements IE4AdminPreferencePage
{
33 CdmPreference showSpecimenPref
= null;
38 if(!CdmStore
.isActive()){
44 protected void getValues(){
45 isAdminPreference
= true;
47 ICdmRepository controller
= CdmStore
.getCurrentApplicationConfiguration();
48 if (controller
!= null){
49 IPreferenceService service
= controller
.getPreferenceService();
50 PrefKey key
= CdmPreference
.NewKey(PreferenceSubject
.NewTaxEditorInstance(), PreferencePredicate
.ShowSpecimen
);
51 showSpecimenPref
= service
.find(key
);
52 if (showSpecimenPref
!= null){
53 this.isShowSpecimenRelatedIssues
= Boolean
.valueOf(showSpecimenPref
.getValue());
54 this.allowOverrideShowSpecimenRelatedIssues
= showSpecimenPref
.isAllowOverride();
56 //showSpecimenPref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowSpecimen, Boolean.toString(true));
57 // this.isShowSpecimenRelatedIssues = true;
58 this.allowOverrideShowSpecimenRelatedIssues
= true;
61 key
= CdmPreference
.NewKey(PreferenceSubject
.NewTaxEditorInstance(), PreferencePredicate
.ShowCollectingAreasInGeneralSection
);
62 CdmPreference isShowCollectingAreaInGeneralSectionPref
= service
.find(key
);
63 if (isShowCollectingAreaInGeneralSectionPref
!= null){
64 this.isShowCollectingAreaInGeneralSection
= Boolean
.valueOf(isShowCollectingAreaInGeneralSectionPref
.getValue());
65 this.allowOverrideShowCollectingAreaInGeneralSection
= isShowCollectingAreaInGeneralSectionPref
.isAllowOverride();
67 // this.isShowCollectingAreaInGeneralSection = (Boolean) PreferencePredicate.ShowCollectingAreasInGeneralSection.getDefaultValue();
68 this.allowOverrideShowCollectingAreaInGeneralSection
= true;
71 key
= CdmPreference
.NewKey(PreferenceSubject
.NewTaxEditorInstance(), PreferencePredicate
.DeterminationOnlyForFieldUnits
);
72 CdmPreference isDeterminationOnlyForFieldUnitsPref
= service
.find(key
);
73 if (isDeterminationOnlyForFieldUnitsPref
!= null){
74 this.isDeterminationOnlyForFieldUnits
= Boolean
.valueOf(isDeterminationOnlyForFieldUnitsPref
.getValue());
75 this.allowOverrideDeterminationOnlyForFieldUnits
= isDeterminationOnlyForFieldUnitsPref
.isAllowOverride();
77 // this.isDeterminationOnlyForFieldUnits =(Boolean)PreferencePredicate.DeterminationOnlyForFieldUnits.getDefaultValue();
78 this.allowOverrideDeterminationOnlyForFieldUnits
= true;
80 key
= CdmPreference
.NewKey(PreferenceSubject
.NewTaxEditorInstance(), PreferencePredicate
.ShowTaxonAssociations
);
81 CdmPreference isShowTaxonAssociationPref
= service
.find(key
);
82 if (isShowTaxonAssociationPref
!= null){
83 this.isShowTaxonAssociation
= Boolean
.valueOf(isShowTaxonAssociationPref
.getValue());
84 this.allowOverrideShowTaxonAssociation
= isShowTaxonAssociationPref
.isAllowOverride();
86 // this.isShowTaxonAssociation = (Boolean)PreferencePredicate.ShowTaxonAssociations.getDefaultValue();
87 this.allowOverrideShowTaxonAssociation
= true;
90 key
= CdmPreference
.NewKey(PreferenceSubject
.NewTaxEditorInstance(), PreferencePredicate
.ShowLifeForm
);
91 CdmPreference isShowLifeFormPref
= service
.find(key
);
92 if (isShowLifeFormPref
!= null){
93 this.isShowLifeForm
= Boolean
.valueOf(isShowLifeFormPref
.getValue());
94 this.allowOverrideShowLifeForm
= isShowLifeFormPref
.isAllowOverride();
96 // this.isShowLifeForm = (Boolean)PreferencePredicate.ShowLifeForm.getDefaultValue();
97 this.allowOverrideShowLifeForm
= true;
104 public boolean performOk() {
108 ICdmRepository controller
= CdmStore
.getCurrentApplicationConfiguration();
109 if (controller
!= null){
110 IPreferenceService service
= controller
.getPreferenceService();
112 if (isShowCollectingAreaInGeneralSection
== null){
113 service
.remove(CdmPreference
.NewKey(PreferenceSubject
.NewTaxEditorInstance(), PreferencePredicate
.ShowCollectingAreasInGeneralSection
));
115 pref
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.ShowCollectingAreasInGeneralSection
, Boolean
.toString(this.isShowCollectingAreaInGeneralSection
));
116 pref
.setAllowOverride(allowOverrideShowCollectingAreaInGeneralSection
);
119 if (isShowSpecimenRelatedIssues
== null){
120 service
.remove(CdmPreference
.NewKey(PreferenceSubject
.NewTaxEditorInstance(), PreferencePredicate
.ShowSpecimen
));
122 pref
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.ShowSpecimen
, Boolean
.toString(this.isShowSpecimenRelatedIssues
));
123 pref
.setAllowOverride(allowOverrideShowSpecimenRelatedIssues
);
127 if (isDeterminationOnlyForFieldUnits
== null){
128 service
.remove(CdmPreference
.NewKey(PreferenceSubject
.NewTaxEditorInstance(), PreferencePredicate
.DeterminationOnlyForFieldUnits
));
130 pref
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.DeterminationOnlyForFieldUnits
, Boolean
.toString(this.isDeterminationOnlyForFieldUnits
));
131 pref
.setAllowOverride(allowOverrideDeterminationOnlyForFieldUnits
);
134 if (isShowTaxonAssociation
== null){
135 service
.remove(CdmPreference
.NewKey(PreferenceSubject
.NewTaxEditorInstance(), PreferencePredicate
.ShowTaxonAssociations
));
137 pref
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.ShowTaxonAssociations
, Boolean
.toString(this.isShowTaxonAssociation
));
138 pref
.setAllowOverride(allowOverrideShowTaxonAssociation
);
141 if (isShowLifeForm
== null){
142 service
.remove(CdmPreference
.NewKey(PreferenceSubject
.NewTaxEditorInstance(), PreferencePredicate
.ShowLifeForm
));
144 pref
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.ShowLifeForm
, Boolean
.toString(this.isShowLifeForm
));
145 pref
.setAllowOverride(allowOverrideShowLifeForm
);
148 PreferencesUtil
.updateDBPreferences();