Project

General

Profile

Download (5.13 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2016 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
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.
8
*/
9
package eu.etaxonomy.taxeditor.databaseAdmin.wizard;
10

    
11
import org.eclipse.jface.wizard.IWizardPage;
12
import org.eclipse.jface.wizard.Wizard;
13

    
14
import eu.etaxonomy.cdm.api.application.ICdmRepository;
15
import eu.etaxonomy.cdm.api.service.IPreferenceService;
16
import eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator;
17
import eu.etaxonomy.cdm.model.metadata.CdmPreference;
18
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
19
import eu.etaxonomy.taxeditor.io.wizard.AbcdImportConfiguratorWizardPage;
20
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
21
import eu.etaxonomy.taxeditor.store.CdmStore;
22

    
23
/**
24
 * @author k.luther
25
 * @date 18.11.2016
26
 *
27
 */
28
public class DatabasePreferencesWizard extends Wizard {
29

    
30

    
31
    public DatabasePreferencesPage preferencePage;
32
    public AbcdImportConfiguratorWizardPage configAbcdImport;
33

    
34

    
35
    public DatabasePreferencesWizard() {
36
        setWindowTitle("Database Preferences Wizard");
37

    
38
        preferencePage = new DatabasePreferencesPage("Database Preferences");
39
        configAbcdImport = AbcdImportConfiguratorWizardPage.createPage(Abcd206ImportConfigurator.NewInstance(null, null));
40

    
41
    }
42

    
43

    
44

    
45
    /**
46
     * @return the preferencePage
47
     */
48
    public DatabasePreferencesPage getPreferencePage() {
49
        return preferencePage;
50
    }
51
    /**
52
     * {@inheritDoc}
53
     */
54
    @Override
55
    public boolean performFinish() {
56

    
57
//       getPreferencePage().performOk();
58
        String value =getPreferencePage().doGetPreferenceStore().getString(IPreferenceKeys.CDM_NOMENCLATURAL_CODE_KEY);
59

    
60
        boolean allowOverride =  getPreferencePage().doGetPreferenceStore().getBoolean(IPreferenceKeys.ALLOW_OVERRIDE_NOMENCLATURAL_CODE_KEY);
61
        CdmPreference pref = CdmPreference.NewDatabaseInstance( PreferencePredicate.NomenclaturalCode, value);
62
        pref.setAllowOverride(allowOverride);
63

    
64
        ICdmRepository controller = CdmStore.getCurrentApplicationConfiguration();
65
        if (controller == null){
66
            return false;
67
        }
68
        IPreferenceService service = controller.getPreferenceService();
69
        service.set(pref);
70

    
71
        value = getPreferencePage().getNameDetailsConfig().createNameDetailsViewConfig().toString();
72
        allowOverride = getPreferencePage().doGetPreferenceStore().getBoolean(IPreferenceKeys.ALLOW_OVERRIDE_NAMEDETAILS);
73
        pref = CdmPreference.NewDatabaseInstance( PreferencePredicate.NameDetailsView, value);
74
        pref.setAllowOverride(allowOverride);
75
        service.set(pref);
76

    
77

    
78
        boolean isDeterminationOnlyForFieldUnit= getPreferencePage().doGetPreferenceStore().getBoolean(IPreferenceKeys.DETERMINATION_ONLY_FOR_FIELD_UNITS );
79
        pref = CdmPreference.NewDatabaseInstance( PreferencePredicate.DeterminationOnlyForFieldUnits, String.valueOf(isDeterminationOnlyForFieldUnit));
80
        pref.setAllowOverride(false);
81
        service.set(pref);
82

    
83
        boolean isShowCollectingAreasInGeneralsecion= getPreferencePage().doGetPreferenceStore().getBoolean(IPreferenceKeys.SHOW_COLLECTING_AREAS_IN_GENERAL_SECTION );
84
        pref = CdmPreference.NewDatabaseInstance( PreferencePredicate.ShowCollectingAreasInGeneralSection, String.valueOf(isShowCollectingAreasInGeneralsecion));
85
        pref.setAllowOverride(false);
86
        service.set(pref);
87

    
88
        boolean isShowTaxonAssociations= getPreferencePage().doGetPreferenceStore().getBoolean(IPreferenceKeys.SHOW_TAXON_ASSOCIATIONS);
89
        pref = CdmPreference.NewDatabaseInstance( PreferencePredicate.ShowTaxonAssociations, String.valueOf(isShowTaxonAssociations));
90
        pref.setAllowOverride(false);
91
        service.set(pref);
92

    
93
        String biocaseProviderList = this.getPreferencePage().getBiocaseProviderList().createAllProviderString();
94
        if (biocaseProviderList == null){
95
            getPreferencePage().doGetPreferenceStore().setValue(IPreferenceKeys.BIOCASE_PROVIDER_LIST,"");
96
        }else{
97
            getPreferencePage().doGetPreferenceStore().setValue(IPreferenceKeys.BIOCASE_PROVIDER_LIST, biocaseProviderList);
98

    
99
        }
100
        pref = CdmPreference.NewDatabaseInstance( PreferencePredicate.BioCaseProvider, String.valueOf(biocaseProviderList));
101
        pref.setAllowOverride(false);
102
        service.set(pref);
103
//        getPreferencePage().createAbcdImportConfig();
104
//        value = getPreferencePage().getAbcdImportConfig().toString();
105
//        allowOverride = getPreferencePage().doGetPreferenceStore().getBoolean(IPreferenceKeys.ALLOW_OVERRIDE_ABCD_IMPORT_CONFIG);
106
//        pref = CdmPreference.NewDatabaseInstance( PreferencePredicate.AbcdImportConfig, value);
107
//        pref.setAllowOverride(allowOverride);
108
//        service.set(pref);
109

    
110
        return true;
111
    }
112

    
113

    
114

    
115
    @Override
116
    public void addPages() {
117
        addPage(preferencePage);
118
        addPage(configAbcdImport);
119
    }
120

    
121
    @Override
122
    public IWizardPage getNextPage(IWizardPage currentPage) {
123
       if (currentPage.equals(preferencePage)){
124
           return configAbcdImport;
125
       }
126
       return null;
127
    }
128

    
129

    
130
}
(2-2/11)