Project

General

Profile

Download (15.7 KB) Statistics
| Branch: | Tag: | Revision:
1
package eu.etaxonomy.taxeditor.preference;
2

    
3

    
4
import org.eclipse.jface.preference.PreferencePage;
5
import org.eclipse.swt.SWT;
6
import org.eclipse.swt.events.SelectionAdapter;
7
import org.eclipse.swt.events.SelectionEvent;
8
import org.eclipse.swt.layout.GridLayout;
9
import org.eclipse.swt.widgets.Button;
10
import org.eclipse.swt.widgets.Composite;
11
import org.eclipse.swt.widgets.Control;
12
import org.eclipse.swt.widgets.Label;
13
import org.eclipse.ui.IWorkbench;
14
import org.eclipse.ui.IWorkbenchPreferencePage;
15

    
16
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
17

    
18

    
19
public class NameDetailsViewConfiguration extends PreferencePage implements IWorkbenchPreferencePage {
20
	boolean isSimpleDetailsViewActivated;
21
	boolean isUseLocalSettings;
22
    Composite child ;
23
    Composite localSettings ;
24
	@Override
25
	public void init(IWorkbench workbench) {
26

    
27
	}
28

    
29
	/*
30
     * (non-Javadoc)
31
     *
32
     * @see
33
     * org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors
34
     * ()
35
     */
36
    @Override
37
    protected Control createContents(Composite parent) {
38

    
39
    	Composite composite = new Composite(parent, SWT.NULL);
40
        composite.setLayout(new GridLayout());
41

    
42
        boolean isAllowOverride = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.NameDetailsView).isAllowOverride();
43

    
44

    
45
        if (isAllowOverride){
46

    
47
            final Button activateLocalButton = new Button(composite, SWT.CHECK);
48
            activateLocalButton.setText("Use local settings for display of name details");
49
            activateLocalButton.setSelection( PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.OVERRIDE_NAME_DETAILS));
50
            activateLocalButton.addSelectionListener(new SelectionAdapter(){
51
            @Override
52
            public void widgetSelected(SelectionEvent e) {
53
                isUseLocalSettings = activateLocalButton.getSelection();
54
                PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.OVERRIDE_NAME_DETAILS, isUseLocalSettings);
55
                if(isUseLocalSettings ){
56
                    child.setVisible(true);
57
                    child.setEnabled(true);
58
                }else{
59
                    child.setVisible(false);
60
                    child.setEnabled(false);
61
                }
62
             }
63
             });
64

    
65
            child  = new Composite(composite, SWT.NONE);
66
            child.setLayout(new GridLayout());
67
            child.setVisible(isUseLocalSettings);
68

    
69
            isSimpleDetailsViewActivated = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION);
70

    
71

    
72

    
73
            final Button activateCheckButton = new Button(child, SWT.CHECK);
74
            activateCheckButton.setText("Show only a simple name details view");
75
            activateCheckButton.setSelection(isSimpleDetailsViewActivated);
76
            activateCheckButton.addSelectionListener(new SelectionAdapter(){
77
            @Override
78
            public void widgetSelected(SelectionEvent e) {
79
            	isSimpleDetailsViewActivated = activateCheckButton.getSelection();
80
                PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION, isSimpleDetailsViewActivated);
81
                if(isSimpleDetailsViewActivated && isUseLocalSettings){
82
                    localSettings.setVisible(true);
83
                    localSettings.setEnabled(true);
84
                }else{
85
                    localSettings.setVisible(false);
86
                    localSettings.setEnabled(false);
87
                }
88
             }
89
             });
90
            localSettings  = new Composite(child, SWT.NONE);
91
            localSettings.setLayout(new GridLayout());
92
            localSettings.setVisible(isSimpleDetailsViewActivated);
93

    
94

    
95
            final Button showTaxon = new Button(localSettings, SWT.CHECK);
96
            boolean isShowTaxon = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_TAXON);
97
            showTaxon.setText("Show taxon of the name");
98
            showTaxon.setSelection(isShowTaxon);
99
            showTaxon.addSelectionListener(new SelectionAdapter(){
100
                 @Override
101
                 public void widgetSelected(SelectionEvent e) {
102
                     boolean isShowTaxon = showTaxon.getSelection();
103
                     PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_TAXON, isShowTaxon);
104
                  }
105
             });
106

    
107
            final Button showLsid = new Button(localSettings, SWT.CHECK);
108
            boolean isShowLSID = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_LSID);
109
            showLsid.setText("Show Lsid of the name");
110
            showLsid.setSelection(isShowLSID);
111
            showLsid.addSelectionListener(new SelectionAdapter(){
112
                 @Override
113
                 public void widgetSelected(SelectionEvent e) {
114
                     boolean isShowLSID = showLsid.getSelection();
115
                     PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_LSID, isShowLSID);
116
                  }
117
             });
118

    
119
            final Button showNomenclaturalCode = new Button(localSettings, SWT.CHECK);
120
            boolean isShowNomenclaturalCode = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE);
121
            showNomenclaturalCode.setText("Show the nomenclatural code");
122
            showNomenclaturalCode.setSelection(isShowNomenclaturalCode);
123
            showNomenclaturalCode.addSelectionListener(new SelectionAdapter(){
124
                 @Override
125
                 public void widgetSelected(SelectionEvent e) {
126
                     boolean isShowNomenclaturalCode = showNomenclaturalCode.getSelection();
127
                     PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE, isShowNomenclaturalCode);
128
                  }
129
             });
130

    
131
            final Button showNameCache = new Button(localSettings, SWT.CHECK);
132
            boolean isShowNameCache = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAMECACHE);
133
            showNameCache.setText("Show nameCache of the name (only the scientific name without the author and year)");
134
            showNameCache.setSelection(isShowNomenclaturalCode);
135
            showNameCache.addSelectionListener(new SelectionAdapter(){
136
                 @Override
137
                 public void widgetSelected(SelectionEvent e) {
138
                     boolean isShowNameCache = showNameCache.getSelection();
139
                     PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAMECACHE, isShowNameCache);
140
                  }
141
             });
142
            final Button showAppendedPhrase = new Button(localSettings, SWT.CHECK);
143
            boolean isShowAppendedPhrase = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE);
144
            showAppendedPhrase.setText("Show appended phrase");
145
            showAppendedPhrase.setSelection(isShowAppendedPhrase);
146
            showAppendedPhrase.addSelectionListener(new SelectionAdapter(){
147
                 @Override
148
                 public void widgetSelected(SelectionEvent e) {
149
                     boolean isShowAppendedPhrase = showAppendedPhrase.getSelection();
150
                     PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE, isShowAppendedPhrase);
151
                  }
152
             });
153

    
154
            final Button showRank = new Button(localSettings, SWT.CHECK);
155
            boolean isShowRank = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_RANK);
156
            showRank.setText("Show rank of the name");
157
            showRank.setSelection(isShowRank);
158
            showRank.addSelectionListener(new SelectionAdapter(){
159
                 @Override
160
                 public void widgetSelected(SelectionEvent e) {
161
                     boolean isShowRank = showRank.getSelection();
162
                     PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_RANK, isShowRank);
163
                  }
164
             });
165
            final Button showEpithets = new Button(localSettings, SWT.CHECK);
166
            boolean isShowEpithets = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS);
167
            showEpithets.setText("Show atomised epithets");
168
            showEpithets.setSelection(isShowEpithets);
169
            showEpithets.addSelectionListener(new SelectionAdapter(){
170
                 @Override
171
                 public void widgetSelected(SelectionEvent e) {
172
                     boolean isShowEpithets = showEpithets.getSelection();
173
                     PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS, isShowEpithets);
174
                  }
175
             });
176
            final Button showAuthorship = new Button(localSettings, SWT.CHECK);
177
            boolean isShowAuthorship = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP);
178
            showAuthorship.setText("Show authorship section");
179
            showAuthorship.setSelection(isShowAuthorship);
180
            showAuthorship.addSelectionListener(new SelectionAdapter(){
181
                 @Override
182
                 public void widgetSelected(SelectionEvent e) {
183
                     boolean isShowAuthorship = showAuthorship.getSelection();
184
                     PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP, isShowAuthorship);
185
                  }
186
             });
187

    
188
            final Button showNomenclaturalRef = new Button(localSettings, SWT.CHECK);
189
            boolean isShowNomenclaturalRef = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE);
190
            showNomenclaturalRef.setText("Show nomenclatural reference section");
191
            showNomenclaturalRef.setSelection(isShowNomenclaturalRef);
192
            showNomenclaturalRef.addSelectionListener(new SelectionAdapter(){
193
                 @Override
194
                 public void widgetSelected(SelectionEvent e) {
195
                     boolean isShowNomenclaturalRef = showNomenclaturalRef.getSelection();
196
                     PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE, isShowNomenclaturalRef);
197
                  }
198
             });
199

    
200
            final Button showNomenclaturalStatus = new Button(localSettings, SWT.CHECK);
201
            boolean isShowNomenclaturalStatus = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS);
202
            showNomenclaturalStatus.setText("Show nomenclatural status section");
203
            showNomenclaturalStatus.setSelection(isShowNomenclaturalStatus);
204
            showNomenclaturalStatus.addSelectionListener(new SelectionAdapter(){
205
                 @Override
206
                 public void widgetSelected(SelectionEvent e) {
207
                     boolean isShowNomenclaturalStatus = showNomenclaturalStatus.getSelection();
208
                     PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS, isShowNomenclaturalStatus);
209
                  }
210
             });
211

    
212
            final Button showProtologue = new Button(localSettings, SWT.CHECK);
213
            boolean isShowProtologue = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_PROTOLOGUE);
214
            showProtologue.setText("Show protologue section");
215
            showProtologue.setSelection(isShowProtologue);
216
            showProtologue.addSelectionListener(new SelectionAdapter(){
217
                 @Override
218
                 public void widgetSelected(SelectionEvent e) {
219
                     boolean isShowProtologue = showProtologue.getSelection();
220
                     PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_PROTOLOGUE, isShowProtologue);
221
                  }
222
             });
223

    
224
            final Button showTypeDesignation = new Button(localSettings, SWT.CHECK);
225
            boolean isShowTypeDesignation = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION);
226
            showTypeDesignation.setText("Show name type designation section");
227
            showTypeDesignation.setSelection(isShowTypeDesignation);
228
            showTypeDesignation.addSelectionListener(new SelectionAdapter(){
229
                 @Override
230
                 public void widgetSelected(SelectionEvent e) {
231
                     boolean isShowTypeDesignation = showTypeDesignation.getSelection();
232
                     PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION, isShowTypeDesignation);
233
                  }
234
             });
235

    
236

    
237
            final Button showNameRelationship = new Button(localSettings, SWT.CHECK);
238
            boolean isShowNameRelationship = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP);
239
            showNameRelationship.setText("Show name relationship section");
240
            showNameRelationship.setSelection(isShowNameRelationship);
241
            showNameRelationship.addSelectionListener(new SelectionAdapter(){
242
                 @Override
243
                 public void widgetSelected(SelectionEvent e) {
244
                     boolean isShowNameRelationship = showNameRelationship.getSelection();
245
                     PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP, isShowNameRelationship);
246
                  }
247
             });
248

    
249
            final Button showHybrid = new Button(localSettings, SWT.CHECK);
250
            boolean isShowHybrid = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_HYBRID);
251
            showHybrid.setText("Show hybrid section");
252
            showHybrid.setSelection(isShowHybrid);
253
            showHybrid.addSelectionListener(new SelectionAdapter(){
254
                 @Override
255
                 public void widgetSelected(SelectionEvent e) {
256
                     boolean isShowHybrid = showHybrid.getSelection();
257
                     PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_HYBRID, isShowHybrid);
258
                  }
259
             });
260
            final Button showNameApprobiation = new Button(localSettings, SWT.CHECK);
261
            boolean isShowNameApprobiation = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAME_APPROBATION);
262
            showNameApprobiation.setText("Show name approbiation (for bacterial names)");
263
            showNameApprobiation.setSelection(isShowNameApprobiation);
264
            showNameApprobiation.addSelectionListener(new SelectionAdapter(){
265
                 @Override
266
                 public void widgetSelected(SelectionEvent e) {
267
                     boolean isShowNameApprobiation = showNameApprobiation.getSelection();
268
                     PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAME_APPROBATION, isShowNameApprobiation);
269
                  }
270
             });
271

    
272

    
273
            if(isSimpleDetailsViewActivated){
274
                localSettings.setEnabled(true);
275
            }else{
276
                localSettings.setEnabled(false);
277
            }
278
        }else{
279
            Label label = new Label(composite, SWT.NONE);
280
            label.setText("The CDM settings don't allow to set the preferences for the display of name details locally. If you need to make local settings, please ask an administrator.");
281
        }
282
        return composite;
283

    
284

    
285

    
286
	}
287

    
288
}
(16-16/25)