Project

General

Profile

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

    
3

    
4
import org.eclipse.swt.SWT;
5
import org.eclipse.swt.events.SelectionAdapter;
6
import org.eclipse.swt.events.SelectionEvent;
7
import org.eclipse.swt.layout.GridLayout;
8
import org.eclipse.swt.widgets.Button;
9
import org.eclipse.swt.widgets.Composite;
10
import org.eclipse.swt.widgets.Control;
11
import org.eclipse.swt.widgets.Label;
12

    
13
import eu.etaxonomy.cdm.model.metadata.CdmPreference;
14
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
15
import eu.etaxonomy.taxeditor.l10n.Messages;
16
import eu.etaxonomy.taxeditor.preference.menu.CdmPreferencePage;
17

    
18

    
19
public class NameDetailsViewConfiguration extends CdmPreferencePage {
20

    
21
    boolean isSimpleDetailsViewActivated;
22
	boolean isUseLocalSettings;
23
    Composite child ;
24
    Composite localSettings ;
25

    
26

    
27
    boolean isShowTaxon;
28
    boolean isShowNameApprobiation ;
29
    boolean isShowHybrid;
30
    boolean isShowNameRelationship;
31
    boolean isShowTypeDesignation;
32
    boolean isShowProtologue;
33
    boolean isShowNomenclaturalStatus;
34
    boolean isShowNomenclaturalRef;
35
    boolean isShowAuthorship;
36
    boolean isShowAuthorCache;
37
    boolean isShowEpithets;
38
    boolean isShowRank;
39
    boolean isShowAppendedPhrase;
40
    boolean isShowNameCache;
41
    boolean isShowNomenclaturalCode;
42
    boolean isShowLSID;
43
    boolean isSecEnabled;
44
    boolean isSecDetailsActivated;
45

    
46
    @Override
47
    protected Control createContents(Composite parent) {
48

    
49
    	Composite composite = new Composite(parent, SWT.NULL);
50
        composite.setLayout(new GridLayout());
51
        CdmPreference nameDetailsPref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.NameDetailsView);
52
        boolean isAllowOverride = false;
53
        if (nameDetailsPref != null){
54
            isAllowOverride = nameDetailsPref.isAllowOverride();
55
        }
56

    
57

    
58
        if (isAllowOverride){
59

    
60
            final Button activateLocalButton = new Button(composite, SWT.CHECK);
61
            activateLocalButton.setText(Messages.NameDetailsViewConfiguration_useLocalSettings);
62
            isUseLocalSettings =PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.OVERRIDE_NAME_DETAILS);
63
            activateLocalButton.setSelection(isUseLocalSettings);
64
            activateLocalButton.addSelectionListener(new SelectionAdapter(){
65
            @Override
66
            public void widgetSelected(SelectionEvent e) {
67
                isUseLocalSettings = activateLocalButton.getSelection();
68
                PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.OVERRIDE_NAME_DETAILS, isUseLocalSettings);
69
                if(isUseLocalSettings ){
70
                    child.setVisible(true);
71
                    child.setEnabled(true);
72
                }else{
73
                    child.setVisible(false);
74
                    child.setEnabled(false);
75
                }
76
             }
77
             });
78

    
79
            child  = new Composite(composite, SWT.NONE);
80
            child.setLayout(new GridLayout());
81
            child.setVisible(isUseLocalSettings);
82

    
83
            isSimpleDetailsViewActivated = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION);
84

    
85

    
86

    
87
            final Button activateCheckButton = new Button(child, SWT.CHECK);
88
            activateCheckButton.setText(Messages.NameDetailsViewConfiguration_activateSimpleDetailsView);
89
            activateCheckButton.setSelection(isSimpleDetailsViewActivated);
90
            activateCheckButton.addSelectionListener(new SelectionAdapter(){
91
            @Override
92
            public void widgetSelected(SelectionEvent e) {
93
            	isSimpleDetailsViewActivated = activateCheckButton.getSelection();
94

    
95
                if(isSimpleDetailsViewActivated && isUseLocalSettings){
96
                    localSettings.setVisible(true);
97
                    localSettings.setEnabled(true);
98
                }else{
99
                    localSettings.setVisible(false);
100
                    localSettings.setEnabled(false);
101
                }
102
             }
103
             });
104
            localSettings  = new Composite(child, SWT.NONE);
105
            localSettings.setLayout(new GridLayout());
106
            localSettings.setVisible(isSimpleDetailsViewActivated);
107

    
108

    
109
            final Button showTaxon = new Button(localSettings, SWT.CHECK);
110
            isShowTaxon = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_TAXON);
111
            showTaxon.setText(Messages.NameDetailsViewComposite_Show_Taxon);
112
            showTaxon.setSelection(isShowTaxon);
113
            showTaxon.addSelectionListener(new SelectionAdapter(){
114
                 @Override
115
                 public void widgetSelected(SelectionEvent e) {
116
                     isShowTaxon = showTaxon.getSelection();
117

    
118
                  }
119
             });
120

    
121
            final Button showSecDetail = new Button(localSettings, SWT.CHECK);
122
            isSecDetailsActivated = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SEC_DETAILS);
123
            showSecDetail.setText(Messages.NameDetailsViewComposite_Show_SecDetail);
124

    
125
            showSecDetail.setSelection(isSecDetailsActivated);
126
            showSecDetail.addSelectionListener(new SelectionAdapter(){
127
                 @Override
128
                 public void widgetSelected(SelectionEvent e) {
129
                     isSecDetailsActivated = showSecDetail.getSelection();
130

    
131
                  }
132
             });
133

    
134
            final Button secEnabled = new Button(localSettings, SWT.CHECK);
135
            secEnabled.setText(Messages.NameDetailsViewComposite_SecEnabled);
136
            isSecEnabled = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.DISABLE_SEC);
137
            secEnabled.setSelection(isSecEnabled);
138
            secEnabled.addSelectionListener(new SelectionAdapter(){
139
                 @Override
140
                 public void widgetSelected(SelectionEvent e) {
141
                     isSecEnabled = secEnabled.getSelection();
142

    
143
                  }
144
             });
145

    
146
            final Button showLsid = new Button(localSettings, SWT.CHECK);
147
            isShowLSID = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_LSID);
148
            showLsid.setText(Messages.NameDetailsViewComposite_Show_LSID);
149
            showLsid.setSelection(isShowLSID);
150
            showLsid.addSelectionListener(new SelectionAdapter(){
151
                 @Override
152
                 public void widgetSelected(SelectionEvent e) {
153
                     isShowLSID = showLsid.getSelection();
154

    
155
                  }
156
             });
157

    
158
            final Button showNomenclaturalCode = new Button(localSettings, SWT.CHECK);
159
            isShowNomenclaturalCode = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE);
160
            showNomenclaturalCode.setText(Messages.NameDetailsViewComposite_Show_NomenclaturalCode);
161
            showNomenclaturalCode.setSelection(isShowNomenclaturalCode);
162
            showNomenclaturalCode.addSelectionListener(new SelectionAdapter(){
163
                 @Override
164
                 public void widgetSelected(SelectionEvent e) {
165
                     isShowNomenclaturalCode = showNomenclaturalCode.getSelection();
166

    
167
                  }
168
             });
169

    
170
            final Button showNameCache = new Button(localSettings, SWT.CHECK);
171
            isShowNameCache = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAMECACHE);
172
            showNameCache.setText(Messages.NameDetailsViewComposite_Show_NameCache);
173
            showNameCache.setSelection(isShowNomenclaturalCode);
174
            showNameCache.addSelectionListener(new SelectionAdapter(){
175
                 @Override
176
                 public void widgetSelected(SelectionEvent e) {
177
                     isShowNameCache = showNameCache.getSelection();
178

    
179
                  }
180
             });
181
            final Button showAppendedPhrase = new Button(localSettings, SWT.CHECK);
182
            isShowAppendedPhrase = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE);
183
            showAppendedPhrase.setText(Messages.NameDetailsViewComposite_Show_AppendedPhrase);
184
            showAppendedPhrase.setSelection(isShowAppendedPhrase);
185
            showAppendedPhrase.addSelectionListener(new SelectionAdapter(){
186
                 @Override
187
                 public void widgetSelected(SelectionEvent e) {
188
                     isShowAppendedPhrase = showAppendedPhrase.getSelection();
189

    
190
                  }
191
             });
192

    
193
            final Button showRank = new Button(localSettings, SWT.CHECK);
194
            isShowRank = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_RANK);
195
            showRank.setText(Messages.NameDetailsViewComposite_Show_Rank);
196
            showRank.setSelection(isShowRank);
197
            showRank.addSelectionListener(new SelectionAdapter(){
198
                 @Override
199
                 public void widgetSelected(SelectionEvent e) {
200
                     isShowRank = showRank.getSelection();
201

    
202
                  }
203
             });
204
            final Button showEpithets = new Button(localSettings, SWT.CHECK);
205
            isShowEpithets = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS);
206
            showEpithets.setText(Messages.NameDetailsViewComposite_Show_AtomisedEpithets);
207
            showEpithets.setSelection(isShowEpithets);
208
            showEpithets.addSelectionListener(new SelectionAdapter(){
209
                 @Override
210
                 public void widgetSelected(SelectionEvent e) {
211
                     isShowEpithets = showEpithets.getSelection();
212

    
213
                  }
214
             });
215

    
216
            final Button showAuthorCache = new Button(localSettings, SWT.CHECK);
217
            isShowAuthorCache = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP_CACHE);
218
            showAuthorCache.setText(Messages.NameDetailsViewComposite_Show_AuthorCache);
219
            showAuthorCache.setSelection(isShowAuthorCache);
220
            showAuthorCache.addSelectionListener(new SelectionAdapter(){
221
                 @Override
222
                 public void widgetSelected(SelectionEvent e) {
223
                     isShowAuthorCache = showAuthorCache.getSelection();
224

    
225
                  }
226
             });
227

    
228
            final Button showAuthorship = new Button(localSettings, SWT.CHECK);
229
            isShowAuthorship = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP);
230
            showAuthorship.setText(Messages.NameDetailsViewComposite_Show_Author);
231
            showAuthorship.setSelection(isShowAuthorship);
232
            showAuthorship.addSelectionListener(new SelectionAdapter(){
233
                 @Override
234
                 public void widgetSelected(SelectionEvent e) {
235
                     isShowAuthorship = showAuthorship.getSelection();
236

    
237
                  }
238
             });
239

    
240
            final Button showNomenclaturalRef = new Button(localSettings, SWT.CHECK);
241
            isShowNomenclaturalRef = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE);
242
            showNomenclaturalRef.setText(Messages.NameDetailsViewComposite_Show_NomenclaturalReference);
243
            showNomenclaturalRef.setSelection(isShowNomenclaturalRef);
244
            showNomenclaturalRef.addSelectionListener(new SelectionAdapter(){
245
                 @Override
246
                 public void widgetSelected(SelectionEvent e) {
247
                     isShowNomenclaturalRef = showNomenclaturalRef.getSelection();
248

    
249
                  }
250
             });
251

    
252
            final Button showNomenclaturalStatus = new Button(localSettings, SWT.CHECK);
253
            isShowNomenclaturalStatus = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS);
254
            showNomenclaturalStatus.setText(Messages.NameDetailsViewComposite_Show_NomenclaturalStatus);
255
            showNomenclaturalStatus.setSelection(isShowNomenclaturalStatus);
256
            showNomenclaturalStatus.addSelectionListener(new SelectionAdapter(){
257
                 @Override
258
                 public void widgetSelected(SelectionEvent e) {
259
                     isShowNomenclaturalStatus = showNomenclaturalStatus.getSelection();
260

    
261
                  }
262
             });
263

    
264
            final Button showProtologue = new Button(localSettings, SWT.CHECK);
265
            isShowProtologue = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_PROTOLOGUE);
266
            showProtologue.setText(Messages.NameDetailsViewComposite_Show_Protologue);
267
            showProtologue.setSelection(isShowProtologue);
268
            showProtologue.addSelectionListener(new SelectionAdapter(){
269
                 @Override
270
                 public void widgetSelected(SelectionEvent e) {
271
                     isShowProtologue = showProtologue.getSelection();
272

    
273
                  }
274
             });
275

    
276
            final Button showTypeDesignation = new Button(localSettings, SWT.CHECK);
277
            isShowTypeDesignation = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION);
278
            showTypeDesignation.setText(Messages.NameDetailsViewComposite_Show_TypeDesignation);
279
            showTypeDesignation.setSelection(isShowTypeDesignation);
280
            showTypeDesignation.addSelectionListener(new SelectionAdapter(){
281
                 @Override
282
                 public void widgetSelected(SelectionEvent e) {
283
                     isShowTypeDesignation = showTypeDesignation.getSelection();
284

    
285
                  }
286
             });
287

    
288

    
289
            final Button showNameRelationship = new Button(localSettings, SWT.CHECK);
290
            isShowNameRelationship = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP);
291
            showNameRelationship.setText(Messages.NameDetailsViewComposite_Show_Namerelationships);
292
            showNameRelationship.setSelection(isShowNameRelationship);
293
            showNameRelationship.addSelectionListener(new SelectionAdapter(){
294
                 @Override
295
                 public void widgetSelected(SelectionEvent e) {
296
                     isShowNameRelationship = showNameRelationship.getSelection();
297

    
298
                  }
299
             });
300

    
301
            final Button showHybrid = new Button(localSettings, SWT.CHECK);
302
            isShowHybrid = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_HYBRID);
303
            showHybrid.setText(Messages.NameDetailsViewComposite_Show_Hybrid);
304
            showHybrid.setSelection(isShowHybrid);
305
            showHybrid.addSelectionListener(new SelectionAdapter(){
306
                 @Override
307
                 public void widgetSelected(SelectionEvent e) {
308
                     isShowHybrid = showHybrid.getSelection();
309

    
310
                  }
311
             });
312
            final Button showNameApprobiation = new Button(localSettings, SWT.CHECK);
313
            isShowNameApprobiation = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAME_APPROBATION);
314
            showNameApprobiation.setText(Messages.NameDetailsViewComposite_Show_NameApprobiation);
315
            showNameApprobiation.setSelection(isShowNameApprobiation);
316
            showNameApprobiation.addSelectionListener(new SelectionAdapter(){
317
                 @Override
318
                 public void widgetSelected(SelectionEvent e) {
319
                     isShowNameApprobiation= showNameApprobiation.getSelection();
320

    
321
                  }
322
             });
323

    
324

    
325
            if(isSimpleDetailsViewActivated){
326
                localSettings.setEnabled(true);
327
            }else{
328
                localSettings.setEnabled(false);
329
            }
330
        }else{
331
            Label label = new Label(composite, SWT.NONE);
332
            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.");
333
        }
334
        return composite;
335
	}
336

    
337
    @Override
338
    public boolean performOk() {
339
        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_TAXON, isShowTaxon);
340
        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_SEC_DETAILS, isSecDetailsActivated);
341
        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.DISABLE_SEC, isSecEnabled);
342
        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION, isSimpleDetailsViewActivated);
343
        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAME_APPROBATION, isShowNameApprobiation);
344
        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_HYBRID, isShowHybrid);
345
        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP, isShowNameRelationship);
346
        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION, isShowTypeDesignation);
347
        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_PROTOLOGUE, isShowProtologue);
348
        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS, isShowNomenclaturalStatus);
349
        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE, isShowNomenclaturalRef);
350
        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP, isShowAuthorship);
351
        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP_CACHE, isShowAuthorCache);
352
        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS, isShowEpithets);
353
        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_RANK, isShowRank);
354
        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE, isShowAppendedPhrase);
355
        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAMECACHE, isShowNameCache);
356
        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE, isShowNomenclaturalCode);
357
        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_LSID, isShowLSID);
358
        return true;
359

    
360
    }
361

    
362
}
(16-16/25)