Merge branch 'release/4.6.0'
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / databaseAdmin / wizard / DatabasePreferencesPage.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.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.l10n.Messages;
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 CdmPreference preferedNomenclaturalCode;
45 NameDetailsConfigurator config ;
46 CdmPreference isRedListPreference;
47 CdmPreference determinationOnlyForFieldUnitsPreference;
48 CdmPreference showCollectingAreaInGeneralSectionPreference;
49 CdmPreference showTaxonAssociationsPreference;
50
51
52 TabFolder tabFolder;
53
54 IPreferenceStore preferenceStore;
55 Composite composite;
56 boolean isSimpleDetailsViewActivated;
57 Composite child ;
58
59 private Combo nomenclaturalCodeCombo;
60 private Label nomenclaturalCodeLabel;
61
62 // private UriWithLabelElement nomenclaturalCodeCombo;
63 // private Label nomenclaturalCodeLabel;
64
65 String[][] labelAndValues;
66
67 /*
68 *
69 */
70 public DatabasePreferencesPage(String pageName) {
71 super(pageName);
72 this.preferedNomenclaturalCode = PreferencesUtil.setPreferredNomenclaturalCode(null, false);
73 this.config = PreferencesUtil.setPreferredNameDetailsConfiguration( false);
74 setPreferenceStore(PreferencesUtil.getPreferenceStore());
75
76 }
77
78 protected void setPreferenceStore(IPreferenceStore store){
79 this.preferenceStore = store;
80 }
81
82
83
84
85 /***
86 * Adds a tab to the page.
87 * @param text the tab label
88 */
89 public Composite addTab(String text) {
90 if (tabFolder == null){
91 // initialize tab folder
92 if (composite == null) {
93 composite = new Composite(getShell(), SWT.NONE);
94 }
95 tabFolder = new TabFolder(composite, SWT.NONE);
96 tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
97 }
98
99 TabItem item = new TabItem(tabFolder, SWT.NONE);
100 item.setText(text);
101
102 Composite currentTab = new Composite(tabFolder, SWT.NULL);
103 GridLayout layout = new GridLayout();
104 currentTab.setLayout(layout);
105 currentTab.setFont(composite.getFont());
106 currentTab.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
107
108 item.setControl(currentTab);
109 return currentTab;
110 }
111
112 /**
113 * @param tabFolder
114 */
115 private void createNameDetailsConfiguration(Composite parent) {
116 if (composite == null){
117 composite = parent;
118 }
119 composite = addTab(Messages.DatabasePreferencesPage_details_view_configuration);
120 // TabItem tbtmNameDetailsConfiguration = new TabItem(tabFolder, SWT.NONE);
121 // Composite c2 = new Composite(tabFolder, SWT.BORDER);
122 // c2.setLayout(new GridLayout(1, true));
123 // tbtmNameDetailsConfiguration.setControl(c2);
124 // composite.setLayout(new GridLayout(1, true));
125 config = new NameDetailsConfigurator(true);
126
127 // Composite composite = new Composite(parent, SWT.NULL);
128 composite.setLayout(new GridLayout());
129
130 isSimpleDetailsViewActivated= PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION);
131 final Button activateCheckButton = new Button(composite, SWT.CHECK);
132 activateCheckButton.setText(Messages.DatabasePreferencesPage_show_only_simple_details_view);
133 activateCheckButton.setSelection(isSimpleDetailsViewActivated);
134 activateCheckButton.addSelectionListener(new SelectionAdapter(){
135 @Override
136 public void widgetSelected(SelectionEvent e) {
137 isSimpleDetailsViewActivated = activateCheckButton.getSelection();
138 PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION, isSimpleDetailsViewActivated);
139 if(isSimpleDetailsViewActivated){
140 child.setVisible(true);
141 child.setEnabled(true);
142 }else{
143 child.setVisible(false);
144 child.setEnabled(false);
145 }
146 }
147 });
148
149 child = new Composite(composite, SWT.NULL);
150 child.setLayout(new GridLayout());
151 child.setVisible(isSimpleDetailsViewActivated);
152
153 final Button showTaxon = new Button(child, SWT.CHECK);
154 boolean isShowTaxon = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_TAXON);
155 showTaxon.setText(Messages.DatabasePreferencesPage_show_taxon);
156 showTaxon.setSelection(isShowTaxon);
157 showTaxon.addSelectionListener(new SelectionAdapter(){
158 @Override
159 public void widgetSelected(SelectionEvent e) {
160 boolean isShowTaxon = showTaxon.getSelection();
161 PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_TAXON, isShowTaxon);
162 }
163 });
164
165 final Button showLsid = new Button(child, SWT.CHECK);
166 boolean isShowLSID = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_LSID);
167 showLsid.setText(Messages.DatabasePreferencesPage_show_lsid);
168 showLsid.setSelection(isShowLSID);
169 showLsid.addSelectionListener(new SelectionAdapter(){
170 @Override
171 public void widgetSelected(SelectionEvent e) {
172 boolean isShowLSID = showLsid.getSelection();
173 PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_LSID, isShowLSID);
174 }
175 });
176
177 final Button showNomenclaturalCode = new Button(child, SWT.CHECK);
178 boolean isShowNomenclaturalCode = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE);
179 showNomenclaturalCode.setText(Messages.DatabasePreferencesPage_show_nomenclatural_code);
180 showNomenclaturalCode.setSelection(isShowNomenclaturalCode);
181 showNomenclaturalCode.addSelectionListener(new SelectionAdapter(){
182 @Override
183 public void widgetSelected(SelectionEvent e) {
184 boolean isShowNomenclaturalCode = showNomenclaturalCode.getSelection();
185 PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE, isShowNomenclaturalCode);
186 }
187 });
188
189 final Button showNameCache = new Button(child, SWT.CHECK);
190 boolean isShowNameCache = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAMECACHE);
191 showNameCache.setText(Messages.DatabasePreferencesPage_show_namecache);
192 showNameCache.setSelection(isShowNomenclaturalCode);
193 showNameCache.addSelectionListener(new SelectionAdapter(){
194 @Override
195 public void widgetSelected(SelectionEvent e) {
196 boolean isShowNameCache = showNameCache.getSelection();
197 PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAMECACHE, isShowNameCache);
198 }
199 });
200 final Button showAppendedPhrase = new Button(child, SWT.CHECK);
201 boolean isShowAppendedPhrase = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE);
202 showAppendedPhrase.setText(Messages.DatabasePreferencesPage_show_appended_phrase);
203 showAppendedPhrase.setSelection(isShowAppendedPhrase);
204 showAppendedPhrase.addSelectionListener(new SelectionAdapter(){
205 @Override
206 public void widgetSelected(SelectionEvent e) {
207 boolean isShowAppendedPhrase = showAppendedPhrase.getSelection();
208 PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE, isShowAppendedPhrase);
209 }
210 });
211
212 final Button showRank = new Button(child, SWT.CHECK);
213 boolean isShowRank = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_RANK);
214 showRank.setText(Messages.DatabasePreferencesPage_show_rank);
215 showRank.setSelection(isShowRank);
216 showRank.addSelectionListener(new SelectionAdapter(){
217 @Override
218 public void widgetSelected(SelectionEvent e) {
219 boolean isShowRank = showRank.getSelection();
220 PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_RANK, isShowRank);
221 }
222 });
223 final Button showEpithets = new Button(child, SWT.CHECK);
224 boolean isShowEpithets = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS);
225 showEpithets.setText(Messages.DatabasePreferencesPage_show_atomised_epithets);
226 showEpithets.setSelection(isShowEpithets);
227 showEpithets.addSelectionListener(new SelectionAdapter(){
228 @Override
229 public void widgetSelected(SelectionEvent e) {
230 boolean isShowEpithets = showEpithets.getSelection();
231 PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS, isShowEpithets);
232 }
233 });
234 final Button showAuthorshipCache = new Button(child, SWT.CHECK);
235 boolean isShowAuthorshipCache = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP_CACHE);
236 showAuthorshipCache.setText(Messages.DatabasePreferencesPage_show_authorship_cache);
237 showAuthorshipCache.setSelection(isShowAuthorshipCache);
238 showAuthorshipCache.addSelectionListener(new SelectionAdapter(){
239 @Override
240 public void widgetSelected(SelectionEvent e) {
241 boolean isShowAuthorshipCache = showAuthorshipCache.getSelection();
242 PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP_CACHE, isShowAuthorshipCache);
243 }
244 });
245
246 final Button showAuthorship = new Button(child, SWT.CHECK);
247 boolean isShowAuthorship = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP);
248 showAuthorship.setText(Messages.DatabasePreferencesPage_show_author_section);
249 showAuthorship.setSelection(isShowAuthorship);
250 showAuthorship.addSelectionListener(new SelectionAdapter(){
251 @Override
252 public void widgetSelected(SelectionEvent e) {
253 boolean isShowAuthorship = showAuthorship.getSelection();
254 PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP, isShowAuthorship);
255 }
256 });
257
258 final Button showNomenclaturalRef = new Button(child, SWT.CHECK);
259 boolean isShowNomenclaturalRef = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE);
260 showNomenclaturalRef.setText(Messages.DatabasePreferencesPage_Show_nomenclatural_Ref);
261 showNomenclaturalRef.setSelection(isShowNomenclaturalRef);
262 showNomenclaturalRef.addSelectionListener(new SelectionAdapter(){
263 @Override
264 public void widgetSelected(SelectionEvent e) {
265 boolean isShowNomenclaturalRef = showNomenclaturalRef.getSelection();
266 PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE, isShowNomenclaturalRef);
267 }
268 });
269
270 final Button showNomenclaturalStatus = new Button(child, SWT.CHECK);
271 boolean isShowNomenclaturalStatus = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS);
272 showNomenclaturalStatus.setText(Messages.DatabasePreferencesPage_Show_nomenclaturalStatus);
273 showNomenclaturalStatus.setSelection(isShowNomenclaturalStatus);
274 showNomenclaturalStatus.addSelectionListener(new SelectionAdapter(){
275 @Override
276 public void widgetSelected(SelectionEvent e) {
277 boolean isShowNomenclaturalStatus = showNomenclaturalStatus.getSelection();
278 PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS, isShowNomenclaturalStatus);
279 }
280 });
281
282 final Button showProtologue = new Button(child, SWT.CHECK);
283 boolean isShowProtologue = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_PROTOLOGUE);
284 showProtologue.setText(Messages.DatabasePreferencesPage_Show_Protologue);
285 showProtologue.setSelection(isShowProtologue);
286 showProtologue.addSelectionListener(new SelectionAdapter(){
287 @Override
288 public void widgetSelected(SelectionEvent e) {
289 boolean isShowProtologue = showProtologue.getSelection();
290 PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_PROTOLOGUE, isShowProtologue);
291 }
292 });
293
294 final Button showTypeDesignation = new Button(child, SWT.CHECK);
295 boolean isShowTypeDesignation = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION);
296 showTypeDesignation.setText(Messages.DatabasePreferencesPage_Show_Type_designation);
297 showTypeDesignation.setSelection(isShowTypeDesignation);
298 showTypeDesignation.addSelectionListener(new SelectionAdapter(){
299 @Override
300 public void widgetSelected(SelectionEvent e) {
301 boolean isShowTypeDesignation = showTypeDesignation.getSelection();
302 PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION, isShowTypeDesignation);
303 }
304 });
305
306
307 final Button showNameRelationship = new Button(child, SWT.CHECK);
308 boolean isShowNameRelationship = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP);
309 showNameRelationship.setText(Messages.DatabasePreferencesPage_Show_NameRelations);
310 showNameRelationship.setSelection(isShowNameRelationship);
311 showNameRelationship.addSelectionListener(new SelectionAdapter(){
312 @Override
313 public void widgetSelected(SelectionEvent e) {
314 boolean isShowNameRelationship = showNameRelationship.getSelection();
315 PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP, isShowNameRelationship);
316 }
317 });
318
319 if(isSimpleDetailsViewActivated){
320 child.setEnabled(true);
321 }else{
322 child.setEnabled(false);
323 }
324
325
326
327 // Label emptyLabel = new Label(getFieldEditorParent(), 0);
328
329
330
331
332 }
333
334
335
336 protected IPreferenceStore doGetPreferenceStore() {
337 return PreferencesUtil.getPreferenceStore();
338 }
339
340 /**
341 * @return
342 */
343 private String[][] getLabelAndValues() {
344 List<NomenclaturalCode> supportedCodes = NomenclaturalCodeHelper
345 .getSupportedCodes();
346 labelAndValues = new String[supportedCodes.size()][2];
347 for (int i = 0; i < supportedCodes.size(); i++) {
348 labelAndValues[i][0] = NomenclaturalCodeHelper
349 .getDescription(supportedCodes.get(i));
350 labelAndValues[i][1] = PreferencesUtil
351 .getPreferenceKey(supportedCodes.get(i));
352 }
353 return labelAndValues;
354 }
355
356
357 /**
358 *
359 */
360 void createNameDetailsViewConfig() {
361 config.setSimpleDetailsViewActivated(doGetPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION));
362 config.setAppendedPhraseActivated(doGetPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE));
363 config.setAtomisedEpithetsActivated(doGetPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS));
364 config.setAuthorshipSectionActivated(doGetPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP));
365 config.setLSIDActivated(doGetPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_LSID));
366 config.setNameCacheActivated(doGetPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_CACHE));
367 config.setNameRelationsSectionActivated(doGetPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP));
368 config.setNomenclaturalCodeActived(doGetPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE));
369 config.setNomenclaturalStatusSectionActivated(doGetPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS));
370 config.setNomenclaturalReferenceSectionActivated(doGetPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE));
371 config.setProtologueActivated(doGetPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_PROTOLOGUE));
372 config.setRankActivated(doGetPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_RANK));
373 config.setSimpleDetailsViewActivated(doGetPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION));
374 config.setTaxonSectionActivated(doGetPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_TAXON));
375 config.setTypeDesignationSectionActivated(doGetPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION));
376 }
377
378 public void createNomenclaturalCodeTab(Composite parent){
379 composite = addTab(Messages.DatabasePreferencesPage_Define_Default_NomenclaturalCode);
380 nomenclaturalCodeCombo = new Combo(composite, SWT.READ_ONLY);
381 List<NomenclaturalCode> supportedCodes = NomenclaturalCodeHelper
382 .getSupportedCodes();
383 for (NomenclaturalCode code: supportedCodes) {
384 nomenclaturalCodeCombo.add(NomenclaturalCodeHelper
385 .getDescription(code));
386
387 }
388 getLabelAndValues();
389 //get the actual nomenclatural code and set it as selection: doGetPreferenceStore().getString(IPreferenceKeys.CDM_NOMENCLATURAL_CODE_KEY);
390 nomenclaturalCodeCombo.addSelectionListener(new SelectionAdapter() {
391 @Override
392 public void widgetSelected(SelectionEvent evt) {
393
394 String name = nomenclaturalCodeCombo.getText();
395 String selectedPreferenceKey = null;
396 for (String[] labelAndValue: labelAndValues){
397 if (labelAndValue[0].equals(name)){
398 selectedPreferenceKey = labelAndValue[1];
399 }
400 }
401
402
403 PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.CDM_NOMENCLATURAL_CODE_KEY, selectedPreferenceKey);
404
405 }
406 });
407 nomenclaturalCodeLabel = new Label(composite, SWT.READ_ONLY);
408
409
410 final Button useLocalPreference = new Button(composite, SWT.CHECK);
411 boolean isUseLocalPreference = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ALLOW_OVERRIDE_NOMENCLATURAL_CODE_KEY);
412 useLocalPreference.setText(Messages.DatabasePreferencesPage_UseLocalPreferences);
413 useLocalPreference.setSelection(isUseLocalPreference);
414 useLocalPreference.addSelectionListener(new SelectionAdapter(){
415 @Override
416 public void widgetSelected(SelectionEvent e) {
417 boolean isUseLocalPreference = useLocalPreference.getSelection();
418 PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ALLOW_OVERRIDE_NOMENCLATURAL_CODE_KEY, isUseLocalPreference);
419 }
420 });
421
422
423
424
425 }
426
427 public void createBiocaseProviderTab(Composite parent){
428 composite = addTab(Messages.DatabasePreferencesPage_Biocase_Provider);
429 nomenclaturalCodeCombo = new Combo(composite, SWT.READ_ONLY);
430 List<NomenclaturalCode> supportedCodes = NomenclaturalCodeHelper
431 .getSupportedCodes();
432 for (NomenclaturalCode code: supportedCodes) {
433 nomenclaturalCodeCombo.add(NomenclaturalCodeHelper
434 .getDescription(code));
435
436 }
437 getLabelAndValues();
438 //get the actual nomenclatural code and set it as selection: doGetPreferenceStore().getString(IPreferenceKeys.CDM_NOMENCLATURAL_CODE_KEY);
439 nomenclaturalCodeCombo.addSelectionListener(new SelectionAdapter() {
440 @Override
441 public void widgetSelected(SelectionEvent evt) {
442
443 String name = nomenclaturalCodeCombo.getText();
444 String selectedPreferenceKey = null;
445 for (String[] labelAndValue: labelAndValues){
446 if (labelAndValue[0].equals(name)){
447 selectedPreferenceKey = labelAndValue[1];
448 }
449 }
450
451
452 PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.CDM_NOMENCLATURAL_CODE_KEY, selectedPreferenceKey);
453
454 }
455 });
456 nomenclaturalCodeLabel = new Label(composite, SWT.READ_ONLY);
457
458
459 final Button useLocalPreference = new Button(composite, SWT.CHECK);
460 boolean isUseLocalPreference = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ALLOW_OVERRIDE_NOMENCLATURAL_CODE_KEY);
461 useLocalPreference.setText(Messages.DatabasePreferencesPage_UseLocalPreferences);
462 useLocalPreference.setSelection(isUseLocalPreference);
463 useLocalPreference.addSelectionListener(new SelectionAdapter(){
464 @Override
465 public void widgetSelected(SelectionEvent e) {
466 boolean isUseLocalPreference = useLocalPreference.getSelection();
467 PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ALLOW_OVERRIDE_NOMENCLATURAL_CODE_KEY, isUseLocalPreference);
468 }
469 });
470
471
472
473
474 }
475
476
477 public void createSpecimenOrObservationTab(Composite parent){
478 composite = addTab(Messages.DatabasePreferencesPage_Specimen_Or_Observation);
479
480 final Button showCollectingAreaInGeneralSectionButton = new Button(composite, SWT.CHECK);
481 boolean isShowCollectingAreaInGeneralSection = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_COLLECTING_AREAS_IN_GENERAL_SECTION);
482 showCollectingAreaInGeneralSectionButton.setText(Messages.DatabasePreferncesPage_Show_Collecting_Areas_in_general_section);
483 showCollectingAreaInGeneralSectionButton.setSelection(isShowCollectingAreaInGeneralSection);
484 showCollectingAreaInGeneralSectionButton.addSelectionListener(new SelectionAdapter(){
485 @Override
486 public void widgetSelected(SelectionEvent e) {
487 boolean isShowCollectingAreaInGeneralSection = showCollectingAreaInGeneralSectionButton.getSelection();
488 PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_COLLECTING_AREAS_IN_GENERAL_SECTION, isShowCollectingAreaInGeneralSection);
489 }
490 });
491
492 final Button determinationOnlyForFieldUnitsButton = new Button(composite, SWT.CHECK);
493 boolean isDeterminationOnlyForFieldUnits = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.DETERMINATION_ONLY_FOR_FIELD_UNITS);
494 determinationOnlyForFieldUnitsButton.setText(Messages.DatabasePreferncesPage_Determination_only_for_field_unnits);
495 determinationOnlyForFieldUnitsButton.setSelection(isDeterminationOnlyForFieldUnits);
496 determinationOnlyForFieldUnitsButton.addSelectionListener(new SelectionAdapter(){
497 @Override
498 public void widgetSelected(SelectionEvent e) {
499 boolean isDeterminationOnlyForFieldUnits = determinationOnlyForFieldUnitsButton.getSelection();
500 PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.DETERMINATION_ONLY_FOR_FIELD_UNITS, isDeterminationOnlyForFieldUnits);
501 }
502 });
503
504 final Button showTaxonAssociationButton = new Button(composite, SWT.CHECK);
505 boolean isShowTaxonAssociation = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_TAXON_ASSOCIATIONS);
506 showTaxonAssociationButton.setText(Messages.DatabasePreferncesPage_Taxon_Associations);
507 showTaxonAssociationButton.setSelection(isShowTaxonAssociation);
508 showTaxonAssociationButton.addSelectionListener(new SelectionAdapter(){
509 @Override
510 public void widgetSelected(SelectionEvent e) {
511 boolean isShowTaxonAssociation = showTaxonAssociationButton.getSelection();
512 PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_TAXON_ASSOCIATIONS, isShowTaxonAssociation);
513 }
514 });
515
516
517
518 }
519
520 /**
521 * {@inheritDoc}
522 */
523 @Override
524 public boolean canFlipToNextPage() {
525 // TODO Auto-generated method stub
526 return false;
527 }
528
529
530
531 /**
532 * {@inheritDoc}
533 */
534 @Override
535 public String getName() {
536 // TODO Auto-generated method stub
537 return null;
538 }
539
540
541
542 /**
543 * {@inheritDoc}
544 */
545 @Override
546 public IWizardPage getNextPage() {
547 // TODO Auto-generated method stub
548 return null;
549 }
550
551
552
553 /**
554 * {@inheritDoc}
555 */
556 @Override
557 public IWizardPage getPreviousPage() {
558 // TODO Auto-generated method stub
559 return null;
560 }
561
562
563
564 /**
565 * {@inheritDoc}
566 */
567 @Override
568 public IWizard getWizard() {
569 // TODO Auto-generated method stub
570 return null;
571 }
572
573
574
575 /**
576 * {@inheritDoc}
577 */
578 @Override
579 public boolean isPageComplete() {
580
581 return true;
582 }
583
584
585
586 /**
587 * {@inheritDoc}
588 */
589 @Override
590 public void setPreviousPage(IWizardPage page) {
591 // TODO Auto-generated method stub
592
593 }
594
595
596
597 /**
598 * {@inheritDoc}
599 */
600 @Override
601 public void setWizard(IWizard newWizard) {
602 // TODO Auto-generated method stub
603
604 }
605
606 /**
607 * {@inheritDoc}
608 */
609 @Override
610 public void createControl(Composite parent) {
611 createNameDetailsConfiguration(parent);
612 createNomenclaturalCodeTab(parent);
613
614 createSpecimenOrObservationTab(parent);
615 setControl(parent);
616 }
617
618 /**
619 * @return
620 */
621 public NameDetailsConfigurator getConfig() {
622
623 return config;
624 }
625
626
627
628
629
630
631
632 }