Project

General

Profile

« Previous | Next » 

Revision ab553c7a

Added by Katja Luther over 6 years ago

minor

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/wizard/DatabasePreferencesPage.java
1
// $Id$
2
/**
3
* Copyright (C) 2016 EDIT
4
* European Distributed Institute of Taxonomy
5
* http://www.e-taxonomy.eu
6
*
7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8
* See LICENSE.TXT at the top of this package for the full license terms.
9
*/
10
package eu.etaxonomy.taxeditor.databaseAdmin.wizard;
11

  
12
import java.util.List;
13

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

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

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

  
44

  
45

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

  
55
    private Combo nomenclaturalCodeCombo;
56

  
57
    private Label nomenclaturalCodeLabel;
58

  
59
    String[][] labelAndValues;
60

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

  
70
    }
71

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

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

  
87

  
88

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  
336

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

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

  
355

  
356

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

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

  
431

  
432
    }
433

  
434

  
435

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

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

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

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

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

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

  
526

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

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

  
533

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

  
546

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

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

  
561
}
562

  
563

  
564

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

  
574

  
575

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

  
585

  
586

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

  
596

  
597

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

  
607

  
608

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

  
618

  
619

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

  
626
    return true;
627
}
628

  
629

  
630

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

  
638
}
639

  
640

  
641

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

  
649
}
650

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

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

  
666
    return config;
667
}
668

  
669

  
670

  
671

  
672

  
673

  
674

  
675
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/wizard/DatabasePreferencesWizard.java
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 org.eclipse.jface.wizard.Wizard;
12

  
13
import eu.etaxonomy.cdm.api.application.ICdmApplicationConfiguration;
14
import eu.etaxonomy.cdm.api.service.IPreferenceService;
15
import eu.etaxonomy.cdm.model.metadata.CdmPreference;
16
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
17
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
18
import eu.etaxonomy.taxeditor.store.CdmStore;
19

  
20
/**
21
 * @author k.luther
22
 * @date 18.11.2016
23
 *
24
 */
25
public class DatabasePreferencesWizard extends Wizard {
26

  
27

  
28
    private final DatabasePreferencesPage preferencePage;
29

  
30

  
31
    public DatabasePreferencesWizard() {
32
        setWindowTitle("Database Preferences Wizard");
33

  
34
        preferencePage = new DatabasePreferencesPage("Nomenclatural Code");
35
       // preferencePage.setDescription("Choose which nomenclatural code you would like to use for scientific names unless otherwise specified.");
36
       // preferencePage.init(PlatformUI.getWorkbench());
37
    }
38

  
39

  
40

  
41
    /**
42
     * {@inheritDoc}
43
     */
44
    @Override
45
    public boolean performFinish() {
46

  
47
//       getPreferencePage().performOk();
48
        String value =getPreferencePage().doGetPreferenceStore().getString(IPreferenceKeys.CDM_NOMENCLATURAL_CODE_KEY);
49

  
50
        boolean allowOverride =  getPreferencePage().doGetPreferenceStore().getBoolean(IPreferenceKeys.ALLOW_OVERRIDE_NOMENCLATURAL_CODE_KEY);
51
        CdmPreference pref = CdmPreference.NewDatabaseInstance( PreferencePredicate.NomenclaturalCode, value);
52
        pref.setAllowOverride(allowOverride);
53

  
54
        ICdmApplicationConfiguration controller = CdmStore.getCurrentApplicationConfiguration();
55
        if (controller == null){
56
            return false;
57
        }
58
        IPreferenceService service = controller.getPreferenceService();
59
        service.set(pref);
60

  
61
        getPreferencePage().createNameDetailsViewConfig();
62
        value = getPreferencePage().getConfig().toString();
63
        allowOverride = getPreferencePage().doGetPreferenceStore().getBoolean(IPreferenceKeys.ALLOW_OVERRIDE_NAMEDETAILS);
64
        pref = CdmPreference.NewDatabaseInstance( PreferencePredicate.NameDetailsView, value);
65
        pref.setAllowOverride(allowOverride);
66
        service.set(pref);
67

  
68
        return true;
69
    }
70

  
71
    /**
72
     * @return the preferencePage
73
     */
74
    public DatabasePreferencesPage getPreferencePage() {
75
        return preferencePage;
76
    }
77

  
78
    @Override
79
    public void addPages() {
80
        addPage(preferencePage);
81
    }
82

  
83

  
84

  
85
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/wizard/DatabaseRepairSortIndexPage.java
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 org.eclipse.jface.wizard.WizardPage;
12
import org.eclipse.swt.SWT;
13
import org.eclipse.swt.events.SelectionAdapter;
14
import org.eclipse.swt.events.SelectionEvent;
15
import org.eclipse.swt.layout.GridLayout;
16
import org.eclipse.swt.widgets.Button;
17
import org.eclipse.swt.widgets.Composite;
18

  
19
import eu.etaxonomy.cdm.io.common.SortIndexUpdaterConfigurator;
20
import eu.etaxonomy.taxeditor.Messages;
21

  
22
/**
23
 * @author k.luther
24
 * @date 06.12.2016
25
 *
26
 */
27
public class DatabaseRepairSortIndexPage extends WizardPage {
28

  
29
    SortIndexUpdaterConfigurator config = null;
30
    /**
31
     * @param pageName
32
     */
33
    protected DatabaseRepairSortIndexPage(String pageName, SortIndexUpdaterConfigurator config){
34
        super(pageName);
35
        this.config = config;
36
        setMessage(Messages.DatabaseRepairPage_chooseParameter);
37
    }
38

  
39

  
40

  
41

  
42

  
43

  
44

  
45

  
46
    /**
47
     * {@inheritDoc}
48
     */
49
    @Override
50
    public void createControl(Composite parent) {
51
        final Composite composite = new Composite(parent, SWT.NULL);
52

  
53
        GridLayout gridLayout = new GridLayout();
54
        composite.setLayout(gridLayout);
55

  
56
        Button checkBoxTaxonNode = new Button(composite, SWT.CHECK);
57
        checkBoxTaxonNode.setSelection(config.isDoTaxonNode());
58
        checkBoxTaxonNode.setText(Messages.DatabaseRepairPage_updateTaxonNodes);
59
        checkBoxTaxonNode
60
                .setToolTipText(Messages.DatabaseRepairPage_toolTip_taxonNode);
61
        checkBoxTaxonNode.addSelectionListener(new SelectionAdapter() {
62
            @Override
63
            public void widgetSelected(SelectionEvent e) {
64
                config.setDoTaxonNode(!config.isDoTaxonNode());
65
            }
66
        });
67

  
68
        Button checkBoxPolytomousKeyNode = new Button(composite, SWT.CHECK);
69
        checkBoxPolytomousKeyNode.setSelection(config.isDoPolytomousKeyNode());
70
        checkBoxPolytomousKeyNode.setText(Messages.DatabaseRepairPage_PolytomousKeyNode);
71
        checkBoxPolytomousKeyNode
72
        .setToolTipText(Messages.DatabaseRepairPage_toolTip_polytomousKeyNode);
73
        checkBoxPolytomousKeyNode.addSelectionListener(new SelectionAdapter() {
74
            @Override
75
            public void widgetSelected(SelectionEvent e) {
76
                config.setDoPolytomousKeyNode(!config.isDoPolytomousKeyNode());
77
            }
78
        });
79

  
80
        Button checkBoxFeatureNode = new Button(composite, SWT.CHECK);
81
        checkBoxFeatureNode.setSelection(config.isDoFeatureNode());
82
        checkBoxFeatureNode.setText(Messages.DatabaseRepairPage_featureNodes);
83
        checkBoxFeatureNode
84
        .setToolTipText(Messages.DatabaseRepairPage_toolTipFeatureNodes);
85
        checkBoxFeatureNode.addSelectionListener(new SelectionAdapter() {
86
            @Override
87
            public void widgetSelected(SelectionEvent e) {
88
                config.setDoFeatureNode(!config.isDoFeatureNode());
89
            }
90
        });
91

  
92

  
93

  
94
        setControl(composite);
95

  
96
    }
97

  
98

  
99

  
100
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/wizard/DatabaseRepairTitleCacheUpdatePage.java
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.wizard.WizardPage;
14
import org.eclipse.swt.SWT;
15
import org.eclipse.swt.events.SelectionAdapter;
16
import org.eclipse.swt.events.SelectionEvent;
17
import org.eclipse.swt.layout.GridLayout;
18
import org.eclipse.swt.widgets.Button;
19
import org.eclipse.swt.widgets.Composite;
20

  
21
import eu.etaxonomy.cdm.io.common.CacheUpdaterConfigurator;
22
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
23
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
24
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
25
import eu.etaxonomy.taxeditor.Messages;
26

  
27
/**
28
 * @author k.luther
29
 * @date 13.12.2016
30
 *
31
 */
32
public class DatabaseRepairTitleCacheUpdatePage extends WizardPage {
33

  
34
    CacheUpdaterConfigurator config;
35

  
36
    /**
37
     * @param pageName
38
     * @param configTitleCache
39
     */
40
    protected DatabaseRepairTitleCacheUpdatePage(String pageName, CacheUpdaterConfigurator configTitleCache) {
41
        super(pageName);
42
        config = configTitleCache;
43

  
44
    }
45

  
46
    /**
47
     * {@inheritDoc}
48
     */
49
    @Override
50
    public void createControl(Composite parent) {
51
        final Composite composite = new Composite(parent, SWT.NULL);
52

  
53
        GridLayout gridLayout = new GridLayout();
54
        composite.setLayout(gridLayout);
55

  
56
        setControl(composite);
57

  
58
        Button checkBoxZoologicalName = new Button(composite, SWT.CHECK);
59
        checkBoxZoologicalName.setSelection(config.getClassList().contains(TaxonBase.class));
60
        checkBoxZoologicalName.setText(Messages.DatabaseRepairPage_TaxonBase);
61
        checkBoxZoologicalName
62
        .setToolTipText(Messages.DatabaseRepairPage_toolTip_taxonBase);
63
        checkBoxZoologicalName.addSelectionListener(new SelectionAdapter() {
64
            @Override
65
            public void widgetSelected(SelectionEvent e) {
66
                List<Class<? extends IdentifiableEntity>> classList  = config.getClassList();
67
                classList.add(TaxonBase.class);
68
            }
69
        });
70

  
71

  
72

  
73

  
74

  
75

  
76

  
77

  
78

  
79
                Button checkBoxTaxonName = new Button(composite, SWT.CHECK);
80
                checkBoxTaxonName.setSelection(config.getClassList().contains(TaxonNameBase.class));
81
                checkBoxTaxonName.setText(Messages.DatabaseRepairPage_updateTaxonName);
82
                checkBoxTaxonName
83
                        .setToolTipText(Messages.DatabaseRepairPage_toolTip_TaxonName);
84
                checkBoxTaxonName.addSelectionListener(new SelectionAdapter() {
85
                    @Override
86
                    public void widgetSelected(SelectionEvent e) {
87
                        List<Class<? extends IdentifiableEntity>> classList = config.getClassList();
88
                        classList.add(TaxonNameBase.class);
89
                    }
90
                });
91

  
92

  
93
    }
94

  
95
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/wizard/DatabaseRepairWizard.java
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 org.eclipse.core.runtime.jobs.Job;
12
import org.eclipse.jface.wizard.Wizard;
13

  
14
import eu.etaxonomy.cdm.config.ICdmSource;
15
import eu.etaxonomy.cdm.io.common.CacheUpdaterConfigurator;
16
import eu.etaxonomy.cdm.io.common.SortIndexUpdaterConfigurator;
17
import eu.etaxonomy.taxeditor.store.CdmStore;
18

  
19
/**
20
 * @author k.luther
21
 * @date 06.12.2016
22
 *
23
 */
24
public class DatabaseRepairWizard extends Wizard {
25
   // private final DatabaseRepairSortIndexPage repairSortIndexPage;
26
    private final Test test;
27
    SortIndexUpdaterConfigurator config;
28
    CacheUpdaterConfigurator cacheUpdaterConfig;
29

  
30

  
31

  
32
    public DatabaseRepairWizard() {
33
        setWindowTitle("Database Repair Wizard");
34
        config = SortIndexUpdaterConfigurator.NewInstance(null);
35
       // repairSortIndexPage = new DatabaseRepairSortIndexPage("SortIndex Repair",config);
36
        cacheUpdaterConfig = CacheUpdaterConfigurator.NewInstance(null);
37
        test = new Test("Test", cacheUpdaterConfig, config);
38

  
39
    }
40

  
41
    /**
42
     * {@inheritDoc}
43
     */
44
    @Override
45
    public boolean performFinish() {
46

  
47
            if (config == null){
48
                ICdmSource source= CdmStore.getActiveCdmSource();
49
                config = SortIndexUpdaterConfigurator.NewInstance(null);
50
                config.setDoFeatureNode(false);
51
                config.setDoPolytomousKeyNode(false);
52

  
53
             }
54
            if (config.isDoFeatureNode() || config.isDoPolytomousKeyNode() || config.isDoTaxonNode()){
55
                Job updateJob = CdmStore.getImportManager().createIOServiceJob(config);
56
                CdmStore.getImportManager().run(updateJob);
57
            }
58
            if (!cacheUpdaterConfig.getClassList().isEmpty()){
59
                Job updateJob2 = CdmStore.getImportManager().createIOServiceJob(cacheUpdaterConfig);
60
                CdmStore.getImportManager().run(updateJob2);
61
            }
62

  
63

  
64

  
65
        return true;
66
    }
67

  
68
    @Override
69
    public void addPages() {
70
       //addPage(repairSortIndexPage);
71
        addPage(test);
72
    }
73

  
74

  
75
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/wizard/PreferencesConfigurator.java
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 eu.etaxonomy.cdm.model.metadata.CdmPreference;
12
import eu.etaxonomy.taxeditor.preference.NameDetailsConfigurator;
13

  
14
/**
15
 * @author k.luther
16
 * @date 16.12.2016
17
 *
18
 */
19
public class PreferencesConfigurator {
20

  
21
    private CdmPreference nomenclaturalCodePreference;
22

  
23
    private NameDetailsConfigurator nameDetailsConfigurator;
24

  
25

  
26

  
27

  
28
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/wizard/SpacerFieldEditor.java
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 org.eclipse.jface.preference.FieldEditor;
12
import org.eclipse.swt.widgets.Composite;
13

  
14
/**
15
 * @author k.luther
16
 * @date 19.12.2016
17
 *
18
 */
19
public class SpacerFieldEditor extends FieldEditor {
20
        public SpacerFieldEditor(Composite parent) {
21
            super("", "", parent);
22
        }
23

  
24
        @Override
25
        protected void adjustForNumColumns(int numColumns) {
26
            // do nothing
27
        }
28

  
29
        @Override
30
        protected void doFillIntoGrid(Composite parent, int numColumns) {
31
            getLabelControl(parent);
32
        }
33

  
34
        @Override
35
        protected void doLoad() {
36
            // do nothing
37
        }
38

  
39
        @Override
40
        protected void doLoadDefault() {
41
            // do nothing
42
        }
43

  
44
        @Override
45
        protected void doStore() {
46
            // do nothing
47
        }
48

  
49
        @Override
50
        public int getNumberOfControls() {
51
            return 0;
52
        }
53

  
54

  
55

  
56
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/wizard/Test.java
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.wizard.WizardPage;
14
import org.eclipse.swt.SWT;
15
import org.eclipse.swt.events.SelectionAdapter;
16
import org.eclipse.swt.events.SelectionEvent;
17
import org.eclipse.swt.layout.FillLayout;
18
import org.eclipse.swt.layout.GridLayout;
19
import org.eclipse.swt.widgets.Button;
20
import org.eclipse.swt.widgets.Composite;
21
import org.eclipse.swt.widgets.TabFolder;
22
import org.eclipse.swt.widgets.TabItem;
23

  
24
import eu.etaxonomy.cdm.io.common.CacheUpdaterConfigurator;
25
import eu.etaxonomy.cdm.io.common.SortIndexUpdaterConfigurator;
26
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
27
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
28
import eu.etaxonomy.cdm.model.reference.Reference;
29
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
30
import eu.etaxonomy.taxeditor.Messages;
31

  
32
/**
33
 * @author k.luther
34
 * @date 14.12.2016
35
 *
36
 */
37
public class Test extends WizardPage {
38

  
39
    CacheUpdaterConfigurator config;
40
    SortIndexUpdaterConfigurator sortIndexConfig;
41
    public Test(String pageName, CacheUpdaterConfigurator configTitleCache, SortIndexUpdaterConfigurator sortIndexConfig) {
42
        super(pageName);
43
        config = configTitleCache;
44
        this.sortIndexConfig = sortIndexConfig;
45
    }
46

  
47
    /**
48
     * {@inheritDoc}
49
     */
50
    @Override
51
    public void createControl(Composite parent) {
52

  
53

  
54
            Composite container = new Composite(parent, SWT.NULL);
55
            setControl(container);
56
            container.setLayout(new FillLayout(SWT.HORIZONTAL));
57

  
58
            TabFolder tabFolder = new TabFolder(container, SWT.NONE);
59

  
60
            TabItem tbtmSortIndex = new TabItem(tabFolder, SWT.NONE);
61
            tbtmSortIndex.setText("Sort Index");
62

  
63
            Composite composite = new Composite(tabFolder, SWT.NONE);
64
            tbtmSortIndex.setControl(composite);
65
            composite.setLayout(new GridLayout(1, true));
66

  
67
            Button checkBoxTaxonNode = new Button(composite, SWT.CHECK);
68
            checkBoxTaxonNode.setSelection(sortIndexConfig.isDoTaxonNode());
69
            checkBoxTaxonNode.setText(Messages.DatabaseRepairPage_updateTaxonNodes);
70
            checkBoxTaxonNode
71
                    .setToolTipText(Messages.DatabaseRepairPage_toolTip_taxonNode);
72
            checkBoxTaxonNode.addSelectionListener(new SelectionAdapter() {
73
                @Override
74
                public void widgetSelected(SelectionEvent e) {
75
                    sortIndexConfig.setDoTaxonNode(!sortIndexConfig.isDoTaxonNode());
76
                }
77
            });
78

  
79
            Button checkBoxPolytomousKeyNode = new Button(composite, SWT.CHECK);
80
            checkBoxPolytomousKeyNode.setSelection(sortIndexConfig.isDoPolytomousKeyNode());
81
            checkBoxPolytomousKeyNode.setText(Messages.DatabaseRepairPage_PolytomousKeyNode);
82
            checkBoxPolytomousKeyNode
83
            .setToolTipText(Messages.DatabaseRepairPage_toolTip_polytomousKeyNode);
84
            checkBoxPolytomousKeyNode.addSelectionListener(new SelectionAdapter() {
85
                @Override
86
                public void widgetSelected(SelectionEvent e) {
87
                    sortIndexConfig.setDoPolytomousKeyNode(!sortIndexConfig.isDoPolytomousKeyNode());
88
                }
89
            });
90

  
91
            Button checkBoxFeatureNode = new Button(composite, SWT.CHECK);
92
            checkBoxFeatureNode.setSelection(sortIndexConfig.isDoFeatureNode());
93
            checkBoxFeatureNode.setText(Messages.DatabaseRepairPage_featureNodes);
94
            checkBoxFeatureNode
95
            .setToolTipText(Messages.DatabaseRepairPage_toolTipFeatureNodes);
96
            checkBoxFeatureNode.addSelectionListener(new SelectionAdapter() {
97
                @Override
98
                public void widgetSelected(SelectionEvent e) {
99
                    sortIndexConfig.setDoFeatureNode(!sortIndexConfig.isDoFeatureNode());
100
                }
101
            });
102

  
103

  
104
            TabItem tbtmNewItem = new TabItem(tabFolder, SWT.NONE);
105
            tbtmNewItem.setText("Update Caches");
106

  
107
            Composite composite_1 = new Composite(tabFolder, SWT.NONE);
108
            tbtmNewItem.setControl(composite_1);
109
            composite_1.setLayout(new GridLayout(1, false));
110

  
111
            Button checkBoxTaxonName = new Button(composite_1, SWT.CHECK);
112
            checkBoxTaxonName.setSelection(config.getClassList().contains(TaxonNameBase.class));
113
            checkBoxTaxonName.setText(Messages.DatabaseRepairPage_updateTaxonName);
114
            checkBoxTaxonName
115
                    .setToolTipText(Messages.DatabaseRepairPage_toolTip_TaxonName);
116
            checkBoxTaxonName.addSelectionListener(new SelectionAdapter() {
117
                @Override
118
                public void widgetSelected(SelectionEvent e) {
119
                    List<Class<? extends IdentifiableEntity>> classList = config.getClassList();
120
                    classList.add(TaxonNameBase.class);
121
                }
122
            });
123

  
124
            Button checkBoxTaxonBase = new Button(composite_1, SWT.CHECK);
125
            checkBoxTaxonBase.setSelection(config.getClassList().contains(TaxonBase.class));
126
            checkBoxTaxonBase.setText(Messages.DatabaseRepairPage_TaxonBase);
127
            checkBoxTaxonBase
128
            .setToolTipText(Messages.DatabaseRepairPage_toolTip_taxonBase);
129
            checkBoxTaxonBase.addSelectionListener(new SelectionAdapter() {
130
                @Override
131
                public void widgetSelected(SelectionEvent e) {
132
                    List<Class<? extends IdentifiableEntity>> classList  = config.getClassList();
133
                    classList.add(TaxonBase.class);
134
                }
135
            });
136

  
137
            Button checkBoxReference = new Button(composite_1, SWT.CHECK);
138
            checkBoxReference.setSelection(config.getClassList().contains(Reference.class));
139
            checkBoxReference.setText(Messages.DatabaseRepairPage_Reference);
140
            checkBoxReference
141
            .setToolTipText(Messages.DatabaseRepairPage_toolTip_reference);
142
            checkBoxReference.addSelectionListener(new SelectionAdapter() {
143
                @Override
144
                public void widgetSelected(SelectionEvent e) {
145
                    List<Class<? extends IdentifiableEntity>> classList  = config.getClassList();
146
                    classList.add(Reference.class);
147
                }
148
            });
149

  
150

  
151
            tabFolder.pack();
152
    }
153
}

Also available in: Unified diff