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