Project

General

Profile

Download (6.65 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.events.SelectionAdapter;
13
import org.eclipse.swt.events.SelectionEvent;
14
import org.eclipse.swt.layout.GridLayout;
15
import org.eclipse.swt.widgets.Button;
16
import org.eclipse.swt.widgets.Composite;
17
import org.eclipse.swt.widgets.Control;
18

    
19
import eu.etaxonomy.cdm.api.application.ICdmRepository;
20
import eu.etaxonomy.cdm.api.service.IPreferenceService;
21
import eu.etaxonomy.cdm.model.metadata.CdmPreference;
22
import eu.etaxonomy.cdm.model.metadata.CdmPreference.PrefKey;
23
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
24
import eu.etaxonomy.cdm.model.metadata.PreferenceSubject;
25
import eu.etaxonomy.taxeditor.l10n.Messages;
26
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
27
import eu.etaxonomy.taxeditor.preference.menu.CdmPreferencePage;
28
import eu.etaxonomy.taxeditor.store.CdmStore;
29

    
30
/**
31
 * @author k.luther
32
 * @since 29.05.2018
33
 *
34
 */
35
public class GeneralAdminPreferencePage extends CdmPreferencePage implements IE4AdminPreferencePage {
36

    
37

    
38
    boolean isShowIOMenu = true;
39
    boolean isShowMediaView = true;
40
    boolean isShowCheckListPerspective = false;
41
    boolean isShowTaxonNodeWizard = true;
42
    ICdmRepository controller = null;
43
    CdmPreference isShowSpecimenPref = null;
44
    /**
45
     * {@inheritDoc}
46
     */
47
    @Override
48
    protected Control createContents(Composite parent) {
49
        final Composite composite = new Composite(parent, SWT.NULL);
50

    
51

    
52
        GridLayout gridLayout = new GridLayout();
53
        composite.setLayout(gridLayout);
54
        controller = CdmStore.getCurrentApplicationConfiguration();
55
        if (controller != null){
56
            IPreferenceService service = controller.getPreferenceService();
57
            PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowImportExportMenu);
58
            CdmPreference isShowSpecimenPref = service.find(key);
59
            if (isShowSpecimenPref != null){
60
                this.isShowIOMenu = Boolean.valueOf(isShowSpecimenPref.getValue());
61
            }
62

    
63
            key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowMediaView);
64
            CdmPreference isShowMediaViewPref = service.find(key);
65
            if (isShowMediaViewPref != null){
66
                this.isShowMediaView = Boolean.valueOf(isShowMediaViewPref.getValue());
67
            }
68

    
69
            key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowChecklistPerspective);
70
            CdmPreference isShowChecklistPref = service.find(key);
71
            if (isShowChecklistPref != null){
72
                this.isShowCheckListPerspective = Boolean.valueOf(isShowChecklistPref.getValue());
73
            }
74

    
75
            key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowTaxonNodeWizard);
76
            CdmPreference isShowTaxonNodeWizardPref = service.find(key);
77
            if (isShowTaxonNodeWizardPref != null){
78
                this.isShowTaxonNodeWizard = Boolean.valueOf(isShowTaxonNodeWizardPref.getValue());
79
            }
80
        }
81
        final Button showIOMenuButton = new Button(composite, SWT.CHECK);
82

    
83
        showIOMenuButton.setText(Messages.DatabasePreferncesPage_Show_IOMenu);
84

    
85
        showIOMenuButton.setSelection(isShowIOMenu);
86
        showIOMenuButton.addSelectionListener(new SelectionAdapter(){
87
             @Override
88
             public void widgetSelected(SelectionEvent e) {
89
                 isShowIOMenu = showIOMenuButton.getSelection();
90

    
91
              }
92
         });
93

    
94
        final Button showMediaViewButton = new Button(composite, SWT.CHECK);
95

    
96
        showMediaViewButton.setText(Messages.DatabasePreferncesPage_Show_MediaView);
97

    
98
        showMediaViewButton.setSelection(isShowMediaView);
99
        showMediaViewButton.addSelectionListener(new SelectionAdapter(){
100
             @Override
101
             public void widgetSelected(SelectionEvent e) {
102
                 isShowMediaView = showIOMenuButton.getSelection();
103

    
104
              }
105
         });
106
        final Button showChecklistPerspectiveButton = new Button(composite, SWT.CHECK);
107

    
108
        showChecklistPerspectiveButton.setText(Messages.DatabasePreferncesPage_Show_ChecklistPerspective);
109

    
110
        showChecklistPerspectiveButton.setSelection(isShowCheckListPerspective);
111
        showChecklistPerspectiveButton.addSelectionListener(new SelectionAdapter(){
112
             @Override
113
             public void widgetSelected(SelectionEvent e) {
114
                 isShowCheckListPerspective = showChecklistPerspectiveButton.getSelection();
115

    
116
              }
117
         });
118

    
119
        final Button showTaxonNodeWizardButton = new Button(composite, SWT.CHECK);
120

    
121
        showTaxonNodeWizardButton.setText(Messages.DatabasePreferncesPage_Show_TaxonNodeWizard);
122

    
123
        showTaxonNodeWizardButton.setSelection(isShowTaxonNodeWizard);
124
        showTaxonNodeWizardButton.addSelectionListener(new SelectionAdapter(){
125
             @Override
126
             public void widgetSelected(SelectionEvent e) {
127
                 isShowTaxonNodeWizard = showTaxonNodeWizardButton.getSelection();
128

    
129
              }
130
         });
131

    
132

    
133
        return composite;
134
    }
135

    
136
    @Override
137
    public void createControl(Composite parent){
138
        super.createControl(parent);
139
        getControl().setVisible(false);
140
    }
141

    
142
    @Override
143
    public boolean performOk() {
144

    
145
       //ICdmRepository controller = CdmStore.getCurrentApplicationConfiguration();
146
       if (controller != null){
147
           IPreferenceService service = controller.getPreferenceService();
148

    
149
           CdmPreference pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowImportExportMenu, Boolean.toString(this.isShowIOMenu));
150
           pref.setAllowOverride(true);
151
           service.set(pref);
152
           pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowMediaView, Boolean.toString(this.isShowMediaView));
153
           pref.setAllowOverride(true);
154
           service.set(pref);
155
           pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowChecklistPerspective, Boolean.toString(this.isShowCheckListPerspective));
156
           pref.setAllowOverride(true);
157
           service.set(pref);
158
           pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowTaxonNodeWizard, Boolean.toString(this.isShowTaxonNodeWizard));
159
           pref.setAllowOverride(true);
160
           service.set(pref);
161
           PreferencesUtil.updateDBPreferences();
162

    
163

    
164
       }
165
       return true;
166
   }
167

    
168
}
(6-6/13)