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