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
;
55 protected Boolean isShowListEditor
;
56 protected boolean allowOverrideShowListEditor
;
57 protected boolean overrideShowListEditor
;
61 protected Combo showSpecimenButton
;
62 protected Button allowOverrideIsShowSpecimenRelatedIssuesButton
;
63 protected Combo showCollectingAreaInGeneralSectionButton
;
64 protected Button allowOverrideShowCollectingAreaButton
;
65 protected Combo determinationOnlyForFieldUnitsButton
;
66 protected Button allowOverridesDeterminationOnlyForFieldUnitsButton
;
67 protected Combo showTaxonAssociationButton
;
68 protected Button allowOverrideIsShowTaxonAssociationButton
;
69 protected Button allowOverrideShowLifeFormButton
;
70 protected Combo showLifeFormButton
;
71 protected Button allowOverrideShowListEditorButton
;
72 protected Combo showListEditorButton
;
74 CdmPreference showSpecimenPref
;
75 CdmPreference showCollectingAreaInGeneralSection
;
76 CdmPreference showDeterminationOnlyForFieldUnits
;
77 CdmPreference showTaxonAssociation
;
78 CdmPreference showLifeForm
;
79 CdmPreference showListEditor
;
84 // setPreferenceStore(PreferencesUtil.getPreferenceStore());
85 if(!CdmStore
.isActive()){
96 protected Control
createContents(Composite parent
) {
99 boolean isEditingAllowed
= true;
100 if(!isAdminPreference
){
101 CdmPreferenceCache cache
= CdmPreferenceCache
.instance();
103 if (showSpecimenPref
!= null){
104 if (!showSpecimenPref
.isAllowOverride() ){
105 isEditingAllowed
= false;
109 if (isEditingAllowed
){
110 Label label
= new Label(parent
, SWT
.NONE
);
111 label
.setText(DESCRIPTION
);
113 Label label
= new Label(parent
, SWT
.NONE
);
114 label
.setText(LOCAL_SETTINGS_NOT_ALLOWED
);
115 this.noDefaultAndApplyButton();
118 Composite titleComp
= createComposite(parent
);
119 GridData gridData
= createTextGridData();
121 Label separator
= new Label(titleComp
, SWT
.HORIZONTAL
| SWT
.SEPARATOR
);
122 separator
.setLayoutData(gridData
);
123 separator
.setVisible(false);
124 showSpecimenButton
= createBooleanCombo(titleComp
, Messages
.GeneralPreference_yes
, Messages
.GeneralPreference_no
, PreferencePredicate
.ShowSpecimen
, Messages
.DatabasePreferncesPage_Show_Specimen
, isAdminPreference
);
126 showSpecimenButton
.addSelectionListener(this);
128 for (String itemLabel
: showSpecimenButton
.getItems()) {
129 if (isShowSpecimenRelatedIssues
== null && itemLabel
.startsWith(Messages
.Preference_Use_Default
)) {
130 showSpecimenButton
.select(index
);
133 if (isShowSpecimenRelatedIssues
!= null && itemLabel
.equals(Messages
.GeneralPreference_yes
) && isShowSpecimenRelatedIssues
){
134 showSpecimenButton
.select(index
);
137 if (isShowSpecimenRelatedIssues
!= null && itemLabel
.equals(Messages
.GeneralPreference_no
) && !isShowSpecimenRelatedIssues
){
138 showSpecimenButton
.select(index
);
143 showSpecimenButton
.setEnabled(isEditingAllowed
);
145 if (isAdminPreference
){
146 allowOverrideIsShowSpecimenRelatedIssuesButton
= createAllowOverrideButton(titleComp
);
147 allowOverrideIsShowSpecimenRelatedIssuesButton
.setSelection(allowOverrideShowSpecimenRelatedIssues
);
148 // allowOverrideIsShowSpecimenRelatedIssuesButton.setEnabled(isShowSpecimenRelatedIssues != null);
149 allowOverrideIsShowSpecimenRelatedIssuesButton
.addSelectionListener(new SelectionAdapter(){
151 public void widgetSelected(SelectionEvent e
) {
153 allowOverrideShowSpecimenRelatedIssues
= allowOverrideIsShowSpecimenRelatedIssuesButton
.getSelection();
158 composite
= createComposite(parent
);
159 //composite.setEnabled(isShowSpecimenRelatedIssues);
160 gridData
= createTextGridData();
162 separator
= new Label(composite
, SWT
.HORIZONTAL
| SWT
.SEPARATOR
);
163 separator
.setLayoutData(gridData
);
165 showListEditorButton
= createBooleanCombo(composite
, Messages
.GeneralPreference_yes
, Messages
.GeneralPreference_no
, PreferencePredicate
.ShowSpecimenListEditor
, Messages
.DatabasePreferncesPage_Show_Specimen_List_Editor
, isAdminPreference
);
167 showListEditorButton
.addSelectionListener(this);
169 for (String itemLabel
: showListEditorButton
.getItems()) {
170 if (isShowListEditor
== null && itemLabel
.startsWith(Messages
.Preference_Use_Default
)) {
171 showListEditorButton
.select(index
);
174 if (isShowListEditor
!= null && itemLabel
.equals(Messages
.GeneralPreference_yes
) && isShowListEditor
){
175 showListEditorButton
.select(index
);
178 if (isShowListEditor
!= null && itemLabel
.equals(Messages
.GeneralPreference_no
) && !isShowListEditor
){
179 showListEditorButton
.select(index
);
184 if (isAdminPreference
){
185 allowOverrideShowListEditorButton
= createAllowOverrideButton(composite
);
186 allowOverrideShowListEditorButton
.setSelection(allowOverrideShowListEditor
);
187 // allowOverrideShowCollectingAreaButton.setEnabled(isShowCollectingAreaInGeneralSection != null);
188 allowOverrideShowListEditorButton
.addSelectionListener(new SelectionAdapter(){
190 public void widgetSelected(SelectionEvent e
) {
192 allowOverrideShowListEditor
= allowOverrideShowListEditorButton
.getSelection();
196 isEditingAllowed
= true;
197 if (showListEditor
!= null && !showListEditor
.isAllowOverride() ){
198 isEditingAllowed
= false;
200 showListEditorButton
.setEnabled(isEditingAllowed
);
202 showCollectingAreaInGeneralSectionButton
= createBooleanCombo(composite
, Messages
.GeneralPreference_yes
, Messages
.GeneralPreference_no
, PreferencePredicate
.ShowCollectingAreasInGeneralSection
, Messages
.DatabasePreferncesPage_Show_Collecting_Areas_in_general_section
, isAdminPreference
);
204 showCollectingAreaInGeneralSectionButton
.addSelectionListener(this);
206 for (String itemLabel
: showCollectingAreaInGeneralSectionButton
.getItems()) {
207 if (isShowCollectingAreaInGeneralSection
== null && itemLabel
.startsWith(Messages
.Preference_Use_Default
)) {
208 showCollectingAreaInGeneralSectionButton
.select(index
);
211 if (isShowCollectingAreaInGeneralSection
!= null && itemLabel
.equals(Messages
.GeneralPreference_yes
) && isShowCollectingAreaInGeneralSection
){
212 showCollectingAreaInGeneralSectionButton
.select(index
);
215 if (isShowCollectingAreaInGeneralSection
!= null && itemLabel
.equals(Messages
.GeneralPreference_no
) && !isShowCollectingAreaInGeneralSection
){
216 showCollectingAreaInGeneralSectionButton
.select(index
);
221 if (isAdminPreference
){
222 allowOverrideShowCollectingAreaButton
= createAllowOverrideButton(composite
);
223 allowOverrideShowCollectingAreaButton
.setSelection(allowOverrideShowCollectingAreaInGeneralSection
);
224 // allowOverrideShowCollectingAreaButton.setEnabled(isShowCollectingAreaInGeneralSection != null);
225 allowOverrideShowCollectingAreaButton
.addSelectionListener(new SelectionAdapter(){
227 public void widgetSelected(SelectionEvent e
) {
229 allowOverrideShowCollectingAreaInGeneralSection
= allowOverrideShowCollectingAreaButton
.getSelection();
233 isEditingAllowed
= true;
234 if (showCollectingAreaInGeneralSection
!= null && !showCollectingAreaInGeneralSection
.isAllowOverride() ){
235 isEditingAllowed
= false;
237 showCollectingAreaInGeneralSectionButton
.setEnabled(isEditingAllowed
);
238 determinationOnlyForFieldUnitsButton
= createBooleanCombo(composite
, Messages
.GeneralPreference_yes
, Messages
.GeneralPreference_no
, PreferencePredicate
.DeterminationOnlyForFieldUnits
, Messages
.DatabasePreferncesPage_Determination_only_for_field_unnits
, isAdminPreference
);
241 determinationOnlyForFieldUnitsButton
.addSelectionListener(this);
243 for (String itemLabel
: determinationOnlyForFieldUnitsButton
.getItems()) {
244 if (isDeterminationOnlyForFieldUnits
== null && itemLabel
.startsWith(Messages
.Preference_Use_Default
)) {
245 determinationOnlyForFieldUnitsButton
.select(index
);
248 if (isDeterminationOnlyForFieldUnits
!= null && itemLabel
.equals(Messages
.GeneralPreference_yes
) && isDeterminationOnlyForFieldUnits
){
249 determinationOnlyForFieldUnitsButton
.select(index
);
252 if (isDeterminationOnlyForFieldUnits
!= null && itemLabel
.equals(Messages
.GeneralPreference_no
) && !isDeterminationOnlyForFieldUnits
){
253 determinationOnlyForFieldUnitsButton
.select(index
);
258 isEditingAllowed
= true;
259 if (showDeterminationOnlyForFieldUnits
!= null && !showDeterminationOnlyForFieldUnits
.isAllowOverride() ){
260 isEditingAllowed
= false;
263 determinationOnlyForFieldUnitsButton
.setEnabled(isEditingAllowed
);
264 if (isAdminPreference
){
265 allowOverridesDeterminationOnlyForFieldUnitsButton
= createAllowOverrideButton(composite
);
266 allowOverridesDeterminationOnlyForFieldUnitsButton
.setSelection(allowOverrideDeterminationOnlyForFieldUnits
);
267 // allowOverridesDeterminationOnlyForFieldUnitsButton.setEnabled(showDeterminationOnlyForFieldUnits != null);
268 allowOverridesDeterminationOnlyForFieldUnitsButton
.addSelectionListener(new SelectionAdapter(){
270 public void widgetSelected(SelectionEvent e
) {
272 allowOverrideDeterminationOnlyForFieldUnits
= allowOverridesDeterminationOnlyForFieldUnitsButton
.getSelection();
277 showTaxonAssociationButton
=createBooleanCombo(composite
, Messages
.GeneralPreference_yes
, Messages
.GeneralPreference_no
, PreferencePredicate
.ShowTaxonAssociations
, Messages
.DatabasePreferncesPage_Taxon_Associations
, isAdminPreference
);
280 showTaxonAssociationButton
.addSelectionListener(this);
282 for (String itemLabel
: showTaxonAssociationButton
.getItems()) {
283 if (isShowTaxonAssociation
== null && itemLabel
.startsWith(Messages
.Preference_Use_Default
)) {
284 showTaxonAssociationButton
.select(index
);
287 if (isShowTaxonAssociation
!= null && itemLabel
.equals(Messages
.GeneralPreference_yes
) && isShowTaxonAssociation
){
288 showTaxonAssociationButton
.select(index
);
291 if (isShowTaxonAssociation
!= null && itemLabel
.equals(Messages
.GeneralPreference_no
) && !isShowTaxonAssociation
){
292 showTaxonAssociationButton
.select(index
);
297 isEditingAllowed
= true;
298 if (showTaxonAssociation
!= null && !showTaxonAssociation
.isAllowOverride() ){
299 isEditingAllowed
= false;
301 showTaxonAssociationButton
.setEnabled(isEditingAllowed
);
302 if (isAdminPreference
){
303 allowOverrideIsShowTaxonAssociationButton
= createAllowOverrideButton(composite
);
304 allowOverrideIsShowTaxonAssociationButton
.setSelection(allowOverrideShowTaxonAssociation
);
305 // allowOverrideIsShowTaxonAssociationButton.setEnabled(showTaxonAssociation != null);
306 allowOverrideIsShowTaxonAssociationButton
.addSelectionListener(new SelectionAdapter(){
308 public void widgetSelected(SelectionEvent e
) {
310 allowOverrideShowTaxonAssociation
= allowOverrideIsShowTaxonAssociationButton
.getSelection();
315 showLifeFormButton
= createBooleanCombo(composite
, Messages
.GeneralPreference_yes
, Messages
.GeneralPreference_no
, PreferencePredicate
.ShowLifeForm
, Messages
.DatabasePreferncesPage_Life_Form
, isAdminPreference
);
316 showLifeFormButton
.addSelectionListener(this);
319 for (String itemLabel
: showLifeFormButton
.getItems()) {
320 if (isShowLifeForm
== null && itemLabel
.startsWith(Messages
.Preference_Use_Default
)) {
321 showLifeFormButton
.select(index
);
324 if (isShowLifeForm
!= null && itemLabel
.equals(Messages
.GeneralPreference_yes
) && isShowLifeForm
){
325 showLifeFormButton
.select(index
);
328 if (isShowLifeForm
!= null && itemLabel
.equals(Messages
.GeneralPreference_no
) && !isShowLifeForm
){
329 showLifeFormButton
.select(index
);
334 isEditingAllowed
= true;
335 if (showLifeForm
!= null && !showLifeForm
.isAllowOverride() ){
336 isEditingAllowed
= false;
338 showLifeFormButton
.setEnabled(isEditingAllowed
);
339 if (isAdminPreference
){
340 allowOverrideShowLifeFormButton
= createAllowOverrideButton(composite
);
341 allowOverrideShowLifeFormButton
.setSelection(allowOverrideShowLifeForm
);
342 // allowOverrideShowLifeFormButton.setEnabled(showLifeForm != null);
343 allowOverrideShowLifeFormButton
.addSelectionListener(new SelectionAdapter(){
345 public void widgetSelected(SelectionEvent e
) {
347 allowOverrideShowLifeForm
= allowOverrideShowLifeFormButton
.getSelection();
352 if (!isEditingAllowed
){
353 PreferencesUtil
.recursiveSetEnabled(composite
, false);
364 protected void getValues() {
365 CdmPreferenceCache cache
= CdmPreferenceCache
.instance();
368 overrideShowSpecimenRelatedIssues
= PreferencesUtil
.getBooleanValue(
369 PreferencesUtil
.prefOverrideKey(PreferencePredicate
.ShowSpecimen
.getKey()), true) != null? PreferencesUtil
.getBooleanValue(
370 PreferencesUtil
.prefOverrideKey(PreferencePredicate
.ShowSpecimen
.getKey()), true): false;
372 PrefKey key
= CdmPreference
.NewKey(PreferenceSubject
.NewTaxEditorInstance(), PreferencePredicate
.ShowSpecimen
);
373 showSpecimenPref
= PreferencesUtil
.getPreferenceFromDB(PreferencePredicate
.ShowSpecimen
);
376 if (showSpecimenPref
!= null) {
377 if (showSpecimenPref
.isAllowOverride() ) {
378 if (overrideShowSpecimenRelatedIssues
){
379 isShowSpecimenRelatedIssues
= PreferencesUtil
.getBooleanValue(PreferencePredicate
.ShowSpecimen
.getKey(), true);
382 isShowSpecimenRelatedIssues
= Boolean
.valueOf(showSpecimenPref
.getValue());
386 if(!overrideShowSpecimenRelatedIssues
){
387 isShowSpecimenRelatedIssues
= null;
389 isShowSpecimenRelatedIssues
= PreferencesUtil
.getBooleanValue(PreferencePredicate
.ShowSpecimen
.getKey(), true);
391 showSpecimenPref
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.ShowSpecimen
, PreferencePredicate
.ShowSpecimen
.getDefaultValue() != null ? PreferencePredicate
.ShowSpecimen
.getDefaultValue().toString(): null);
394 key
= CdmPreference
.NewKey(PreferenceSubject
.NewTaxEditorInstance(), PreferencePredicate
.ShowSpecimenListEditor
);
395 showListEditor
= PreferencesUtil
.getPreferenceFromDB(PreferencePredicate
.ShowSpecimenListEditor
);
397 overrideShowListEditor
= PreferencesUtil
.getBooleanValue(
398 PreferencesUtil
.prefOverrideKey(PreferencePredicate
.ShowSpecimenListEditor
.getKey()), true) != null? PreferencesUtil
.getBooleanValue(
399 PreferencesUtil
.prefOverrideKey(PreferencePredicate
.ShowSpecimenListEditor
.getKey()), true): false;
400 if (showListEditor
!= null) {
401 if (showListEditor
.isAllowOverride() ) {
402 if (overrideShowListEditor
){
403 isShowListEditor
= PreferencesUtil
.getBooleanValue(PreferencePredicate
.ShowSpecimenListEditor
.getKey(), true);
406 isShowListEditor
= Boolean
.valueOf(showListEditor
.getValue());
410 if(!overrideShowListEditor
){
411 isShowListEditor
= null;
413 isShowListEditor
= PreferencesUtil
.getBooleanValue(PreferencePredicate
.ShowSpecimenListEditor
.getKey(), true);
415 showListEditor
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.ShowSpecimenListEditor
, PreferencePredicate
.ShowSpecimenListEditor
.getDefaultValue() != null ? PreferencePredicate
.ShowSpecimenListEditor
.getDefaultValue().toString(): null);
420 key
= CdmPreference
.NewKey(PreferenceSubject
.NewTaxEditorInstance(), PreferencePredicate
.ShowCollectingAreasInGeneralSection
);
421 showCollectingAreaInGeneralSection
= PreferencesUtil
.getPreferenceFromDB(PreferencePredicate
.ShowCollectingAreasInGeneralSection
);
422 overrideShowCollectionAreaInGeneralSection
= PreferencesUtil
.getBooleanValue(
423 PreferencesUtil
.prefOverrideKey(PreferencePredicate
.ShowCollectingAreasInGeneralSection
.getKey()), true) != null? PreferencesUtil
.getBooleanValue(
424 PreferencesUtil
.prefOverrideKey(PreferencePredicate
.ShowCollectingAreasInGeneralSection
.getKey()), true): false;
425 allowOverrideShowCollectingAreaInGeneralSection
= showCollectingAreaInGeneralSection
!= null ? showCollectingAreaInGeneralSection
.isAllowOverride():true;
426 if (showCollectingAreaInGeneralSection
!= null) {
427 if (showCollectingAreaInGeneralSection
.isAllowOverride() ) {
428 if (overrideShowCollectionAreaInGeneralSection
){
429 isShowCollectingAreaInGeneralSection
= PreferencesUtil
.getBooleanValue(PreferencePredicate
.ShowCollectingAreasInGeneralSection
.getKey(), true);
433 isShowCollectingAreaInGeneralSection
= Boolean
.valueOf(showCollectingAreaInGeneralSection
.getValue());
438 if(!overrideShowCollectionAreaInGeneralSection
){
439 isShowCollectingAreaInGeneralSection
= null;
441 isShowCollectingAreaInGeneralSection
= PreferencesUtil
.getBooleanValue(PreferencePredicate
.ShowCollectingAreasInGeneralSection
.getKey(), true);
443 showCollectingAreaInGeneralSection
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.ShowCollectingAreasInGeneralSection
, PreferencePredicate
.ShowCollectingAreasInGeneralSection
.getDefaultValue() != null ? PreferencePredicate
.ShowCollectingAreasInGeneralSection
.getDefaultValue().toString(): null);
447 key
= CdmPreference
.NewKey(PreferenceSubject
.NewTaxEditorInstance(), PreferencePredicate
.DeterminationOnlyForFieldUnits
);
448 showDeterminationOnlyForFieldUnits
= PreferencesUtil
.getPreferenceFromDB(PreferencePredicate
.DeterminationOnlyForFieldUnits
);
449 overrideDeterminationOnlyForFieldUnits
= PreferencesUtil
.getBooleanValue(
450 PreferencesUtil
.prefOverrideKey(PreferencePredicate
.DeterminationOnlyForFieldUnits
.getKey()), true) != null? PreferencesUtil
.getBooleanValue(
451 PreferencesUtil
.prefOverrideKey(PreferencePredicate
.DeterminationOnlyForFieldUnits
.getKey()), true): false;
452 if (showDeterminationOnlyForFieldUnits
!= null) {
453 if (showDeterminationOnlyForFieldUnits
.isAllowOverride() ) {
454 if (overrideDeterminationOnlyForFieldUnits
){
455 isDeterminationOnlyForFieldUnits
= PreferencesUtil
.getBooleanValue(PreferencePredicate
.DeterminationOnlyForFieldUnits
.getKey());
459 isDeterminationOnlyForFieldUnits
= Boolean
.valueOf(showDeterminationOnlyForFieldUnits
.getValue());
464 if(!overrideDeterminationOnlyForFieldUnits
){
465 isDeterminationOnlyForFieldUnits
= null;
467 isDeterminationOnlyForFieldUnits
= PreferencesUtil
.getBooleanValue(PreferencePredicate
.DeterminationOnlyForFieldUnits
.getKey(), true);
469 showDeterminationOnlyForFieldUnits
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.DeterminationOnlyForFieldUnits
, PreferencePredicate
.DeterminationOnlyForFieldUnits
.getDefaultValue() != null ? PreferencePredicate
.DeterminationOnlyForFieldUnits
.getDefaultValue().toString(): null);
472 allowOverrideDeterminationOnlyForFieldUnits
= showDeterminationOnlyForFieldUnits
!= null ? showDeterminationOnlyForFieldUnits
.isAllowOverride():true;
475 key
= CdmPreference
.NewKey(PreferenceSubject
.NewTaxEditorInstance(), PreferencePredicate
.ShowTaxonAssociations
);
476 showTaxonAssociation
= PreferencesUtil
.getPreferenceFromDB(PreferencePredicate
.ShowTaxonAssociations
);
477 overrideShowTaxonAssociation
= PreferencesUtil
.getBooleanValue(
478 PreferencesUtil
.prefOverrideKey(PreferencePredicate
.ShowTaxonAssociations
.getKey()), true) != null? PreferencesUtil
.getBooleanValue(
479 PreferencesUtil
.prefOverrideKey(PreferencePredicate
.ShowTaxonAssociations
.getKey()), true): false;
480 if (showTaxonAssociation
!= null) {
481 if (showTaxonAssociation
.isAllowOverride() ) {
482 if (overrideShowTaxonAssociation
){
483 isShowTaxonAssociation
= PreferencesUtil
.getBooleanValue(PreferencePredicate
.ShowTaxonAssociations
.getKey());
487 isShowTaxonAssociation
= Boolean
.valueOf(showTaxonAssociation
.getValue());
492 if(!overrideShowTaxonAssociation
){
493 isShowTaxonAssociation
= null;
495 isShowTaxonAssociation
= PreferencesUtil
.getBooleanValue(PreferencePredicate
.ShowTaxonAssociations
.getKey(), true);
497 showTaxonAssociation
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.ShowTaxonAssociations
, PreferencePredicate
.ShowTaxonAssociations
.getDefaultValue() != null ? PreferencePredicate
.ShowTaxonAssociations
.getDefaultValue().toString(): null);
500 allowOverrideShowTaxonAssociation
= showTaxonAssociation
!= null ? showTaxonAssociation
.isAllowOverride():true;
503 key
= CdmPreference
.NewKey(PreferenceSubject
.NewTaxEditorInstance(), PreferencePredicate
.ShowLifeForm
);
504 showLifeForm
= PreferencesUtil
.getPreferenceFromDB(PreferencePredicate
.ShowLifeForm
);
505 overrideShowLifeForm
= PreferencesUtil
.getBooleanValue(
506 PreferencesUtil
.prefOverrideKey(PreferencePredicate
.ShowLifeForm
.getKey()), true) != null? PreferencesUtil
.getBooleanValue(
507 PreferencesUtil
.prefOverrideKey(PreferencePredicate
.ShowLifeForm
.getKey()), true): false;
508 if (showLifeForm
!= null) {
509 if (showLifeForm
.isAllowOverride() ) {
510 if (overrideShowLifeForm
){
511 isShowLifeForm
= PreferencesUtil
.getBooleanValue(PreferencePredicate
.ShowLifeForm
.getKey());
515 isShowLifeForm
= Boolean
.valueOf(showLifeForm
.getValue());
520 if(!overrideShowLifeForm
){
521 isShowLifeForm
= null;
523 isShowLifeForm
= PreferencesUtil
.getBooleanValue(PreferencePredicate
.ShowLifeForm
.getKey(), true);
525 showLifeForm
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.ShowLifeForm
, PreferencePredicate
.ShowLifeForm
.getDefaultValue() != null ? PreferencePredicate
.ShowLifeForm
.getDefaultValue().toString(): null);
528 allowOverrideShowLifeForm
= showLifeForm
!= null ? showLifeForm
.isAllowOverride():true;
534 public boolean performOk() {
536 boolean override
= false;
537 if (isShowSpecimenRelatedIssues
!= null ) {
539 PreferencesUtil
.setStringValue(PreferencePredicate
.ShowSpecimen
.getKey(), isShowSpecimenRelatedIssues
.toString());
541 PreferencesUtil
.setBooleanValue(
542 PreferencesUtil
.prefOverrideKey(PreferencePredicate
.ShowSpecimen
.getKey()),
545 if (isShowListEditor
!= null ) {
547 PreferencesUtil
.setStringValue(PreferencePredicate
.ShowSpecimenListEditor
.getKey(), isShowListEditor
.toString());
549 PreferencesUtil
.setBooleanValue(
550 PreferencesUtil
.prefOverrideKey(PreferencePredicate
.ShowSpecimenListEditor
.getKey()),
554 if (isShowCollectingAreaInGeneralSection
!= null ) {
556 PreferencesUtil
.setStringValue(PreferencePredicate
.ShowCollectingAreasInGeneralSection
.getKey(), isShowCollectingAreaInGeneralSection
.toString());
558 PreferencesUtil
.setBooleanValue(
559 PreferencesUtil
.prefOverrideKey(PreferencePredicate
.ShowCollectingAreasInGeneralSection
.getKey()),
563 if (isDeterminationOnlyForFieldUnits
!= null ) {
565 PreferencesUtil
.setStringValue(PreferencePredicate
.DeterminationOnlyForFieldUnits
.getKey(), isDeterminationOnlyForFieldUnits
.toString());
567 PreferencesUtil
.setBooleanValue(
568 PreferencesUtil
.prefOverrideKey(PreferencePredicate
.DeterminationOnlyForFieldUnits
.getKey()),
572 if (isShowTaxonAssociation
!= null ) {
574 PreferencesUtil
.setStringValue(PreferencePredicate
.ShowTaxonAssociations
.getKey(), isShowTaxonAssociation
.toString());
576 PreferencesUtil
.setBooleanValue(
577 PreferencesUtil
.prefOverrideKey(PreferencePredicate
.ShowTaxonAssociations
.getKey()),
581 if (isShowLifeForm
!= null ) {
583 PreferencesUtil
.setStringValue(PreferencePredicate
.ShowLifeForm
.getKey(), isShowLifeForm
.toString());
585 PreferencesUtil
.setBooleanValue(
586 PreferencesUtil
.prefOverrideKey(PreferencePredicate
.ShowLifeForm
.getKey()),
595 protected void performDefaults() {
596 isShowSpecimenRelatedIssues
= null;
597 showSpecimenButton
.select(0);
599 if (allowOverrideIsShowSpecimenRelatedIssuesButton
!= null){
600 allowOverrideShowSpecimenRelatedIssues
= true;
601 allowOverrideIsShowSpecimenRelatedIssuesButton
.setSelection(allowOverrideShowSpecimenRelatedIssues
);
604 isShowListEditor
= null;
605 showListEditorButton
.select(0);
607 if (allowOverrideShowListEditorButton
!= null){
608 allowOverrideShowListEditor
= true;
609 allowOverrideShowListEditorButton
.setSelection(allowOverrideShowListEditor
);
612 isShowCollectingAreaInGeneralSection
= null;
613 showCollectingAreaInGeneralSectionButton
.select(0);
615 if (allowOverrideShowCollectingAreaButton
!= null){
616 allowOverrideShowCollectingAreaInGeneralSection
= true;
617 allowOverrideShowCollectingAreaButton
.setSelection(allowOverrideShowCollectingAreaInGeneralSection
);
619 isDeterminationOnlyForFieldUnits
= null;
620 determinationOnlyForFieldUnitsButton
.select(0);
622 if (allowOverridesDeterminationOnlyForFieldUnitsButton
!= null){
623 allowOverrideDeterminationOnlyForFieldUnits
= true;
624 allowOverridesDeterminationOnlyForFieldUnitsButton
.setSelection(allowOverrideDeterminationOnlyForFieldUnits
);
627 isShowTaxonAssociation
= null;
628 showTaxonAssociationButton
.select(0);
630 if (allowOverrideIsShowTaxonAssociationButton
!= null){
631 allowOverrideShowTaxonAssociation
= true;
632 allowOverrideIsShowTaxonAssociationButton
.setSelection(allowOverrideShowTaxonAssociation
);
636 isShowLifeForm
= null;
638 showLifeFormButton
.select(0);
640 if (allowOverrideShowLifeFormButton
!= null){
641 allowOverrideShowLifeForm
= true;
642 allowOverrideShowLifeFormButton
.setSelection(allowOverrideShowLifeForm
);
646 super.performDefaults();
653 public void widgetSelected(SelectionEvent e
) {
655 if (e
.getSource().equals(this.showSpecimenButton
)) {
656 String text
= showSpecimenButton
.getText();
657 if(text
.startsWith(Messages
.Preference_Use_Default
)){
658 isShowSpecimenRelatedIssues
= null;
662 if (text
.equals(Messages
.GeneralPreference_yes
)){
663 isShowSpecimenRelatedIssues
= true;
665 isShowSpecimenRelatedIssues
= false;
669 if (e
.getSource().equals(this.showListEditorButton
)) {
670 String text
= showListEditorButton
.getText();
671 if(text
.startsWith(Messages
.Preference_Use_Default
)){
672 isShowListEditor
= null;
676 if (text
.equals(Messages
.GeneralPreference_yes
)){
677 isShowListEditor
= true;
679 isShowListEditor
= false;
683 if (e
.getSource().equals(this.showCollectingAreaInGeneralSectionButton
)) {
684 String text
= showCollectingAreaInGeneralSectionButton
.getText();
685 if(text
.startsWith(Messages
.Preference_Use_Default
)){
686 isShowCollectingAreaInGeneralSection
= null;
690 if (text
.equals(Messages
.GeneralPreference_yes
)){
691 isShowCollectingAreaInGeneralSection
= true;
693 isShowCollectingAreaInGeneralSection
= false;
697 if (e
.getSource().equals(this.determinationOnlyForFieldUnitsButton
)) {
698 String text
= determinationOnlyForFieldUnitsButton
.getText();
699 if(text
.startsWith(Messages
.Preference_Use_Default
)){
700 isDeterminationOnlyForFieldUnits
= null;
703 if (text
.equals(Messages
.GeneralPreference_yes
)){
704 isDeterminationOnlyForFieldUnits
= true;
706 isDeterminationOnlyForFieldUnits
= false;
710 if (e
.getSource().equals(this.showTaxonAssociationButton
)) {
711 String text
= showTaxonAssociationButton
.getText();
712 if(text
.startsWith(Messages
.Preference_Use_Default
)){
713 isShowTaxonAssociation
= null;
717 if (text
.equals(Messages
.GeneralPreference_yes
)){
718 isShowTaxonAssociation
= true;
720 isShowTaxonAssociation
= false;
724 if (e
.getSource().equals(this.showLifeFormButton
)) {
725 String text
= showLifeFormButton
.getText();
726 if(text
.startsWith(Messages
.Preference_Use_Default
)){
727 isShowLifeForm
= null;
731 if (text
.equals(Messages
.GeneralPreference_yes
)){
732 isShowLifeForm
= true;
734 isShowLifeForm
= false;
744 public void widgetDefaultSelected(SelectionEvent e
) {
745 // TODO Auto-generated method stub