1
|
/**
|
2
|
* Copyright (C) 2018 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.databaseAdmin.preferencePage;
|
10
|
|
11
|
import org.eclipse.swt.widgets.Composite;
|
12
|
|
13
|
import eu.etaxonomy.cdm.api.application.ICdmRepository;
|
14
|
import eu.etaxonomy.cdm.api.service.IPreferenceService;
|
15
|
import eu.etaxonomy.cdm.model.metadata.CdmPreference;
|
16
|
import eu.etaxonomy.cdm.model.metadata.CdmPreference.PrefKey;
|
17
|
import eu.etaxonomy.cdm.model.metadata.PreferenceSubject;
|
18
|
import eu.etaxonomy.taxeditor.preference.EditorPreferencePredicate;
|
19
|
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
|
20
|
import eu.etaxonomy.taxeditor.preference.SpecimenOrObservationPreferences;
|
21
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
22
|
|
23
|
/**
|
24
|
* @author k.luther
|
25
|
* @since 27.04.2018
|
26
|
*
|
27
|
*/
|
28
|
public class SpecimenAdminPreferences extends SpecimenOrObservationPreferences implements IE4AdminPreferencePage {
|
29
|
|
30
|
|
31
|
|
32
|
Composite composite;
|
33
|
CdmPreference showSpecimenPref = null;
|
34
|
|
35
|
@Override
|
36
|
public void init() {
|
37
|
super.init();
|
38
|
if(!CdmStore.isActive()){
|
39
|
return;
|
40
|
}
|
41
|
}
|
42
|
|
43
|
@Override
|
44
|
protected void getValues(){
|
45
|
isAdminPreference = true;
|
46
|
|
47
|
ICdmRepository controller = CdmStore.getCurrentApplicationConfiguration();
|
48
|
if (controller != null){
|
49
|
IPreferenceService service = controller.getPreferenceService();
|
50
|
PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), EditorPreferencePredicate.ShowSpecimen);
|
51
|
showSpecimenPref = service.find(key);
|
52
|
if (showSpecimenPref != null){
|
53
|
this.isShowSpecimenRelatedIssues = Boolean.valueOf(showSpecimenPref.getValue());
|
54
|
this.allowOverrideShowSpecimenRelatedIssues = showSpecimenPref.isAllowOverride();
|
55
|
}else{
|
56
|
showSpecimenPref = CdmPreference.NewTaxEditorInstance(EditorPreferencePredicate.ShowSpecimen, Boolean.toString(true));
|
57
|
this.isShowSpecimenRelatedIssues = true;
|
58
|
this.allowOverrideShowSpecimenRelatedIssues = true;
|
59
|
}
|
60
|
|
61
|
key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), EditorPreferencePredicate.ShowCollectingAreasInGeneralSection);
|
62
|
CdmPreference isShowCollectingAreaInGeneralSectionPref = service.find(key);
|
63
|
if (isShowCollectingAreaInGeneralSectionPref != null){
|
64
|
this.isShowCollectingAreaInGeneralSection = Boolean.valueOf(isShowCollectingAreaInGeneralSectionPref.getValue());
|
65
|
this.allowOverrideShowCollectingAreaInGeneralSection = isShowCollectingAreaInGeneralSectionPref.isAllowOverride();
|
66
|
}else{
|
67
|
this.isShowCollectingAreaInGeneralSection = (Boolean) EditorPreferencePredicate.ShowCollectingAreasInGeneralSection.getDefaultValue();
|
68
|
this.allowOverrideShowCollectingAreaInGeneralSection = true;
|
69
|
}
|
70
|
|
71
|
key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), EditorPreferencePredicate.DeterminationOnlyForFieldUnits);
|
72
|
CdmPreference isDeterminationOnlyForFieldUnitsPref = service.find(key);
|
73
|
if (isDeterminationOnlyForFieldUnitsPref != null){
|
74
|
this.isDeterminationOnlyForFieldUnits = Boolean.valueOf(isDeterminationOnlyForFieldUnitsPref.getValue());
|
75
|
this.allowOverrideDeterminationOnlyForFieldUnits = isDeterminationOnlyForFieldUnitsPref.isAllowOverride();
|
76
|
}else{
|
77
|
this.isDeterminationOnlyForFieldUnits =(Boolean)EditorPreferencePredicate.DeterminationOnlyForFieldUnits.getDefaultValue();
|
78
|
this.allowOverrideDeterminationOnlyForFieldUnits = true;
|
79
|
}
|
80
|
key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), EditorPreferencePredicate.ShowTaxonAssociations);
|
81
|
CdmPreference isShowTaxonAssociationPref = service.find(key);
|
82
|
if (isShowTaxonAssociationPref != null){
|
83
|
this.isShowTaxonAssociation = Boolean.valueOf(isShowTaxonAssociationPref.getValue());
|
84
|
this.allowOverrideShowTaxonAssociation = isShowTaxonAssociationPref.isAllowOverride();
|
85
|
}else{
|
86
|
this.isShowTaxonAssociation = (Boolean)EditorPreferencePredicate.ShowTaxonAssociations.getDefaultValue();
|
87
|
this.allowOverrideShowTaxonAssociation = true;
|
88
|
}
|
89
|
|
90
|
key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), EditorPreferencePredicate.ShowLifeForm);
|
91
|
CdmPreference isShowLifeFormPref = service.find(key);
|
92
|
if (isShowLifeFormPref != null){
|
93
|
this.isShowLifeForm = Boolean.valueOf(isShowLifeFormPref.getValue());
|
94
|
this.allowOverrideShowLifeForm = isShowLifeFormPref.isAllowOverride();
|
95
|
} else{
|
96
|
this.isShowLifeForm = (Boolean)EditorPreferencePredicate.ShowLifeForm.getDefaultValue();
|
97
|
this.allowOverrideShowLifeForm = true;
|
98
|
}
|
99
|
|
100
|
}
|
101
|
}
|
102
|
|
103
|
@Override
|
104
|
public boolean performOk() {
|
105
|
if (showSpecimenPref == null){
|
106
|
return true;
|
107
|
}
|
108
|
ICdmRepository controller = CdmStore.getCurrentApplicationConfiguration();
|
109
|
if (controller != null){
|
110
|
IPreferenceService service = controller.getPreferenceService();
|
111
|
|
112
|
CdmPreference pref = CdmPreference.NewTaxEditorInstance(EditorPreferencePredicate.ShowCollectingAreasInGeneralSection, Boolean.toString(this.isShowCollectingAreaInGeneralSection));
|
113
|
pref.setAllowOverride(allowOverrideShowCollectingAreaInGeneralSection);
|
114
|
service.set(pref);
|
115
|
pref = CdmPreference.NewTaxEditorInstance(EditorPreferencePredicate.ShowSpecimen, Boolean.toString(this.isShowSpecimenRelatedIssues));
|
116
|
pref.setAllowOverride(allowOverrideShowSpecimenRelatedIssues);
|
117
|
service.set(pref);
|
118
|
|
119
|
pref = CdmPreference.NewTaxEditorInstance(EditorPreferencePredicate.DeterminationOnlyForFieldUnits, Boolean.toString(this.isDeterminationOnlyForFieldUnits));
|
120
|
pref.setAllowOverride(allowOverrideDeterminationOnlyForFieldUnits);
|
121
|
service.set(pref);
|
122
|
|
123
|
pref = CdmPreference.NewTaxEditorInstance(EditorPreferencePredicate.ShowTaxonAssociations, Boolean.toString(this.isShowTaxonAssociation));
|
124
|
pref.setAllowOverride(allowOverrideShowTaxonAssociation);
|
125
|
service.set(pref);
|
126
|
|
127
|
pref = CdmPreference.NewTaxEditorInstance(EditorPreferencePredicate.ShowLifeForm, Boolean.toString(this.isShowLifeForm));
|
128
|
pref.setAllowOverride(allowOverrideShowLifeForm);
|
129
|
service.set(pref);
|
130
|
PreferencesUtil.updateDBPreferences();
|
131
|
|
132
|
|
133
|
}
|
134
|
return true;
|
135
|
}
|
136
|
|
137
|
}
|