2 * Copyright (C) 2014 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.taxeditor
.preference
;
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
;
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
;
35 public class SpecimenOrObservationPreferences
extends CdmPreferencePage
implements SelectionListener
{
37 private static final String LOCAL_SETTINGS_NOT_ALLOWED
= Messages
.SpecimenOrObservationPreferences_0
;
38 private static final String DESCRIPTION
= Messages
.SpecimenOrObservationPreferences_1
;
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
;
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
;
68 CdmPreference showSpecimenPref
;
69 CdmPreference showCollectingAreaInGeneralSection
;
70 CdmPreference showDeterminationOnlyForFieldUnits
;
71 CdmPreference showTaxonAssociation
;
72 CdmPreference showLifeForm
;
77 // setPreferenceStore(PreferencesUtil.getPreferenceStore());
78 if(!CdmStore
.isActive()){
89 protected Control
createContents(Composite parent
) {
92 boolean isEditingAllowed
= true;
93 if(!isAdminPreference
){
94 CdmPreferenceCache cache
= CdmPreferenceCache
.instance();
96 if (showSpecimenPref
!= null){
97 if (!showSpecimenPref
.isAllowOverride() ){
99 isEditingAllowed
= false;
104 if (isEditingAllowed
){
105 Label label
= new Label(parent
, SWT
.NONE
);
106 label
.setText(DESCRIPTION
);
108 Label label
= new Label(parent
, SWT
.NONE
);
109 label
.setText(LOCAL_SETTINGS_NOT_ALLOWED
);
110 this.noDefaultAndApplyButton();
113 Composite titleComp
= createComposite(parent
);
114 GridData gridData
= createTextGridData();
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
);
121 showSpecimenButton
.addSelectionListener(this);
123 for (String itemLabel
: showSpecimenButton
.getItems()) {
124 if (isShowSpecimenRelatedIssues
== null && itemLabel
.equals(Messages
.Preference_Use_Default
)) {
125 showSpecimenButton
.select(index
);
128 if (isShowSpecimenRelatedIssues
!= null && itemLabel
.equals(Messages
.GeneralPreference_yes
) && isShowSpecimenRelatedIssues
){
129 showSpecimenButton
.select(index
);
132 if (isShowSpecimenRelatedIssues
!= null && itemLabel
.equals(Messages
.GeneralPreference_no
) && !isShowSpecimenRelatedIssues
){
133 showSpecimenButton
.select(index
);
138 showSpecimenButton
.setEnabled(isEditingAllowed
);
140 if (isAdminPreference
){
141 allowOverrideIsShowSpecimenRelatedIssuesButton
= createAllowOverrideButton(titleComp
);
142 allowOverrideIsShowSpecimenRelatedIssuesButton
.setSelection(allowOverrideShowSpecimenRelatedIssues
);
143 allowOverrideIsShowSpecimenRelatedIssuesButton
.addSelectionListener(new SelectionAdapter(){
145 public void widgetSelected(SelectionEvent e
) {
147 allowOverrideShowSpecimenRelatedIssues
= allowOverrideIsShowSpecimenRelatedIssuesButton
.getSelection();
152 composite
= createComposite(parent
);
153 //composite.setEnabled(isShowSpecimenRelatedIssues);
154 gridData
= createTextGridData();
156 separator
= new Label(composite
, SWT
.HORIZONTAL
| SWT
.SEPARATOR
);
157 separator
.setLayoutData(gridData
);
159 showCollectingAreaInGeneralSectionButton
= createBooleanCombo(composite
, Messages
.GeneralPreference_yes
, Messages
.GeneralPreference_no
, PreferencePredicate
.ShowCollectingAreasInGeneralSection
, Messages
.DatabasePreferncesPage_Show_Collecting_Areas_in_general_section
, isAdminPreference
);
161 showCollectingAreaInGeneralSectionButton
.addSelectionListener(this);
163 for (String itemLabel
: showCollectingAreaInGeneralSectionButton
.getItems()) {
164 if (isShowCollectingAreaInGeneralSection
== null && itemLabel
.equals(Messages
.Preference_Use_Default
)) {
165 showCollectingAreaInGeneralSectionButton
.select(index
);
168 if (isShowCollectingAreaInGeneralSection
!= null && itemLabel
.equals(Messages
.GeneralPreference_yes
) && isShowCollectingAreaInGeneralSection
){
169 showCollectingAreaInGeneralSectionButton
.select(index
);
172 if (isShowCollectingAreaInGeneralSection
!= null && itemLabel
.equals(Messages
.GeneralPreference_no
) && !isShowCollectingAreaInGeneralSection
){
173 showCollectingAreaInGeneralSectionButton
.select(index
);
178 if (isAdminPreference
){
179 allowOverrideShowCollectingAreaButton
= createAllowOverrideButton(composite
);
180 allowOverrideShowCollectingAreaButton
.setSelection(allowOverrideShowCollectingAreaInGeneralSection
);
181 allowOverrideShowCollectingAreaButton
.addSelectionListener(new SelectionAdapter(){
183 public void widgetSelected(SelectionEvent e
) {
185 allowOverrideShowCollectingAreaInGeneralSection
= allowOverrideShowCollectingAreaButton
.getSelection();
189 if (showCollectingAreaInGeneralSection
!= null && !showCollectingAreaInGeneralSection
.isAllowOverride() ){
190 isEditingAllowed
= false;
192 showCollectingAreaInGeneralSectionButton
.setEnabled(isEditingAllowed
);
193 determinationOnlyForFieldUnitsButton
= createBooleanCombo(composite
, Messages
.GeneralPreference_yes
, Messages
.GeneralPreference_no
, PreferencePredicate
.DeterminationOnlyForFieldUnits
, Messages
.DatabasePreferncesPage_Determination_only_for_field_unnits
, isAdminPreference
);
196 determinationOnlyForFieldUnitsButton
.addSelectionListener(this);
198 for (String itemLabel
: determinationOnlyForFieldUnitsButton
.getItems()) {
199 if (isDeterminationOnlyForFieldUnits
== null && itemLabel
.equals(Messages
.Preference_Use_Default
)) {
200 determinationOnlyForFieldUnitsButton
.select(index
);
203 if (isDeterminationOnlyForFieldUnits
!= null && itemLabel
.equals(Messages
.GeneralPreference_yes
) && isDeterminationOnlyForFieldUnits
){
204 determinationOnlyForFieldUnitsButton
.select(index
);
207 if (isDeterminationOnlyForFieldUnits
!= null && itemLabel
.equals(Messages
.GeneralPreference_no
) && !isDeterminationOnlyForFieldUnits
){
208 determinationOnlyForFieldUnitsButton
.select(index
);
213 if (showDeterminationOnlyForFieldUnits
!= null && !showDeterminationOnlyForFieldUnits
.isAllowOverride() ){
214 isEditingAllowed
= false;
216 determinationOnlyForFieldUnitsButton
.setEnabled(isEditingAllowed
);
217 if (isAdminPreference
){
218 allowOverridesDeterminationOnlyForFieldUnitsButton
= createAllowOverrideButton(composite
);
219 allowOverridesDeterminationOnlyForFieldUnitsButton
.setSelection(allowOverrideDeterminationOnlyForFieldUnits
);
220 allowOverridesDeterminationOnlyForFieldUnitsButton
.addSelectionListener(new SelectionAdapter(){
222 public void widgetSelected(SelectionEvent e
) {
224 allowOverrideDeterminationOnlyForFieldUnits
= allowOverridesDeterminationOnlyForFieldUnitsButton
.getSelection();
229 showTaxonAssociationButton
=createBooleanCombo(composite
, Messages
.GeneralPreference_yes
, Messages
.GeneralPreference_no
, PreferencePredicate
.ShowTaxonAssociations
, Messages
.DatabasePreferncesPage_Taxon_Associations
, isAdminPreference
);
232 showTaxonAssociationButton
.addSelectionListener(this);
234 for (String itemLabel
: showTaxonAssociationButton
.getItems()) {
235 if (isShowTaxonAssociation
== null && itemLabel
.equals(Messages
.Preference_Use_Default
)) {
236 showTaxonAssociationButton
.select(index
);
239 if (isShowTaxonAssociation
!= null && itemLabel
.equals(Messages
.GeneralPreference_yes
) && isShowTaxonAssociation
){
240 showTaxonAssociationButton
.select(index
);
243 if (isShowTaxonAssociation
!= null && itemLabel
.equals(Messages
.GeneralPreference_no
) && !isShowTaxonAssociation
){
244 showTaxonAssociationButton
.select(index
);
249 if (showTaxonAssociation
!= null && !showTaxonAssociation
.isAllowOverride() ){
250 isEditingAllowed
= false;
252 showTaxonAssociationButton
.setEnabled(isEditingAllowed
);
253 if (isAdminPreference
){
254 allowOverrideIsShowTaxonAssociationButton
= createAllowOverrideButton(composite
);
255 allowOverrideIsShowTaxonAssociationButton
.setSelection(allowOverrideShowTaxonAssociation
);
256 allowOverrideIsShowTaxonAssociationButton
.addSelectionListener(new SelectionAdapter(){
258 public void widgetSelected(SelectionEvent e
) {
260 allowOverrideShowTaxonAssociation
= allowOverrideIsShowTaxonAssociationButton
.getSelection();
265 showLifeFormButton
= createBooleanCombo(composite
, Messages
.GeneralPreference_yes
, Messages
.GeneralPreference_no
, PreferencePredicate
.ShowLifeForm
, Messages
.DatabasePreferncesPage_Life_Form
, isAdminPreference
);
266 showLifeFormButton
.addSelectionListener(this);
269 for (String itemLabel
: showLifeFormButton
.getItems()) {
270 if (isShowLifeForm
== null && itemLabel
.equals(Messages
.Preference_Use_Default
)) {
271 showLifeFormButton
.select(index
);
274 if (isShowLifeForm
!= null && itemLabel
.equals(Messages
.GeneralPreference_yes
) && isShowLifeForm
){
275 showLifeFormButton
.select(index
);
278 if (isShowLifeForm
!= null && itemLabel
.equals(Messages
.GeneralPreference_no
) && !isShowLifeForm
){
279 showLifeFormButton
.select(index
);
284 if (showLifeForm
!= null && !showLifeForm
.isAllowOverride() ){
285 isEditingAllowed
= false;
287 showLifeFormButton
.setEnabled(isEditingAllowed
);
288 if (isAdminPreference
){
289 allowOverrideShowLifeFormButton
= createAllowOverrideButton(composite
);
290 allowOverrideShowLifeFormButton
.setSelection(allowOverrideShowLifeForm
);
291 allowOverrideShowLifeFormButton
.addSelectionListener(new SelectionAdapter(){
293 public void widgetSelected(SelectionEvent e
) {
295 allowOverrideShowLifeForm
= allowOverrideShowLifeFormButton
.getSelection();
300 if (!isEditingAllowed
){
301 PreferencesUtil
.recursiveSetEnabled(composite
, false);
312 protected void getValues() {
313 CdmPreferenceCache cache
= CdmPreferenceCache
.instance();
316 overrideShowSpecimenRelatedIssues
= PreferencesUtil
.getBooleanValue(
317 PreferencesUtil
.prefOverrideKey(PreferencePredicate
.ShowSpecimen
.getKey()), true);
319 PrefKey key
= CdmPreference
.NewKey(PreferenceSubject
.NewTaxEditorInstance(), PreferencePredicate
.ShowSpecimen
);
320 showSpecimenPref
= PreferencesUtil
.getPreferenceFromDB(PreferencePredicate
.ShowSpecimen
);
323 if (showSpecimenPref
!= null) {
324 if (showSpecimenPref
.isAllowOverride() ) {
325 if (overrideShowSpecimenRelatedIssues
){
326 isShowSpecimenRelatedIssues
= PreferencesUtil
.getBooleanValue(PreferencePredicate
.ShowSpecimen
.getKey(), true);
329 isShowSpecimenRelatedIssues
= Boolean
.valueOf(showSpecimenPref
.getValue());
333 if(!overrideShowSpecimenRelatedIssues
){
334 isShowSpecimenRelatedIssues
= null;
336 isShowSpecimenRelatedIssues
= PreferencesUtil
.getBooleanValue(PreferencePredicate
.ShowSpecimen
.getKey(), true);
338 showSpecimenPref
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.ShowSpecimen
, PreferencePredicate
.ShowSpecimen
.getDefaultValue() != null ? PreferencePredicate
.ShowSpecimen
.getDefaultValue().toString(): null);
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);
356 isShowCollectingAreaInGeneralSection
= Boolean
.valueOf(showCollectingAreaInGeneralSection
.getValue());
361 if(!overrideShowCollectionAreaInGeneralSection
){
362 isShowCollectingAreaInGeneralSection
= null;
364 isShowCollectingAreaInGeneralSection
= PreferencesUtil
.getBooleanValue(PreferencePredicate
.ShowCollectingAreasInGeneralSection
.getKey(), true);
366 showCollectingAreaInGeneralSection
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.ShowCollectingAreasInGeneralSection
, PreferencePredicate
.ShowCollectingAreasInGeneralSection
.getDefaultValue() != null ? PreferencePredicate
.ShowCollectingAreasInGeneralSection
.getDefaultValue().toString(): null);
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());
381 isDeterminationOnlyForFieldUnits
= Boolean
.valueOf(showDeterminationOnlyForFieldUnits
.getValue());
386 if(!overrideDeterminationOnlyForFieldUnits
){
387 isDeterminationOnlyForFieldUnits
= null;
389 isDeterminationOnlyForFieldUnits
= PreferencesUtil
.getBooleanValue(PreferencePredicate
.DeterminationOnlyForFieldUnits
.getKey(), true);
391 showDeterminationOnlyForFieldUnits
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.DeterminationOnlyForFieldUnits
, PreferencePredicate
.DeterminationOnlyForFieldUnits
.getDefaultValue() != null ? PreferencePredicate
.DeterminationOnlyForFieldUnits
.getDefaultValue().toString(): null);
394 allowOverrideDeterminationOnlyForFieldUnits
= showDeterminationOnlyForFieldUnits
!= null ? showDeterminationOnlyForFieldUnits
.isAllowOverride():true;
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());
408 isShowTaxonAssociation
= Boolean
.valueOf(showTaxonAssociation
.getValue());
413 if(!overrideShowTaxonAssociation
){
414 isShowTaxonAssociation
= null;
416 isShowTaxonAssociation
= PreferencesUtil
.getBooleanValue(PreferencePredicate
.ShowTaxonAssociations
.getKey(), true);
418 showTaxonAssociation
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.ShowTaxonAssociations
, PreferencePredicate
.ShowTaxonAssociations
.getDefaultValue() != null ? PreferencePredicate
.ShowTaxonAssociations
.getDefaultValue().toString(): null);
421 allowOverrideShowTaxonAssociation
= showTaxonAssociation
!= null ? showTaxonAssociation
.isAllowOverride():true;
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());
435 isShowLifeForm
= Boolean
.valueOf(showLifeForm
.getValue());
440 if(!overrideShowLifeForm
){
441 isShowLifeForm
= null;
443 isShowLifeForm
= PreferencesUtil
.getBooleanValue(PreferencePredicate
.ShowLifeForm
.getKey(), true);
445 showLifeForm
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.ShowLifeForm
, PreferencePredicate
.ShowLifeForm
.getDefaultValue() != null ? PreferencePredicate
.ShowLifeForm
.getDefaultValue().toString(): null);
448 allowOverrideShowLifeForm
= showLifeForm
!= null ? showLifeForm
.isAllowOverride():true;
454 public boolean performOk() {
456 boolean override
= false;
457 if (isShowSpecimenRelatedIssues
!= null ) {
459 PreferencesUtil
.setStringValue(PreferencePredicate
.ShowSpecimen
.getKey(), isShowSpecimenRelatedIssues
.toString());
461 PreferencesUtil
.setBooleanValue(
462 PreferencesUtil
.prefOverrideKey(PreferencePredicate
.ShowSpecimen
.getKey()),
466 if (isShowCollectingAreaInGeneralSection
!= null ) {
468 PreferencesUtil
.setStringValue(PreferencePredicate
.ShowCollectingAreasInGeneralSection
.getKey(), isShowCollectingAreaInGeneralSection
.toString());
470 PreferencesUtil
.setBooleanValue(
471 PreferencesUtil
.prefOverrideKey(PreferencePredicate
.ShowCollectingAreasInGeneralSection
.getKey()),
475 if (isDeterminationOnlyForFieldUnits
!= null ) {
477 PreferencesUtil
.setStringValue(PreferencePredicate
.DeterminationOnlyForFieldUnits
.getKey(), isDeterminationOnlyForFieldUnits
.toString());
479 PreferencesUtil
.setBooleanValue(
480 PreferencesUtil
.prefOverrideKey(PreferencePredicate
.DeterminationOnlyForFieldUnits
.getKey()),
484 if (isShowTaxonAssociation
!= null ) {
486 PreferencesUtil
.setStringValue(PreferencePredicate
.ShowTaxonAssociations
.getKey(), isShowTaxonAssociation
.toString());
488 PreferencesUtil
.setBooleanValue(
489 PreferencesUtil
.prefOverrideKey(PreferencePredicate
.ShowTaxonAssociations
.getKey()),
493 if (isShowLifeForm
!= null ) {
495 PreferencesUtil
.setStringValue(PreferencePredicate
.ShowLifeForm
.getKey(), isShowLifeForm
.toString());
497 PreferencesUtil
.setBooleanValue(
498 PreferencesUtil
.prefOverrideKey(PreferencePredicate
.ShowLifeForm
.getKey()),
507 protected void performDefaults() {
508 isShowSpecimenRelatedIssues
= (Boolean
)PreferencePredicate
.ShowSpecimen
.getDefaultValue();
509 if (isShowSpecimenRelatedIssues
){
510 showSpecimenButton
.select(0);
512 showSpecimenButton
.select(1);
514 if (allowOverrideIsShowSpecimenRelatedIssuesButton
!= null){
515 allowOverrideShowSpecimenRelatedIssues
= true;
516 allowOverrideIsShowSpecimenRelatedIssuesButton
.setSelection(allowOverrideShowSpecimenRelatedIssues
);
518 isShowCollectingAreaInGeneralSection
= (Boolean
)PreferencePredicate
.ShowCollectingAreasInGeneralSection
.getDefaultValue();
519 if (isShowCollectingAreaInGeneralSection
){
520 showCollectingAreaInGeneralSectionButton
.select(0);
522 showCollectingAreaInGeneralSectionButton
.select(1);
524 if (allowOverrideShowCollectingAreaButton
!= null){
525 allowOverrideShowCollectingAreaInGeneralSection
= true;
526 allowOverrideShowCollectingAreaButton
.setSelection(allowOverrideShowSpecimenRelatedIssues
);
528 isDeterminationOnlyForFieldUnits
= (Boolean
) PreferencePredicate
.DeterminationOnlyForFieldUnits
.getDefaultValue();
529 if (isDeterminationOnlyForFieldUnits
){
530 determinationOnlyForFieldUnitsButton
.select(0);
532 determinationOnlyForFieldUnitsButton
.select(1);
534 if (allowOverridesDeterminationOnlyForFieldUnitsButton
!= null){
535 allowOverrideDeterminationOnlyForFieldUnits
= true;
536 allowOverridesDeterminationOnlyForFieldUnitsButton
.setSelection(allowOverrideShowSpecimenRelatedIssues
);
539 isShowTaxonAssociation
= (Boolean
) PreferencePredicate
.ShowTaxonAssociations
.getDefaultValue();
540 if (isShowTaxonAssociation
){
541 showTaxonAssociationButton
.select(0);
543 showTaxonAssociationButton
.select(1);
545 if (allowOverrideIsShowTaxonAssociationButton
!= null){
546 allowOverrideShowTaxonAssociation
= true;
547 allowOverrideIsShowTaxonAssociationButton
.setSelection(allowOverrideShowSpecimenRelatedIssues
);
551 isShowLifeForm
= (Boolean
) PreferencePredicate
.ShowLifeForm
.getDefaultValue();
554 showLifeFormButton
.select(0);
556 showLifeFormButton
.select(1);
558 if (allowOverrideShowLifeFormButton
!= null){
559 allowOverrideShowLifeForm
= true;
560 allowOverrideShowLifeFormButton
.setSelection(allowOverrideShowSpecimenRelatedIssues
);
564 super.performDefaults();
571 public void widgetSelected(SelectionEvent e
) {
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);
582 if (text
.equals(Messages
.GeneralPreference_yes
)){
583 isShowSpecimenRelatedIssues
= true;
585 isShowSpecimenRelatedIssues
= false;
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);
599 if (text
.equals(Messages
.GeneralPreference_yes
)){
600 isShowCollectingAreaInGeneralSection
= true;
602 isShowCollectingAreaInGeneralSection
= false;
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);
616 if (text
.equals(Messages
.GeneralPreference_yes
)){
617 isDeterminationOnlyForFieldUnits
= true;
619 isDeterminationOnlyForFieldUnits
= false;
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);
633 if (text
.equals(Messages
.GeneralPreference_yes
)){
634 isShowTaxonAssociation
= true;
636 isShowTaxonAssociation
= false;
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);
650 if (text
.equals(Messages
.GeneralPreference_yes
)){
651 isShowLifeForm
= true;
653 isShowLifeForm
= false;
663 public void widgetDefaultSelected(SelectionEvent e
) {
664 // TODO Auto-generated method stub