Merge branch 'release/5.9.0'
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / preference / SpecimenOrObservationPreferences.java
1 /**
2 * Copyright (C) 2014 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.preference;
10
11 import org.eclipse.swt.SWT;
12 import org.eclipse.swt.events.SelectionAdapter;
13 import org.eclipse.swt.events.SelectionEvent;
14 import org.eclipse.swt.events.SelectionListener;
15 import org.eclipse.swt.layout.GridData;
16 import org.eclipse.swt.widgets.Button;
17 import org.eclipse.swt.widgets.Combo;
18 import org.eclipse.swt.widgets.Composite;
19 import org.eclipse.swt.widgets.Control;
20 import org.eclipse.swt.widgets.Label;
21
22 import eu.etaxonomy.cdm.model.metadata.CdmPreference;
23 import eu.etaxonomy.cdm.model.metadata.CdmPreference.PrefKey;
24 import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
25 import eu.etaxonomy.cdm.model.metadata.PreferenceSubject;
26 import eu.etaxonomy.taxeditor.l10n.Messages;
27 import eu.etaxonomy.taxeditor.preference.menu.CdmPreferencePage;
28 import eu.etaxonomy.taxeditor.store.CdmStore;
29
30 /**
31 * @author pplitzner
32 * @date 13.02.2014
33 *
34 */
35 public class SpecimenOrObservationPreferences extends CdmPreferencePage implements SelectionListener{
36
37 private static final String LOCAL_SETTINGS_NOT_ALLOWED = Messages.SpecimenOrObservationPreferences_0;
38 private static final String DESCRIPTION = Messages.SpecimenOrObservationPreferences_1;
39
40 protected Boolean isShowSpecimenRelatedIssues;
41 protected boolean allowOverrideShowSpecimenRelatedIssues;
42 protected boolean overrideShowSpecimenRelatedIssues;
43 protected Boolean isShowCollectingAreaInGeneralSection;
44 protected boolean allowOverrideShowCollectingAreaInGeneralSection;
45 protected boolean overrideShowCollectionAreaInGeneralSection;
46 protected Boolean isDeterminationOnlyForFieldUnits;
47 protected boolean allowOverrideDeterminationOnlyForFieldUnits;
48 protected boolean overrideDeterminationOnlyForFieldUnits;
49 protected Boolean isShowTaxonAssociation;
50 protected boolean allowOverrideShowTaxonAssociation;
51 protected boolean overrideShowTaxonAssociation;
52 protected Boolean isShowLifeForm;
53 protected boolean allowOverrideShowLifeForm;
54 protected boolean overrideShowLifeForm;
55 Composite composite;
56
57 protected Combo showSpecimenButton;
58 protected Button allowOverrideIsShowSpecimenRelatedIssuesButton;
59 protected Combo showCollectingAreaInGeneralSectionButton;
60 protected Button allowOverrideShowCollectingAreaButton;
61 protected Combo determinationOnlyForFieldUnitsButton;
62 protected Button allowOverridesDeterminationOnlyForFieldUnitsButton;
63 protected Combo showTaxonAssociationButton;
64 protected Button allowOverrideIsShowTaxonAssociationButton;
65 protected Button allowOverrideShowLifeFormButton;
66 protected Combo showLifeFormButton;
67
68 CdmPreference showSpecimenPref;
69 CdmPreference showCollectingAreaInGeneralSection;
70 CdmPreference showDeterminationOnlyForFieldUnits;
71 CdmPreference showTaxonAssociation;
72 CdmPreference showLifeForm;
73
74 @Override
75 public void init() {
76 super.init();
77 // setPreferenceStore(PreferencesUtil.getPreferenceStore());
78 if(!CdmStore.isActive()){
79 return;
80 }
81
82
83 }
84
85 /**
86 * {@inheritDoc}
87 */
88 @Override
89 protected Control createContents(Composite parent) {
90 getValues();
91
92 boolean isEditingAllowed = true;
93 if(!isAdminPreference){
94 CdmPreferenceCache cache = CdmPreferenceCache.instance();
95
96 if (showSpecimenPref != null){
97 if (!showSpecimenPref.isAllowOverride() ){
98 isEditingAllowed = false;
99 }
100 }
101 }
102 if (isEditingAllowed){
103 Label label = new Label(parent, SWT.NONE);
104 label.setText(DESCRIPTION);
105 }else{
106 Label label = new Label(parent, SWT.NONE);
107 label.setText(LOCAL_SETTINGS_NOT_ALLOWED);
108 this.noDefaultAndApplyButton();
109 return parent;
110 }
111 Composite titleComp = createComposite(parent);
112 GridData gridData = createTextGridData();
113
114 Label separator= new Label(titleComp, SWT.HORIZONTAL | SWT.SEPARATOR);
115 separator.setLayoutData(gridData);
116 separator.setVisible(false);
117 showSpecimenButton = createBooleanCombo(titleComp, Messages.GeneralPreference_yes, Messages.GeneralPreference_no, PreferencePredicate.ShowSpecimen, Messages.DatabasePreferncesPage_Show_Specimen, isAdminPreference);
118
119 showSpecimenButton.addSelectionListener(this);
120 int index = 0;
121 for (String itemLabel : showSpecimenButton.getItems()) {
122 if (isShowSpecimenRelatedIssues == null && itemLabel.startsWith(Messages.Preference_Use_Default)) {
123 showSpecimenButton.select(index);
124 break;
125 }
126 if (isShowSpecimenRelatedIssues != null && itemLabel.equals(Messages.GeneralPreference_yes) && isShowSpecimenRelatedIssues){
127 showSpecimenButton.select(index);
128 break;
129 }
130 if (isShowSpecimenRelatedIssues != null && itemLabel.equals(Messages.GeneralPreference_no) && !isShowSpecimenRelatedIssues){
131 showSpecimenButton.select(index);
132 break;
133 }
134 index++;
135 }
136 showSpecimenButton.setEnabled(isEditingAllowed);
137
138 if (isAdminPreference){
139 allowOverrideIsShowSpecimenRelatedIssuesButton = createAllowOverrideButton(titleComp);
140 allowOverrideIsShowSpecimenRelatedIssuesButton.setSelection(allowOverrideShowSpecimenRelatedIssues);
141 // allowOverrideIsShowSpecimenRelatedIssuesButton.setEnabled(isShowSpecimenRelatedIssues != null);
142 allowOverrideIsShowSpecimenRelatedIssuesButton.addSelectionListener(new SelectionAdapter(){
143 @Override
144 public void widgetSelected(SelectionEvent e) {
145 setApply(true);
146 allowOverrideShowSpecimenRelatedIssues = allowOverrideIsShowSpecimenRelatedIssuesButton.getSelection();
147 }
148 });
149 }
150
151 composite = createComposite(parent);
152 //composite.setEnabled(isShowSpecimenRelatedIssues);
153 gridData = createTextGridData();
154
155 separator= new Label(composite, SWT.HORIZONTAL | SWT.SEPARATOR);
156 separator.setLayoutData(gridData);
157
158 showCollectingAreaInGeneralSectionButton = createBooleanCombo(composite, Messages.GeneralPreference_yes, Messages.GeneralPreference_no, PreferencePredicate.ShowCollectingAreasInGeneralSection, Messages.DatabasePreferncesPage_Show_Collecting_Areas_in_general_section, isAdminPreference);
159
160 showCollectingAreaInGeneralSectionButton.addSelectionListener(this);
161 index = 0;
162 for (String itemLabel : showCollectingAreaInGeneralSectionButton.getItems()) {
163 if (isShowCollectingAreaInGeneralSection == null && itemLabel.startsWith(Messages.Preference_Use_Default)) {
164 showCollectingAreaInGeneralSectionButton.select(index);
165 break;
166 }
167 if (isShowCollectingAreaInGeneralSection != null && itemLabel.equals(Messages.GeneralPreference_yes) && isShowCollectingAreaInGeneralSection){
168 showCollectingAreaInGeneralSectionButton.select(index);
169 break;
170 }
171 if (isShowCollectingAreaInGeneralSection != null && itemLabel.equals(Messages.GeneralPreference_no) && !isShowCollectingAreaInGeneralSection){
172 showCollectingAreaInGeneralSectionButton.select(index);
173 break;
174 }
175 index++;
176 }
177 if (isAdminPreference){
178 allowOverrideShowCollectingAreaButton = createAllowOverrideButton(composite);
179 allowOverrideShowCollectingAreaButton.setSelection(allowOverrideShowCollectingAreaInGeneralSection);
180 // allowOverrideShowCollectingAreaButton.setEnabled(isShowCollectingAreaInGeneralSection != null);
181 allowOverrideShowCollectingAreaButton.addSelectionListener(new SelectionAdapter(){
182 @Override
183 public void widgetSelected(SelectionEvent e) {
184 setApply(true);
185 allowOverrideShowCollectingAreaInGeneralSection = allowOverrideShowCollectingAreaButton.getSelection();
186 }
187 });
188 }
189 isEditingAllowed = true;
190 if (showCollectingAreaInGeneralSection != null && !showCollectingAreaInGeneralSection.isAllowOverride() ){
191 isEditingAllowed = false;
192 }
193 showCollectingAreaInGeneralSectionButton.setEnabled(isEditingAllowed);
194 determinationOnlyForFieldUnitsButton = createBooleanCombo(composite, Messages.GeneralPreference_yes, Messages.GeneralPreference_no, PreferencePredicate.DeterminationOnlyForFieldUnits, Messages.DatabasePreferncesPage_Determination_only_for_field_unnits, isAdminPreference);
195
196
197 determinationOnlyForFieldUnitsButton.addSelectionListener(this);
198 index = 0;
199 for (String itemLabel : determinationOnlyForFieldUnitsButton.getItems()) {
200 if (isDeterminationOnlyForFieldUnits == null && itemLabel.startsWith(Messages.Preference_Use_Default)) {
201 determinationOnlyForFieldUnitsButton.select(index);
202 break;
203 }
204 if (isDeterminationOnlyForFieldUnits != null && itemLabel.equals(Messages.GeneralPreference_yes) && isDeterminationOnlyForFieldUnits){
205 determinationOnlyForFieldUnitsButton.select(index);
206 break;
207 }
208 if (isDeterminationOnlyForFieldUnits != null && itemLabel.equals(Messages.GeneralPreference_no) && !isDeterminationOnlyForFieldUnits){
209 determinationOnlyForFieldUnitsButton.select(index);
210 break;
211 }
212 index++;
213 }
214 isEditingAllowed = true;
215 if (showDeterminationOnlyForFieldUnits != null && !showDeterminationOnlyForFieldUnits.isAllowOverride() ){
216 isEditingAllowed = false;
217 }
218
219 determinationOnlyForFieldUnitsButton.setEnabled(isEditingAllowed);
220 if (isAdminPreference){
221 allowOverridesDeterminationOnlyForFieldUnitsButton = createAllowOverrideButton(composite);
222 allowOverridesDeterminationOnlyForFieldUnitsButton.setSelection(allowOverrideDeterminationOnlyForFieldUnits);
223 // allowOverridesDeterminationOnlyForFieldUnitsButton.setEnabled(showDeterminationOnlyForFieldUnits != null);
224 allowOverridesDeterminationOnlyForFieldUnitsButton.addSelectionListener(new SelectionAdapter(){
225 @Override
226 public void widgetSelected(SelectionEvent e) {
227 setApply(true);
228 allowOverrideDeterminationOnlyForFieldUnits = allowOverridesDeterminationOnlyForFieldUnitsButton.getSelection();
229 }
230 });
231 }
232
233 showTaxonAssociationButton =createBooleanCombo(composite, Messages.GeneralPreference_yes, Messages.GeneralPreference_no, PreferencePredicate.ShowTaxonAssociations, Messages.DatabasePreferncesPage_Taxon_Associations, isAdminPreference);
234
235
236 showTaxonAssociationButton.addSelectionListener(this);
237 index = 0;
238 for (String itemLabel : showTaxonAssociationButton.getItems()) {
239 if (isShowTaxonAssociation == null && itemLabel.startsWith(Messages.Preference_Use_Default)) {
240 showTaxonAssociationButton.select(index);
241 break;
242 }
243 if (isShowTaxonAssociation != null && itemLabel.equals(Messages.GeneralPreference_yes) && isShowTaxonAssociation){
244 showTaxonAssociationButton.select(index);
245 break;
246 }
247 if (isShowTaxonAssociation != null && itemLabel.equals(Messages.GeneralPreference_no) && !isShowTaxonAssociation){
248 showTaxonAssociationButton.select(index);
249 break;
250 }
251 index++;
252 }
253 isEditingAllowed = true;
254 if (showTaxonAssociation != null && !showTaxonAssociation.isAllowOverride() ){
255 isEditingAllowed = false;
256 }
257 showTaxonAssociationButton.setEnabled(isEditingAllowed);
258 if (isAdminPreference){
259 allowOverrideIsShowTaxonAssociationButton = createAllowOverrideButton(composite);
260 allowOverrideIsShowTaxonAssociationButton.setSelection(allowOverrideShowTaxonAssociation);
261 // allowOverrideIsShowTaxonAssociationButton.setEnabled(showTaxonAssociation != null);
262 allowOverrideIsShowTaxonAssociationButton.addSelectionListener(new SelectionAdapter(){
263 @Override
264 public void widgetSelected(SelectionEvent e) {
265 setApply(true);
266 allowOverrideShowTaxonAssociation = allowOverrideIsShowTaxonAssociationButton.getSelection();
267 }
268 });
269 }
270
271 showLifeFormButton = createBooleanCombo(composite, Messages.GeneralPreference_yes, Messages.GeneralPreference_no, PreferencePredicate.ShowLifeForm, Messages.DatabasePreferncesPage_Life_Form, isAdminPreference);
272 showLifeFormButton.addSelectionListener(this);
273
274 index = 0;
275 for (String itemLabel: showLifeFormButton.getItems()) {
276 if (isShowLifeForm == null && itemLabel.startsWith(Messages.Preference_Use_Default)) {
277 showLifeFormButton.select(index);
278 break;
279 }
280 if (isShowLifeForm != null && itemLabel.equals(Messages.GeneralPreference_yes) && isShowLifeForm){
281 showLifeFormButton.select(index);
282 break;
283 }
284 if (isShowLifeForm != null && itemLabel.equals(Messages.GeneralPreference_no) && !isShowLifeForm){
285 showLifeFormButton.select(index);
286 break;
287 }
288 index++;
289 }
290 isEditingAllowed = true;
291 if (showLifeForm != null && !showLifeForm.isAllowOverride() ){
292 isEditingAllowed = false;
293 }
294 showLifeFormButton.setEnabled(isEditingAllowed);
295 if (isAdminPreference){
296 allowOverrideShowLifeFormButton = createAllowOverrideButton(composite);
297 allowOverrideShowLifeFormButton.setSelection(allowOverrideShowLifeForm);
298 // allowOverrideShowLifeFormButton.setEnabled(showLifeForm != null);
299 allowOverrideShowLifeFormButton.addSelectionListener(new SelectionAdapter(){
300 @Override
301 public void widgetSelected(SelectionEvent e) {
302 setApply(true);
303 allowOverrideShowLifeForm = allowOverrideShowLifeFormButton.getSelection();
304 }
305 });
306 }
307
308 if (!isEditingAllowed){
309 PreferencesUtil.recursiveSetEnabled(composite, false);
310 }
311
312 return composite;
313 }
314
315
316 /**
317 * {@inheritDoc}
318 */
319 @Override
320 protected void getValues() {
321 CdmPreferenceCache cache = CdmPreferenceCache.instance();
322
323
324 overrideShowSpecimenRelatedIssues = PreferencesUtil.getBooleanValue(
325 PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowSpecimen.getKey()), true) != null? PreferencesUtil.getBooleanValue(
326 PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowSpecimen.getKey()), true): false;
327
328 PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowSpecimen);
329 showSpecimenPref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.ShowSpecimen);
330
331
332 if (showSpecimenPref != null) {
333 if (showSpecimenPref.isAllowOverride() ) {
334 if (overrideShowSpecimenRelatedIssues){
335 isShowSpecimenRelatedIssues = PreferencesUtil.getBooleanValue(PreferencePredicate.ShowSpecimen.getKey(), true);
336 }
337 } else {
338 isShowSpecimenRelatedIssues = Boolean.valueOf(showSpecimenPref.getValue());
339 }
340
341 } else {
342 if(!overrideShowSpecimenRelatedIssues){
343 isShowSpecimenRelatedIssues = null;
344 }else{
345 isShowSpecimenRelatedIssues = PreferencesUtil.getBooleanValue(PreferencePredicate.ShowSpecimen.getKey(), true);
346 }
347 showSpecimenPref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowSpecimen, PreferencePredicate.ShowSpecimen.getDefaultValue() != null ? PreferencePredicate.ShowSpecimen.getDefaultValue().toString(): null);
348 }
349
350
351
352
353 key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowCollectingAreasInGeneralSection);
354 showCollectingAreaInGeneralSection = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.ShowCollectingAreasInGeneralSection);
355 overrideShowCollectionAreaInGeneralSection = PreferencesUtil.getBooleanValue(
356 PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowCollectingAreasInGeneralSection.getKey()), true) != null? PreferencesUtil.getBooleanValue(
357 PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowCollectingAreasInGeneralSection.getKey()), true): false;
358 allowOverrideShowCollectingAreaInGeneralSection = showCollectingAreaInGeneralSection != null ? showCollectingAreaInGeneralSection.isAllowOverride():true;
359 if (showCollectingAreaInGeneralSection != null) {
360 if (showCollectingAreaInGeneralSection.isAllowOverride() ) {
361 if (overrideShowCollectionAreaInGeneralSection){
362 isShowCollectingAreaInGeneralSection = PreferencesUtil.getBooleanValue(PreferencePredicate.ShowCollectingAreasInGeneralSection.getKey(), true);
363 }
364
365 } else {
366 isShowCollectingAreaInGeneralSection = Boolean.valueOf(showCollectingAreaInGeneralSection.getValue());
367
368 }
369
370 } else {
371 if(!overrideShowCollectionAreaInGeneralSection){
372 isShowCollectingAreaInGeneralSection = null;
373 }else{
374 isShowCollectingAreaInGeneralSection = PreferencesUtil.getBooleanValue(PreferencePredicate.ShowCollectingAreasInGeneralSection.getKey(), true);
375 }
376 showCollectingAreaInGeneralSection = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowCollectingAreasInGeneralSection, PreferencePredicate.ShowCollectingAreasInGeneralSection.getDefaultValue() != null ? PreferencePredicate.ShowCollectingAreasInGeneralSection.getDefaultValue().toString(): null);
377 }
378
379
380 key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.DeterminationOnlyForFieldUnits);
381 showDeterminationOnlyForFieldUnits = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.DeterminationOnlyForFieldUnits);
382 overrideDeterminationOnlyForFieldUnits = PreferencesUtil.getBooleanValue(
383 PreferencesUtil.prefOverrideKey(PreferencePredicate.DeterminationOnlyForFieldUnits.getKey()), true) != null? PreferencesUtil.getBooleanValue(
384 PreferencesUtil.prefOverrideKey(PreferencePredicate.DeterminationOnlyForFieldUnits.getKey()), true): false;
385 if (showDeterminationOnlyForFieldUnits != null) {
386 if (showDeterminationOnlyForFieldUnits.isAllowOverride() ) {
387 if (overrideDeterminationOnlyForFieldUnits){
388 isDeterminationOnlyForFieldUnits = PreferencesUtil.getBooleanValue(PreferencePredicate.DeterminationOnlyForFieldUnits.getKey());
389 }
390
391 } else {
392 isDeterminationOnlyForFieldUnits = Boolean.valueOf(showDeterminationOnlyForFieldUnits.getValue());
393
394 }
395
396 } else {
397 if(!overrideDeterminationOnlyForFieldUnits){
398 isDeterminationOnlyForFieldUnits = null;
399 }else{
400 isDeterminationOnlyForFieldUnits = PreferencesUtil.getBooleanValue(PreferencePredicate.DeterminationOnlyForFieldUnits.getKey(), true);
401 }
402 showDeterminationOnlyForFieldUnits = CdmPreference.NewTaxEditorInstance(PreferencePredicate.DeterminationOnlyForFieldUnits, PreferencePredicate.DeterminationOnlyForFieldUnits.getDefaultValue() != null ? PreferencePredicate.DeterminationOnlyForFieldUnits.getDefaultValue().toString(): null);
403 }
404
405 allowOverrideDeterminationOnlyForFieldUnits = showDeterminationOnlyForFieldUnits != null ? showDeterminationOnlyForFieldUnits.isAllowOverride():true;
406
407
408 key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowTaxonAssociations);
409 showTaxonAssociation = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.ShowTaxonAssociations);
410 overrideShowTaxonAssociation = PreferencesUtil.getBooleanValue(
411 PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowTaxonAssociations.getKey()), true) != null? PreferencesUtil.getBooleanValue(
412 PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowTaxonAssociations.getKey()), true): false;
413 if (showTaxonAssociation != null) {
414 if (showTaxonAssociation.isAllowOverride() ) {
415 if (overrideShowTaxonAssociation){
416 isShowTaxonAssociation = PreferencesUtil.getBooleanValue(PreferencePredicate.ShowTaxonAssociations.getKey());
417 }
418
419 } else {
420 isShowTaxonAssociation = Boolean.valueOf(showTaxonAssociation.getValue());
421
422 }
423
424 } else {
425 if(!overrideShowTaxonAssociation){
426 isShowTaxonAssociation = null;
427 }else{
428 isShowTaxonAssociation = PreferencesUtil.getBooleanValue(PreferencePredicate.ShowTaxonAssociations.getKey(), true);
429 }
430 showTaxonAssociation = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowTaxonAssociations, PreferencePredicate.ShowTaxonAssociations.getDefaultValue() != null ? PreferencePredicate.ShowTaxonAssociations.getDefaultValue().toString(): null);
431 }
432
433 allowOverrideShowTaxonAssociation = showTaxonAssociation != null ? showTaxonAssociation.isAllowOverride():true;
434
435
436 key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowLifeForm);
437 showLifeForm = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.ShowLifeForm);
438 overrideShowLifeForm = PreferencesUtil.getBooleanValue(
439 PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowLifeForm.getKey()), true) != null? PreferencesUtil.getBooleanValue(
440 PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowLifeForm.getKey()), true): false;
441 if (showLifeForm != null) {
442 if (showLifeForm.isAllowOverride() ) {
443 if (overrideShowLifeForm){
444 isShowLifeForm = PreferencesUtil.getBooleanValue(PreferencePredicate.ShowLifeForm.getKey());
445 }
446
447 } else {
448 isShowLifeForm = Boolean.valueOf(showLifeForm.getValue());
449
450 }
451
452 } else {
453 if(!overrideShowLifeForm){
454 isShowLifeForm = null;
455 }else{
456 isShowLifeForm = PreferencesUtil.getBooleanValue(PreferencePredicate.ShowLifeForm.getKey(), true);
457 }
458 showLifeForm = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowLifeForm, PreferencePredicate.ShowLifeForm.getDefaultValue() != null ? PreferencePredicate.ShowLifeForm.getDefaultValue().toString(): null);
459 }
460
461 allowOverrideShowLifeForm = showLifeForm != null ? showLifeForm.isAllowOverride():true;
462
463
464 }
465
466 @Override
467 public boolean performOk() {
468
469 boolean override = false;
470 if (isShowSpecimenRelatedIssues != null ) {
471 override = true;
472 PreferencesUtil.setStringValue(PreferencePredicate.ShowSpecimen.getKey(), isShowSpecimenRelatedIssues.toString());
473 }
474 PreferencesUtil.setBooleanValue(
475 PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowSpecimen.getKey()),
476 override);
477
478 override = false;
479 if (isShowCollectingAreaInGeneralSection != null ) {
480 override = true;
481 PreferencesUtil.setStringValue(PreferencePredicate.ShowCollectingAreasInGeneralSection.getKey(), isShowCollectingAreaInGeneralSection.toString());
482 }
483 PreferencesUtil.setBooleanValue(
484 PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowCollectingAreasInGeneralSection.getKey()),
485 override);
486
487 override = false;
488 if (isDeterminationOnlyForFieldUnits != null ) {
489 override = true;
490 PreferencesUtil.setStringValue(PreferencePredicate.DeterminationOnlyForFieldUnits.getKey(), isDeterminationOnlyForFieldUnits.toString());
491 }
492 PreferencesUtil.setBooleanValue(
493 PreferencesUtil.prefOverrideKey(PreferencePredicate.DeterminationOnlyForFieldUnits.getKey()),
494 override);
495
496 override = false;
497 if (isShowTaxonAssociation != null ) {
498 override = true;
499 PreferencesUtil.setStringValue(PreferencePredicate.ShowTaxonAssociations.getKey(), isShowTaxonAssociation.toString());
500 }
501 PreferencesUtil.setBooleanValue(
502 PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowTaxonAssociations.getKey()),
503 override);
504
505 override = false;
506 if (isShowLifeForm != null ) {
507 override = true;
508 PreferencesUtil.setStringValue(PreferencePredicate.ShowLifeForm.getKey(), isShowLifeForm.toString());
509 }
510 PreferencesUtil.setBooleanValue(
511 PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowLifeForm.getKey()),
512 override);
513
514 return true;
515 }
516
517
518
519 @Override
520 protected void performDefaults() {
521 isShowSpecimenRelatedIssues = null;
522 showSpecimenButton.select(0);
523
524 if (allowOverrideIsShowSpecimenRelatedIssuesButton != null){
525 allowOverrideShowSpecimenRelatedIssues = true;
526 allowOverrideIsShowSpecimenRelatedIssuesButton.setSelection(allowOverrideShowSpecimenRelatedIssues);
527 }
528 isShowCollectingAreaInGeneralSection = null;
529 showCollectingAreaInGeneralSectionButton.select(0);
530
531 if (allowOverrideShowCollectingAreaButton != null){
532 allowOverrideShowCollectingAreaInGeneralSection = true;
533 allowOverrideShowCollectingAreaButton.setSelection(allowOverrideShowSpecimenRelatedIssues);
534 }
535 isDeterminationOnlyForFieldUnits = null;
536 determinationOnlyForFieldUnitsButton.select(0);
537
538 if (allowOverridesDeterminationOnlyForFieldUnitsButton != null){
539 allowOverrideDeterminationOnlyForFieldUnits = true;
540 allowOverridesDeterminationOnlyForFieldUnitsButton.setSelection(allowOverrideShowSpecimenRelatedIssues);
541 }
542
543 isShowTaxonAssociation = null;
544 showTaxonAssociationButton.select(0);
545
546 if (allowOverrideIsShowTaxonAssociationButton != null){
547 allowOverrideShowTaxonAssociation = true;
548 allowOverrideIsShowTaxonAssociationButton.setSelection(allowOverrideShowSpecimenRelatedIssues);
549 }
550
551
552 isShowLifeForm = null;
553
554 showLifeFormButton.select(0);
555
556 if (allowOverrideShowLifeFormButton != null){
557 allowOverrideShowLifeForm = true;
558 allowOverrideShowLifeFormButton.setSelection(allowOverrideShowSpecimenRelatedIssues);
559 }
560 setApply(true);
561
562 super.performDefaults();
563 }
564
565 /**
566 * {@inheritDoc}
567 */
568 @Override
569 public void widgetSelected(SelectionEvent e) {
570 setApply(true);
571 if (e.getSource().equals(this.showSpecimenButton)) {
572 String text = showSpecimenButton.getText();
573 if(text.startsWith(Messages.Preference_Use_Default)){
574 isShowSpecimenRelatedIssues = null;
575 return;
576 }
577
578 if (text.equals(Messages.GeneralPreference_yes)){
579 isShowSpecimenRelatedIssues = true;
580 }else{
581 isShowSpecimenRelatedIssues = false;
582 }
583 }
584
585 if (e.getSource().equals(this.showCollectingAreaInGeneralSectionButton)) {
586 String text = showCollectingAreaInGeneralSectionButton.getText();
587 if(text.startsWith(Messages.Preference_Use_Default)){
588 isShowCollectingAreaInGeneralSection = null;
589 return;
590 }
591
592 if (text.equals(Messages.GeneralPreference_yes)){
593 isShowCollectingAreaInGeneralSection = true;
594 }else{
595 isShowCollectingAreaInGeneralSection = false;
596 }
597 }
598
599 if (e.getSource().equals(this.determinationOnlyForFieldUnitsButton)) {
600 String text = determinationOnlyForFieldUnitsButton.getText();
601 if(text.startsWith(Messages.Preference_Use_Default)){
602 isDeterminationOnlyForFieldUnits = null;
603 return;
604 }
605 if (text.equals(Messages.GeneralPreference_yes)){
606 isDeterminationOnlyForFieldUnits = true;
607 }else{
608 isDeterminationOnlyForFieldUnits = false;
609 }
610 }
611
612 if (e.getSource().equals(this.showTaxonAssociationButton)) {
613 String text = showTaxonAssociationButton.getText();
614 if(text.startsWith(Messages.Preference_Use_Default)){
615 isShowTaxonAssociation = null;
616 return;
617 }
618
619 if (text.equals(Messages.GeneralPreference_yes)){
620 isShowTaxonAssociation = true;
621 }else{
622 isShowTaxonAssociation = false;
623 }
624 }
625
626 if (e.getSource().equals(this.showLifeFormButton)) {
627 String text = showLifeFormButton.getText();
628 if(text.startsWith(Messages.Preference_Use_Default)){
629 isShowLifeForm = null;
630 return;
631 }
632
633 if (text.equals(Messages.GeneralPreference_yes)){
634 isShowLifeForm = true;
635 }else{
636 isShowLifeForm = false;
637 }
638 }
639
640 }
641
642 /**
643 * {@inheritDoc}
644 */
645 @Override
646 public void widgetDefaultSelected(SelectionEvent e) {
647 // TODO Auto-generated method stub
648
649 }
650
651
652
653
654 }