2 * Copyright (C) 2016 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
.wizard
;
11 import org
.eclipse
.jface
.wizard
.IWizardPage
;
12 import org
.eclipse
.jface
.wizard
.Wizard
;
14 import eu
.etaxonomy
.cdm
.api
.application
.ICdmRepository
;
15 import eu
.etaxonomy
.cdm
.api
.service
.IPreferenceService
;
16 import eu
.etaxonomy
.cdm
.model
.metadata
.CdmPreference
;
17 import eu
.etaxonomy
.cdm
.model
.metadata
.PreferencePredicate
;
18 import eu
.etaxonomy
.taxeditor
.preference
.IPreferenceKeys
;
19 import eu
.etaxonomy
.taxeditor
.preference
.NameDetailsConfigurator
;
20 import eu
.etaxonomy
.taxeditor
.preference
.PreferencesUtil
;
21 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
28 public class DatabasePreferencesWizard
extends Wizard
{
31 public DatabasePreferencesPage preferencePage
;
35 public DatabasePreferencesWizard() {
36 setWindowTitle("Database Preferences Wizard");
38 preferencePage
= new DatabasePreferencesPage("Database Preferences");
46 * @return the preferencePage
48 public DatabasePreferencesPage
getPreferencePage() {
49 return preferencePage
;
55 public boolean performFinish() {
57 // getPreferencePage().performOk();
59 String value
=getPreferencePage().doGetPreferenceStore().getString(IPreferenceKeys
.CDM_NOMENCLATURAL_CODE_KEY
);
61 boolean allowOverride
= getPreferencePage().doGetPreferenceStore().getBoolean(IPreferenceKeys
.ALLOW_OVERRIDE_NOMENCLATURAL_CODE_KEY
);
62 CdmPreference pref
= CdmPreference
.NewDatabaseInstance( PreferencePredicate
.NomenclaturalCode
, value
);
63 pref
.setAllowOverride(allowOverride
);
65 ICdmRepository controller
= CdmStore
.getCurrentApplicationConfiguration();
66 if (controller
== null){
69 IPreferenceService service
= controller
.getPreferenceService();
71 NameDetailsConfigurator config
= getPreferencePage().getNameDetailsConfig().createNameDetailsViewConfig();
72 value
= config
.toString();
73 allowOverride
= getPreferencePage().doGetPreferenceStore().getBoolean(IPreferenceKeys
.ALLOW_OVERRIDE_NAME_DETAILS
);
75 pref
= CdmPreference
.NewDatabaseInstance( PreferencePredicate
.NameDetailsView
, value
);
76 pref
.setAllowOverride(allowOverride
);
78 if (!allowOverride
|| (allowOverride
&& !PreferencesUtil
.getPreferenceStore().getBoolean(IPreferenceKeys
.OVERRIDE_NAME_DETAILS
))){
79 PreferencesUtil
.saveConfigToPrefernceStore(config
);
83 boolean isDeterminationOnlyForFieldUnit
= getPreferencePage().doGetPreferenceStore().getBoolean(IPreferenceKeys
.DETERMINATION_ONLY_FOR_FIELD_UNITS
);
84 pref
= CdmPreference
.NewDatabaseInstance( PreferencePredicate
.DeterminationOnlyForFieldUnits
, String
.valueOf(isDeterminationOnlyForFieldUnit
));
85 allowOverride
= getPreferencePage().doGetPreferenceStore().getBoolean(IPreferenceKeys
.ALLOW_OVERRIDE_SPECIMEN_PREF
);
86 pref
.setAllowOverride(allowOverride
);
89 boolean isShowCollectingAreasInGeneralsecion
= getPreferencePage().doGetPreferenceStore().getBoolean(IPreferenceKeys
.SHOW_COLLECTING_AREAS_IN_GENERAL_SECTION
);
90 pref
= CdmPreference
.NewDatabaseInstance( PreferencePredicate
.ShowCollectingAreasInGeneralSection
, String
.valueOf(isShowCollectingAreasInGeneralsecion
));
91 pref
.setAllowOverride(allowOverride
);
94 boolean isShowTaxonAssociations
= getPreferencePage().doGetPreferenceStore().getBoolean(IPreferenceKeys
.SHOW_TAXON_ASSOCIATIONS
);
95 pref
= CdmPreference
.NewDatabaseInstance( PreferencePredicate
.ShowTaxonAssociations
, String
.valueOf(isShowTaxonAssociations
));
96 pref
.setAllowOverride(allowOverride
);
99 boolean isShowLifeForm
= getPreferencePage().doGetPreferenceStore().getBoolean(IPreferenceKeys
.SHOW_LIFE_FORM
);
100 pref
= CdmPreference
.NewDatabaseInstance( PreferencePredicate
.ShowLifeForm
, String
.valueOf(isShowLifeForm
));
101 pref
.setAllowOverride(allowOverride
);
104 String biocaseProviderList
= this.getPreferencePage().getBiocaseProviderList().createAllProviderString();
105 if (biocaseProviderList
== null){
106 getPreferencePage().doGetPreferenceStore().setValue(IPreferenceKeys
.BIOCASE_PROVIDER_LIST
,"");
108 getPreferencePage().doGetPreferenceStore().setValue(IPreferenceKeys
.BIOCASE_PROVIDER_LIST
, biocaseProviderList
);
111 pref
= CdmPreference
.NewDatabaseInstance( PreferencePredicate
.BioCaseProvider
, String
.valueOf(biocaseProviderList
));
112 pref
.setAllowOverride(false);
114 // getPreferencePage().createAbcdImportConfig();
115 // value = getPreferencePage().getAbcdImportConfig().toString();
116 // allowOverride = getPreferencePage().doGetPreferenceStore().getBoolean(IPreferenceKeys.ALLOW_OVERRIDE_ABCD_IMPORT_CONFIG);
117 // pref = CdmPreference.NewDatabaseInstance( PreferencePredicate.AbcdImportConfig, value);
118 // pref.setAllowOverride(allowOverride);
119 // service.set(pref);
127 public void addPages() {
128 addPage(preferencePage
);
133 public IWizardPage
getNextPage(IWizardPage currentPage
) {