1
|
package eu.etaxonomy.taxeditor.databaseAdmin.preferencePage;
|
2
|
|
3
|
|
4
|
import org.eclipse.swt.SWT;
|
5
|
import org.eclipse.swt.custom.CLabel;
|
6
|
import org.eclipse.swt.events.SelectionAdapter;
|
7
|
import org.eclipse.swt.events.SelectionEvent;
|
8
|
import org.eclipse.swt.layout.GridData;
|
9
|
import org.eclipse.swt.layout.GridLayout;
|
10
|
import org.eclipse.swt.widgets.Button;
|
11
|
import org.eclipse.swt.widgets.Composite;
|
12
|
import org.eclipse.swt.widgets.Control;
|
13
|
import org.eclipse.swt.widgets.Label;
|
14
|
|
15
|
import eu.etaxonomy.cdm.api.application.ICdmRepository;
|
16
|
import eu.etaxonomy.cdm.api.service.IPreferenceService;
|
17
|
import eu.etaxonomy.cdm.model.metadata.CdmPreference;
|
18
|
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
|
19
|
import eu.etaxonomy.taxeditor.l10n.Messages;
|
20
|
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
|
21
|
import eu.etaxonomy.taxeditor.preference.NameDetailsConfigurator;
|
22
|
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
|
23
|
import eu.etaxonomy.taxeditor.preference.menu.CdmPreferencePage;
|
24
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
25
|
|
26
|
|
27
|
public class NameDetailsViewConfiguration extends CdmPreferencePage implements IE4AdminPreferencePage{
|
28
|
|
29
|
boolean isSimpleDetailsViewActivated;
|
30
|
|
31
|
Composite dbSettings ;
|
32
|
boolean isAllowOverride;
|
33
|
boolean isShowTaxon;
|
34
|
boolean isShowLSID;
|
35
|
boolean isShowNomenclaturalCode;
|
36
|
boolean isShowNameCache;
|
37
|
boolean isShowAppendedPhrase;
|
38
|
boolean isShowRank;
|
39
|
boolean isShowEpithets;
|
40
|
boolean isShowAuthorCache;
|
41
|
boolean isShowAuthorship;
|
42
|
boolean isShowNomenclaturalRef;
|
43
|
boolean isShowNomenclaturalStatus;
|
44
|
boolean isShowProtologue;
|
45
|
boolean isShowTypeDesignation;
|
46
|
boolean isShowNameRelationship;
|
47
|
boolean isShowHybrid;
|
48
|
boolean isShowNameApprobiation;
|
49
|
|
50
|
|
51
|
@Override
|
52
|
protected Control createContents(Composite parent) {
|
53
|
final CLabel description = new CLabel(parent, SWT.NULL);
|
54
|
description.setText(Messages.NameDetailsViewConfiguration_description);
|
55
|
CdmPreference nameDetailsPref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.NameDetailsView);
|
56
|
isAllowOverride = false;
|
57
|
if (nameDetailsPref != null){
|
58
|
//TODO: create checkbox
|
59
|
|
60
|
isAllowOverride = nameDetailsPref.isAllowOverride();
|
61
|
}
|
62
|
|
63
|
|
64
|
|
65
|
isSimpleDetailsViewActivated = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION);
|
66
|
|
67
|
final Button activateCheckButton = new Button(parent, SWT.CHECK);
|
68
|
activateCheckButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, true, 1, 1));
|
69
|
activateCheckButton.setText(Messages.NameDetailsViewConfiguration_activateSimpleDetailsView);
|
70
|
activateCheckButton.setSelection(isSimpleDetailsViewActivated);
|
71
|
activateCheckButton.addSelectionListener(new SelectionAdapter(){
|
72
|
@Override
|
73
|
public void widgetSelected(SelectionEvent e) {
|
74
|
isSimpleDetailsViewActivated = activateCheckButton.getSelection();
|
75
|
//
|
76
|
if(isSimpleDetailsViewActivated){
|
77
|
dbSettings.setVisible(true);
|
78
|
dbSettings.setEnabled(true);
|
79
|
}else{
|
80
|
dbSettings.setVisible(false);
|
81
|
dbSettings.setEnabled(false);
|
82
|
}
|
83
|
}
|
84
|
});
|
85
|
|
86
|
|
87
|
|
88
|
dbSettings = new Composite(parent, SWT.NONE);
|
89
|
dbSettings.setLayout(new GridLayout());
|
90
|
dbSettings.setVisible(isSimpleDetailsViewActivated);
|
91
|
// Table table = new Table(dbSettings,SWT.BORDER | SWT.CHECK);
|
92
|
// TableColumn tableColumnValue = new TableColumn(table, SWT.CENTER);
|
93
|
//
|
94
|
// TableColumn tableColumnAllowOverride = new TableColumn(table, SWT.CENTER);
|
95
|
|
96
|
|
97
|
|
98
|
final Button allowLocalPreference = new Button(dbSettings, SWT.CHECK);
|
99
|
// boolean isUseLocalPreference = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ALLOW_OVERRIDE_NAME_DETAILS);
|
100
|
allowLocalPreference.setText(Messages.DatabasePreferencesPage_UseLocalPreferences);
|
101
|
allowLocalPreference.setSelection(isAllowOverride);
|
102
|
allowLocalPreference.addSelectionListener(new SelectionAdapter(){
|
103
|
@Override
|
104
|
public void widgetSelected(SelectionEvent e) {
|
105
|
isAllowOverride = allowLocalPreference.getSelection();
|
106
|
|
107
|
}
|
108
|
});
|
109
|
Label separator= new Label(dbSettings, SWT.HORIZONTAL | SWT.SEPARATOR);
|
110
|
separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
111
|
final Button showTaxon = new Button(dbSettings, SWT.CHECK);
|
112
|
isShowTaxon = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_TAXON);
|
113
|
showTaxon.setText(Messages.NameDetailsViewComposite_Show_Taxon);
|
114
|
showTaxon.setSelection(isShowTaxon);
|
115
|
showTaxon.addSelectionListener(new SelectionAdapter(){
|
116
|
@Override
|
117
|
public void widgetSelected(SelectionEvent e) {
|
118
|
isShowTaxon = showTaxon.getSelection();
|
119
|
|
120
|
}
|
121
|
});
|
122
|
|
123
|
final Button showLsid = new Button(dbSettings, SWT.CHECK);
|
124
|
isShowLSID = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_LSID);
|
125
|
showLsid.setText(Messages.NameDetailsViewComposite_Show_LSID);
|
126
|
showLsid.setSelection(isShowLSID);
|
127
|
showLsid.addSelectionListener(new SelectionAdapter(){
|
128
|
@Override
|
129
|
public void widgetSelected(SelectionEvent e) {
|
130
|
isShowLSID = showLsid.getSelection();
|
131
|
|
132
|
}
|
133
|
});
|
134
|
|
135
|
final Button showNomenclaturalCode = new Button(dbSettings, SWT.CHECK);
|
136
|
isShowNomenclaturalCode = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE);
|
137
|
showNomenclaturalCode.setText(Messages.NameDetailsViewComposite_Show_NomenclaturalCode);
|
138
|
showNomenclaturalCode.setSelection(isShowNomenclaturalCode);
|
139
|
showNomenclaturalCode.addSelectionListener(new SelectionAdapter(){
|
140
|
@Override
|
141
|
public void widgetSelected(SelectionEvent e) {
|
142
|
isShowNomenclaturalCode = showNomenclaturalCode.getSelection();
|
143
|
|
144
|
}
|
145
|
});
|
146
|
|
147
|
final Button showNameCache = new Button(dbSettings, SWT.CHECK);
|
148
|
isShowNameCache = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAMECACHE);
|
149
|
showNameCache.setText(Messages.NameDetailsViewComposite_Show_NameCache);
|
150
|
showNameCache.setSelection(isShowNameCache);
|
151
|
showNameCache.addSelectionListener(new SelectionAdapter(){
|
152
|
@Override
|
153
|
public void widgetSelected(SelectionEvent e) {
|
154
|
isShowNameCache = showNameCache.getSelection();
|
155
|
|
156
|
}
|
157
|
});
|
158
|
final Button showAppendedPhrase = new Button(dbSettings, SWT.CHECK);
|
159
|
isShowAppendedPhrase= PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE);
|
160
|
showAppendedPhrase.setText(Messages.NameDetailsViewComposite_Show_AppendedPhrase);
|
161
|
showAppendedPhrase.setSelection(isShowAppendedPhrase);
|
162
|
showAppendedPhrase.addSelectionListener(new SelectionAdapter(){
|
163
|
@Override
|
164
|
public void widgetSelected(SelectionEvent e) {
|
165
|
isShowAppendedPhrase = showAppendedPhrase.getSelection();
|
166
|
|
167
|
}
|
168
|
});
|
169
|
|
170
|
final Button showRank = new Button(dbSettings, SWT.CHECK);
|
171
|
isShowRank = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_RANK);
|
172
|
showRank.setText(Messages.NameDetailsViewComposite_Show_Rank);
|
173
|
showRank.setSelection(isShowRank);
|
174
|
showRank.addSelectionListener(new SelectionAdapter(){
|
175
|
@Override
|
176
|
public void widgetSelected(SelectionEvent e) {
|
177
|
isShowRank = showRank.getSelection();
|
178
|
|
179
|
}
|
180
|
});
|
181
|
final Button showEpithets = new Button(dbSettings, SWT.CHECK);
|
182
|
isShowEpithets = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS);
|
183
|
showEpithets.setText(Messages.NameDetailsViewComposite_Show_AtomisedEpithets);
|
184
|
showEpithets.setSelection(isShowEpithets);
|
185
|
showEpithets.addSelectionListener(new SelectionAdapter(){
|
186
|
@Override
|
187
|
public void widgetSelected(SelectionEvent e) {
|
188
|
isShowEpithets = showEpithets.getSelection();
|
189
|
|
190
|
}
|
191
|
});
|
192
|
|
193
|
final Button showAuthorCache = new Button(dbSettings, SWT.CHECK);
|
194
|
isShowAuthorCache = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP_CACHE);
|
195
|
showAuthorCache.setText(Messages.NameDetailsViewComposite_Show_AuthorCache);
|
196
|
showAuthorCache.setSelection(isShowAuthorCache);
|
197
|
showAuthorCache.addSelectionListener(new SelectionAdapter(){
|
198
|
@Override
|
199
|
public void widgetSelected(SelectionEvent e) {
|
200
|
isShowAuthorCache = showAuthorCache.getSelection();
|
201
|
|
202
|
}
|
203
|
});
|
204
|
|
205
|
final Button showAuthorship = new Button(dbSettings, SWT.CHECK);
|
206
|
isShowAuthorship = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP);
|
207
|
showAuthorship.setText(Messages.NameDetailsViewComposite_Show_Author);
|
208
|
showAuthorship.setSelection(isShowAuthorship);
|
209
|
showAuthorship.addSelectionListener(new SelectionAdapter(){
|
210
|
@Override
|
211
|
public void widgetSelected(SelectionEvent e) {
|
212
|
isShowAuthorship = showAuthorship.getSelection();
|
213
|
|
214
|
}
|
215
|
});
|
216
|
|
217
|
final Button showNomenclaturalRef = new Button(dbSettings, SWT.CHECK);
|
218
|
isShowNomenclaturalRef = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE);
|
219
|
showNomenclaturalRef.setText(Messages.NameDetailsViewComposite_Show_NomenclaturalReference);
|
220
|
showNomenclaturalRef.setSelection(isShowNomenclaturalRef);
|
221
|
showNomenclaturalRef.addSelectionListener(new SelectionAdapter(){
|
222
|
@Override
|
223
|
public void widgetSelected(SelectionEvent e) {
|
224
|
isShowNomenclaturalRef = showNomenclaturalRef.getSelection();
|
225
|
|
226
|
}
|
227
|
});
|
228
|
|
229
|
final Button showNomenclaturalStatus = new Button(dbSettings, SWT.CHECK);
|
230
|
isShowNomenclaturalStatus = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS);
|
231
|
showNomenclaturalStatus.setText(Messages.NameDetailsViewComposite_Show_NomenclaturalStatus);
|
232
|
showNomenclaturalStatus.setSelection(isShowNomenclaturalStatus);
|
233
|
showNomenclaturalStatus.addSelectionListener(new SelectionAdapter(){
|
234
|
@Override
|
235
|
public void widgetSelected(SelectionEvent e) {
|
236
|
isShowNomenclaturalStatus = showNomenclaturalStatus.getSelection();
|
237
|
|
238
|
}
|
239
|
});
|
240
|
|
241
|
final Button showProtologue = new Button(dbSettings, SWT.CHECK);
|
242
|
isShowProtologue = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_PROTOLOGUE);
|
243
|
showProtologue.setText(Messages.NameDetailsViewComposite_Show_Protologue);
|
244
|
showProtologue.setSelection(isShowProtologue);
|
245
|
showProtologue.addSelectionListener(new SelectionAdapter(){
|
246
|
@Override
|
247
|
public void widgetSelected(SelectionEvent e) {
|
248
|
isShowProtologue = showProtologue.getSelection();
|
249
|
|
250
|
}
|
251
|
});
|
252
|
|
253
|
final Button showTypeDesignation = new Button(dbSettings, SWT.CHECK);
|
254
|
isShowTypeDesignation = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION);
|
255
|
showTypeDesignation.setText(Messages.NameDetailsViewComposite_Show_TypeDesignation);
|
256
|
showTypeDesignation.setSelection(isShowTypeDesignation);
|
257
|
showTypeDesignation.addSelectionListener(new SelectionAdapter(){
|
258
|
@Override
|
259
|
public void widgetSelected(SelectionEvent e) {
|
260
|
isShowTypeDesignation = showTypeDesignation.getSelection();
|
261
|
|
262
|
}
|
263
|
});
|
264
|
|
265
|
|
266
|
final Button showNameRelationship = new Button(dbSettings, SWT.CHECK);
|
267
|
isShowNameRelationship = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP);
|
268
|
showNameRelationship.setText(Messages.NameDetailsViewComposite_Show_Namerelationships);
|
269
|
showNameRelationship.setSelection(isShowNameRelationship);
|
270
|
showNameRelationship.addSelectionListener(new SelectionAdapter(){
|
271
|
@Override
|
272
|
public void widgetSelected(SelectionEvent e) {
|
273
|
isShowNameRelationship = showNameRelationship.getSelection();
|
274
|
|
275
|
}
|
276
|
});
|
277
|
|
278
|
final Button showHybrid = new Button(dbSettings, SWT.CHECK);
|
279
|
isShowHybrid = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_HYBRID);
|
280
|
showHybrid.setText(Messages.NameDetailsViewComposite_Show_Hybrid);
|
281
|
showHybrid.setSelection(isShowHybrid);
|
282
|
showHybrid.addSelectionListener(new SelectionAdapter(){
|
283
|
@Override
|
284
|
public void widgetSelected(SelectionEvent e) {
|
285
|
isShowHybrid = showHybrid.getSelection();
|
286
|
|
287
|
}
|
288
|
});
|
289
|
final Button showNameApprobiation = new Button(dbSettings, SWT.CHECK);
|
290
|
isShowNameApprobiation = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAME_APPROBATION);
|
291
|
showNameApprobiation.setText(Messages.NameDetailsViewComposite_Show_NameApprobiation);
|
292
|
showNameApprobiation.setSelection(isShowNameApprobiation);
|
293
|
showNameApprobiation.addSelectionListener(new SelectionAdapter(){
|
294
|
@Override
|
295
|
public void widgetSelected(SelectionEvent e) {
|
296
|
isShowNameApprobiation = showNameApprobiation.getSelection();
|
297
|
PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAME_APPROBATION, isShowNameApprobiation);
|
298
|
}
|
299
|
});
|
300
|
|
301
|
|
302
|
|
303
|
|
304
|
return dbSettings;
|
305
|
}
|
306
|
|
307
|
/**
|
308
|
*
|
309
|
*/
|
310
|
protected NameDetailsConfigurator createNameDetailsViewConfig() {
|
311
|
NameDetailsConfigurator config = new NameDetailsConfigurator(isSimpleDetailsViewActivated);
|
312
|
|
313
|
config.setAppendedPhraseActivated(isShowAppendedPhrase);
|
314
|
config.setAtomisedEpithetsActivated(isShowEpithets);
|
315
|
config.setAuthorshipSectionActivated(isShowAuthorship);
|
316
|
config.setAuthorCacheActivated(isShowAuthorCache);
|
317
|
config.setLSIDActivated(isShowLSID);
|
318
|
config.setNameApprobiationActivated(isShowNameApprobiation);
|
319
|
config.setNameCacheActivated(isShowNameCache);
|
320
|
config.setNameRelationsSectionActivated(isShowNameRelationship);
|
321
|
config.setNomenclaturalCodeActived(isShowNomenclaturalCode);
|
322
|
config.setNomenclaturalStatusSectionActivated(isShowNomenclaturalStatus);
|
323
|
config.setNomenclaturalReferenceSectionActivated(isShowNomenclaturalRef);
|
324
|
config.setProtologueActivated(isShowProtologue);
|
325
|
config.setRankActivated(isShowRank);
|
326
|
config.setTaxonSectionActivated(isShowTaxon);
|
327
|
config.setTypeDesignationSectionActivated(isShowTypeDesignation);
|
328
|
config.setHybridActivated(isShowHybrid);
|
329
|
|
330
|
|
331
|
return config;
|
332
|
}
|
333
|
|
334
|
|
335
|
@Override
|
336
|
public boolean performOk() {
|
337
|
ICdmRepository controller = CdmStore.getCurrentApplicationConfiguration();
|
338
|
if (controller == null){
|
339
|
return false;
|
340
|
}
|
341
|
IPreferenceService service = controller.getPreferenceService();
|
342
|
NameDetailsConfigurator config = createNameDetailsViewConfig();
|
343
|
String value = config.toString();
|
344
|
// boolean allowOverride = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ALLOW_OVERRIDE_NAME_DETAILS);
|
345
|
|
346
|
CdmPreference pref = CdmPreference.NewDatabaseInstance( PreferencePredicate.NameDetailsView, value);
|
347
|
pref.setAllowOverride(isAllowOverride);
|
348
|
service.set(pref);
|
349
|
PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_TAXON, isShowTaxon);
|
350
|
PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_LSID, isShowLSID);
|
351
|
PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE, isShowNomenclaturalCode);
|
352
|
PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAMECACHE, isShowNameCache);
|
353
|
PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE, isShowAppendedPhrase);
|
354
|
PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_RANK, isShowRank);
|
355
|
PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS, isShowEpithets);
|
356
|
PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP, isShowAuthorship);
|
357
|
PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP_CACHE, isShowAuthorCache);
|
358
|
PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE, isShowNomenclaturalRef);
|
359
|
PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS, isShowNomenclaturalStatus);
|
360
|
PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_PROTOLOGUE, isShowProtologue);
|
361
|
PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION, isShowTypeDesignation);
|
362
|
PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP, isShowNameRelationship);
|
363
|
PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_HYBRID, isShowHybrid);
|
364
|
PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ALLOW_OVERRIDE_NAME_DETAILS, isAllowOverride);
|
365
|
PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION, isSimpleDetailsViewActivated);
|
366
|
return true;
|
367
|
}
|
368
|
|
369
|
}
|