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.PreferencePredicate;
|
18
|
import eu.etaxonomy.cdm.model.metadata.PreferenceSubject;
|
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
|
// protected Control createContents(Composite parent) {
|
37
|
//
|
38
|
// getValues();
|
39
|
// composite = createComposite(parent);
|
40
|
// composite.setEnabled(isShowSpecimenRelatedIssues);
|
41
|
// final Button showSpecimenButton = new Button(parent, SWT.CHECK);
|
42
|
//
|
43
|
// showSpecimenButton.setText(Messages.DatabasePreferncesPage_Show_Specimen);
|
44
|
//
|
45
|
// showSpecimenButton.setSelection(isShowSpecimenRelatedIssues);
|
46
|
// showSpecimenButton.addSelectionListener(new SelectionAdapter(){
|
47
|
// @Override
|
48
|
// public void widgetSelected(SelectionEvent e) {
|
49
|
// isShowSpecimenRelatedIssues = showSpecimenButton.getSelection();
|
50
|
// if(isShowSpecimenRelatedIssues){
|
51
|
// composite.setVisible(true);
|
52
|
// composite.setEnabled(true);
|
53
|
// }else{
|
54
|
// composite.setVisible(false);
|
55
|
// composite.setEnabled(false);
|
56
|
// }
|
57
|
// }
|
58
|
// });
|
59
|
// if (isAdminPreference){
|
60
|
// createAllowOverrideButton(parent);
|
61
|
// }
|
62
|
//
|
63
|
// GridData gridData = createTextGridData();
|
64
|
//
|
65
|
// Label separator= new Label(composite, SWT.HORIZONTAL | SWT.SEPARATOR);
|
66
|
// separator.setLayoutData(gridData);
|
67
|
//
|
68
|
// final Button showCollectingAreaInGeneralSectionButton = new Button(composite, SWT.CHECK);
|
69
|
//
|
70
|
// showCollectingAreaInGeneralSectionButton.setText(Messages.DatabasePreferncesPage_Show_Collecting_Areas_in_general_section);
|
71
|
//
|
72
|
// showCollectingAreaInGeneralSectionButton.setSelection(isShowCollectingAreaInGeneralSection);
|
73
|
// showCollectingAreaInGeneralSectionButton.addSelectionListener(new SelectionAdapter(){
|
74
|
// @Override
|
75
|
// public void widgetSelected(SelectionEvent e) {
|
76
|
// isShowCollectingAreaInGeneralSection = showCollectingAreaInGeneralSectionButton.getSelection();
|
77
|
//
|
78
|
// }
|
79
|
// });
|
80
|
//
|
81
|
// if (isAdminPreference){
|
82
|
// createAllowOverrideButton(composite);
|
83
|
// }
|
84
|
// final Button determinationOnlyForFieldUnitsButton = new Button(composite, SWT.CHECK);
|
85
|
//
|
86
|
// determinationOnlyForFieldUnitsButton.setText(Messages.DatabasePreferncesPage_Determination_only_for_field_unnits);
|
87
|
//
|
88
|
// determinationOnlyForFieldUnitsButton.setSelection(isDeterminationOnlyForFieldUnits);
|
89
|
// determinationOnlyForFieldUnitsButton.addSelectionListener(new SelectionAdapter(){
|
90
|
// @Override
|
91
|
// public void widgetSelected(SelectionEvent e) {
|
92
|
// isDeterminationOnlyForFieldUnits = determinationOnlyForFieldUnitsButton.getSelection();
|
93
|
// }
|
94
|
// });
|
95
|
// if (isAdminPreference){
|
96
|
// createAllowOverrideButton(composite);
|
97
|
// }
|
98
|
//
|
99
|
// final Button showTaxonAssociationButton = new Button(composite, SWT.CHECK);
|
100
|
//
|
101
|
// showTaxonAssociationButton.setText(Messages.DatabasePreferncesPage_Taxon_Associations);
|
102
|
//
|
103
|
// showTaxonAssociationButton.setSelection(isShowTaxonAssociation);
|
104
|
// showTaxonAssociationButton.addSelectionListener(new SelectionAdapter(){
|
105
|
// @Override
|
106
|
// public void widgetSelected(SelectionEvent e) {
|
107
|
// isShowTaxonAssociation = showTaxonAssociationButton.getSelection();
|
108
|
//
|
109
|
// }
|
110
|
// });
|
111
|
//
|
112
|
// if (isAdminPreference){
|
113
|
// createAllowOverrideButton(composite);
|
114
|
// }
|
115
|
//
|
116
|
// final Button showLifeFormButton = new Button(composite, SWT.CHECK);
|
117
|
// showLifeFormButton.setText(Messages.DatabasePreferncesPage_Life_Form);
|
118
|
// showLifeFormButton.setSelection(isShowLifeForm);
|
119
|
// showLifeFormButton.addSelectionListener(new SelectionAdapter(){
|
120
|
// @Override
|
121
|
// public void widgetSelected(SelectionEvent e) {
|
122
|
// isShowLifeForm = showLifeFormButton.getSelection();
|
123
|
//
|
124
|
// }
|
125
|
// });
|
126
|
// if (isAdminPreference){
|
127
|
// createAllowOverrideButton(composite);
|
128
|
// }
|
129
|
//
|
130
|
//
|
131
|
// return composite;
|
132
|
// }
|
133
|
|
134
|
@Override
|
135
|
public void init() {
|
136
|
super.init();
|
137
|
if(!CdmStore.isActive()){
|
138
|
return;
|
139
|
}
|
140
|
}
|
141
|
|
142
|
@Override
|
143
|
protected void getValues(){
|
144
|
isAdminPreference = true;
|
145
|
|
146
|
ICdmRepository controller = CdmStore.getCurrentApplicationConfiguration();
|
147
|
if (controller != null){
|
148
|
IPreferenceService service = controller.getPreferenceService();
|
149
|
PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowSpecimen);
|
150
|
showSpecimenPref = service.find(key);
|
151
|
if (showSpecimenPref != null){
|
152
|
this.isShowSpecimenRelatedIssues = Boolean.valueOf(showSpecimenPref.getValue());
|
153
|
this.allowOverrideShowSpecimenRelatedIssues = showSpecimenPref.isAllowOverride();
|
154
|
}else{
|
155
|
showSpecimenPref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowSpecimen, Boolean.toString(true));
|
156
|
this.isShowSpecimenRelatedIssues = true;
|
157
|
this.allowOverrideShowSpecimenRelatedIssues = true;
|
158
|
}
|
159
|
|
160
|
key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowCollectingAreasInGeneralSection);
|
161
|
CdmPreference isShowCollectingAreaInGeneralSectionPref = service.find(key);
|
162
|
if (isShowCollectingAreaInGeneralSectionPref != null){
|
163
|
this.isShowCollectingAreaInGeneralSection = Boolean.valueOf(isShowCollectingAreaInGeneralSectionPref.getValue());
|
164
|
this.allowOverrideShowCollectingAreaInGeneralSection = isShowCollectingAreaInGeneralSectionPref.isAllowOverride();
|
165
|
}
|
166
|
|
167
|
key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.DeterminationOnlyForFieldUnits);
|
168
|
CdmPreference isDeterminationOnlyForFieldUnitsPref = service.find(key);
|
169
|
if (isDeterminationOnlyForFieldUnitsPref != null){
|
170
|
this.isDeterminationOnlyForFieldUnits = Boolean.valueOf(isDeterminationOnlyForFieldUnitsPref.getValue());
|
171
|
this.allowOverrideDeterminationOnlyForFieldUnits = isDeterminationOnlyForFieldUnitsPref.isAllowOverride();
|
172
|
}
|
173
|
key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowTaxonAssociations);
|
174
|
CdmPreference isShowTaxonAssociationPref = service.find(key);
|
175
|
if (isShowTaxonAssociationPref != null){
|
176
|
this.isShowTaxonAssociation = Boolean.valueOf(isShowTaxonAssociationPref.getValue());
|
177
|
this.allowOverrideShowTaxonAssociation = isShowTaxonAssociationPref.isAllowOverride();
|
178
|
}
|
179
|
|
180
|
key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowLifeForm);
|
181
|
CdmPreference isShowLifeFormPref = service.find(key);
|
182
|
if (isShowLifeFormPref != null){
|
183
|
this.isShowLifeForm = Boolean.valueOf(isShowLifeFormPref.getValue());
|
184
|
this.allowOverrideShowLifeForm = isShowLifeFormPref.isAllowOverride();
|
185
|
}
|
186
|
|
187
|
}
|
188
|
}
|
189
|
|
190
|
@Override
|
191
|
public boolean performOk() {
|
192
|
if (showSpecimenPref == null){
|
193
|
return true;
|
194
|
}
|
195
|
ICdmRepository controller = CdmStore.getCurrentApplicationConfiguration();
|
196
|
if (controller != null){
|
197
|
IPreferenceService service = controller.getPreferenceService();
|
198
|
|
199
|
CdmPreference pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowCollectingAreasInGeneralSection, Boolean.toString(this.isShowCollectingAreaInGeneralSection));
|
200
|
pref.setAllowOverride(allowOverrideShowCollectingAreaInGeneralSection);
|
201
|
service.set(pref);
|
202
|
pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowSpecimen, Boolean.toString(this.isShowSpecimenRelatedIssues));
|
203
|
pref.setAllowOverride(allowOverrideShowSpecimenRelatedIssues);
|
204
|
service.set(pref);
|
205
|
|
206
|
pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.DeterminationOnlyForFieldUnits, Boolean.toString(this.isDeterminationOnlyForFieldUnits));
|
207
|
pref.setAllowOverride(allowOverrideDeterminationOnlyForFieldUnits);
|
208
|
service.set(pref);
|
209
|
|
210
|
pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowTaxonAssociations, Boolean.toString(this.isShowTaxonAssociation));
|
211
|
pref.setAllowOverride(allowOverrideShowTaxonAssociation);
|
212
|
service.set(pref);
|
213
|
|
214
|
pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowLifeForm, Boolean.toString(this.isShowLifeForm));
|
215
|
pref.setAllowOverride(allowOverrideShowLifeForm);
|
216
|
service.set(pref);
|
217
|
PreferencesUtil.updateDBPreferences();
|
218
|
|
219
|
|
220
|
}
|
221
|
return true;
|
222
|
}
|
223
|
|
224
|
}
|