1
|
package eu.etaxonomy.taxeditor.databaseAdmin.preferencePage;
|
2
|
|
3
|
|
4
|
import eu.etaxonomy.cdm.api.application.ICdmRepository;
|
5
|
import eu.etaxonomy.cdm.api.service.IPreferenceService;
|
6
|
import eu.etaxonomy.cdm.model.metadata.CdmPreference;
|
7
|
import eu.etaxonomy.cdm.model.metadata.CdmPreference.PrefKey;
|
8
|
import eu.etaxonomy.cdm.model.metadata.PreferenceSubject;
|
9
|
import eu.etaxonomy.taxeditor.preference.CdmPreferenceCache;
|
10
|
import eu.etaxonomy.taxeditor.preference.EditorPreferencePredicate;
|
11
|
import eu.etaxonomy.taxeditor.preference.NameDetailsConfigurator;
|
12
|
import eu.etaxonomy.taxeditor.preference.NameDetailsViewConfiguration;
|
13
|
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
|
14
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
15
|
|
16
|
|
17
|
public class NameDetailsViewAdminConfiguration extends NameDetailsViewConfiguration implements IE4AdminPreferencePage{
|
18
|
|
19
|
protected NameDetailsConfigurator createNameDetailsViewConfig() {
|
20
|
NameDetailsConfigurator config = new NameDetailsConfigurator(isSimpleDetailsViewActivated);
|
21
|
|
22
|
config.setAppendedPhraseActivated(isShowAppendedPhrase);
|
23
|
config.setAtomisedEpithetsActivated(isShowEpithets);
|
24
|
config.setAuthorshipSectionActivated(isShowAuthorship);
|
25
|
config.setAuthorCacheActivated(isShowAuthorCache);
|
26
|
config.setLSIDActivated(isShowLSID);
|
27
|
config.setNameApprobiationActivated(isShowNameApprobiation);
|
28
|
config.setNameCacheActivated(isShowNameCache);
|
29
|
config.setNameRelationsSectionActivated(isShowNameRelationship);
|
30
|
config.setNomenclaturalCodeActived(isShowNomenclaturalCode);
|
31
|
config.setNomenclaturalStatusSectionActivated(isShowNomenclaturalStatus);
|
32
|
config.setNomenclaturalReferenceSectionActivated(isShowNomenclaturalRef);
|
33
|
config.setProtologueActivated(isShowProtologue);
|
34
|
config.setRankActivated(isShowRank);
|
35
|
config.setTaxonSectionActivated(isShowTaxon);
|
36
|
config.setSecDetailsActivated(isSecDetailsActivated);
|
37
|
config.setSecEnabled(isSecEnabled);
|
38
|
config.setTypeDesignationSectionActivated(isShowTypeDesignation);
|
39
|
config.setHybridActivated(isShowHybrid);
|
40
|
|
41
|
|
42
|
return config;
|
43
|
}
|
44
|
|
45
|
|
46
|
@Override
|
47
|
public boolean performOk() {
|
48
|
if (nameDetailsConfig == null){
|
49
|
return true;
|
50
|
}
|
51
|
ICdmRepository controller = CdmStore.getCurrentApplicationConfiguration();
|
52
|
if (controller == null){
|
53
|
return false;
|
54
|
}
|
55
|
IPreferenceService service = controller.getPreferenceService();
|
56
|
NameDetailsConfigurator config = createNameDetailsViewConfig();
|
57
|
String value = config.toString();
|
58
|
|
59
|
|
60
|
CdmPreference pref = CdmPreference.NewTaxEditorInstance(EditorPreferencePredicate.NameDetailsView, value);
|
61
|
pref.setAllowOverride(isAllowOverride);
|
62
|
service.set(pref);
|
63
|
PreferencesUtil.saveConfigToPrefernceStore(config);
|
64
|
|
65
|
return true;
|
66
|
}
|
67
|
|
68
|
|
69
|
@Override
|
70
|
public void init(){
|
71
|
isAdminPreference = true;
|
72
|
ICdmRepository controller = CdmStore.getCurrentApplicationConfiguration();
|
73
|
if (controller != null){
|
74
|
IPreferenceService service = controller.getPreferenceService();
|
75
|
PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), EditorPreferencePredicate.NameDetailsView);
|
76
|
CdmPreference pref = service.find(key);
|
77
|
|
78
|
isAllowOverride = pref.isAllowOverride();
|
79
|
CdmPreferenceCache cache = CdmPreferenceCache.instance();
|
80
|
cache.put(pref);
|
81
|
}
|
82
|
nameDetailsConfig = PreferencesUtil.getPreferredNameDetailsConfiguration(false);
|
83
|
if (nameDetailsConfig == null){
|
84
|
nameDetailsConfig = new NameDetailsConfigurator(false);
|
85
|
}
|
86
|
|
87
|
}
|
88
|
|
89
|
|
90
|
}
|