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.SWT;
|
12
|
import org.eclipse.swt.events.SelectionAdapter;
|
13
|
import org.eclipse.swt.events.SelectionEvent;
|
14
|
import org.eclipse.swt.layout.GridData;
|
15
|
import org.eclipse.swt.widgets.Button;
|
16
|
import org.eclipse.swt.widgets.Composite;
|
17
|
import org.eclipse.swt.widgets.Control;
|
18
|
|
19
|
import eu.etaxonomy.cdm.api.application.ICdmRepository;
|
20
|
import eu.etaxonomy.cdm.api.service.IPreferenceService;
|
21
|
import eu.etaxonomy.cdm.model.metadata.CdmPreference;
|
22
|
import eu.etaxonomy.cdm.model.metadata.CdmPreference.PrefKey;
|
23
|
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
|
24
|
import eu.etaxonomy.cdm.model.metadata.PreferenceSubject;
|
25
|
import eu.etaxonomy.taxeditor.l10n.Messages;
|
26
|
import eu.etaxonomy.taxeditor.preference.menu.CdmPreferencePage;
|
27
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
28
|
|
29
|
/**
|
30
|
* @author k.luther
|
31
|
* @since 27.04.2018
|
32
|
*
|
33
|
*/
|
34
|
public class SpecimenAdminPreferences extends CdmPreferencePage implements IE4AdminPreferencePage {
|
35
|
|
36
|
|
37
|
|
38
|
boolean isShowCollectingAreaInGeneralSection = false;
|
39
|
boolean isDeterminationOnlyForFieldUnits = false;
|
40
|
boolean isShowTaxonAssociation = false;
|
41
|
boolean isShowLifeForm = false;
|
42
|
boolean isUseLocalPreference = false;
|
43
|
|
44
|
|
45
|
@Override
|
46
|
protected Control createContents(Composite parent) {
|
47
|
Composite composite = new Composite(parent, SWT.NULL);
|
48
|
|
49
|
final Button showCollectingAreaInGeneralSectionButton = new Button(composite, SWT.CHECK);
|
50
|
|
51
|
showCollectingAreaInGeneralSectionButton.setText(Messages.DatabasePreferncesPage_Show_Collecting_Areas_in_general_section);
|
52
|
|
53
|
showCollectingAreaInGeneralSectionButton.setSelection(isShowCollectingAreaInGeneralSection);
|
54
|
showCollectingAreaInGeneralSectionButton.addSelectionListener(new SelectionAdapter(){
|
55
|
@Override
|
56
|
public void widgetSelected(SelectionEvent e) {
|
57
|
isShowCollectingAreaInGeneralSection = showCollectingAreaInGeneralSectionButton.getSelection();
|
58
|
|
59
|
}
|
60
|
});
|
61
|
|
62
|
final Button determinationOnlyForFieldUnitsButton = new Button(composite, SWT.CHECK);
|
63
|
|
64
|
determinationOnlyForFieldUnitsButton.setText(Messages.DatabasePreferncesPage_Determination_only_for_field_unnits);
|
65
|
|
66
|
determinationOnlyForFieldUnitsButton.setSelection(isDeterminationOnlyForFieldUnits);
|
67
|
determinationOnlyForFieldUnitsButton.addSelectionListener(new SelectionAdapter(){
|
68
|
@Override
|
69
|
public void widgetSelected(SelectionEvent e) {
|
70
|
isDeterminationOnlyForFieldUnits = determinationOnlyForFieldUnitsButton.getSelection();
|
71
|
}
|
72
|
});
|
73
|
|
74
|
final Button showTaxonAssociationButton = new Button(composite, SWT.CHECK);
|
75
|
|
76
|
showTaxonAssociationButton.setText(Messages.DatabasePreferncesPage_Taxon_Associations);
|
77
|
|
78
|
showTaxonAssociationButton.setSelection(isShowTaxonAssociation);
|
79
|
showTaxonAssociationButton.addSelectionListener(new SelectionAdapter(){
|
80
|
@Override
|
81
|
public void widgetSelected(SelectionEvent e) {
|
82
|
isShowTaxonAssociation = showTaxonAssociationButton.getSelection();
|
83
|
|
84
|
}
|
85
|
});
|
86
|
|
87
|
final Button showLifeFormButton = new Button(composite, SWT.CHECK);
|
88
|
showLifeFormButton.setText(Messages.DatabasePreferncesPage_Life_Form);
|
89
|
showLifeFormButton.setSelection(isShowLifeForm);
|
90
|
showLifeFormButton.addSelectionListener(new SelectionAdapter(){
|
91
|
@Override
|
92
|
public void widgetSelected(SelectionEvent e) {
|
93
|
isShowLifeForm = showLifeFormButton.getSelection();
|
94
|
|
95
|
}
|
96
|
});
|
97
|
|
98
|
// Composite useLocalComp = new Composite(composite, SWT.NONE);
|
99
|
|
100
|
|
101
|
final Button useLocalPreference = new Button(composite, SWT.CHECK);
|
102
|
|
103
|
useLocalPreference.setText(Messages.DatabasePreferencesPage_UseLocalPreferences);
|
104
|
GridData gridData = new GridData(SWT.FILL, SWT.BOTTOM, false, false);
|
105
|
gridData.verticalIndent = 10;
|
106
|
useLocalPreference.setLayoutData(gridData);
|
107
|
|
108
|
useLocalPreference.setSelection(isUseLocalPreference);
|
109
|
useLocalPreference.addSelectionListener(new SelectionAdapter(){
|
110
|
@Override
|
111
|
public void widgetSelected(SelectionEvent e) {
|
112
|
isUseLocalPreference = useLocalPreference.getSelection();
|
113
|
|
114
|
}
|
115
|
});
|
116
|
return composite;
|
117
|
}
|
118
|
|
119
|
@Override
|
120
|
public void init() {
|
121
|
super.init();
|
122
|
if(!CdmStore.isActive()){
|
123
|
return;
|
124
|
}
|
125
|
ICdmRepository controller = CdmStore.getCurrentApplicationConfiguration();
|
126
|
if (controller != null){
|
127
|
IPreferenceService service = controller.getPreferenceService();
|
128
|
PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.ShowCollectingAreasInGeneralSection);
|
129
|
CdmPreference isShowCollectingAreaInGeneralSectionPref = service.find(key);
|
130
|
if (isShowCollectingAreaInGeneralSectionPref != null){
|
131
|
this.isShowCollectingAreaInGeneralSection = Boolean.valueOf(isShowCollectingAreaInGeneralSectionPref.getValue());
|
132
|
}
|
133
|
key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.DeterminationOnlyForFieldUnits);
|
134
|
CdmPreference isDeterminationOnlyForFieldUnitsPref = service.find(key);
|
135
|
if (isDeterminationOnlyForFieldUnitsPref != null){
|
136
|
this.isDeterminationOnlyForFieldUnits = Boolean.valueOf(isDeterminationOnlyForFieldUnitsPref.getValue());
|
137
|
}
|
138
|
key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.ShowTaxonAssociations);
|
139
|
CdmPreference isShowTaxonAssociationPref = service.find(key);
|
140
|
if (isShowTaxonAssociationPref != null){
|
141
|
this.isShowTaxonAssociation = Boolean.valueOf(isShowTaxonAssociationPref.getValue());
|
142
|
isUseLocalPreference = isShowTaxonAssociationPref.isAllowOverride();
|
143
|
}
|
144
|
|
145
|
key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.ShowLifeForm);
|
146
|
CdmPreference isShowLifeFormPref = service.find(key);
|
147
|
if (isShowLifeFormPref != null){
|
148
|
this.isShowLifeForm = Boolean.valueOf(isShowLifeFormPref.getValue());
|
149
|
}
|
150
|
|
151
|
|
152
|
|
153
|
|
154
|
}
|
155
|
|
156
|
|
157
|
}
|
158
|
|
159
|
@Override
|
160
|
public boolean performOk() {
|
161
|
|
162
|
|
163
|
return true;
|
164
|
}
|
165
|
|
166
|
}
|