Project

General

Profile

Download (6.38 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2018 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.preferencePage;
10

    
11
import org.eclipse.swt.SWT;
12
import org.eclipse.swt.widgets.Composite;
13
import org.eclipse.swt.widgets.Control;
14

    
15
import eu.etaxonomy.cdm.api.application.ICdmRepository;
16
import eu.etaxonomy.cdm.api.service.IPreferenceService;
17
import eu.etaxonomy.cdm.model.metadata.CdmPreference;
18
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
19
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
20
import eu.etaxonomy.taxeditor.preference.menu.CdmPreferencePage;
21

    
22
/**
23
 * @author k.luther
24
 * @since 29.05.2018
25
 *
26
 */
27
public class GeneralAdminPreferencePage extends CdmPreferencePage implements IE4AdminPreferencePage {
28

    
29

    
30
    boolean isShowIOMenu = true;
31
    boolean isShowMediaView = true;
32
    boolean isShowCheckListPerspective = false;
33
    boolean isShowTaxonNodeWizard = true;
34
    ICdmRepository controller = null;
35
    /**
36
     * {@inheritDoc}
37
     */
38
    @Override
39
    protected Control createContents(Composite parent) {
40
        final Composite composite = new Composite(parent, SWT.NULL);
41

    
42
//        GridLayout gridLayout = new GridLayout();
43
//        composite.setLayout(gridLayout);
44
//        controller = CdmStore.getCurrentApplicationConfiguration();
45
//        if (controller != null){
46
//            IPreferenceService service = controller.getPreferenceService();
47
//            PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowImportExportMenu);
48
//            CdmPreference isShowSpecimenPref = service.find(key);
49
//            if (isShowSpecimenPref != null){
50
//                this.isShowIOMenu = Boolean.valueOf(isShowSpecimenPref.getValue());
51
//            }
52
//
53
//            key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowMediaView);
54
//            CdmPreference isShowMediaViewPref = service.find(key);
55
//            if (isShowMediaViewPref != null){
56
//                this.isShowMediaView = Boolean.valueOf(isShowMediaViewPref.getValue());
57
//            }
58
//
59
//            key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowChecklistPerspective);
60
//            CdmPreference isShowChecklistPref = service.find(key);
61
//            if (isShowChecklistPref != null){
62
//                this.isShowCheckListPerspective = Boolean.valueOf(isShowChecklistPref.getValue());
63
//            }
64
//
65
//            key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowTaxonNodeWizard);
66
//            CdmPreference isShowTaxonNodeWizardPref = service.find(key);
67
//            if (isShowTaxonNodeWizardPref != null){
68
//                this.isShowTaxonNodeWizard = Boolean.valueOf(isShowTaxonNodeWizardPref.getValue());
69
//            }
70
//        }
71
//        final Button showIOMenuButton = new Button(composite, SWT.CHECK);
72
//
73
//        showIOMenuButton.setText(Messages.DatabasePreferncesPage_Show_IOMenu);
74
//
75
//        showIOMenuButton.setSelection(isShowIOMenu);
76
//        showIOMenuButton.addSelectionListener(new SelectionAdapter(){
77
//             @Override
78
//             public void widgetSelected(SelectionEvent e) {
79
//                 isShowIOMenu = showIOMenuButton.getSelection();
80
//
81
//              }
82
//         });
83
//
84
//        final Button showMediaViewButton = new Button(composite, SWT.CHECK);
85
//
86
//        showMediaViewButton.setText(Messages.DatabasePreferncesPage_Show_MediaView);
87
//
88
//        showMediaViewButton.setSelection(isShowMediaView);
89
//        showMediaViewButton.addSelectionListener(new SelectionAdapter(){
90
//             @Override
91
//             public void widgetSelected(SelectionEvent e) {
92
//                 isShowMediaView = showIOMenuButton.getSelection();
93
//
94
//              }
95
//         });
96
//        final Button showChecklistPerspectiveButton = new Button(composite, SWT.CHECK);
97
//
98
//        showChecklistPerspectiveButton.setText(Messages.DatabasePreferncesPage_Show_ChecklistPerspective);
99
//
100
//        showChecklistPerspectiveButton.setSelection(isShowCheckListPerspective);
101
//        showChecklistPerspectiveButton.addSelectionListener(new SelectionAdapter(){
102
//             @Override
103
//             public void widgetSelected(SelectionEvent e) {
104
//                 isShowCheckListPerspective = showChecklistPerspectiveButton.getSelection();
105
//
106
//              }
107
//         });
108
//
109
//        final Button showTaxonNodeWizardButton = new Button(composite, SWT.CHECK);
110
//
111
//        showTaxonNodeWizardButton.setText(Messages.DatabasePreferncesPage_Show_TaxonNodeWizard);
112
//
113
//        showTaxonNodeWizardButton.setSelection(isShowTaxonNodeWizard);
114
//        showTaxonNodeWizardButton.addSelectionListener(new SelectionAdapter(){
115
//             @Override
116
//             public void widgetSelected(SelectionEvent e) {
117
//                 isShowTaxonNodeWizard = showTaxonNodeWizardButton.getSelection();
118
//
119
//              }
120
//         });
121

    
122
        return composite;
123
    }
124

    
125
    @Override
126
    public void createControl(Composite parent){
127
        super.createControl(parent);
128
        getControl().setVisible(false);
129
    }
130

    
131
    @Override
132
    public boolean performOk() {
133
       //ICdmRepository controller = CdmStore.getCurrentApplicationConfiguration();
134
       if (controller != null){
135
           IPreferenceService service = controller.getPreferenceService();
136

    
137
           CdmPreference pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowImportExportMenu, Boolean.toString(this.isShowIOMenu));
138
           pref.setAllowOverride(true);
139
           service.set(pref);
140
           pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowMediaView, Boolean.toString(this.isShowMediaView));
141
           pref.setAllowOverride(true);
142
           service.set(pref);
143
           pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowChecklistPerspective, Boolean.toString(this.isShowCheckListPerspective));
144
           pref.setAllowOverride(true);
145
           service.set(pref);
146
           pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowTaxonNodeWizard, Boolean.toString(this.isShowTaxonNodeWizard));
147
           pref.setAllowOverride(true);
148
           service.set(pref);
149
           PreferencesUtil.updateDBPreferences();
150

    
151

    
152
       }
153
       return true;
154
   }
155

    
156
}
(5-5/12)