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 eu
.etaxonomy
.cdm
.api
.application
.ICdmRepository
;
12 import eu
.etaxonomy
.cdm
.api
.service
.IPreferenceService
;
13 import eu
.etaxonomy
.cdm
.model
.metadata
.CdmPreference
;
14 import eu
.etaxonomy
.cdm
.model
.metadata
.CdmPreference
.PrefKey
;
15 import eu
.etaxonomy
.cdm
.model
.metadata
.PreferencePredicate
;
16 import eu
.etaxonomy
.cdm
.model
.metadata
.PreferenceSubject
;
17 import eu
.etaxonomy
.taxeditor
.preference
.GeneralPreferencePage
;
18 import eu
.etaxonomy
.taxeditor
.preference
.PreferencesUtil
;
19 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
26 public class GeneralAdminPreferencePage
extends GeneralPreferencePage
implements IE4AdminPreferencePage
{
28 ICdmRepository controller
= null;
29 CdmPreference isShowSpecimenPref
= null;
36 public boolean performOk() {
41 if (controller
!= null){
42 IPreferenceService service
= controller
.getPreferenceService();
44 if (isShowIOMenu
== null && isAllowOverrideShowIOMenu
){
45 service
.remove(CdmPreference
.NewKey(PreferenceSubject
.NewTaxEditorInstance(), PreferencePredicate
.ShowImportExportMenu
));
47 pref
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.ShowImportExportMenu
, isShowIOMenu
!= null? Boolean
.toString(this.isShowIOMenu
):null);
48 pref
.setAllowOverride(isAllowOverrideShowIOMenu
);
52 if(isShowCheckListPerspective
== null && isAllowOverrideShowCheckListPerspective
){
53 service
.remove(CdmPreference
.NewKey(PreferenceSubject
.NewTaxEditorInstance(), PreferencePredicate
.ShowChecklistPerspective
));
55 pref
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.ShowChecklistPerspective
, isShowCheckListPerspective
!= null?Boolean
.toString(this.isShowCheckListPerspective
): null);
56 pref
.setAllowOverride(isAllowOverrideShowCheckListPerspective
);
61 PreferencesUtil
.updateDBPreferences();
68 protected void getValues(){
69 isAdminPreference
= true;
71 controller
= CdmStore
.getCurrentApplicationConfiguration();
72 if (controller
!= null){
73 IPreferenceService service
= controller
.getPreferenceService();
74 PrefKey key
= CdmPreference
.NewKey(PreferenceSubject
.NewTaxEditorInstance(), PreferencePredicate
.ShowImportExportMenu
);
75 CdmPreference pref
= service
.find(key
);
77 isShowIOMenu
= pref
.getValue()!= null?Boolean
.valueOf(pref
.getValue()): null;
78 isAllowOverrideShowIOMenu
= pref
.isAllowOverride();
81 isAllowOverrideShowIOMenu
= true;
84 // key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowMediaView);
85 // pref = service.find(key);
87 // isShowMediaView = Boolean.valueOf(pref.getValue());
88 // isAllowOverrideShowMediaView = pref.isAllowOverride();
90 // isShowMediaView = Boolean.valueOf(PreferencePredicate.ShowMediaView.getDefaultValue().toString());
91 // isAllowOverrideShowMediaView = true;
94 key
= CdmPreference
.NewKey(PreferenceSubject
.NewTaxEditorInstance(), PreferencePredicate
.ShowChecklistPerspective
);
95 pref
= service
.find(key
);
97 isShowCheckListPerspective
= pref
.getValue()!= null?Boolean
.valueOf(pref
.getValue()): null;
98 isAllowOverrideShowCheckListPerspective
= pref
.isAllowOverride();
100 isShowCheckListPerspective
= null;
101 isAllowOverrideShowCheckListPerspective
= true;
104 key
= CdmPreference
.NewKey(PreferenceSubject
.NewTaxEditorInstance(), PreferencePredicate
.ShowTaxonNodeWizard
);
105 pref
= service
.find(key
);
106 // if (pref != null){
107 // isShowTaxonNodeWizard = pref.getValue() != null?Boolean.valueOf(pref.getValue()): null;
108 // isAllowOverrideShowTaxonNodeWizard = pref.isAllowOverride();
110 // isShowTaxonNodeWizard = null;
111 // isAllowOverrideShowTaxonNodeWizard = true;
118 protected void performDefaults() {
120 isShowCheckListPerspective
= null;
121 //isShowTaxonNodeWizard = null;
124 isAllowOverrideShowIOMenu
= true;
127 isAllowOverrideShowCheckListPerspective
= true;
129 //isAllowOverrideShowTaxonNodeWizard = true;
131 super.performDefaults();