1
|
/**
|
2
|
* Copyright (C) 2014 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.widgets.Composite;
|
12
|
import org.eclipse.swt.widgets.Control;
|
13
|
|
14
|
import eu.etaxonomy.cdm.api.application.ICdmRepository;
|
15
|
import eu.etaxonomy.cdm.api.service.IPreferenceService;
|
16
|
import eu.etaxonomy.cdm.model.metadata.CdmPreference;
|
17
|
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
|
18
|
import eu.etaxonomy.cdm.model.metadata.PreferenceSubject;
|
19
|
import eu.etaxonomy.taxeditor.preference.ChecklistEditorGeneralPreference;
|
20
|
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
|
21
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
22
|
|
23
|
/**
|
24
|
* @author a.oppermann
|
25
|
* @date 21.07.2014
|
26
|
*
|
27
|
*/
|
28
|
public class ChecklistEditorGeneralAdminPreference extends ChecklistEditorGeneralPreference implements IE4AdminPreferencePage {
|
29
|
|
30
|
Composite parent;
|
31
|
|
32
|
|
33
|
@Override
|
34
|
protected Control createContents(Composite parent) {
|
35
|
this.parent = parent;
|
36
|
return super.createContents(parent);
|
37
|
|
38
|
}
|
39
|
|
40
|
@Override
|
41
|
public boolean performOk() {
|
42
|
if (!isApply()){
|
43
|
return true;
|
44
|
}
|
45
|
ICdmRepository controller = CdmStore.getCurrentApplicationConfiguration();
|
46
|
if (controller == null){
|
47
|
return false;
|
48
|
}
|
49
|
IPreferenceService service = controller.getPreferenceService();
|
50
|
CdmPreference pref;
|
51
|
if (isEditorActivated == null){
|
52
|
service.remove(CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.DistributionEditorActivated));
|
53
|
}else{
|
54
|
pref = CdmPreference.NewTaxEditorInstance( PreferencePredicate.DistributionEditorActivated, Boolean.toString(isEditorActivated));
|
55
|
pref.setAllowOverride(allowOverrideActivatedButton.getSelection());
|
56
|
service.set(pref);
|
57
|
}
|
58
|
if(displayArea == null){
|
59
|
service.remove(CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.DisplayOfAreasInDistributionEditor));
|
60
|
}else{
|
61
|
pref = CdmPreference.NewTaxEditorInstance( PreferencePredicate.DisplayOfAreasInDistributionEditor, this.displayArea);
|
62
|
pref.setAllowOverride(allowOverrideAreaDisplayButton.getSelection());
|
63
|
service.set(pref);
|
64
|
}
|
65
|
|
66
|
if (displayStatus == null){
|
67
|
service.remove(CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.DisplayOfStatus));
|
68
|
}else{
|
69
|
pref = CdmPreference.NewTaxEditorInstance( PreferencePredicate.DisplayOfStatus, this.displayStatus);
|
70
|
pref.setAllowOverride(allowOverrideStatusDisplayButton.getSelection());
|
71
|
service.set(pref);
|
72
|
}
|
73
|
|
74
|
if (isShowRank == null){
|
75
|
service.remove(CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowRankInDistributionEditor));
|
76
|
}else{
|
77
|
pref = CdmPreference.NewTaxEditorInstance( PreferencePredicate.ShowRankInDistributionEditor, Boolean.toString(isShowRank));
|
78
|
pref.setAllowOverride(allowOverrideRankButton.getSelection());
|
79
|
service.set(pref);
|
80
|
}
|
81
|
if (orderAreas == null){
|
82
|
service.remove(CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.AreasSortedInDistributionEditor));
|
83
|
}else{
|
84
|
pref = CdmPreference.NewTaxEditorInstance( PreferencePredicate.AreasSortedInDistributionEditor, this.orderAreas);
|
85
|
pref.setAllowOverride(allowOverrideOrderAreasButton.getSelection());
|
86
|
service.set(pref);
|
87
|
}
|
88
|
|
89
|
if (displayStatusCombo == null){
|
90
|
service.remove(CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.DisplayOfStatusInCombo));
|
91
|
}else{
|
92
|
pref = CdmPreference.NewTaxEditorInstance( PreferencePredicate.DisplayOfStatusInCombo, displayStatusCombo);
|
93
|
if (prefStatusDisplayInCombo == null){
|
94
|
prefStatusDisplayInCombo = pref;
|
95
|
}
|
96
|
pref.setAllowOverride(prefStatusDisplayInCombo.isAllowOverride());
|
97
|
service.set(pref);
|
98
|
}
|
99
|
|
100
|
PreferencesUtil.updateDBPreferences();
|
101
|
|
102
|
return true;
|
103
|
}
|
104
|
|
105
|
@Override
|
106
|
public void getValues() {
|
107
|
super.getValues();
|
108
|
distributionEditorPref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.DistributionEditorActivated);
|
109
|
if (distributionEditorPref != null){
|
110
|
isEditorActivated = Boolean.valueOf(distributionEditorPref.getValue());
|
111
|
}else{
|
112
|
isEditorActivated = null;
|
113
|
}
|
114
|
|
115
|
|
116
|
isAdminPreference = true;
|
117
|
|
118
|
if (prefAreaDisplay != null){
|
119
|
this.displayArea = prefAreaDisplay.getValue();
|
120
|
}else{
|
121
|
this.displayArea = null;
|
122
|
}
|
123
|
|
124
|
|
125
|
if (prefStatusDisplay != null){
|
126
|
this.displayStatus = prefStatusDisplay.getValue();
|
127
|
}else{
|
128
|
this.displayStatus = null;
|
129
|
}
|
130
|
|
131
|
if (prefStatusDisplayInCombo != null){
|
132
|
this.displayStatusCombo = prefStatusDisplayInCombo.getValue();
|
133
|
}else{
|
134
|
this.displayStatusCombo = null;
|
135
|
}
|
136
|
|
137
|
|
138
|
if (prefAreaSort != null){
|
139
|
if (prefAreaSort.getValue() != null){
|
140
|
this.orderAreas = prefAreaSort.getValue().toString();
|
141
|
}else{
|
142
|
this.orderAreas = null;
|
143
|
}
|
144
|
|
145
|
}else{
|
146
|
this.orderAreas = null;
|
147
|
|
148
|
}
|
149
|
|
150
|
|
151
|
if (prefRank != null){
|
152
|
this.isShowRank = Boolean.valueOf(prefRank.getValue().toString());
|
153
|
|
154
|
}else{
|
155
|
this.isShowRank = null;
|
156
|
}
|
157
|
|
158
|
|
159
|
if (prefOwnDescription != null){
|
160
|
this.ownDescriptionForDistributionEditor = Boolean.valueOf(prefOwnDescription.getValue().toString());
|
161
|
}else{
|
162
|
this.ownDescriptionForDistributionEditor = null;
|
163
|
}
|
164
|
|
165
|
|
166
|
|
167
|
setValid(false);
|
168
|
}
|
169
|
|
170
|
|
171
|
|
172
|
}
|