Project

General

Profile

Download (6.58 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
    /**
43
     * {@inheritDoc}
44
     */
45
    @Override
46
    protected Control createContents(Composite parent) {
47
        final Composite composite = new Composite(parent, SWT.NULL);
48

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

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

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

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

    
80
        showIOMenuButton.setText(Messages.DatabasePreferncesPage_Show_IOMenu);
81

    
82
        showIOMenuButton.setSelection(isShowIOMenu);
83
        showIOMenuButton.addSelectionListener(new SelectionAdapter(){
84
             @Override
85
             public void widgetSelected(SelectionEvent e) {
86
                 isShowIOMenu = showIOMenuButton.getSelection();
87

    
88
              }
89
         });
90

    
91
        final Button showMediaViewButton = new Button(composite, SWT.CHECK);
92

    
93
        showMediaViewButton.setText(Messages.DatabasePreferncesPage_Show_MediaView);
94

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

    
101
              }
102
         });
103
        final Button showChecklistPerspectiveButton = new Button(composite, SWT.CHECK);
104

    
105
        showChecklistPerspectiveButton.setText(Messages.DatabasePreferncesPage_Show_ChecklistPerspective);
106

    
107
        showChecklistPerspectiveButton.setSelection(isShowCheckListPerspective);
108
        showChecklistPerspectiveButton.addSelectionListener(new SelectionAdapter(){
109
             @Override
110
             public void widgetSelected(SelectionEvent e) {
111
                 isShowCheckListPerspective = showChecklistPerspectiveButton.getSelection();
112

    
113
              }
114
         });
115

    
116
        final Button showTaxonNodeWizardButton = new Button(composite, SWT.CHECK);
117

    
118
        showTaxonNodeWizardButton.setText(Messages.DatabasePreferncesPage_Show_TaxonNodeWizard);
119

    
120
        showTaxonNodeWizardButton.setSelection(isShowTaxonNodeWizard);
121
        showTaxonNodeWizardButton.addSelectionListener(new SelectionAdapter(){
122
             @Override
123
             public void widgetSelected(SelectionEvent e) {
124
                 isShowTaxonNodeWizard = showTaxonNodeWizardButton.getSelection();
125

    
126
              }
127
         });
128

    
129
        return composite;
130
    }
131

    
132
    @Override
133
    public void createControl(Composite parent){
134
        super.createControl(parent);
135
        getControl().setVisible(false);
136
    }
137

    
138
    @Override
139
    public boolean performOk() {
140
       ICdmRepository controller = CdmStore.getCurrentApplicationConfiguration();
141
       if (controller != null){
142
           IPreferenceService service = controller.getPreferenceService();
143

    
144
           CdmPreference pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowImportExportMenu, Boolean.toString(this.isShowIOMenu));
145
           pref.setAllowOverride(false);
146
           service.set(pref);
147
           pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowMediaView, Boolean.toString(this.isShowMediaView));
148
           pref.setAllowOverride(false);
149
           service.set(pref);
150
           pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowChecklistPerspective, Boolean.toString(this.isShowCheckListPerspective));
151
           pref.setAllowOverride(false);
152
           service.set(pref);
153
           pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowTaxonNodeWizard, Boolean.toString(this.isShowTaxonNodeWizard));
154
           pref.setAllowOverride(false);
155
           service.set(pref);
156
           PreferencesUtil.updateDBPreferences();
157

    
158

    
159
       }
160
       return true;
161
   }
162

    
163
}
(5-5/12)