Project

General

Profile

Download (2.66 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.Wizard;
12

    
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.PreferencePredicate;
17
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
18
import eu.etaxonomy.taxeditor.store.CdmStore;
19

    
20
/**
21
 * @author k.luther
22
 * @date 18.11.2016
23
 *
24
 */
25
public class DatabasePreferencesWizard extends Wizard {
26

    
27

    
28
    private final DatabasePreferencesPage preferencePage;
29

    
30

    
31
    public DatabasePreferencesWizard() {
32
        setWindowTitle("Database Preferences Wizard");
33

    
34
        preferencePage = new DatabasePreferencesPage("Nomenclatural Code");
35
       // preferencePage.setDescription("Choose which nomenclatural code you would like to use for scientific names unless otherwise specified.");
36
       // preferencePage.init(PlatformUI.getWorkbench());
37
    }
38

    
39

    
40

    
41
    /**
42
     * {@inheritDoc}
43
     */
44
    @Override
45
    public boolean performFinish() {
46

    
47
//       getPreferencePage().performOk();
48
        String value =getPreferencePage().doGetPreferenceStore().getString(IPreferenceKeys.CDM_NOMENCLATURAL_CODE_KEY);
49

    
50
        boolean allowOverride =  getPreferencePage().doGetPreferenceStore().getBoolean(IPreferenceKeys.ALLOW_OVERRIDE_NOMENCLATURAL_CODE_KEY);
51
        CdmPreference pref = CdmPreference.NewDatabaseInstance( PreferencePredicate.NomenclaturalCode, value);
52
        pref.setAllowOverride(allowOverride);
53

    
54
        ICdmRepository controller = CdmStore.getCurrentApplicationConfiguration();
55
        if (controller == null){
56
            return false;
57
        }
58
        IPreferenceService service = controller.getPreferenceService();
59
        service.set(pref);
60

    
61
        getPreferencePage().createNameDetailsViewConfig();
62
        value = getPreferencePage().getConfig().toString();
63
        allowOverride = getPreferencePage().doGetPreferenceStore().getBoolean(IPreferenceKeys.ALLOW_OVERRIDE_NAMEDETAILS);
64
        pref = CdmPreference.NewDatabaseInstance( PreferencePredicate.NameDetailsView, value);
65
        pref.setAllowOverride(allowOverride);
66
        service.set(pref);
67

    
68
        return true;
69
    }
70

    
71
    /**
72
     * @return the preferencePage
73
     */
74
    public DatabasePreferencesPage getPreferencePage() {
75
        return preferencePage;
76
    }
77

    
78
    @Override
79
    public void addPages() {
80
        addPage(preferencePage);
81
    }
82

    
83

    
84

    
85
}
(2-2/8)