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 isSecDetailsActivated;
|
35
|
boolean isSecEnabled;
|
36
|
boolean isShowLSID;
|
37
|
boolean isShowNomenclaturalCode;
|
38
|
boolean isShowNameCache;
|
39
|
boolean isShowAppendedPhrase;
|
40
|
boolean isShowRank;
|
41
|
boolean isShowEpithets;
|
42
|
boolean isShowAuthorCache;
|
43
|
boolean isShowAuthorship;
|
44
|
boolean isShowNomenclaturalRef;
|
45
|
boolean isShowNomenclaturalStatus;
|
46
|
boolean isShowProtologue;
|
47
|
boolean isShowTypeDesignation;
|
48
|
boolean isShowNameRelationship;
|
49
|
boolean isShowHybrid;
|
50
|
boolean isShowNameApprobiation;
|
51
|
NameDetailsConfigurator nameDetailsConfig = null;
|
52
|
|
53
|
@Override
|
54
|
protected Control createContents(Composite parent) {
|
55
|
final CLabel description = new CLabel(parent, SWT.NULL);
|
56
|
description.setText(Messages.NameDetailsViewConfiguration_description);
|
57
|
nameDetailsConfig = PreferencesUtil.getPreferredNameDetailsConfiguration(false);
|
58
|
if (nameDetailsConfig == null){
|
59
|
nameDetailsConfig = new NameDetailsConfigurator(false);
|
60
|
}
|
61
|
final Button activateCheckButton = new Button(parent, SWT.CHECK);
|
62
|
activateCheckButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, true, 1, 1));
|
63
|
activateCheckButton.setText(Messages.NameDetailsViewConfiguration_activateSimpleDetailsView);
|
64
|
isSimpleDetailsViewActivated = nameDetailsConfig.isSimpleDetailsViewActivated();
|
65
|
activateCheckButton.setSelection(isSimpleDetailsViewActivated);
|
66
|
activateCheckButton.addSelectionListener(new SelectionAdapter(){
|
67
|
@Override
|
68
|
public void widgetSelected(SelectionEvent e) {
|
69
|
isSimpleDetailsViewActivated = activateCheckButton.getSelection();
|
70
|
//
|
71
|
if(isSimpleDetailsViewActivated){
|
72
|
dbSettings.setVisible(true);
|
73
|
dbSettings.setEnabled(true);
|
74
|
}else{
|
75
|
dbSettings.setVisible(false);
|
76
|
dbSettings.setEnabled(false);
|
77
|
}
|
78
|
}
|
79
|
});
|
80
|
|
81
|
|
82
|
|
83
|
dbSettings = new Composite(parent, SWT.NONE);
|
84
|
dbSettings.setLayout(new GridLayout());
|
85
|
dbSettings.setVisible(isSimpleDetailsViewActivated);
|
86
|
// Table table = new Table(dbSettings,SWT.BORDER | SWT.CHECK);
|
87
|
// TableColumn tableColumnValue = new TableColumn(table, SWT.CENTER);
|
88
|
//
|
89
|
// TableColumn tableColumnAllowOverride = new TableColumn(table, SWT.CENTER);
|
90
|
|
91
|
|
92
|
|
93
|
final Button allowLocalPreference = new Button(dbSettings, SWT.CHECK);
|
94
|
// boolean isUseLocalPreference = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ALLOW_OVERRIDE_NAME_DETAILS);
|
95
|
allowLocalPreference.setText(Messages.DatabasePreferencesPage_UseLocalPreferences);
|
96
|
isAllowOverride = nameDetailsConfig.isAllowOverride();
|
97
|
allowLocalPreference.setSelection(isAllowOverride);
|
98
|
allowLocalPreference.addSelectionListener(new SelectionAdapter(){
|
99
|
@Override
|
100
|
public void widgetSelected(SelectionEvent e) {
|
101
|
isAllowOverride = allowLocalPreference.getSelection();
|
102
|
|
103
|
}
|
104
|
});
|
105
|
Label separator= new Label(dbSettings, SWT.HORIZONTAL | SWT.SEPARATOR);
|
106
|
separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
107
|
final Button showTaxon = new Button(dbSettings, SWT.CHECK);
|
108
|
showTaxon.setText(Messages.NameDetailsViewComposite_Show_Taxon);
|
109
|
isShowTaxon = nameDetailsConfig.isTaxonSectionActivated();
|
110
|
showTaxon.setSelection(isShowTaxon);
|
111
|
showTaxon.addSelectionListener(new SelectionAdapter(){
|
112
|
@Override
|
113
|
public void widgetSelected(SelectionEvent e) {
|
114
|
isShowTaxon = showTaxon.getSelection();
|
115
|
|
116
|
}
|
117
|
});
|
118
|
|
119
|
final Button showSecDetail = new Button(dbSettings, SWT.CHECK);
|
120
|
showSecDetail.setText(Messages.NameDetailsViewComposite_Show_SecDetail);
|
121
|
isSecDetailsActivated = nameDetailsConfig.isSecDetailsActivated();
|
122
|
showSecDetail.setSelection(isSecDetailsActivated);
|
123
|
showSecDetail.addSelectionListener(new SelectionAdapter(){
|
124
|
@Override
|
125
|
public void widgetSelected(SelectionEvent e) {
|
126
|
isSecDetailsActivated = showSecDetail.getSelection();
|
127
|
|
128
|
}
|
129
|
});
|
130
|
|
131
|
final Button secEnabled = new Button(dbSettings, SWT.CHECK);
|
132
|
secEnabled.setText(Messages.NameDetailsViewComposite_SecEnabled);
|
133
|
isSecEnabled = nameDetailsConfig.isSecEnabled();
|
134
|
secEnabled.setSelection(isSecEnabled);
|
135
|
secEnabled.addSelectionListener(new SelectionAdapter(){
|
136
|
@Override
|
137
|
public void widgetSelected(SelectionEvent e) {
|
138
|
isSecEnabled = secEnabled.getSelection();
|
139
|
|
140
|
}
|
141
|
});
|
142
|
|
143
|
|
144
|
final Button showLsid = new Button(dbSettings, SWT.CHECK);
|
145
|
showLsid.setText(Messages.NameDetailsViewComposite_Show_LSID);
|
146
|
isShowLSID = nameDetailsConfig.isLSIDActivated();
|
147
|
showLsid.setSelection(isShowLSID);
|
148
|
showLsid.addSelectionListener(new SelectionAdapter(){
|
149
|
@Override
|
150
|
public void widgetSelected(SelectionEvent e) {
|
151
|
isShowLSID = showLsid.getSelection();
|
152
|
|
153
|
}
|
154
|
});
|
155
|
|
156
|
final Button showNomenclaturalCode = new Button(dbSettings, SWT.CHECK);
|
157
|
showNomenclaturalCode.setText(Messages.NameDetailsViewComposite_Show_NomenclaturalCode);
|
158
|
isShowNomenclaturalCode = nameDetailsConfig.isNomenclaturalCodeActived();
|
159
|
showNomenclaturalCode.setSelection(isShowNomenclaturalCode);
|
160
|
showNomenclaturalCode.addSelectionListener(new SelectionAdapter(){
|
161
|
@Override
|
162
|
public void widgetSelected(SelectionEvent e) {
|
163
|
isShowNomenclaturalCode = showNomenclaturalCode.getSelection();
|
164
|
|
165
|
}
|
166
|
});
|
167
|
|
168
|
final Button showNameCache = new Button(dbSettings, SWT.CHECK);
|
169
|
showNameCache.setText(Messages.NameDetailsViewComposite_Show_NameCache);
|
170
|
isShowNameCache = nameDetailsConfig.isNameCacheActivated();
|
171
|
showNameCache.setSelection(isShowNameCache);
|
172
|
showNameCache.addSelectionListener(new SelectionAdapter(){
|
173
|
@Override
|
174
|
public void widgetSelected(SelectionEvent e) {
|
175
|
isShowNameCache = showNameCache.getSelection();
|
176
|
|
177
|
}
|
178
|
});
|
179
|
final Button showAppendedPhrase = new Button(dbSettings, SWT.CHECK);
|
180
|
isShowAppendedPhrase= nameDetailsConfig.isAppendedPhraseActivated();
|
181
|
showAppendedPhrase.setText(Messages.NameDetailsViewComposite_Show_AppendedPhrase);
|
182
|
showAppendedPhrase.setSelection(isShowAppendedPhrase);
|
183
|
showAppendedPhrase.addSelectionListener(new SelectionAdapter(){
|
184
|
@Override
|
185
|
public void widgetSelected(SelectionEvent e) {
|
186
|
isShowAppendedPhrase = showAppendedPhrase.getSelection();
|
187
|
|
188
|
}
|
189
|
});
|
190
|
|
191
|
final Button showRank = new Button(dbSettings, SWT.CHECK);
|
192
|
isShowRank = nameDetailsConfig.isRankActivated();
|
193
|
showRank.setText(Messages.NameDetailsViewComposite_Show_Rank);
|
194
|
showRank.setSelection(isShowRank);
|
195
|
showRank.addSelectionListener(new SelectionAdapter(){
|
196
|
@Override
|
197
|
public void widgetSelected(SelectionEvent e) {
|
198
|
isShowRank = showRank.getSelection();
|
199
|
|
200
|
}
|
201
|
});
|
202
|
final Button showEpithets = new Button(dbSettings, SWT.CHECK);
|
203
|
isShowEpithets = nameDetailsConfig.isAtomisedEpithetsActivated();
|
204
|
showEpithets.setText(Messages.NameDetailsViewComposite_Show_AtomisedEpithets);
|
205
|
showEpithets.setSelection(isShowEpithets);
|
206
|
showEpithets.addSelectionListener(new SelectionAdapter(){
|
207
|
@Override
|
208
|
public void widgetSelected(SelectionEvent e) {
|
209
|
isShowEpithets = showEpithets.getSelection();
|
210
|
|
211
|
}
|
212
|
});
|
213
|
|
214
|
final Button showAuthorCache = new Button(dbSettings, SWT.CHECK);
|
215
|
isShowAuthorCache = nameDetailsConfig.isAuthorCacheActivated();
|
216
|
showAuthorCache.setText(Messages.NameDetailsViewComposite_Show_AuthorCache);
|
217
|
showAuthorCache.setSelection(isShowAuthorCache);
|
218
|
showAuthorCache.addSelectionListener(new SelectionAdapter(){
|
219
|
@Override
|
220
|
public void widgetSelected(SelectionEvent e) {
|
221
|
isShowAuthorCache = showAuthorCache.getSelection();
|
222
|
|
223
|
}
|
224
|
});
|
225
|
|
226
|
final Button showAuthorship = new Button(dbSettings, SWT.CHECK);
|
227
|
isShowAuthorship = nameDetailsConfig.isAuthorshipSectionActivated();
|
228
|
showAuthorship.setText(Messages.NameDetailsViewComposite_Show_Author);
|
229
|
showAuthorship.setSelection(isShowAuthorship);
|
230
|
showAuthorship.addSelectionListener(new SelectionAdapter(){
|
231
|
@Override
|
232
|
public void widgetSelected(SelectionEvent e) {
|
233
|
isShowAuthorship = showAuthorship.getSelection();
|
234
|
|
235
|
}
|
236
|
});
|
237
|
|
238
|
final Button showNomenclaturalRef = new Button(dbSettings, SWT.CHECK);
|
239
|
isShowNomenclaturalRef = nameDetailsConfig.isNomenclaturalReferenceSectionActivated();
|
240
|
showNomenclaturalRef.setText(Messages.NameDetailsViewComposite_Show_NomenclaturalReference);
|
241
|
showNomenclaturalRef.setSelection(isShowNomenclaturalRef);
|
242
|
showNomenclaturalRef.addSelectionListener(new SelectionAdapter(){
|
243
|
@Override
|
244
|
public void widgetSelected(SelectionEvent e) {
|
245
|
isShowNomenclaturalRef = showNomenclaturalRef.getSelection();
|
246
|
|
247
|
}
|
248
|
});
|
249
|
|
250
|
final Button showNomenclaturalStatus = new Button(dbSettings, SWT.CHECK);
|
251
|
isShowNomenclaturalStatus = nameDetailsConfig.isNomenclaturalStatusSectionActivated();
|
252
|
showNomenclaturalStatus.setText(Messages.NameDetailsViewComposite_Show_NomenclaturalStatus);
|
253
|
showNomenclaturalStatus.setSelection(isShowNomenclaturalStatus);
|
254
|
showNomenclaturalStatus.addSelectionListener(new SelectionAdapter(){
|
255
|
@Override
|
256
|
public void widgetSelected(SelectionEvent e) {
|
257
|
isShowNomenclaturalStatus = showNomenclaturalStatus.getSelection();
|
258
|
|
259
|
}
|
260
|
});
|
261
|
|
262
|
final Button showProtologue = new Button(dbSettings, SWT.CHECK);
|
263
|
isShowProtologue = nameDetailsConfig.isProtologueActivated();
|
264
|
showProtologue.setText(Messages.NameDetailsViewComposite_Show_Protologue);
|
265
|
showProtologue.setSelection(isShowProtologue);
|
266
|
showProtologue.addSelectionListener(new SelectionAdapter(){
|
267
|
@Override
|
268
|
public void widgetSelected(SelectionEvent e) {
|
269
|
isShowProtologue = showProtologue.getSelection();
|
270
|
|
271
|
}
|
272
|
});
|
273
|
|
274
|
final Button showTypeDesignation = new Button(dbSettings, SWT.CHECK);
|
275
|
isShowTypeDesignation = nameDetailsConfig.isTypeDesignationSectionActivated();
|
276
|
showTypeDesignation.setText(Messages.NameDetailsViewComposite_Show_TypeDesignation);
|
277
|
showTypeDesignation.setSelection(isShowTypeDesignation);
|
278
|
showTypeDesignation.addSelectionListener(new SelectionAdapter(){
|
279
|
@Override
|
280
|
public void widgetSelected(SelectionEvent e) {
|
281
|
isShowTypeDesignation = showTypeDesignation.getSelection();
|
282
|
|
283
|
}
|
284
|
});
|
285
|
|
286
|
|
287
|
final Button showNameRelationship = new Button(dbSettings, SWT.CHECK);
|
288
|
isShowNameRelationship = nameDetailsConfig.isNameRelationsSectionActivated();
|
289
|
showNameRelationship.setText(Messages.NameDetailsViewComposite_Show_Namerelationships);
|
290
|
showNameRelationship.setSelection(isShowNameRelationship);
|
291
|
showNameRelationship.addSelectionListener(new SelectionAdapter(){
|
292
|
@Override
|
293
|
public void widgetSelected(SelectionEvent e) {
|
294
|
isShowNameRelationship = showNameRelationship.getSelection();
|
295
|
|
296
|
}
|
297
|
});
|
298
|
|
299
|
final Button showHybrid = new Button(dbSettings, SWT.CHECK);
|
300
|
isShowHybrid = nameDetailsConfig.isHybridActivated();
|
301
|
showHybrid.setText(Messages.NameDetailsViewComposite_Show_Hybrid);
|
302
|
showHybrid.setSelection(isShowHybrid);
|
303
|
showHybrid.addSelectionListener(new SelectionAdapter(){
|
304
|
@Override
|
305
|
public void widgetSelected(SelectionEvent e) {
|
306
|
isShowHybrid = showHybrid.getSelection();
|
307
|
|
308
|
}
|
309
|
});
|
310
|
final Button showNameApprobiation = new Button(dbSettings, SWT.CHECK);
|
311
|
isShowNameApprobiation = nameDetailsConfig.isNameApprobiationActivated();
|
312
|
showNameApprobiation.setText(Messages.NameDetailsViewComposite_Show_NameApprobiation);
|
313
|
showNameApprobiation.setSelection(isShowNameApprobiation);
|
314
|
showNameApprobiation.addSelectionListener(new SelectionAdapter(){
|
315
|
@Override
|
316
|
public void widgetSelected(SelectionEvent e) {
|
317
|
isShowNameApprobiation = showNameApprobiation.getSelection();
|
318
|
//PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAME_APPROBATION, isShowNameApprobiation);
|
319
|
}
|
320
|
});
|
321
|
|
322
|
|
323
|
|
324
|
|
325
|
return dbSettings;
|
326
|
}
|
327
|
|
328
|
/**
|
329
|
*
|
330
|
*/
|
331
|
protected NameDetailsConfigurator createNameDetailsViewConfig() {
|
332
|
NameDetailsConfigurator config = new NameDetailsConfigurator(isSimpleDetailsViewActivated);
|
333
|
|
334
|
config.setAppendedPhraseActivated(isShowAppendedPhrase);
|
335
|
config.setAtomisedEpithetsActivated(isShowEpithets);
|
336
|
config.setAuthorshipSectionActivated(isShowAuthorship);
|
337
|
config.setAuthorCacheActivated(isShowAuthorCache);
|
338
|
config.setLSIDActivated(isShowLSID);
|
339
|
config.setNameApprobiationActivated(isShowNameApprobiation);
|
340
|
config.setNameCacheActivated(isShowNameCache);
|
341
|
config.setNameRelationsSectionActivated(isShowNameRelationship);
|
342
|
config.setNomenclaturalCodeActived(isShowNomenclaturalCode);
|
343
|
config.setNomenclaturalStatusSectionActivated(isShowNomenclaturalStatus);
|
344
|
config.setNomenclaturalReferenceSectionActivated(isShowNomenclaturalRef);
|
345
|
config.setProtologueActivated(isShowProtologue);
|
346
|
config.setRankActivated(isShowRank);
|
347
|
config.setTaxonSectionActivated(isShowTaxon);
|
348
|
config.setSecDetailsActivated(isSecDetailsActivated);
|
349
|
config.setSecEnabled(isSecEnabled);
|
350
|
config.setTypeDesignationSectionActivated(isShowTypeDesignation);
|
351
|
config.setHybridActivated(isShowHybrid);
|
352
|
|
353
|
|
354
|
return config;
|
355
|
}
|
356
|
|
357
|
|
358
|
@Override
|
359
|
public boolean performOk() {
|
360
|
if (nameDetailsConfig == null){
|
361
|
return true;
|
362
|
}
|
363
|
ICdmRepository controller = CdmStore.getCurrentApplicationConfiguration();
|
364
|
if (controller == null){
|
365
|
return false;
|
366
|
}
|
367
|
IPreferenceService service = controller.getPreferenceService();
|
368
|
NameDetailsConfigurator config = createNameDetailsViewConfig();
|
369
|
String value = config.toString();
|
370
|
// boolean allowOverride = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ALLOW_OVERRIDE_NAME_DETAILS);
|
371
|
|
372
|
CdmPreference pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.NameDetailsView, value);
|
373
|
pref.setAllowOverride(isAllowOverride);
|
374
|
service.set(pref);
|
375
|
PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_TAXON, isShowTaxon);
|
376
|
PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_SEC_DETAILS, isSecDetailsActivated);
|
377
|
PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.DISABLE_SEC, isSecEnabled);
|
378
|
PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_LSID, isShowLSID);
|
379
|
PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE, isShowNomenclaturalCode);
|
380
|
PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAMECACHE, isShowNameCache);
|
381
|
PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE, isShowAppendedPhrase);
|
382
|
PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_RANK, isShowRank);
|
383
|
PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS, isShowEpithets);
|
384
|
PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP, isShowAuthorship);
|
385
|
PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP_CACHE, isShowAuthorCache);
|
386
|
PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE, isShowNomenclaturalRef);
|
387
|
PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS, isShowNomenclaturalStatus);
|
388
|
PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_PROTOLOGUE, isShowProtologue);
|
389
|
PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION, isShowTypeDesignation);
|
390
|
PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP, isShowNameRelationship);
|
391
|
PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_HYBRID, isShowHybrid);
|
392
|
PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ALLOW_OVERRIDE_NAME_DETAILS, isAllowOverride);
|
393
|
PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION, isSimpleDetailsViewActivated);
|
394
|
return true;
|
395
|
}
|
396
|
|
397
|
}
|