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.taxeditor.l10n.Messages;
|
18
|
import eu.etaxonomy.taxeditor.preference.ChecklistEditorGeneralPreference;
|
19
|
import eu.etaxonomy.taxeditor.preference.EditorPreferencePredicate;
|
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
|
|
31
|
@Override
|
32
|
protected Control createContents(Composite parent) {
|
33
|
return super.createContents(parent);
|
34
|
|
35
|
}
|
36
|
|
37
|
@Override
|
38
|
public boolean performOk() {
|
39
|
if (!isValid()){
|
40
|
return true;
|
41
|
}
|
42
|
ICdmRepository controller = CdmStore.getCurrentApplicationConfiguration();
|
43
|
if (controller == null){
|
44
|
return false;
|
45
|
}
|
46
|
IPreferenceService service = controller.getPreferenceService();
|
47
|
|
48
|
CdmPreference pref = CdmPreference.NewTaxEditorInstance( EditorPreferencePredicate.DistributionEditorActivated, Boolean.toString(isEditorActivated));
|
49
|
pref.setAllowOverride(this.allowOverrideActivated);
|
50
|
service.set(pref);
|
51
|
|
52
|
pref = CdmPreference.NewTaxEditorInstance( EditorPreferencePredicate.DisplayOfAreasInDistributionEditor, this.displayArea);
|
53
|
pref.setAllowOverride(this.allowOverrideAreaDisplay);
|
54
|
service.set(pref);
|
55
|
|
56
|
pref = CdmPreference.NewTaxEditorInstance( EditorPreferencePredicate.DisplayOfStatus, this.displayStatus);
|
57
|
pref.setAllowOverride(this.allowOverrideStatusDisplay);
|
58
|
service.set(pref);
|
59
|
|
60
|
pref = CdmPreference.NewTaxEditorInstance( EditorPreferencePredicate.ShowRankInDistributionEditor, Boolean.toString(isShowRank));
|
61
|
pref.setAllowOverride(this.allowOverrideRank);
|
62
|
service.set(pref);
|
63
|
|
64
|
pref = CdmPreference.NewTaxEditorInstance( EditorPreferencePredicate.AreasSortedByIdInVocabulary, Boolean.toString(isSortByVocabularyOrder));
|
65
|
pref.setAllowOverride(this.allowOverrideOrderAreas);
|
66
|
service.set(pref);
|
67
|
|
68
|
pref = CdmPreference.NewTaxEditorInstance( EditorPreferencePredicate.OwnDescriptionForDistributionEditor, Boolean.toString(ownDescriptionForDistributionEditor));
|
69
|
pref.setAllowOverride(this.allowOverrideOwnDescriptionForDistributionEditor);
|
70
|
service.set(pref);
|
71
|
|
72
|
PreferencesUtil.updateDBPreferences();
|
73
|
|
74
|
return true;
|
75
|
}
|
76
|
|
77
|
@Override
|
78
|
public void getValues() {
|
79
|
|
80
|
distributionEditorPref = PreferencesUtil.getPreferenceFromDB(EditorPreferencePredicate.DistributionEditorActivated);
|
81
|
if (distributionEditorPref == null){
|
82
|
distributionEditorPref = CdmPreference.NewTaxEditorInstance(EditorPreferencePredicate.DistributionEditorActivated, EditorPreferencePredicate.DistributionEditorActivated.getDefaultValue().toString());
|
83
|
}
|
84
|
isEditorActivated = Boolean.valueOf(distributionEditorPref.getValue());
|
85
|
allowOverrideActivated = distributionEditorPref.isAllowOverride();
|
86
|
isAdminPreference = true;
|
87
|
|
88
|
CdmPreference pref = PreferencesUtil.getPreferenceFromDB(EditorPreferencePredicate.DisplayOfAreasInDistributionEditor);
|
89
|
if (pref != null){
|
90
|
this.displayArea = pref.getValue();
|
91
|
this.allowOverrideAreaDisplay = pref.isAllowOverride();
|
92
|
}else{
|
93
|
this.displayArea = EditorPreferencePredicate.DisplayOfAreasInDistributionEditor.getDefaultValue().toString();
|
94
|
this.allowOverrideAreaDisplay = true;
|
95
|
}
|
96
|
|
97
|
pref = PreferencesUtil.getPreferenceFromDB(EditorPreferencePredicate.DisplayOfStatus);
|
98
|
if (pref != null){
|
99
|
this.displayStatus = pref.getValue();
|
100
|
this.allowOverrideStatusDisplay = pref.isAllowOverride();
|
101
|
}else{
|
102
|
this.displayStatus = EditorPreferencePredicate.DisplayOfStatus.getDefaultValue().toString();
|
103
|
this.allowOverrideStatusDisplay = true;
|
104
|
}
|
105
|
|
106
|
pref = PreferencesUtil.getPreferenceFromDB(EditorPreferencePredicate.AreasSortedByIdInVocabulary);
|
107
|
if (pref != null){
|
108
|
this.isSortByVocabularyOrder = Boolean.valueOf(pref.getValue().toString());
|
109
|
this.allowOverrideOrderAreas = pref.isAllowOverride();
|
110
|
}else{
|
111
|
this.isSortByVocabularyOrder = Boolean.valueOf(EditorPreferencePredicate.AreasSortedByIdInVocabulary.getDefaultValue().toString());
|
112
|
this.allowOverrideOrderAreas = true;
|
113
|
}
|
114
|
|
115
|
pref = PreferencesUtil.getPreferenceFromDB(EditorPreferencePredicate.ShowRankInDistributionEditor);
|
116
|
if (pref != null){
|
117
|
this.isShowRank = Boolean.valueOf(pref.getValue().toString());
|
118
|
this.allowOverrideRank = pref.isAllowOverride();
|
119
|
}else{
|
120
|
this.isShowRank = Boolean.valueOf(EditorPreferencePredicate.ShowRankInDistributionEditor.getDefaultValue().toString());
|
121
|
this.allowOverrideRank = true;
|
122
|
}
|
123
|
|
124
|
pref = PreferencesUtil.getPreferenceFromDB(EditorPreferencePredicate.OwnDescriptionForDistributionEditor);
|
125
|
if (pref != null){
|
126
|
this.ownDescriptionForDistributionEditor = Boolean.valueOf(pref.getValue().toString());
|
127
|
this.allowOverrideOwnDescriptionForDistributionEditor= pref.isAllowOverride();
|
128
|
}else{
|
129
|
this.ownDescriptionForDistributionEditor = Boolean.valueOf(EditorPreferencePredicate.OwnDescriptionForDistributionEditor.getDefaultValue().toString());
|
130
|
this.allowOverrideOwnDescriptionForDistributionEditor = true;
|
131
|
}
|
132
|
|
133
|
commandHandlerString = "eu.etaxonomy.taxeditor.store.open.OpenDistributionEditorWizardAdminHandler";
|
134
|
commandHandlerStringStatus = "eu.etaxonomy.taxeditor.store.open.OpenDistributionStatusWizardAdminHandler";
|
135
|
overrideString = Messages.GeneralPreference_allowOverride;
|
136
|
setValid(false);
|
137
|
}
|
138
|
|
139
|
}
|