1 |
4db49a38
|
Alexander Oppermann
|
/**
|
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 |
432276e4
|
Katja Luther
|
import org.eclipse.swt.events.SelectionListener;
|
16 |
|
|
import org.eclipse.swt.layout.GridData;
|
17 |
4db49a38
|
Alexander Oppermann
|
import org.eclipse.swt.layout.GridLayout;
|
18 |
|
|
import org.eclipse.swt.widgets.Button;
|
19 |
432276e4
|
Katja Luther
|
import org.eclipse.swt.widgets.Combo;
|
20 |
4db49a38
|
Alexander Oppermann
|
import org.eclipse.swt.widgets.Composite;
|
21 |
|
|
import org.eclipse.swt.widgets.Control;
|
22 |
fbd932cc
|
Katja Luther
|
import org.eclipse.swt.widgets.Event;
|
23 |
1d76231c
|
Katja Luther
|
import org.eclipse.swt.widgets.Label;
|
24 |
fbd932cc
|
Katja Luther
|
import org.eclipse.swt.widgets.Listener;
|
25 |
4db49a38
|
Alexander Oppermann
|
|
26 |
1d76231c
|
Katja Luther
|
import eu.etaxonomy.cdm.model.metadata.CdmPreference;
|
27 |
|
|
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
|
28 |
96615335
|
Katja Luther
|
import eu.etaxonomy.cdm.model.metadata.TermDisplayEnum;
|
29 |
321b9521
|
Katja Luther
|
import eu.etaxonomy.taxeditor.l10n.Messages;
|
30 |
c6b1be20
|
Patrick Plitzner
|
import eu.etaxonomy.taxeditor.preference.menu.CdmPreferencePage;
|
31 |
4db49a38
|
Alexander Oppermann
|
import eu.etaxonomy.taxeditor.ui.element.CommandHandlerButton;
|
32 |
|
|
|
33 |
|
|
/**
|
34 |
|
|
* @author a.oppermann
|
35 |
|
|
* @date 21.07.2014
|
36 |
|
|
*
|
37 |
|
|
*/
|
38 |
432276e4
|
Katja Luther
|
public class ChecklistEditorGeneralPreference extends CdmPreferencePage implements SelectionListener {
|
39 |
4db49a38
|
Alexander Oppermann
|
|
40 |
432276e4
|
Katja Luther
|
protected boolean isEditorActivated;
|
41 |
|
|
protected boolean allowOverrideActivated;
|
42 |
a51915c2
|
Katja Luther
|
protected boolean overrideActivated;
|
43 |
1d76231c
|
Katja Luther
|
boolean isUseLocal;
|
44 |
432276e4
|
Katja Luther
|
protected boolean isShowRank;
|
45 |
|
|
protected boolean isSortByVocabularyOrder;
|
46 |
|
|
protected String displayStatus;
|
47 |
|
|
protected String displayArea;
|
48 |
a51915c2
|
Katja Luther
|
protected boolean ownDescriptionForDistributionEditor;
|
49 |
|
|
protected boolean allowOverrideOwnDescriptionForDistributionEditor;
|
50 |
|
|
protected boolean overrideOwnDescriptionForDistributionEditor;
|
51 |
|
|
protected boolean allowOverrideAreaVoc;
|
52 |
|
|
protected boolean overrideAreaVoc;
|
53 |
432276e4
|
Katja Luther
|
protected boolean allowOverrideRank;
|
54 |
a51915c2
|
Katja Luther
|
protected boolean overrideRank;
|
55 |
432276e4
|
Katja Luther
|
protected boolean allowOverrideOrderAreas;
|
56 |
a51915c2
|
Katja Luther
|
protected boolean overrideOrderAreas;
|
57 |
432276e4
|
Katja Luther
|
protected boolean allowOverrideAreaDisplay;
|
58 |
a51915c2
|
Katja Luther
|
protected boolean overrideAreaDisplay;
|
59 |
432276e4
|
Katja Luther
|
protected boolean allowOverrideStatusDisplay;
|
60 |
a51915c2
|
Katja Luther
|
protected boolean overrideStatusDisplay;
|
61 |
185eb33b
|
Katja Luther
|
|
62 |
|
|
protected boolean allowOverrideStatus;
|
63 |
432276e4
|
Katja Luther
|
Combo statusDisplaySelectionCombo;
|
64 |
|
|
Combo areaDisplaySelectionCombo;
|
65 |
|
|
|
66 |
|
|
protected String commandHandlerString;
|
67 |
|
|
protected String commandHandlerStringStatus;
|
68 |
|
|
|
69 |
185eb33b
|
Katja Luther
|
|
70 |
|
|
|
71 |
432276e4
|
Katja Luther
|
protected CdmPreference distributionEditorPref;
|
72 |
4db49a38
|
Alexander Oppermann
|
Composite child ;
|
73 |
432276e4
|
Katja Luther
|
protected boolean isAllowOverride;
|
74 |
672874ab
|
Patrick Plitzner
|
|
75 |
4db49a38
|
Alexander Oppermann
|
@Override
|
76 |
|
|
protected Control createContents(Composite parent) {
|
77 |
185eb33b
|
Katja Luther
|
getValues();
|
78 |
4db49a38
|
Alexander Oppermann
|
Composite composite = new Composite(parent, SWT.NULL);
|
79 |
|
|
composite.setLayout(new GridLayout());
|
80 |
f10b2ba0
|
Katja Luther
|
if(!isAdminPreference && !isEditorActivated && !isAllowOverride){
|
81 |
e398666b
|
Katja Luther
|
Label label = new Label(composite, SWT.NONE);
|
82 |
|
|
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.");
|
83 |
4db49a38
|
Alexander Oppermann
|
|
84 |
e398666b
|
Katja Luther
|
}else{
|
85 |
432276e4
|
Katja Luther
|
Composite activateComp = createComposite(composite);
|
86 |
914fe91d
|
Katja Luther
|
Label separator= new Label(activateComp, SWT.HORIZONTAL | SWT.SEPARATOR);
|
87 |
|
|
GridData sepGrid = createTextGridData();
|
88 |
|
|
separator.setLayoutData(sepGrid);
|
89 |
|
|
separator.setVisible(false);
|
90 |
432276e4
|
Katja Luther
|
final Button activateCheckButton = new Button(activateComp, SWT.CHECK);
|
91 |
|
|
activateCheckButton.setText(Messages.ChecklistEditorGeneralPreference_enable);
|
92 |
1d76231c
|
Katja Luther
|
activateCheckButton.setSelection(isEditorActivated);
|
93 |
|
|
activateCheckButton.addSelectionListener(new SelectionAdapter(){
|
94 |
|
|
@Override
|
95 |
|
|
public void widgetSelected(SelectionEvent e) {
|
96 |
fbd932cc
|
Katja Luther
|
setApply(true);
|
97 |
1d76231c
|
Katja Luther
|
isEditorActivated = activateCheckButton.getSelection();
|
98 |
a51915c2
|
Katja Luther
|
if(!isAdminPreference){
|
99 |
|
|
overrideActivated = true;
|
100 |
f10b2ba0
|
Katja Luther
|
child.setEnabled(isEditorActivated);
|
101 |
|
|
PreferencesUtil.recursiveSetEnabled(child, isEditorActivated);
|
102 |
a51915c2
|
Katja Luther
|
}
|
103 |
f10b2ba0
|
Katja Luther
|
|
104 |
|
|
|
105 |
1d76231c
|
Katja Luther
|
|
106 |
|
|
|
107 |
|
|
}
|
108 |
|
|
});
|
109 |
185eb33b
|
Katja Luther
|
Button allowOverrideActivatedButton = createAllowOverrideButton(activateComp);
|
110 |
432276e4
|
Katja Luther
|
if (isAdminPreference){
|
111 |
|
|
allowOverrideActivatedButton.setSelection(allowOverrideActivated);
|
112 |
|
|
allowOverrideActivatedButton.addSelectionListener(new SelectionAdapter(){
|
113 |
|
|
@Override
|
114 |
|
|
public void widgetSelected(SelectionEvent e) {
|
115 |
fbd932cc
|
Katja Luther
|
setApply(true);
|
116 |
432276e4
|
Katja Luther
|
allowOverrideActivated = allowOverrideActivatedButton.getSelection();
|
117 |
|
|
}
|
118 |
|
|
});
|
119 |
185eb33b
|
Katja Luther
|
}else{
|
120 |
|
|
allowOverrideActivatedButton.setSelection(overrideActivated);
|
121 |
|
|
allowOverrideActivatedButton.addSelectionListener(new SelectionAdapter(){
|
122 |
|
|
@Override
|
123 |
|
|
public void widgetSelected(SelectionEvent e) {
|
124 |
fbd932cc
|
Katja Luther
|
setApply(true);
|
125 |
185eb33b
|
Katja Luther
|
overrideActivated = allowOverrideActivatedButton.getSelection();
|
126 |
|
|
}
|
127 |
|
|
});
|
128 |
432276e4
|
Katja Luther
|
}
|
129 |
321b9521
|
Katja Luther
|
|
130 |
|
|
|
131 |
432276e4
|
Katja Luther
|
child = createComposite(composite);
|
132 |
321b9521
|
Katja Luther
|
|
133 |
f10b2ba0
|
Katja Luther
|
if(!isAdminPreference){
|
134 |
|
|
child.setEnabled(isEditorActivated);
|
135 |
|
|
}
|
136 |
914fe91d
|
Katja Luther
|
separator= new Label(child, SWT.HORIZONTAL | SWT.SEPARATOR);
|
137 |
|
|
sepGrid = createTextGridData();
|
138 |
321b9521
|
Katja Luther
|
|
139 |
185eb33b
|
Katja Luther
|
GridData textGrid = createTextGridData();
|
140 |
432276e4
|
Katja Luther
|
textGrid.verticalSpan = 2;
|
141 |
|
|
separator.setLayoutData(sepGrid);
|
142 |
321b9521
|
Katja Luther
|
|
143 |
|
|
|
144 |
1d76231c
|
Katja Luther
|
final Button activateRankButton = new Button(child, SWT.CHECK);
|
145 |
432276e4
|
Katja Luther
|
activateRankButton.setText(Messages.ChecklistEditorGeneralPreference_show_rank);
|
146 |
1d76231c
|
Katja Luther
|
activateRankButton.setSelection(isShowRank);
|
147 |
|
|
activateRankButton.addSelectionListener(new SelectionAdapter(){
|
148 |
|
|
@Override
|
149 |
|
|
public void widgetSelected(SelectionEvent e) {
|
150 |
fbd932cc
|
Katja Luther
|
setApply(true);
|
151 |
1d76231c
|
Katja Luther
|
isShowRank = activateRankButton.getSelection();
|
152 |
|
|
}
|
153 |
|
|
});
|
154 |
185eb33b
|
Katja Luther
|
Button allowOverrideRankButton = createAllowOverrideButton(child);
|
155 |
432276e4
|
Katja Luther
|
if (isAdminPreference){
|
156 |
|
|
allowOverrideRankButton.setSelection(allowOverrideRank);
|
157 |
|
|
allowOverrideRankButton.addSelectionListener(new SelectionAdapter(){
|
158 |
|
|
@Override
|
159 |
|
|
public void widgetSelected(SelectionEvent e) {
|
160 |
fbd932cc
|
Katja Luther
|
setApply(true);
|
161 |
432276e4
|
Katja Luther
|
allowOverrideRank = allowOverrideRankButton.getSelection();
|
162 |
|
|
}
|
163 |
|
|
});
|
164 |
|
|
}else{
|
165 |
185eb33b
|
Katja Luther
|
allowOverrideRankButton.setSelection(overrideRank);
|
166 |
|
|
allowOverrideRankButton.addSelectionListener(new SelectionAdapter(){
|
167 |
|
|
@Override
|
168 |
|
|
public void widgetSelected(SelectionEvent e) {
|
169 |
fbd932cc
|
Katja Luther
|
setApply(true);
|
170 |
185eb33b
|
Katja Luther
|
overrideRank = allowOverrideRankButton.getSelection();
|
171 |
|
|
}
|
172 |
|
|
});
|
173 |
432276e4
|
Katja Luther
|
if (!allowOverrideRank){
|
174 |
|
|
activateRankButton.setEnabled(false);
|
175 |
185eb33b
|
Katja Luther
|
allowOverrideRankButton.setEnabled(false);
|
176 |
432276e4
|
Katja Luther
|
}
|
177 |
|
|
}
|
178 |
|
|
|
179 |
|
|
|
180 |
1d76231c
|
Katja Luther
|
final Button sortNamedAreaByVocabularyOrder = new Button(child, SWT.CHECK);
|
181 |
432276e4
|
Katja Luther
|
sortNamedAreaByVocabularyOrder.setText(Messages.ChecklistEditorGeneralPreference_sort_areas);
|
182 |
1d76231c
|
Katja Luther
|
sortNamedAreaByVocabularyOrder.setSelection(isSortByVocabularyOrder);
|
183 |
|
|
sortNamedAreaByVocabularyOrder.addSelectionListener(new SelectionAdapter(){
|
184 |
|
|
@Override
|
185 |
|
|
public void widgetSelected(SelectionEvent e) {
|
186 |
fbd932cc
|
Katja Luther
|
setApply(true);
|
187 |
1d76231c
|
Katja Luther
|
isSortByVocabularyOrder = sortNamedAreaByVocabularyOrder.getSelection();
|
188 |
|
|
}
|
189 |
|
|
});
|
190 |
185eb33b
|
Katja Luther
|
Button allowOverrideOrderAreasButton = createAllowOverrideButton(child);
|
191 |
432276e4
|
Katja Luther
|
if (isAdminPreference){
|
192 |
|
|
allowOverrideOrderAreasButton.setSelection(allowOverrideOrderAreas);
|
193 |
|
|
allowOverrideOrderAreasButton.addSelectionListener(new SelectionAdapter(){
|
194 |
|
|
@Override
|
195 |
|
|
public void widgetSelected(SelectionEvent e) {
|
196 |
fbd932cc
|
Katja Luther
|
setApply(true);
|
197 |
432276e4
|
Katja Luther
|
allowOverrideOrderAreas = allowOverrideOrderAreasButton.getSelection();
|
198 |
|
|
}
|
199 |
|
|
});
|
200 |
|
|
}else{
|
201 |
185eb33b
|
Katja Luther
|
allowOverrideOrderAreasButton.setSelection(overrideOrderAreas);
|
202 |
|
|
allowOverrideOrderAreasButton.addSelectionListener(new SelectionAdapter(){
|
203 |
|
|
@Override
|
204 |
|
|
public void widgetSelected(SelectionEvent e) {
|
205 |
fbd932cc
|
Katja Luther
|
setApply(true);
|
206 |
185eb33b
|
Katja Luther
|
overrideOrderAreas = allowOverrideOrderAreasButton.getSelection();
|
207 |
|
|
}
|
208 |
|
|
});
|
209 |
432276e4
|
Katja Luther
|
if (!allowOverrideOrderAreas){
|
210 |
|
|
sortNamedAreaByVocabularyOrder.setEnabled(false);
|
211 |
185eb33b
|
Katja Luther
|
allowOverrideOrderAreasButton.setEnabled(false);
|
212 |
432276e4
|
Katja Luther
|
}
|
213 |
|
|
}
|
214 |
|
|
|
215 |
e398666b
|
Katja Luther
|
// final Button ownDescription = new Button(child, SWT.CHECK);
|
216 |
|
|
// ownDescription.setText(Messages.ChecklistEditorGeneralPreference_own_Description);
|
217 |
|
|
// ownDescription.setToolTipText(Messages.ChecklistEditorGeneralPreference_own_DescriptionToolTip);
|
218 |
|
|
// ownDescription.setSelection(ownDescriptionForDistributionEditor);
|
219 |
|
|
// ownDescription.addSelectionListener(new SelectionAdapter(){
|
220 |
|
|
// @Override
|
221 |
|
|
// public void widgetSelected(SelectionEvent e) {
|
222 |
|
|
// setApply(true);
|
223 |
|
|
// ownDescriptionForDistributionEditor = ownDescription.getSelection();
|
224 |
|
|
// }
|
225 |
|
|
// });
|
226 |
|
|
// Button allowOverrideDescription = createAllowOverrideButton(child);
|
227 |
|
|
// if (isAdminPreference){
|
228 |
|
|
// allowOverrideDescription.setSelection(allowOverrideOwnDescriptionForDistributionEditor);
|
229 |
|
|
// allowOverrideDescription.addSelectionListener(new SelectionAdapter(){
|
230 |
|
|
// @Override
|
231 |
|
|
// public void widgetSelected(SelectionEvent e) {
|
232 |
|
|
// setApply(true);
|
233 |
|
|
// allowOverrideOwnDescriptionForDistributionEditor = allowOverrideDescription.getSelection();
|
234 |
|
|
// }
|
235 |
|
|
// });
|
236 |
|
|
// }else{
|
237 |
|
|
// allowOverrideDescription.setSelection(overrideOwnDescriptionForDistributionEditor);
|
238 |
|
|
// allowOverrideDescription.addSelectionListener(new SelectionAdapter(){
|
239 |
|
|
// @Override
|
240 |
|
|
// public void widgetSelected(SelectionEvent e) {
|
241 |
|
|
// setApply(true);
|
242 |
|
|
// overrideOwnDescriptionForDistributionEditor = allowOverrideDescription.getSelection();
|
243 |
|
|
// }
|
244 |
|
|
// });
|
245 |
|
|
// if (!allowOverrideOwnDescriptionForDistributionEditor){
|
246 |
|
|
// ownDescription.setEnabled(false);
|
247 |
|
|
// allowOverrideDescription.setEnabled(false);
|
248 |
|
|
// }
|
249 |
|
|
// }
|
250 |
a51915c2
|
Katja Luther
|
|
251 |
|
|
|
252 |
432276e4
|
Katja Luther
|
separator= new Label(child, SWT.HORIZONTAL | SWT.SEPARATOR);
|
253 |
|
|
separator.setLayoutData(sepGrid);
|
254 |
|
|
|
255 |
|
|
//
|
256 |
|
|
|
257 |
|
|
final CLabel description = new CLabel(child, SWT.NULL);
|
258 |
|
|
description.setText(Messages.ChecklistEditorGeneralPreference_Configure_display_of_Areas);
|
259 |
|
|
description.setLayoutData(textGrid);
|
260 |
|
|
|
261 |
|
|
GridData gridData = new GridData();
|
262 |
|
|
gridData = new GridData(GridData.BEGINNING, GridData.CENTER, true, false);
|
263 |
|
|
//gridData.horizontalIndent = 5;
|
264 |
|
|
|
265 |
|
|
|
266 |
|
|
areaDisplaySelectionCombo = new Combo(child, SWT.BORDER| SWT.READ_ONLY);
|
267 |
|
|
areaDisplaySelectionCombo.setLayoutData(gridData);
|
268 |
|
|
|
269 |
|
|
for(TermDisplayEnum display: TermDisplayEnum.values()){
|
270 |
|
|
areaDisplaySelectionCombo.add(display.getLabel());
|
271 |
|
|
}
|
272 |
|
|
int index = 0;
|
273 |
a51915c2
|
Katja Luther
|
if (PreferencesUtil.getStringValue(EditorPreferencePredicate.DistributionEditorActivated.getKey()) != null){
|
274 |
|
|
TermDisplayEnum areaDisplay;
|
275 |
|
|
try{
|
276 |
bb082354
|
Katja Luther
|
if (displayArea != null){
|
277 |
|
|
areaDisplay = TermDisplayEnum.valueOf(displayArea);
|
278 |
|
|
}else{
|
279 |
|
|
areaDisplay = TermDisplayEnum.Title;
|
280 |
|
|
}
|
281 |
a51915c2
|
Katja Luther
|
}catch(IllegalArgumentException e){
|
282 |
|
|
areaDisplay = TermDisplayEnum.Title;
|
283 |
|
|
}
|
284 |
432276e4
|
Katja Luther
|
for (String itemLabel : areaDisplaySelectionCombo.getItems()){
|
285 |
|
|
if (itemLabel.equalsIgnoreCase(areaDisplay.getLabel())){
|
286 |
|
|
areaDisplaySelectionCombo.select(index);
|
287 |
|
|
break;
|
288 |
|
|
}
|
289 |
|
|
index++;
|
290 |
|
|
}
|
291 |
|
|
}
|
292 |
|
|
areaDisplaySelectionCombo.addSelectionListener(this);
|
293 |
185eb33b
|
Katja Luther
|
Button allowOverrideOrderAreaDisplayButton = createAllowOverrideButton(child);
|
294 |
432276e4
|
Katja Luther
|
if (isAdminPreference){
|
295 |
|
|
allowOverrideOrderAreaDisplayButton.setSelection(allowOverrideAreaDisplay);
|
296 |
|
|
allowOverrideOrderAreaDisplayButton.addSelectionListener(new SelectionAdapter(){
|
297 |
|
|
@Override
|
298 |
|
|
public void widgetSelected(SelectionEvent e) {
|
299 |
fbd932cc
|
Katja Luther
|
setApply(true);
|
300 |
432276e4
|
Katja Luther
|
allowOverrideAreaDisplay = allowOverrideOrderAreaDisplayButton.getSelection();
|
301 |
|
|
}
|
302 |
|
|
});
|
303 |
|
|
}else{
|
304 |
185eb33b
|
Katja Luther
|
allowOverrideOrderAreaDisplayButton.setSelection(overrideAreaDisplay);
|
305 |
|
|
allowOverrideOrderAreaDisplayButton.addSelectionListener(new SelectionAdapter(){
|
306 |
|
|
@Override
|
307 |
|
|
public void widgetSelected(SelectionEvent e) {
|
308 |
fbd932cc
|
Katja Luther
|
setApply(true);
|
309 |
185eb33b
|
Katja Luther
|
overrideAreaDisplay = allowOverrideOrderAreaDisplayButton.getSelection();
|
310 |
|
|
}
|
311 |
|
|
});
|
312 |
432276e4
|
Katja Luther
|
if (!allowOverrideAreaDisplay){
|
313 |
|
|
areaDisplaySelectionCombo.setEnabled(false);
|
314 |
185eb33b
|
Katja Luther
|
allowOverrideOrderAreaDisplayButton.setEnabled(false);
|
315 |
432276e4
|
Katja Luther
|
}
|
316 |
|
|
}
|
317 |
|
|
|
318 |
|
|
final CLabel descriptionStatus = new CLabel(child, SWT.NULL);
|
319 |
|
|
descriptionStatus.setText(Messages.ChecklistEditorGeneralPreference_Configure_display_of_Status);
|
320 |
|
|
descriptionStatus.setLayoutData(textGrid);
|
321 |
|
|
|
322 |
|
|
|
323 |
|
|
|
324 |
|
|
statusDisplaySelectionCombo = new Combo(child, SWT.BORDER| SWT.READ_ONLY);
|
325 |
|
|
statusDisplaySelectionCombo.setLayoutData(gridData);
|
326 |
|
|
|
327 |
|
|
for(TermDisplayEnum display: TermDisplayEnum.values()){
|
328 |
|
|
statusDisplaySelectionCombo.add(display.getLabel());
|
329 |
|
|
}
|
330 |
|
|
index = 0;
|
331 |
bb082354
|
Katja Luther
|
if (displayStatus != null){
|
332 |
432276e4
|
Katja Luther
|
TermDisplayEnum statusDisplay = TermDisplayEnum.valueOf(displayStatus);
|
333 |
185eb33b
|
Katja Luther
|
for (String itemLabel : statusDisplaySelectionCombo.getItems()){
|
334 |
432276e4
|
Katja Luther
|
if (itemLabel.equalsIgnoreCase(statusDisplay.getLabel())){
|
335 |
|
|
statusDisplaySelectionCombo.select(index);
|
336 |
|
|
break;
|
337 |
|
|
}
|
338 |
|
|
index++;
|
339 |
|
|
}
|
340 |
|
|
}
|
341 |
|
|
|
342 |
|
|
statusDisplaySelectionCombo.addSelectionListener(this);
|
343 |
185eb33b
|
Katja Luther
|
Button allowOverrideOrderStatusDisplayButton = createAllowOverrideButton(child);
|
344 |
432276e4
|
Katja Luther
|
if (isAdminPreference){
|
345 |
|
|
allowOverrideOrderStatusDisplayButton.setSelection(allowOverrideStatusDisplay);
|
346 |
|
|
allowOverrideOrderStatusDisplayButton.addSelectionListener(new SelectionAdapter(){
|
347 |
|
|
@Override
|
348 |
|
|
public void widgetSelected(SelectionEvent e) {
|
349 |
fbd932cc
|
Katja Luther
|
setApply(true);
|
350 |
432276e4
|
Katja Luther
|
allowOverrideStatusDisplay = allowOverrideOrderStatusDisplayButton.getSelection();
|
351 |
|
|
}
|
352 |
|
|
});
|
353 |
|
|
}else{
|
354 |
185eb33b
|
Katja Luther
|
allowOverrideOrderStatusDisplayButton.setSelection(overrideStatusDisplay);
|
355 |
|
|
allowOverrideOrderStatusDisplayButton.addSelectionListener(new SelectionAdapter(){
|
356 |
|
|
@Override
|
357 |
|
|
public void widgetSelected(SelectionEvent e) {
|
358 |
fbd932cc
|
Katja Luther
|
setApply(true);
|
359 |
185eb33b
|
Katja Luther
|
overrideStatusDisplay = allowOverrideOrderStatusDisplayButton.getSelection();
|
360 |
|
|
}
|
361 |
|
|
});
|
362 |
432276e4
|
Katja Luther
|
if (!allowOverrideStatusDisplay){
|
363 |
|
|
statusDisplaySelectionCombo.setEnabled(false);
|
364 |
185eb33b
|
Katja Luther
|
allowOverrideOrderStatusDisplayButton.setEnabled(false);
|
365 |
432276e4
|
Katja Luther
|
}
|
366 |
|
|
}
|
367 |
|
|
|
368 |
185eb33b
|
Katja Luther
|
|
369 |
|
|
final CLabel labelStatus = new CLabel(child, SWT.NULL);
|
370 |
|
|
labelStatus.setText(Messages.DistributionAdminPreferences_SELECT_STATUS);
|
371 |
|
|
labelStatus.setLayoutData(textGrid);
|
372 |
|
|
|
373 |
|
|
final CommandHandlerButton button_openStatusWizard = new CommandHandlerButton(child, SWT.PUSH,
|
374 |
|
|
commandHandlerStringStatus);
|
375 |
|
|
|
376 |
|
|
button_openStatusWizard.setText(Messages.Distribution_status_selection);
|
377 |
fbd932cc
|
Katja Luther
|
button_openStatusWizard.addListener(SWT.Selection, new Listener() {
|
378 |
|
|
@Override
|
379 |
|
|
public void handleEvent(Event e) {
|
380 |
|
|
switch (e.type) {
|
381 |
|
|
case SWT.Selection:
|
382 |
|
|
setApply(true);
|
383 |
|
|
break;
|
384 |
|
|
}
|
385 |
|
|
}
|
386 |
|
|
});
|
387 |
|
|
|
388 |
432276e4
|
Katja Luther
|
|
389 |
a51915c2
|
Katja Luther
|
final CLabel label = new CLabel(child, SWT.NULL);
|
390 |
|
|
label.setText(Messages.ChecklistEditorGeneralPreference_open_wizard);
|
391 |
|
|
label.setLayoutData(textGrid);
|
392 |
185eb33b
|
Katja Luther
|
|
393 |
a51915c2
|
Katja Luther
|
final CommandHandlerButton button_openSelectAreas = new CommandHandlerButton(child, SWT.PUSH,
|
394 |
|
|
commandHandlerString);
|
395 |
|
|
button_openSelectAreas.setText(Messages.ChecklistEditorGeneralPreference_open_distribution_selection);
|
396 |
432276e4
|
Katja Luther
|
|
397 |
185eb33b
|
Katja Luther
|
|
398 |
|
|
|
399 |
432276e4
|
Katja Luther
|
|
400 |
f10b2ba0
|
Katja Luther
|
// if(isEditorActivated){
|
401 |
|
|
// child.setEnabled(true);
|
402 |
|
|
// }else{
|
403 |
|
|
// child.setEnabled(false);
|
404 |
|
|
// }
|
405 |
|
|
if (!isAdminPreference){
|
406 |
|
|
PreferencesUtil.recursiveSetEnabled(child, isEditorActivated);
|
407 |
a5b15eef
|
Katja Luther
|
}
|
408 |
185eb33b
|
Katja Luther
|
if (!isAdminPreference){
|
409 |
42aae678
|
Katja Luther
|
if (!allowOverrideAreaVoc){
|
410 |
|
|
button_openSelectAreas.setButtonEnabled(false);
|
411 |
|
|
}
|
412 |
|
|
if (!allowOverrideStatus){
|
413 |
|
|
button_openStatusWizard.setButtonEnabled(false);
|
414 |
185eb33b
|
Katja Luther
|
}
|
415 |
42aae678
|
Katja Luther
|
}
|
416 |
4db49a38
|
Alexander Oppermann
|
}
|
417 |
6ff64c46
|
Katja Luther
|
|
418 |
|
|
|
419 |
c130c5fe
|
Katja Luther
|
setValid(true);
|
420 |
4db49a38
|
Alexander Oppermann
|
return composite;
|
421 |
|
|
}
|
422 |
|
|
|
423 |
432276e4
|
Katja Luther
|
|
424 |
|
|
|
425 |
185eb33b
|
Katja Luther
|
|
426 |
|
|
|
427 |
|
|
|
428 |
|
|
|
429 |
|
|
|
430 |
432276e4
|
Katja Luther
|
|
431 |
9457da34
|
Katja Luther
|
@Override
|
432 |
|
|
public boolean performOk() {
|
433 |
3b975922
|
Katja Luther
|
if (isAllowOverride){
|
434 |
185eb33b
|
Katja Luther
|
|
435 |
a51915c2
|
Katja Luther
|
PreferencesUtil.setBooleanValue(EditorPreferencePredicate.DistributionEditorActivated.getKey(), isEditorActivated);
|
436 |
12d75812
|
Katja Luther
|
PreferencesUtil.setBooleanValue(PreferencesUtil.prefOverrideKey(EditorPreferencePredicate.DistributionEditorActivated.getKey()), overrideActivated);
|
437 |
3b975922
|
Katja Luther
|
PreferencesUtil.setSortNamedAreasByOrderInVocabulary(isSortByVocabularyOrder);
|
438 |
12d75812
|
Katja Luther
|
PreferencesUtil.setBooleanValue(PreferencesUtil.prefOverrideKey(EditorPreferencePredicate.AreasSortedByIdInVocabulary.getKey()), overrideOrderAreas);
|
439 |
3b975922
|
Katja Luther
|
PreferencesUtil.setShowRankInChecklistEditor(isShowRank);
|
440 |
12d75812
|
Katja Luther
|
PreferencesUtil.setBooleanValue(PreferencesUtil.prefOverrideKey(EditorPreferencePredicate.ShowRankInDistributionEditor.getKey()), overrideRank);
|
441 |
432276e4
|
Katja Luther
|
PreferencesUtil.setDisplayStatusInChecklistEditor(displayStatus);
|
442 |
12d75812
|
Katja Luther
|
PreferencesUtil.setBooleanValue(PreferencesUtil.prefOverrideKey(EditorPreferencePredicate.DisplayOfStatus.getKey()), overrideStatusDisplay);
|
443 |
432276e4
|
Katja Luther
|
PreferencesUtil.setAreaDisplayInChecklistEditor(displayArea);
|
444 |
12d75812
|
Katja Luther
|
PreferencesUtil.setBooleanValue(PreferencesUtil.prefOverrideKey(EditorPreferencePredicate.DisplayOfAreasInDistributionEditor.getKey()), overrideAreaDisplay);
|
445 |
a51915c2
|
Katja Luther
|
PreferencesUtil.setOwnDescriptionForChecklistEditor(ownDescriptionForDistributionEditor);
|
446 |
12d75812
|
Katja Luther
|
PreferencesUtil.setBooleanValue(PreferencesUtil.prefOverrideKey(EditorPreferencePredicate.OwnDescriptionForDistributionEditor.getKey()), overrideOwnDescriptionForDistributionEditor);
|
447 |
432276e4
|
Katja Luther
|
|
448 |
|
|
|
449 |
185eb33b
|
Katja Luther
|
|
450 |
|
|
|
451 |
3b975922
|
Katja Luther
|
}
|
452 |
9457da34
|
Katja Luther
|
return true;
|
453 |
|
|
}
|
454 |
|
|
|
455 |
432276e4
|
Katja Luther
|
/**
|
456 |
|
|
* {@inheritDoc}
|
457 |
|
|
*/
|
458 |
|
|
@Override
|
459 |
|
|
public void widgetSelected(SelectionEvent e) {
|
460 |
fbd932cc
|
Katja Luther
|
setApply(true);
|
461 |
432276e4
|
Katja Luther
|
if (e.getSource().equals(statusDisplaySelectionCombo)){
|
462 |
|
|
String text = statusDisplaySelectionCombo.getText();
|
463 |
|
|
for (TermDisplayEnum display: TermDisplayEnum.values()){
|
464 |
|
|
if (display.getLabel().equals(text)){
|
465 |
|
|
displayStatus = display.getKey();
|
466 |
|
|
break;
|
467 |
|
|
}
|
468 |
|
|
}
|
469 |
|
|
}
|
470 |
|
|
if (e.getSource().equals(areaDisplaySelectionCombo)){
|
471 |
|
|
String text = areaDisplaySelectionCombo.getText();
|
472 |
|
|
for (TermDisplayEnum display: TermDisplayEnum.values()){
|
473 |
|
|
if (display.getLabel().equals(text)){
|
474 |
|
|
displayArea = display.getKey();
|
475 |
|
|
break;
|
476 |
|
|
}
|
477 |
|
|
}
|
478 |
|
|
}
|
479 |
|
|
|
480 |
|
|
}
|
481 |
|
|
|
482 |
|
|
/**
|
483 |
|
|
* {@inheritDoc}
|
484 |
|
|
*/
|
485 |
|
|
@Override
|
486 |
|
|
public void widgetDefaultSelected(SelectionEvent e) {
|
487 |
|
|
// TODO Auto-generated method stub
|
488 |
|
|
|
489 |
|
|
}
|
490 |
|
|
|
491 |
185eb33b
|
Katja Luther
|
|
492 |
|
|
/**
|
493 |
|
|
* {@inheritDoc}
|
494 |
|
|
*/
|
495 |
432276e4
|
Katja Luther
|
@Override
|
496 |
6285cec5
|
Katja Luther
|
public void getValues() {
|
497 |
432276e4
|
Katja Luther
|
isAdminPreference = false;
|
498 |
|
|
setPreferenceStore(PreferencesUtil.getPreferenceStore());
|
499 |
a51915c2
|
Katja Luther
|
distributionEditorPref = PreferencesUtil.getPreferenceFromDB(EditorPreferencePredicate.DistributionEditorActivated);
|
500 |
432276e4
|
Katja Luther
|
|
501 |
|
|
|
502 |
|
|
if (distributionEditorPref != null){
|
503 |
|
|
isAllowOverride = distributionEditorPref.isAllowOverride();
|
504 |
e398666b
|
Katja Luther
|
|
505 |
|
|
if (isAllowOverride && PreferencesUtil.getBooleanValue(PreferencesUtil.prefOverrideKey(EditorPreferencePredicate.DistributionEditorActivated.getKey()))){
|
506 |
a51915c2
|
Katja Luther
|
isEditorActivated = PreferencesUtil.getBooleanValue(EditorPreferencePredicate.DistributionEditorActivated.getKey());
|
507 |
e398666b
|
Katja Luther
|
overrideActivated = PreferencesUtil.getBooleanValue(PreferencesUtil.prefOverrideKey(EditorPreferencePredicate.DistributionEditorActivated.getKey()));
|
508 |
432276e4
|
Katja Luther
|
}else{
|
509 |
|
|
isEditorActivated = Boolean.valueOf(distributionEditorPref.getValue());
|
510 |
|
|
}
|
511 |
|
|
}else{
|
512 |
a51915c2
|
Katja Luther
|
isEditorActivated = PreferencesUtil.getBooleanValue(EditorPreferencePredicate.DistributionEditorActivated.getKey());
|
513 |
432276e4
|
Katja Luther
|
isAllowOverride = true;
|
514 |
e398666b
|
Katja Luther
|
overrideActivated = PreferencesUtil.getBooleanValue(PreferencesUtil.prefOverrideKey(EditorPreferencePredicate.DistributionEditorActivated.getKey()));
|
515 |
432276e4
|
Katja Luther
|
}
|
516 |
|
|
|
517 |
185eb33b
|
Katja Luther
|
CdmPreference prefStatus = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.AvailableDistributionAreaVocabularies);
|
518 |
0082e2d6
|
Katja Luther
|
allowOverrideAreaVoc = prefStatus != null?prefStatus.isAllowOverride():true;
|
519 |
432276e4
|
Katja Luther
|
|
520 |
185eb33b
|
Katja Luther
|
prefStatus = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.AvailableDistributionStatus);
|
521 |
0082e2d6
|
Katja Luther
|
allowOverrideStatus = prefStatus != null?prefStatus.isAllowOverride():true;
|
522 |
185eb33b
|
Katja Luther
|
|
523 |
432276e4
|
Katja Luther
|
CdmPreference pref = PreferencesUtil.getPreferenceFromDB(EditorPreferencePredicate.DisplayOfAreasInDistributionEditor);
|
524 |
|
|
if (pref != null){
|
525 |
|
|
this.allowOverrideAreaDisplay = pref.isAllowOverride();
|
526 |
|
|
if (allowOverrideAreaDisplay){
|
527 |
57d3d692
|
Katja Luther
|
displayArea = PreferencesUtil.displayAreaInChecklistEditor();
|
528 |
e398666b
|
Katja Luther
|
overrideAreaDisplay = PreferencesUtil.getBooleanValue(PreferencesUtil.prefOverrideKey(EditorPreferencePredicate.DisplayOfAreasInDistributionEditor.getKey()));
|
529 |
432276e4
|
Katja Luther
|
}else{
|
530 |
|
|
displayArea = pref.getValue();
|
531 |
|
|
}
|
532 |
|
|
}else{
|
533 |
57d3d692
|
Katja Luther
|
displayArea = PreferencesUtil.displayAreaInChecklistEditor();;
|
534 |
432276e4
|
Katja Luther
|
this.allowOverrideAreaDisplay = true;
|
535 |
e398666b
|
Katja Luther
|
overrideAreaDisplay = PreferencesUtil.getBooleanValue(PreferencesUtil.prefOverrideKey(EditorPreferencePredicate.DisplayOfAreasInDistributionEditor.getKey()));
|
536 |
432276e4
|
Katja Luther
|
}
|
537 |
|
|
|
538 |
|
|
pref = PreferencesUtil.getPreferenceFromDB(EditorPreferencePredicate.DisplayOfStatus);
|
539 |
|
|
if (pref != null){
|
540 |
|
|
this.allowOverrideStatusDisplay = pref.isAllowOverride();
|
541 |
|
|
if (allowOverrideStatusDisplay){
|
542 |
|
|
displayStatus = PreferencesUtil.displayStatusInChecklistEditor();
|
543 |
e398666b
|
Katja Luther
|
overrideStatusDisplay = PreferencesUtil.getBooleanValue(PreferencesUtil.prefOverrideKey(EditorPreferencePredicate.DisplayOfStatus.getKey()));
|
544 |
432276e4
|
Katja Luther
|
}else{
|
545 |
|
|
this.displayStatus = pref.getValue();
|
546 |
|
|
}
|
547 |
|
|
}else{
|
548 |
|
|
displayStatus = PreferencesUtil.displayStatusInChecklistEditor();
|
549 |
|
|
this.allowOverrideStatusDisplay = true;
|
550 |
e398666b
|
Katja Luther
|
overrideStatusDisplay = PreferencesUtil.getBooleanValue(PreferencesUtil.prefOverrideKey(EditorPreferencePredicate.DisplayOfStatus.getKey()));
|
551 |
432276e4
|
Katja Luther
|
}
|
552 |
|
|
|
553 |
|
|
pref = PreferencesUtil.getPreferenceFromDB(EditorPreferencePredicate.AreasSortedByIdInVocabulary);
|
554 |
|
|
if (pref != null){
|
555 |
|
|
|
556 |
|
|
this.allowOverrideOrderAreas = pref.isAllowOverride();
|
557 |
|
|
if (allowOverrideOrderAreas){
|
558 |
|
|
isSortByVocabularyOrder = PreferencesUtil.isSortNamedAreaByOrderInVocabulary();
|
559 |
e398666b
|
Katja Luther
|
overrideOrderAreas = PreferencesUtil.getBooleanValue(PreferencesUtil.prefOverrideKey(EditorPreferencePredicate.AreasSortedByIdInVocabulary.getKey()));
|
560 |
432276e4
|
Katja Luther
|
}else{
|
561 |
|
|
this.isSortByVocabularyOrder = Boolean.valueOf(pref.getValue().toString());
|
562 |
|
|
}
|
563 |
|
|
}else{
|
564 |
|
|
isSortByVocabularyOrder = PreferencesUtil.isSortNamedAreaByOrderInVocabulary();
|
565 |
|
|
this.allowOverrideOrderAreas = true;
|
566 |
e398666b
|
Katja Luther
|
overrideOrderAreas = PreferencesUtil.getBooleanValue(PreferencesUtil.prefOverrideKey(EditorPreferencePredicate.AreasSortedByIdInVocabulary.getKey()));
|
567 |
432276e4
|
Katja Luther
|
}
|
568 |
|
|
|
569 |
|
|
pref = PreferencesUtil.getPreferenceFromDB(EditorPreferencePredicate.ShowRankInDistributionEditor);
|
570 |
|
|
if (pref != null){
|
571 |
|
|
|
572 |
a51915c2
|
Katja Luther
|
allowOverrideRank = pref.isAllowOverride();
|
573 |
432276e4
|
Katja Luther
|
if (allowOverrideRank){
|
574 |
|
|
isShowRank = PreferencesUtil.isShowRankInChecklistEditor();
|
575 |
e398666b
|
Katja Luther
|
overrideRank = PreferencesUtil.getBooleanValue(PreferencesUtil.prefOverrideKey(EditorPreferencePredicate.ShowRankInDistributionEditor.getKey()));
|
576 |
432276e4
|
Katja Luther
|
}else{
|
577 |
|
|
this.isShowRank = Boolean.valueOf(pref.getValue().toString());
|
578 |
|
|
}
|
579 |
|
|
}else{
|
580 |
|
|
isShowRank = PreferencesUtil.isShowRankInChecklistEditor();
|
581 |
|
|
this.allowOverrideRank = true;
|
582 |
e398666b
|
Katja Luther
|
overrideRank = PreferencesUtil.getBooleanValue(PreferencesUtil.prefOverrideKey(EditorPreferencePredicate.ShowRankInDistributionEditor.getKey()));
|
583 |
432276e4
|
Katja Luther
|
}
|
584 |
|
|
|
585 |
a51915c2
|
Katja Luther
|
pref = PreferencesUtil.getPreferenceFromDB(EditorPreferencePredicate.OwnDescriptionForDistributionEditor);
|
586 |
|
|
if (pref != null){
|
587 |
|
|
|
588 |
|
|
allowOverrideOwnDescriptionForDistributionEditor = pref.isAllowOverride();
|
589 |
|
|
if (allowOverrideOwnDescriptionForDistributionEditor){
|
590 |
|
|
ownDescriptionForDistributionEditor = PreferencesUtil.isOwnDescriptionForChecklistEditor();
|
591 |
|
|
}else{
|
592 |
|
|
ownDescriptionForDistributionEditor = Boolean.valueOf(pref.getValue().toString());
|
593 |
|
|
}
|
594 |
|
|
}else{
|
595 |
|
|
ownDescriptionForDistributionEditor = PreferencesUtil.isShowRankInChecklistEditor();
|
596 |
42aae678
|
Katja Luther
|
allowOverrideOwnDescriptionForDistributionEditor = true;
|
597 |
e398666b
|
Katja Luther
|
overrideOwnDescriptionForDistributionEditor = PreferencesUtil.getBooleanValue(PreferencesUtil.prefOverrideKey(EditorPreferencePredicate.OwnDescriptionForDistributionEditor.getKey()));
|
598 |
a51915c2
|
Katja Luther
|
}
|
599 |
432276e4
|
Katja Luther
|
|
600 |
|
|
|
601 |
|
|
commandHandlerString = "eu.etaxonomy.taxeditor.store.open.OpenDistributionEditorWizardHandler";
|
602 |
|
|
commandHandlerStringStatus = "eu.etaxonomy.taxeditor.store.open.OpenDistributionStatusWizardHandler";
|
603 |
9181d281
|
Katja Luther
|
|
604 |
432276e4
|
Katja Luther
|
|
605 |
|
|
}
|
606 |
e398666b
|
Katja Luther
|
|
607 |
|
|
|
608 |
4db49a38
|
Alexander Oppermann
|
}
|