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
.jface
.preference
.BooleanFieldEditor
;
12 import org
.eclipse
.swt
.SWT
;
13 import org
.eclipse
.swt
.layout
.GridData
;
14 import org
.eclipse
.swt
.widgets
.Label
;
16 import eu
.etaxonomy
.cdm
.api
.application
.ICdmRepository
;
17 import eu
.etaxonomy
.cdm
.api
.service
.IPreferenceService
;
18 import eu
.etaxonomy
.cdm
.model
.metadata
.CdmPreference
;
19 import eu
.etaxonomy
.cdm
.model
.metadata
.CdmPreference
.PrefKey
;
20 import eu
.etaxonomy
.cdm
.model
.metadata
.PreferencePredicate
;
21 import eu
.etaxonomy
.cdm
.model
.metadata
.PreferenceSubject
;
22 import eu
.etaxonomy
.taxeditor
.preference
.menu
.FieldEditorPreferencePageE4
;
23 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
30 public class SpecimenOrObservationPreferences
extends FieldEditorPreferencePageE4
{
32 public SpecimenOrObservationPreferences(){
34 setPreferenceStore(PreferencesUtil
.getPreferenceStore());
35 if (getPreferenceStore().getBoolean(IPreferenceKeys
.ALLOW_OVERRIDE_NOMENCLATURAL_CODE_KEY
)){
36 setDescription("Set the preferences for the display of specimen and obeservations.");
38 setDescription("The CDM settings don't allow to set the preferences for the display of specimen and obeservations locally. If you need to make local settings, please ask an administrator.");
46 // setPreferenceStore(PreferencesUtil.getPreferenceStore());
47 if(!CdmStore
.isActive()){
50 ICdmRepository controller
= CdmStore
.getCurrentApplicationConfiguration();
51 if (controller
!= null){
52 IPreferenceService service
= controller
.getPreferenceService();
53 PrefKey keyTaxonAssociation
= CdmPreference
.NewKey(PreferenceSubject
.NewDatabaseInstance(), PreferencePredicate
.ShowTaxonAssociations
);
54 CdmPreference prefTaxonAssociation
= service
.find(keyTaxonAssociation
);
55 PrefKey keyDeterminationFieldUnit
= CdmPreference
.NewKey(PreferenceSubject
.NewDatabaseInstance(), PreferencePredicate
.DeterminationOnlyForFieldUnits
);
56 CdmPreference prefDeterminationFieldUnit
= service
.find(keyDeterminationFieldUnit
);
57 PrefKey keyCollectingAreas
= CdmPreference
.NewKey(PreferenceSubject
.NewDatabaseInstance(), PreferencePredicate
.ShowCollectingAreasInGeneralSection
);
58 CdmPreference prefCollectingAreas
= service
.find(keyCollectingAreas
);
60 getPreferenceStore().setValue(IPreferenceKeys
.SHOW_TAXON_ASSOCIATIONS_ALLOW_OVERRIDE
, prefTaxonAssociation
== null?
true : prefTaxonAssociation
.isAllowOverride());
61 getPreferenceStore().setValue(IPreferenceKeys
.DETERMINATIONS_ONLY_FOR_FIELDUNITS_ALLOW_OVERRIDE
, prefTaxonAssociation
== null?
true : prefTaxonAssociation
.isAllowOverride());
62 getPreferenceStore().setValue(IPreferenceKeys
.SHOW_COLLECTING_AREAS_IN_GENERAL_SECTION_ALLOW_OVERRIDE
, prefTaxonAssociation
== null?
true : prefTaxonAssociation
.isAllowOverride());
63 getPreferenceStore().setValue(IPreferenceKeys
.SHOW_LIFE_FORM_ALLOW_OVERRIDE
, prefTaxonAssociation
== null?
true : prefTaxonAssociation
.isAllowOverride());
65 if (getPreferenceStore().getBoolean(IPreferenceKeys
.SHOW_TAXON_ASSOCIATIONS_OVERRIDE
)) {
66 setDescription("Set the preferences for the display of specimen and obeservations.");
68 setDescription("The CDM settings don't allow to set the preferences for the display of specimen and obeservations locally. If you need to make local settings, please ask an administrator.");
74 protected void createFieldEditors() {
75 if (getPreferenceStore().getBoolean(IPreferenceKeys
.SHOW_SPECIMEN_ALLOW_OVERRIDE
)) {
76 addField(new BooleanFieldEditor(IPreferenceKeys
.DETERMINATION_ONLY_FOR_FIELD_UNITS
,
77 "Taxon determination only on FieldUnit level",
78 getFieldEditorParent()));
79 addField(new BooleanFieldEditor(IPreferenceKeys
.SHOW_COLLECTING_AREAS_IN_GENERAL_SECTION
,
80 "Show \"Collecting Areas\" in \"General\" section of details view",
81 getFieldEditorParent()));
82 addField(new BooleanFieldEditor(IPreferenceKeys
.SHOW_TAXON_ASSOCIATIONS
,
83 "Show taxon associations of a specimen in the details view",
84 getFieldEditorParent()));
85 addField(new BooleanFieldEditor(IPreferenceKeys
.SHOW_LIFE_FORM
,
86 "Show life form of a specimen in the details view",
87 getFieldEditorParent()));
88 Label label
= new Label(getFieldEditorParent(), SWT
.NONE
);
90 label
.setLayoutData(new GridData(SWT
.FILL
, SWT
.TOP
, false, false, 1, 1));
92 addField(new BooleanFieldEditor(
93 IPreferenceKeys
.SHOW_SPECIMEN_OVERRIDE
,
94 "Use local specimen preferences",
95 getFieldEditorParent()));