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.preference;
|
10
|
|
11
|
import org.eclipse.swt.SWT;
|
12
|
import org.eclipse.swt.custom.CLabel;
|
13
|
import org.eclipse.swt.events.SelectionAdapter;
|
14
|
import org.eclipse.swt.events.SelectionEvent;
|
15
|
import org.eclipse.swt.layout.GridLayout;
|
16
|
import org.eclipse.swt.widgets.Button;
|
17
|
import org.eclipse.swt.widgets.Composite;
|
18
|
import org.eclipse.swt.widgets.Control;
|
19
|
import org.eclipse.swt.widgets.Label;
|
20
|
|
21
|
import eu.etaxonomy.cdm.model.metadata.CdmPreference;
|
22
|
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
|
23
|
import eu.etaxonomy.taxeditor.l10n.Messages;
|
24
|
import eu.etaxonomy.taxeditor.preference.menu.CdmPreferencePage;
|
25
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
26
|
import eu.etaxonomy.taxeditor.ui.element.CommandHandlerButton;
|
27
|
|
28
|
/**
|
29
|
* @author a.oppermann
|
30
|
* @date 21.07.2014
|
31
|
*
|
32
|
*/
|
33
|
public class ChecklistEditorGeneralPreference extends CdmPreferencePage {
|
34
|
|
35
|
boolean isEditorActivated;
|
36
|
boolean isUseLocal;
|
37
|
boolean isShowRank;
|
38
|
boolean isSortByVocabularyOrder;
|
39
|
boolean isShowSymbol;
|
40
|
boolean isShowIdInVocabulary;
|
41
|
boolean isShowSymbol1;
|
42
|
boolean isShowSymbol2;
|
43
|
boolean isShowTitle;
|
44
|
Composite child ;
|
45
|
boolean isAllowOverride;
|
46
|
|
47
|
@Override
|
48
|
protected Control createContents(Composite parent) {
|
49
|
|
50
|
Composite composite = new Composite(parent, SWT.NULL);
|
51
|
composite.setLayout(new GridLayout());
|
52
|
|
53
|
CdmPreference distributionEditorPref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.DistributionEditorActivated);
|
54
|
isAllowOverride = false;
|
55
|
if (distributionEditorPref != null){
|
56
|
isAllowOverride = distributionEditorPref.isAllowOverride();
|
57
|
}else{
|
58
|
isAllowOverride = true;
|
59
|
}
|
60
|
|
61
|
|
62
|
if (isAllowOverride){
|
63
|
isEditorActivated = PreferencesUtil.getBooleanValue(IPreferenceKeys.DISTRIBUTION_AREA_PREFRENCES_ACTIVE);
|
64
|
final Button activateCheckButton = new Button(composite, SWT.CHECK);
|
65
|
activateCheckButton.setText("Enable Distribution Editor");
|
66
|
activateCheckButton.setSelection(isEditorActivated);
|
67
|
activateCheckButton.addSelectionListener(new SelectionAdapter(){
|
68
|
@Override
|
69
|
public void widgetSelected(SelectionEvent e) {
|
70
|
isEditorActivated = activateCheckButton.getSelection();
|
71
|
|
72
|
if(isEditorActivated){
|
73
|
child.setVisible(true);
|
74
|
child.setEnabled(true);
|
75
|
}else{
|
76
|
child.setVisible(false);
|
77
|
child.setEnabled(false);
|
78
|
}
|
79
|
|
80
|
}
|
81
|
});
|
82
|
|
83
|
child = new Composite(composite, SWT.NULL);
|
84
|
child.setLayout(new GridLayout());
|
85
|
child.setVisible(isEditorActivated);
|
86
|
final CLabel label = new CLabel(child, SWT.NULL);
|
87
|
label.setText("Please open the wizard below, in order to \n" + "choose the area vocabularies for the Distribution Editor");
|
88
|
final CommandHandlerButton button_openFeatureTree = new CommandHandlerButton(child, SWT.PUSH,
|
89
|
"eu.etaxonomy.taxeditor.store.open.OpenDistributionEditorWizardHandler");
|
90
|
|
91
|
button_openFeatureTree.setText("Select Areas");
|
92
|
|
93
|
final CLabel description = new CLabel(child, SWT.NULL);
|
94
|
description.setText(Messages.ChecklistEditorGeneralPreference_Configure_display_of_Areas);
|
95
|
|
96
|
final Button showIdInVocabulary = new Button(child, SWT.RADIO);
|
97
|
isShowIdInVocabulary = PreferencesUtil.isShowIdInVocabularyInChecklistEditor();
|
98
|
showIdInVocabulary.setText("Show Id in Vocabulary instead of full title of the areas");
|
99
|
showIdInVocabulary.setSelection(isShowIdInVocabulary);
|
100
|
showIdInVocabulary.addSelectionListener(new SelectionAdapter(){
|
101
|
@Override
|
102
|
public void widgetSelected(SelectionEvent e) {
|
103
|
isShowIdInVocabulary = showIdInVocabulary.getSelection();
|
104
|
|
105
|
}
|
106
|
});
|
107
|
|
108
|
|
109
|
final Button showSymbol1 = new Button(child, SWT.RADIO);
|
110
|
isShowSymbol1 = PreferencesUtil.isShowSymbol1InChecklistEditor();
|
111
|
|
112
|
showSymbol1.setText(Messages.ChecklistEditorGeneralPreference_show_symbol1);
|
113
|
showSymbol1.setSelection(isShowSymbol1);
|
114
|
showSymbol1.addSelectionListener(new SelectionAdapter(){
|
115
|
@Override
|
116
|
public void widgetSelected(SelectionEvent e) {
|
117
|
isShowSymbol1 = showSymbol1.getSelection();
|
118
|
|
119
|
}
|
120
|
});
|
121
|
final Button showSymbol2 = new Button(child, SWT.RADIO);
|
122
|
isShowSymbol2 = PreferencesUtil.isShowSymbol2InChecklistEditor();
|
123
|
|
124
|
showSymbol2.setText(Messages.ChecklistEditorGeneralPreference_show_symbol2);
|
125
|
showSymbol2.setSelection(isShowSymbol2);
|
126
|
showSymbol2.addSelectionListener(new SelectionAdapter(){
|
127
|
@Override
|
128
|
public void widgetSelected(SelectionEvent e) {
|
129
|
isShowSymbol2 = showSymbol2.getSelection();
|
130
|
|
131
|
}
|
132
|
});
|
133
|
|
134
|
final Button showTitle = new Button(child, SWT.RADIO);
|
135
|
isShowTitle = !(isShowIdInVocabulary || isShowSymbol1 || isShowSymbol2);
|
136
|
|
137
|
showTitle.setText(Messages.ChecklistEditorGeneralPreference_show_title);
|
138
|
showTitle.setSelection(isShowTitle);
|
139
|
showTitle.addSelectionListener(new SelectionAdapter(){
|
140
|
@Override
|
141
|
public void widgetSelected(SelectionEvent e) {
|
142
|
isShowTitle = showTitle.getSelection();
|
143
|
|
144
|
}
|
145
|
});
|
146
|
|
147
|
|
148
|
final Button showSymbol = new Button(child, SWT.CHECK);
|
149
|
isShowSymbol = PreferencesUtil.isShowSymbolInChecklistEditor();
|
150
|
showSymbol.setText("Show Symbol of the Status, if existing");
|
151
|
showSymbol.setSelection(isShowSymbol);
|
152
|
showSymbol.addSelectionListener(new SelectionAdapter(){
|
153
|
@Override
|
154
|
public void widgetSelected(SelectionEvent e) {
|
155
|
isShowSymbol = showSymbol.getSelection();
|
156
|
}
|
157
|
});
|
158
|
PreferencesUtil.recursiveSetEnabled(button_openFeatureTree, CdmStore.isActive());
|
159
|
isShowRank = PreferencesUtil.isShowRankInChecklistEditor();
|
160
|
final Button activateRankButton = new Button(child, SWT.CHECK);
|
161
|
activateRankButton.setText("Show Rank in Distribution Editor");
|
162
|
activateRankButton.setSelection(isShowRank);
|
163
|
activateRankButton.addSelectionListener(new SelectionAdapter(){
|
164
|
@Override
|
165
|
public void widgetSelected(SelectionEvent e) {
|
166
|
isShowRank = activateRankButton.getSelection();
|
167
|
}
|
168
|
});
|
169
|
final Button sortNamedAreaByVocabularyOrder = new Button(child, SWT.CHECK);
|
170
|
isSortByVocabularyOrder = PreferencesUtil.isSortNamedAreaByOrderInVocabulary();
|
171
|
sortNamedAreaByVocabularyOrder.setText("Sort Areas by Order in Vocabulary");
|
172
|
sortNamedAreaByVocabularyOrder.setSelection(isSortByVocabularyOrder);
|
173
|
sortNamedAreaByVocabularyOrder.addSelectionListener(new SelectionAdapter(){
|
174
|
@Override
|
175
|
public void widgetSelected(SelectionEvent e) {
|
176
|
isSortByVocabularyOrder = sortNamedAreaByVocabularyOrder.getSelection();
|
177
|
}
|
178
|
});
|
179
|
|
180
|
if(isEditorActivated){
|
181
|
child.setEnabled(true);
|
182
|
}else{
|
183
|
child.setEnabled(false);
|
184
|
}
|
185
|
}else{
|
186
|
Label label = new Label(composite, SWT.NONE);
|
187
|
label.setText("The CDM settings don't allow to set the preferences for using the distribution editor locally. If you need to make local settings, please ask an administrator.");
|
188
|
|
189
|
}
|
190
|
|
191
|
return composite;
|
192
|
}
|
193
|
|
194
|
@Override
|
195
|
public boolean performOk() {
|
196
|
if (isAllowOverride){
|
197
|
PreferencesUtil.setBooleanValue(IPreferenceKeys.DISTRIBUTION_AREA_PREFRENCES_ACTIVE, isEditorActivated);
|
198
|
PreferencesUtil.setSortNamedAreasByOrderInVocabulary(isSortByVocabularyOrder);
|
199
|
PreferencesUtil.setShowRankInChecklistEditor(isShowRank);
|
200
|
PreferencesUtil.setShowSymbolInChecklistEditor(isShowSymbol);
|
201
|
String displayString;
|
202
|
if (isShowIdInVocabulary){
|
203
|
displayString = IPreferenceKeys.CHECKLIST_AREA_DISPLAY_TITLE;
|
204
|
}else if (isShowSymbol1){
|
205
|
displayString = IPreferenceKeys.CHECKLIST_AREA_DISPLAY_SYMBOL1;
|
206
|
}else if (isShowSymbol2){
|
207
|
displayString = IPreferenceKeys.CHECKLIST_AREA_DISPLAY_SYMBOL2;
|
208
|
}else{
|
209
|
displayString = IPreferenceKeys.CHECKLIST_AREA_DISPLAY_TITLE;
|
210
|
}
|
211
|
PreferencesUtil.setShowIdInVocabularyInChecklistEditor(displayString);
|
212
|
}
|
213
|
return true;
|
214
|
}
|
215
|
|
216
|
}
|