Project

General

Profile

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

    
11
import java.util.List;
12

    
13
import org.eclipse.jface.preference.IPreferenceStore;
14
import org.eclipse.jface.wizard.IWizard;
15
import org.eclipse.jface.wizard.IWizardPage;
16
import org.eclipse.jface.wizard.WizardPage;
17
import org.eclipse.swt.SWT;
18
import org.eclipse.swt.events.SelectionAdapter;
19
import org.eclipse.swt.events.SelectionEvent;
20
import org.eclipse.swt.layout.GridData;
21
import org.eclipse.swt.layout.GridLayout;
22
import org.eclipse.swt.widgets.Button;
23
import org.eclipse.swt.widgets.Combo;
24
import org.eclipse.swt.widgets.Composite;
25
import org.eclipse.swt.widgets.Label;
26
import org.eclipse.swt.widgets.TabFolder;
27
import org.eclipse.swt.widgets.TabItem;
28

    
29
import eu.etaxonomy.cdm.model.metadata.CdmPreference;
30
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
31
import eu.etaxonomy.taxeditor.model.NomenclaturalCodeHelper;
32
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
33
import eu.etaxonomy.taxeditor.preference.NameDetailsConfigurator;
34
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
35

    
36
/**
37
 * @author k.luther
38
 * @date 01.11.2016
39
 *
40
 */
41
public class DatabasePreferencesPage extends WizardPage implements IWizardPage{
42

    
43

    
44

    
45
    CdmPreference preferedNomenclaturalCode;
46
    NameDetailsConfigurator config ;
47
    TabFolder tabFolder;
48
   // private int maxNumOfColumns;
49
    IPreferenceStore preferenceStore;
50
    Composite composite;
51
    boolean isSimpleDetailsViewActivated;
52
    Composite child ;
53

    
54
    private Combo nomenclaturalCodeCombo;
55

    
56
    private Label nomenclaturalCodeLabel;
57

    
58
    String[][] labelAndValues;
59

    
60
    /*
61
     *
62
     */
63
    public DatabasePreferencesPage(String pageName) {
64
        super(pageName);
65
        this.preferedNomenclaturalCode = PreferencesUtil.setPreferredNomenclaturalCode(null, false);
66
        this.config = PreferencesUtil.setPreferredNameDetailsConfiguration( false);
67
        setPreferenceStore(PreferencesUtil.getPreferenceStore());
68

    
69
    }
70

    
71
    protected void setPreferenceStore(IPreferenceStore store){
72
        this.preferenceStore = store;
73
    }
74

    
75
//    @Override
76
//    protected void createFieldEditors() {
77
//        setMessage("Choose the preferences for the whole cdm store.");
78
//        tabFolder = new TabFolder(getFieldEditorParent(), SWT.NONE);
79
//
80
//        createNomenclaturalCodeTab();
81
//        createNameDetailsConfiguration();
82
//
83
//
84
//    }
85

    
86

    
87

    
88
//
89
//    /***
90
//    * Adjust the layout of the field editors so that they are properly aligned.
91
//    */
92
//    @Override
93
//    protected void adjustGridLayout() {
94
//        if (tabFolder != null){
95
//            TabItem[] items = tabFolder.getItems();
96
//            for (int j = 0; j < items.length; j++){
97
//                GridLayout layout = ((GridLayout) ((Composite) items[j].getControl()).getLayout());
98
//                layout.numColumns = this.maxNumOfColumns;
99
//                layout.marginHeight = 5;
100
//                layout.marginWidth = 5;
101
//            }
102
//        }
103
//        // need to call super.adjustGridLayout() since fieldEditor.adjustForNumColumns() is protected
104
//        super.adjustGridLayout();
105
//
106
//        // reset the main container to a single column
107
//        ((GridLayout) super.getFieldEditorParent().getLayout()).numColumns = 1;
108
//    }
109

    
110
//    /***
111
//    * Returns a parent composite for a field editor.
112
//    * <p>
113
//    * This value must not be cached since a new parent may be created each time this method called. Thus this method
114
//    * must be called each time a field editor is constructed.
115
//    * </p>
116
//    * @return a parent
117
//    */
118
//    @Override
119
//    protected Composite getEditorParent(){
120
//        if (tabFolder == null || tabFolder.getItemCount() == 0){
121
//            return super.getWizard();
122
//        }
123
//        return (Composite) tabFolder.getItem(tabFolder.getItemCount() - 1).getControl();
124
//    }
125

    
126
    /***
127
    * Adds a tab to the page.
128
    * @param text the tab label
129
    */
130
    public Composite addTab(String text)    {
131
        if (tabFolder == null){
132
            // initialize tab folder
133
            if (composite == null) {
134
                composite = new Composite(getShell(), SWT.NONE);
135
            }
136
            tabFolder = new TabFolder(composite, SWT.NONE);
137
            tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
138
        }
139

    
140
        TabItem item = new TabItem(tabFolder, SWT.NONE);
141
        item.setText(text);
142

    
143
        Composite currentTab = new Composite(tabFolder, SWT.NULL);
144
        GridLayout layout = new GridLayout();
145
        currentTab.setLayout(layout);
146
        currentTab.setFont(composite.getFont());
147
        currentTab.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
148

    
149
        item.setControl(currentTab);
150
        return currentTab;
151
    }
152

    
153
    /**
154
     * @param tabFolder
155
     */
156
    private void createNameDetailsConfiguration(Composite parent) {
157
        if (composite == null){
158
            composite = parent;
159
        }
160
       composite = addTab("Name Details View Configuration");
161
//        TabItem tbtmNameDetailsConfiguration = new TabItem(tabFolder, SWT.NONE);
162
//        Composite c2 = new Composite(tabFolder, SWT.BORDER);
163
//        c2.setLayout(new GridLayout(1, true));
164
//        tbtmNameDetailsConfiguration.setControl(c2);
165
       // composite.setLayout(new GridLayout(1, true));
166
       config = new NameDetailsConfigurator(true);
167

    
168
      // Composite composite = new Composite(parent, SWT.NULL);
169
       composite.setLayout(new GridLayout());
170

    
171
       isSimpleDetailsViewActivated= PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION);
172
       final Button activateCheckButton = new Button(composite, SWT.CHECK);
173
       activateCheckButton.setText("Show only a simple name details view");
174
       activateCheckButton.setSelection(isSimpleDetailsViewActivated);
175
       activateCheckButton.addSelectionListener(new SelectionAdapter(){
176
       @Override
177
       public void widgetSelected(SelectionEvent e) {
178
           isSimpleDetailsViewActivated = activateCheckButton.getSelection();
179
           PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION, isSimpleDetailsViewActivated);
180
           if(isSimpleDetailsViewActivated){
181
               child.setVisible(true);
182
               child.setEnabled(true);
183
           }else{
184
               child.setVisible(false);
185
               child.setEnabled(false);
186
           }
187
        }
188
        });
189

    
190
       child = new Composite(composite, SWT.NULL);
191
       child.setLayout(new GridLayout());
192
       child.setVisible(isSimpleDetailsViewActivated);
193

    
194
       final Button showTaxon = new Button(child, SWT.CHECK);
195
       boolean isShowTaxon = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_TAXON);
196
       showTaxon.setText("Show taxon of the name");
197
       showTaxon.setSelection(isShowTaxon);
198
       showTaxon.addSelectionListener(new SelectionAdapter(){
199
            @Override
200
            public void widgetSelected(SelectionEvent e) {
201
                boolean isShowTaxon = showTaxon.getSelection();
202
                PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_TAXON, isShowTaxon);
203
             }
204
        });
205

    
206
       final Button showLsid = new Button(child, SWT.CHECK);
207
       boolean isShowLSID = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_LSID);
208
       showLsid.setText("Show Lsid of the name");
209
       showLsid.setSelection(isShowLSID);
210
       showLsid.addSelectionListener(new SelectionAdapter(){
211
            @Override
212
            public void widgetSelected(SelectionEvent e) {
213
                boolean isShowLSID = showLsid.getSelection();
214
                PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_LSID, isShowLSID);
215
             }
216
        });
217

    
218
       final Button showNomenclaturalCode = new Button(child, SWT.CHECK);
219
       boolean isShowNomenclaturalCode = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE);
220
       showNomenclaturalCode.setText("Show the nomenclatural code");
221
       showNomenclaturalCode.setSelection(isShowNomenclaturalCode);
222
       showNomenclaturalCode.addSelectionListener(new SelectionAdapter(){
223
            @Override
224
            public void widgetSelected(SelectionEvent e) {
225
                boolean isShowNomenclaturalCode = showNomenclaturalCode.getSelection();
226
                PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE, isShowNomenclaturalCode);
227
             }
228
        });
229

    
230
       final Button showNameCache = new Button(child, SWT.CHECK);
231
       boolean isShowNameCache = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAMECACHE);
232
       showNameCache.setText("Show nameCache of the name (only the scientific name without the author and year)");
233
       showNameCache.setSelection(isShowNomenclaturalCode);
234
       showNameCache.addSelectionListener(new SelectionAdapter(){
235
            @Override
236
            public void widgetSelected(SelectionEvent e) {
237
                boolean isShowNameCache = showNameCache.getSelection();
238
                PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAMECACHE, isShowNameCache);
239
             }
240
        });
241
       final Button showAppendedPhrase = new Button(child, SWT.CHECK);
242
       boolean isShowAppendedPhrase = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE);
243
       showAppendedPhrase.setText("Show appended phrase");
244
       showAppendedPhrase.setSelection(isShowAppendedPhrase);
245
       showAppendedPhrase.addSelectionListener(new SelectionAdapter(){
246
            @Override
247
            public void widgetSelected(SelectionEvent e) {
248
                boolean isShowAppendedPhrase = showAppendedPhrase.getSelection();
249
                PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE, isShowAppendedPhrase);
250
             }
251
        });
252

    
253
       final Button showRank = new Button(child, SWT.CHECK);
254
       boolean isShowRank = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_RANK);
255
       showRank.setText("Show rank of the name");
256
       showRank.setSelection(isShowRank);
257
       showRank.addSelectionListener(new SelectionAdapter(){
258
            @Override
259
            public void widgetSelected(SelectionEvent e) {
260
                boolean isShowRank = showRank.getSelection();
261
                PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_RANK, isShowRank);
262
             }
263
        });
264
       final Button showEpithets = new Button(child, SWT.CHECK);
265
       boolean isShowEpithets = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS);
266
       showEpithets.setText("Show atomised epithets");
267
       showEpithets.setSelection(isShowEpithets);
268
       showEpithets.addSelectionListener(new SelectionAdapter(){
269
            @Override
270
            public void widgetSelected(SelectionEvent e) {
271
                boolean isShowEpithets = showEpithets.getSelection();
272
                PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS, isShowEpithets);
273
             }
274
        });
275
       final Button showAuthorship = new Button(child, SWT.CHECK);
276
       boolean isShowAuthorship = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP);
277
       showAuthorship.setText("Show authorship section");
278
       showAuthorship.setSelection(isShowAuthorship);
279
       showAuthorship.addSelectionListener(new SelectionAdapter(){
280
            @Override
281
            public void widgetSelected(SelectionEvent e) {
282
                boolean isShowAuthorship = showAuthorship.getSelection();
283
                PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP, isShowAuthorship);
284
             }
285
        });
286

    
287
       final Button showNomenclaturalRef = new Button(child, SWT.CHECK);
288
       boolean isShowNomenclaturalRef = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE);
289
       showNomenclaturalRef.setText("Show nomenclatural reference section");
290
       showNomenclaturalRef.setSelection(isShowNomenclaturalRef);
291
       showNomenclaturalRef.addSelectionListener(new SelectionAdapter(){
292
            @Override
293
            public void widgetSelected(SelectionEvent e) {
294
                boolean isShowNomenclaturalRef = showNomenclaturalRef.getSelection();
295
                PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE, isShowNomenclaturalRef);
296
             }
297
        });
298

    
299
       final Button showNomenclaturalStatus = new Button(child, SWT.CHECK);
300
       boolean isShowNomenclaturalStatus = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS);
301
       showNomenclaturalStatus.setText("Show nomenclatural status section");
302
       showNomenclaturalStatus.setSelection(isShowNomenclaturalStatus);
303
       showNomenclaturalStatus.addSelectionListener(new SelectionAdapter(){
304
            @Override
305
            public void widgetSelected(SelectionEvent e) {
306
                boolean isShowNomenclaturalStatus = showNomenclaturalStatus.getSelection();
307
                PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS, isShowNomenclaturalStatus);
308
             }
309
        });
310

    
311
       final Button showProtologue = new Button(child, SWT.CHECK);
312
       boolean isShowProtologue = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_PROTOLOGUE);
313
       showProtologue.setText("Show protologue section");
314
       showProtologue.setSelection(isShowProtologue);
315
       showProtologue.addSelectionListener(new SelectionAdapter(){
316
            @Override
317
            public void widgetSelected(SelectionEvent e) {
318
                boolean isShowProtologue = showProtologue.getSelection();
319
                PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_PROTOLOGUE, isShowProtologue);
320
             }
321
        });
322

    
323
       final Button showTypeDesignation = new Button(child, SWT.CHECK);
324
       boolean isShowTypeDesignation = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION);
325
       showTypeDesignation.setText("Show name type designation section");
326
       showTypeDesignation.setSelection(isShowTypeDesignation);
327
       showTypeDesignation.addSelectionListener(new SelectionAdapter(){
328
            @Override
329
            public void widgetSelected(SelectionEvent e) {
330
                boolean isShowTypeDesignation = showTypeDesignation.getSelection();
331
                PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION, isShowTypeDesignation);
332
             }
333
        });
334

    
335

    
336
       final Button showNameRelationship = new Button(child, SWT.CHECK);
337
       boolean isShowNameRelationship = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP);
338
       showNameRelationship.setText("Show name relationship section");
339
       showNameRelationship.setSelection(isShowNameRelationship);
340
       showNameRelationship.addSelectionListener(new SelectionAdapter(){
341
            @Override
342
            public void widgetSelected(SelectionEvent e) {
343
                boolean isShowNameRelationship = showNameRelationship.getSelection();
344
                PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP, isShowNameRelationship);
345
             }
346
        });
347

    
348
       if(isSimpleDetailsViewActivated){
349
           child.setEnabled(true);
350
       }else{
351
           child.setEnabled(false);
352
       }
353

    
354

    
355

    
356
       // Label emptyLabel = new Label(getFieldEditorParent(), 0);
357

    
358
//       addField(new BooleanFieldEditor(
359
//               IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION, "show simple (configurable) details", getFieldEditorParent()));
360
//       addField(new SpacerFieldEditor(getFieldEditorParent()));
361
//
362
//       addField(new BooleanFieldEditor(
363
//                IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_TAXON,
364
//                "show taxon section",
365
//                getFieldEditorParent()));
366
//
367
//       addField(new BooleanFieldEditor(
368
//               IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_CACHE,
369
//               "show name cache",
370
//               getFieldEditorParent()));
371
//
372
//       addField(new BooleanFieldEditor(
373
//                IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_LSID,
374
//                "show LSID of the name",
375
//                getFieldEditorParent()));
376
//
377
//
378
//       addField(new BooleanFieldEditor(
379
//                IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE,
380
//                "show nomenclatural code of the name",
381
//                getFieldEditorParent()));
382
//
383
//
384
//       addField(new BooleanFieldEditor(
385
//                IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE,
386
//                "show appended phrase",
387
//                getFieldEditorParent()));
388
//
389
//
390
//       addField(new BooleanFieldEditor(
391
//                IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_RANK,
392
//                "show rank of the name",
393
//                getFieldEditorParent()));
394
//
395
//
396
//       addField(new BooleanFieldEditor(
397
//                IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS,
398
//                "show atomised epithets of the name",
399
//                getFieldEditorParent()));
400
//
401
//       addField(new BooleanFieldEditor(
402
//                IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP,
403
//                "show authorship section",
404
//                getFieldEditorParent()));
405
//
406
//
407
//       addField(new BooleanFieldEditor(
408
//                IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE,
409
//                "show nomenclatural reference section",
410
//                getFieldEditorParent()));
411
//
412
//
413
//       addField( new BooleanFieldEditor(
414
//                IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS,
415
//                "show nomenclatural status section",
416
//                getFieldEditorParent()));
417
//
418
//
419
//       addField(new BooleanFieldEditor(
420
//                IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_PROTOLOGUE,
421
//                "show protologue section",
422
//                getFieldEditorParent()));
423
//
424
//
425
//       addField(new BooleanFieldEditor(
426
//                IPreferenceKeys.ALLOW_OVERRIDE_NAMEDETAILS,
427
//                "allow to use local preference",
428
//                getFieldEditorParent()));
429

    
430

    
431
    }
432

    
433

    
434

    
435
    protected IPreferenceStore doGetPreferenceStore() {
436
        return PreferencesUtil.getPreferenceStore();
437
    }
438

    
439
    /**
440
     * @return
441
     */
442
    private String[][] getLabelAndValues() {
443
        List<NomenclaturalCode> supportedCodes = NomenclaturalCodeHelper
444
                .getSupportedCodes();
445
        labelAndValues = new String[supportedCodes.size()][2];
446
        for (int i = 0; i < supportedCodes.size(); i++) {
447
            labelAndValues[i][0] = NomenclaturalCodeHelper
448
                    .getDescription(supportedCodes.get(i));
449
            labelAndValues[i][1] = PreferencesUtil
450
                    .getPreferenceKey(supportedCodes.get(i));
451
        }
452
        return labelAndValues;
453
    }
454
//    @Override
455
//    public boolean performOk() {
456
//       if (doGetPreferenceStore()== null){
457
//           setPreferenceStore(PreferencesUtil.getPreferenceStore());
458
//       }
459
//
460
//
461
//           String value =doGetPreferenceStore().getString(IPreferenceKeys.CDM_NOMENCLATURAL_CODE_KEY);
462
//           boolean allowOverride =  doGetPreferenceStore().getBoolean(IPreferenceKeys.ALLOW_OVERRIDE_NOMENCLATURAL_CODE_KEY);
463
//           CdmPreference pref = CdmPreference.NewDatabaseInstance( PreferencePredicate.NomenclaturalCode, value);
464
//           pref.setAllowOverride(allowOverride);
465
//           ICdmRepository controller = CdmStore.getCurrentApplicationConfiguration();
466
//           if (controller == null){
467
//               return false;
468
//           }
469
//           IPreferenceService service = controller.getPreferenceService();
470
//           service.set(pref);
471
//           createNameDetailsViewConfig();
472
//           value =config.toString();
473
//           allowOverride = doGetPreferenceStore().getBoolean(IPreferenceKeys.ALLOW_OVERRIDE_NAMEDETAILS);
474
//           pref = CdmPreference.NewDatabaseInstance( PreferencePredicate.NameDetailsView, value);
475
//           pref.setAllowOverride(allowOverride);
476
//           service.set(pref);
477
//
478
//       return true;
479
//   }
480

    
481
/**
482
     *
483
     */
484
    void createNameDetailsViewConfig() {
485
       config.setSimpleDetailsViewActivated(doGetPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION));
486
       config.setAppendedPhraseActivated(doGetPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE));
487
       config.setAtomisedEpithetsActivated(doGetPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS));
488
       config.setAuthorshipSectionActivated(doGetPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP));
489
       config.setLSIDActivated(doGetPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_LSID));
490
       config.setNameCacheActivated(doGetPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_CACHE));
491
       config.setNameRelationsSectionActivated(doGetPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP));
492
       config.setNomenclaturalCodeActived(doGetPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE));
493
       config.setNomenclaturalStatusSectionActivated(doGetPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS));
494
       config.setNomenclaturalReferenceSectionActivated(doGetPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE));
495
       config.setProtologueActivated(doGetPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_PROTOLOGUE));
496
       config.setRankActivated(doGetPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_RANK));
497
       config.setSimpleDetailsViewActivated(doGetPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION));
498
       config.setTaxonSectionActivated(doGetPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_TAXON));
499
       config.setTypeDesignationSectionActivated(doGetPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION));
500
    }
501

    
502
    public void createNomenclaturalCodeTab(Composite parent){
503
       composite = addTab("Nomenclatural Code");
504
       nomenclaturalCodeCombo = new Combo(composite, SWT.READ_ONLY);
505
      List<NomenclaturalCode> supportedCodes = NomenclaturalCodeHelper
506
              .getSupportedCodes();
507
       for (NomenclaturalCode code: supportedCodes) {
508
           nomenclaturalCodeCombo.add(NomenclaturalCodeHelper
509
                   .getDescription(code));
510

    
511
       }
512
       getLabelAndValues();
513
       nomenclaturalCodeCombo.addSelectionListener(new SelectionAdapter() {
514
           @Override
515
        public void widgetSelected(SelectionEvent evt) {
516

    
517
               String name = nomenclaturalCodeCombo.getText();
518
               String selectedPreferenceKey = null;
519
               for (String[] labelAndValue: labelAndValues){
520
                   if (labelAndValue[0].equals(name)){
521
                       selectedPreferenceKey = labelAndValue[1];
522
                   }
523
               }
524

    
525

    
526
               PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.CDM_NOMENCLATURAL_CODE_KEY, selectedPreferenceKey);
527

    
528
           }
529
       });
530
       nomenclaturalCodeLabel = new Label(composite, SWT.READ_ONLY);
531

    
532

    
533
        final Button useLocalPreference = new Button(composite, SWT.CHECK);
534
        boolean isUseLocalPreference = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ALLOW_OVERRIDE_NOMENCLATURAL_CODE_KEY);
535
        useLocalPreference.setText("allow to use local preference");
536
        useLocalPreference.setSelection(isUseLocalPreference);
537
        useLocalPreference.addSelectionListener(new SelectionAdapter(){
538
             @Override
539
             public void widgetSelected(SelectionEvent e) {
540
                 boolean isUseLocalPreference = useLocalPreference.getSelection();
541
                 PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ALLOW_OVERRIDE_NOMENCLATURAL_CODE_KEY, isUseLocalPreference);
542
              }
543
         });
544

    
545

    
546
   // Label emptyLabel = new Label(getFieldEditorParent(), 0);
547

    
548
 //   addField(new ComboFieldEditor(
549
//            IPreferenceKeys.CDM_NOMENCLATURAL_CODE_KEY,
550
//            "Choose which nomenclatural code you would like to use for scientific names unless otherwise specified.", getLabelAndValues(),
551
//            getFieldEditorParent()));
552
//
553
//
554
//    addField(new BooleanFieldEditor(
555
//            IPreferenceKeys.ALLOW_OVERRIDE_NOMENCLATURAL_CODE_KEY,
556
//            "allow to use local preference",
557
//            getFieldEditorParent()));
558
//    adjustGridLayout();
559

    
560
}
561

    
562

    
563

    
564
/**
565
 * {@inheritDoc}
566
 */
567
@Override
568
public boolean canFlipToNextPage() {
569
    // TODO Auto-generated method stub
570
    return false;
571
}
572

    
573

    
574

    
575
/**
576
 * {@inheritDoc}
577
 */
578
@Override
579
public String getName() {
580
    // TODO Auto-generated method stub
581
    return null;
582
}
583

    
584

    
585

    
586
/**
587
 * {@inheritDoc}
588
 */
589
@Override
590
public IWizardPage getNextPage() {
591
    // TODO Auto-generated method stub
592
    return null;
593
}
594

    
595

    
596

    
597
/**
598
 * {@inheritDoc}
599
 */
600
@Override
601
public IWizardPage getPreviousPage() {
602
    // TODO Auto-generated method stub
603
    return null;
604
}
605

    
606

    
607

    
608
/**
609
 * {@inheritDoc}
610
 */
611
@Override
612
public IWizard getWizard() {
613
    // TODO Auto-generated method stub
614
    return null;
615
}
616

    
617

    
618

    
619
/**
620
 * {@inheritDoc}
621
 */
622
@Override
623
public boolean isPageComplete() {
624

    
625
    return true;
626
}
627

    
628

    
629

    
630
/**
631
 * {@inheritDoc}
632
 */
633
@Override
634
public void setPreviousPage(IWizardPage page) {
635
    // TODO Auto-generated method stub
636

    
637
}
638

    
639

    
640

    
641
/**
642
 * {@inheritDoc}
643
 */
644
@Override
645
public void setWizard(IWizard newWizard) {
646
    // TODO Auto-generated method stub
647

    
648
}
649

    
650
/**
651
 * {@inheritDoc}
652
 */
653
@Override
654
public void createControl(Composite parent) {
655
    createNameDetailsConfiguration(parent);
656
    createNomenclaturalCodeTab(parent);
657
    setControl(parent);
658
}
659

    
660
/**
661
 * @return
662
 */
663
public NameDetailsConfigurator getConfig() {
664

    
665
    return config;
666
}
667

    
668

    
669

    
670

    
671

    
672

    
673

    
674
}
(1-1/8)