1
|
/**
|
2
|
* Copyright (C) 2019 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 eu.etaxonomy.cdm.api.application.ICdmRepository;
|
12
|
import eu.etaxonomy.cdm.api.service.IPreferenceService;
|
13
|
import eu.etaxonomy.cdm.model.metadata.CdmPreference;
|
14
|
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
|
15
|
import eu.etaxonomy.taxeditor.preference.SearchDialogPreferences;
|
16
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
17
|
|
18
|
/**
|
19
|
* @author k.luther
|
20
|
* @since 08.08.2019
|
21
|
*/
|
22
|
public class SearchDialogAdminPreferences extends SearchDialogPreferences implements IE4AdminPreferencePage {
|
23
|
|
24
|
|
25
|
|
26
|
|
27
|
@Override
|
28
|
public void getValues(){
|
29
|
super.getValues();
|
30
|
if(showIdInSelectionDialogPref != null){
|
31
|
showIdInSelectionDialog = Boolean.parseBoolean(showIdInSelectionDialogPref.getValue());
|
32
|
}else{
|
33
|
showIdInSelectionDialog = null;
|
34
|
showIdInSelectionDialogPref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowIdInSelectionDialog, null);
|
35
|
}
|
36
|
if (searchForIdentifierAsDefaultPref != null){
|
37
|
searchForIdentifierAsDefault = Boolean.parseBoolean(searchForIdentifierAsDefaultPref.getValue());
|
38
|
}else{
|
39
|
searchForIdentifierAsDefault = null;
|
40
|
searchForIdentifierAsDefaultPref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.SearchForIdentifierAsDefault, null);
|
41
|
}
|
42
|
if (searchForIdentifierAndTitleCachePref != null){
|
43
|
searchForIdentifierAndTitleCache = Boolean.parseBoolean(searchForIdentifierAndTitleCachePref.getValue());
|
44
|
}else{
|
45
|
searchForIdentifierAndTitleCache = null;
|
46
|
searchForIdentifierAndTitleCachePref =CdmPreference.NewTaxEditorInstance(PreferencePredicate.SearchForIdentifierAndTitleCache, null);
|
47
|
}
|
48
|
if (sortTaxaByRankAndNamePref != null){
|
49
|
sortTaxaByRankAndName = Boolean.parseBoolean(sortTaxaByRankAndNamePref.getValue());
|
50
|
}else{
|
51
|
sortTaxaByRankAndName = null;
|
52
|
sortTaxaByRankAndNamePref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.SortTaxaByRankAndName, null);
|
53
|
}
|
54
|
if (filterCommonNameReferencesPref != null){
|
55
|
filterCommonNameReferences = Boolean.parseBoolean(filterCommonNameReferencesPref.getValue());
|
56
|
}else{
|
57
|
filterCommonNameReferences = null;
|
58
|
filterCommonNameReferencesPref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.CommonNameReferencesWithMarker, null);
|
59
|
}
|
60
|
}
|
61
|
|
62
|
@Override
|
63
|
public boolean performOk(){
|
64
|
if (!isApply()){
|
65
|
return true;
|
66
|
}
|
67
|
ICdmRepository controller = CdmStore.getCurrentApplicationConfiguration();
|
68
|
if (controller != null){
|
69
|
IPreferenceService service = controller.getPreferenceService();
|
70
|
CdmPreference pref;
|
71
|
if (showIdInSelectionDialog != null || !showIdInSelectionDialogPref.isAllowOverride()) {
|
72
|
pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowIdInSelectionDialog, showIdInSelectionDialog != null? showIdInSelectionDialog.toString():null);
|
73
|
pref.setAllowOverride(showIdInSelectionDialogPref.isAllowOverride());
|
74
|
service.set(pref);
|
75
|
}else{
|
76
|
service.remove(showIdInSelectionDialogPref.getKey());
|
77
|
}
|
78
|
|
79
|
|
80
|
if(searchForIdentifierAsDefault != null || !searchForIdentifierAsDefaultPref.isAllowOverride()){
|
81
|
pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.SearchForIdentifierAsDefault, searchForIdentifierAsDefault!= null? searchForIdentifierAsDefault.toString():null);
|
82
|
pref.setAllowOverride(searchForIdentifierAsDefaultPref.isAllowOverride());
|
83
|
service.set(pref);
|
84
|
}else{
|
85
|
service.remove(searchForIdentifierAsDefaultPref.getKey());
|
86
|
}
|
87
|
|
88
|
|
89
|
if(searchForIdentifierAndTitleCache != null){
|
90
|
pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.SearchForIdentifierAndTitleCache, searchForIdentifierAndTitleCache!= null? searchForIdentifierAndTitleCache.toString():null);
|
91
|
pref.setAllowOverride(searchForIdentifierAndTitleCachePref.isAllowOverride());
|
92
|
service.set(pref);
|
93
|
}else{
|
94
|
service.remove(searchForIdentifierAndTitleCachePref.getKey());
|
95
|
}
|
96
|
|
97
|
if(sortTaxaByRankAndName != null){
|
98
|
|
99
|
pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.SortTaxaByRankAndName, sortTaxaByRankAndName!= null? sortTaxaByRankAndName.toString():null);
|
100
|
pref.setAllowOverride(sortTaxaByRankAndNamePref.isAllowOverride());
|
101
|
service.set(pref);
|
102
|
}else{
|
103
|
service.remove(sortTaxaByRankAndNamePref.getKey());
|
104
|
}
|
105
|
|
106
|
|
107
|
|
108
|
if(filterCommonNameReferences != null){
|
109
|
pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.CommonNameReferencesWithMarker, filterCommonNameReferences!= null? filterCommonNameReferences.toString():null);
|
110
|
pref.setAllowOverride(filterCommonNameReferencesPref.isAllowOverride());
|
111
|
service.set(pref);
|
112
|
}else{
|
113
|
service.remove(filterCommonNameReferencesPref.getKey());
|
114
|
}
|
115
|
}
|
116
|
|
117
|
return true;
|
118
|
}
|
119
|
|
120
|
|
121
|
|
122
|
}
|