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.TermDisplayEnum;
|
19
|
import eu.etaxonomy.cdm.model.metadata.TermOrder;
|
20
|
import eu.etaxonomy.taxeditor.preference.ChecklistEditorGeneralPreference;
|
21
|
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
|
22
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
23
|
|
24
|
/**
|
25
|
* @author a.oppermann
|
26
|
* @date 21.07.2014
|
27
|
*
|
28
|
*/
|
29
|
public class ChecklistEditorGeneralAdminPreference extends ChecklistEditorGeneralPreference implements IE4AdminPreferencePage {
|
30
|
|
31
|
Composite parent;
|
32
|
|
33
|
|
34
|
@Override
|
35
|
protected Control createContents(Composite parent) {
|
36
|
this.parent = parent;
|
37
|
return super.createContents(parent);
|
38
|
|
39
|
}
|
40
|
|
41
|
@Override
|
42
|
public boolean performOk() {
|
43
|
if (distributionEditorPref == null){
|
44
|
return true;
|
45
|
}
|
46
|
ICdmRepository controller = CdmStore.getCurrentApplicationConfiguration();
|
47
|
if (controller == null){
|
48
|
return false;
|
49
|
}
|
50
|
IPreferenceService service = controller.getPreferenceService();
|
51
|
|
52
|
CdmPreference pref = CdmPreference.NewTaxEditorInstance( PreferencePredicate.DistributionEditorActivated, Boolean.toString(isEditorActivated));
|
53
|
pref.setAllowOverride(this.distributionEditorPref.isAllowOverride());
|
54
|
service.set(pref);
|
55
|
|
56
|
pref = CdmPreference.NewTaxEditorInstance( PreferencePredicate.DisplayOfAreasInDistributionEditor, this.displayArea);
|
57
|
pref.setAllowOverride(prefAreaDisplay.isAllowOverride());
|
58
|
service.set(pref);
|
59
|
|
60
|
pref = CdmPreference.NewTaxEditorInstance( PreferencePredicate.DisplayOfStatus, this.displayStatus);
|
61
|
pref.setAllowOverride(prefStatusDisplay.isAllowOverride());
|
62
|
service.set(pref);
|
63
|
|
64
|
pref = CdmPreference.NewTaxEditorInstance( PreferencePredicate.ShowRankInDistributionEditor, Boolean.toString(isShowRank));
|
65
|
pref.setAllowOverride(prefRank.isAllowOverride());
|
66
|
service.set(pref);
|
67
|
|
68
|
pref = CdmPreference.NewTaxEditorInstance( PreferencePredicate.AreasSortedInDistributionEditor, this.orderAreas);
|
69
|
pref.setAllowOverride(prefAreaSort.isAllowOverride());
|
70
|
service.set(pref);
|
71
|
|
72
|
pref = CdmPreference.NewTaxEditorInstance( PreferencePredicate.OwnDescriptionForDistributionEditor, Boolean.toString(ownDescriptionForDistributionEditor));
|
73
|
pref.setAllowOverride(prefOwnDescription.isAllowOverride());
|
74
|
service.set(pref);
|
75
|
|
76
|
// if (statusPref != null){
|
77
|
// service.set(statusPref);
|
78
|
// }
|
79
|
// if (areaVocPref != null){
|
80
|
// service.set(areaVocPref);
|
81
|
// }
|
82
|
PreferencesUtil.updateDBPreferences();
|
83
|
|
84
|
return true;
|
85
|
}
|
86
|
|
87
|
@Override
|
88
|
public void getValues() {
|
89
|
super.getValues();
|
90
|
distributionEditorPref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.DistributionEditorActivated);
|
91
|
if (distributionEditorPref == null){
|
92
|
distributionEditorPref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.DistributionEditorActivated, PreferencePredicate.DistributionEditorActivated.getDefaultValue().toString());
|
93
|
}
|
94
|
isEditorActivated = Boolean.valueOf(distributionEditorPref.getValue());
|
95
|
// allowOverrideActivated = distributionEditorPref.isAllowOverride();
|
96
|
isAdminPreference = true;
|
97
|
|
98
|
if (prefAreaDisplay != null){
|
99
|
this.displayArea = prefAreaDisplay.getValue();
|
100
|
}else{
|
101
|
this.displayArea = ((TermDisplayEnum)PreferencePredicate.DisplayOfAreasInDistributionEditor.getDefaultValue()).getKey();
|
102
|
}
|
103
|
|
104
|
|
105
|
if (prefStatusDisplay != null){
|
106
|
this.displayStatus = prefStatusDisplay.getValue();
|
107
|
}else{
|
108
|
this.displayStatus = ((TermDisplayEnum)PreferencePredicate.DisplayOfStatus.getDefaultValue()).getKey();
|
109
|
}
|
110
|
|
111
|
if (prefAreaSort != null){
|
112
|
if (prefAreaSort.getValue() != null){
|
113
|
this.orderAreas = prefAreaSort.getValue().toString();
|
114
|
}else{
|
115
|
this.orderAreas = ((TermOrder)PreferencePredicate.AreasSortedInDistributionEditor.getDefaultValue()).getKey();
|
116
|
}
|
117
|
|
118
|
}else{
|
119
|
this.orderAreas = ((TermOrder)PreferencePredicate.AreasSortedInDistributionEditor.getDefaultValue()).getKey();
|
120
|
|
121
|
}
|
122
|
|
123
|
|
124
|
if (prefRank != null){
|
125
|
this.isShowRank = Boolean.valueOf(prefRank.getValue().toString());
|
126
|
|
127
|
}else{
|
128
|
this.isShowRank = Boolean.valueOf(PreferencePredicate.ShowRankInDistributionEditor.getDefaultValue().toString());
|
129
|
}
|
130
|
|
131
|
|
132
|
if (prefOwnDescription != null){
|
133
|
this.ownDescriptionForDistributionEditor = Boolean.valueOf(prefOwnDescription.getValue().toString());
|
134
|
}else{
|
135
|
this.ownDescriptionForDistributionEditor = Boolean.valueOf(PreferencePredicate.OwnDescriptionForDistributionEditor.getDefaultValue().toString());
|
136
|
}
|
137
|
|
138
|
commandHandlerString = "eu.etaxonomy.taxeditor.store.open.OpenDistributionEditorWizardAdminHandler";
|
139
|
commandHandlerStringStatus = "eu.etaxonomy.taxeditor.store.open.OpenDistributionPerAreaStatusWizardHandler";
|
140
|
|
141
|
setValid(false);
|
142
|
}
|
143
|
|
144
|
|
145
|
|
146
|
}
|