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.events.SelectionListener;
|
16
|
import org.eclipse.swt.layout.GridData;
|
17
|
import org.eclipse.swt.layout.GridLayout;
|
18
|
import org.eclipse.swt.widgets.Button;
|
19
|
import org.eclipse.swt.widgets.Combo;
|
20
|
import org.eclipse.swt.widgets.Composite;
|
21
|
import org.eclipse.swt.widgets.Control;
|
22
|
import org.eclipse.swt.widgets.Event;
|
23
|
import org.eclipse.swt.widgets.Label;
|
24
|
import org.eclipse.swt.widgets.Listener;
|
25
|
|
26
|
import eu.etaxonomy.cdm.model.metadata.CdmPreference;
|
27
|
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
|
28
|
import eu.etaxonomy.cdm.model.metadata.TermDisplayEnum;
|
29
|
import eu.etaxonomy.cdm.model.metadata.TermOrder;
|
30
|
import eu.etaxonomy.taxeditor.l10n.Messages;
|
31
|
import eu.etaxonomy.taxeditor.preference.menu.CdmPreferencePage;
|
32
|
import eu.etaxonomy.taxeditor.ui.element.CommandHandlerButton;
|
33
|
|
34
|
/**
|
35
|
* @author a.oppermann
|
36
|
* @date 21.07.2014
|
37
|
*
|
38
|
*/
|
39
|
public class ChecklistEditorGeneralPreference extends CdmPreferencePage implements SelectionListener {
|
40
|
|
41
|
|
42
|
|
43
|
protected Boolean isEditorActivated;
|
44
|
|
45
|
protected boolean overrideActivated;
|
46
|
boolean isUseLocal;
|
47
|
protected Boolean isShowRank;
|
48
|
protected String orderAreas;
|
49
|
protected String displayStatus;
|
50
|
protected String displayArea;
|
51
|
protected Boolean ownDescriptionForDistributionEditor;
|
52
|
|
53
|
protected boolean overrideOwnDescriptionForDistributionEditor;
|
54
|
protected boolean overrideAreaVoc;
|
55
|
protected boolean overrideRank;
|
56
|
protected boolean overrideOrderAreas;
|
57
|
protected boolean overrideAreaDisplay;
|
58
|
protected boolean overrideStatusDisplay;
|
59
|
|
60
|
protected Combo areaOrderSelectionCombo;
|
61
|
protected Button allowOverrideOrderAreasButton;
|
62
|
protected Combo statusDisplaySelectionCombo;
|
63
|
protected Button allowOverrideStatusDisplayButton;
|
64
|
protected Combo areaDisplaySelectionCombo;
|
65
|
protected Button allowOverrideAreaDisplayButton;
|
66
|
protected String commandHandlerString;
|
67
|
protected String commandHandlerStringStatus;
|
68
|
|
69
|
protected CdmPreference distributionEditorPref;
|
70
|
protected CdmPreference prefStatus;
|
71
|
protected CdmPreference prefAreaVoc;
|
72
|
protected CdmPreference prefAreaDisplay;
|
73
|
protected CdmPreference prefStatusDisplay;
|
74
|
protected CdmPreference prefAreaSort;
|
75
|
protected CdmPreference prefRank;
|
76
|
protected CdmPreference prefOwnDescription;
|
77
|
Composite child;
|
78
|
|
79
|
protected Combo activateCombo;
|
80
|
protected Button allowOverrideActivatedButton;
|
81
|
final String ENABLE = "Enable";
|
82
|
final String DISABLE = "Disable";
|
83
|
|
84
|
protected Combo activateRankCombo;
|
85
|
protected Button allowOverrideRankButton;
|
86
|
final String SHOW_RANK = "Show Rank";
|
87
|
final String NO_RANK = "No Rank";
|
88
|
|
89
|
protected CdmPreference areaVocPref = null;
|
90
|
protected CdmPreference statusPref = null;
|
91
|
private CommandHandlerButton button_openSelectAreaVocabularies;
|
92
|
|
93
|
private CommandHandlerButton button_openStatusWizard;
|
94
|
|
95
|
@Override
|
96
|
protected Control createContents(Composite parent) {
|
97
|
getValues();
|
98
|
Composite composite = new Composite(parent, SWT.NULL);
|
99
|
composite.setLayout(new GridLayout());
|
100
|
if (!isAdminPreference && distributionEditorPref != null && !distributionEditorPref.isAllowOverride()&& !isEditorActivated ) {
|
101
|
Label label = new Label(composite, SWT.NONE);
|
102
|
label.setText(
|
103
|
"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.");
|
104
|
this.setDefaultButtonActivated(false);
|
105
|
} else {
|
106
|
Composite activateComp = createComposite(composite);
|
107
|
Label separator = new Label(activateComp, SWT.HORIZONTAL | SWT.SEPARATOR);
|
108
|
GridData sepGrid = createTextGridData();
|
109
|
separator.setLayoutData(sepGrid);
|
110
|
separator.setVisible(false);
|
111
|
CdmPreference dbPref;
|
112
|
GridData textGrid = createTextGridData();
|
113
|
textGrid.verticalSpan = 2;
|
114
|
separator.setLayoutData(sepGrid);
|
115
|
|
116
|
activateCombo = createBooleanCombo(activateComp, ENABLE, DISABLE, PreferencePredicate.DistributionEditorActivated, Messages.ChecklistEditorGeneralPreference_enable, isAdminPreference);
|
117
|
|
118
|
int index = 0;
|
119
|
for (String itemLabel : activateCombo.getItems()) {
|
120
|
if (isEditorActivated == null && itemLabel.equals(Messages.Preference_Use_Default)) {
|
121
|
activateCombo.select(index);
|
122
|
break;
|
123
|
}
|
124
|
if (isEditorActivated != null && itemLabel.equals(ENABLE) && isEditorActivated){
|
125
|
activateCombo.select(index);
|
126
|
break;
|
127
|
}
|
128
|
if (isEditorActivated != null && itemLabel.equals(DISABLE) && !isEditorActivated){
|
129
|
activateCombo.select(index);
|
130
|
break;
|
131
|
}
|
132
|
index++;
|
133
|
}
|
134
|
|
135
|
|
136
|
activateCombo.addSelectionListener(this);
|
137
|
if (isAdminPreference) {
|
138
|
allowOverrideActivatedButton = createAllowOverrideButton(activateComp);
|
139
|
allowOverrideActivatedButton.setSelection(this.distributionEditorPref != null? this.distributionEditorPref.isAllowOverride(): true);
|
140
|
allowOverrideActivatedButton.addSelectionListener(new SelectionAdapter() {
|
141
|
@Override
|
142
|
public void widgetSelected(SelectionEvent e) {
|
143
|
setApply(true);
|
144
|
if (distributionEditorPref == null){
|
145
|
distributionEditorPref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.DistributionEditorActivated, PreferencePredicate.DistributionEditorActivated.getDefaultValue() != null ? PreferencePredicate.DistributionEditorActivated.getDefaultValue().toString(): null);
|
146
|
}
|
147
|
distributionEditorPref.setAllowOverride(!distributionEditorPref.isAllowOverride());
|
148
|
}
|
149
|
});
|
150
|
}
|
151
|
child = createComposite(composite);
|
152
|
|
153
|
if (!isAdminPreference) {
|
154
|
if (isEditorActivated != null){
|
155
|
child.setEnabled(isEditorActivated);
|
156
|
}else{
|
157
|
child.setEnabled(Boolean.parseBoolean(distributionEditorPref.getValue().toString()));
|
158
|
}
|
159
|
}
|
160
|
separator = new Label(child, SWT.HORIZONTAL | SWT.SEPARATOR);
|
161
|
sepGrid = createTextGridData();
|
162
|
separator.setLayoutData(sepGrid);
|
163
|
|
164
|
activateRankCombo = createBooleanCombo(child, SHOW_RANK, NO_RANK,
|
165
|
PreferencePredicate.ShowRankInDistributionEditor, Messages.ChecklistEditorGeneralPreference_show_rank, isAdminPreference);
|
166
|
index = 0;
|
167
|
for (String itemLabel : activateRankCombo.getItems()) {
|
168
|
if (isShowRank == null && itemLabel.equals(Messages.Preference_Use_Default)) {
|
169
|
activateRankCombo.select(index);
|
170
|
break;
|
171
|
}
|
172
|
if (isShowRank != null && itemLabel.equals(SHOW_RANK) && isShowRank){
|
173
|
activateRankCombo.select(index);
|
174
|
break;
|
175
|
}
|
176
|
if (isShowRank != null && itemLabel.equals(NO_RANK) && !isShowRank){
|
177
|
activateRankCombo.select(index);
|
178
|
break;
|
179
|
}
|
180
|
index++;
|
181
|
}
|
182
|
activateRankCombo.addSelectionListener(this);
|
183
|
if (isAdminPreference) {
|
184
|
allowOverrideRankButton = createAllowOverrideButton(child);
|
185
|
allowOverrideRankButton.setSelection(prefRank != null? prefRank.isAllowOverride():true);
|
186
|
allowOverrideRankButton.addSelectionListener(new SelectionAdapter() {
|
187
|
@Override
|
188
|
public void widgetSelected(SelectionEvent e) {
|
189
|
setApply(true);
|
190
|
prefRank.setAllowOverride(allowOverrideRankButton.getSelection());
|
191
|
}
|
192
|
});
|
193
|
}
|
194
|
|
195
|
GridData gridData = new GridData();
|
196
|
gridData = new GridData(GridData.BEGINNING, GridData.CENTER, true, false);
|
197
|
|
198
|
areaOrderSelectionCombo = createCombo(child, TermOrder.values(), PreferencePredicate.AreasSortedInDistributionEditor, Messages.ChecklistEditorGeneralPreference_Configure_area_order, isAdminPreference);
|
199
|
|
200
|
index = 0;
|
201
|
TermOrder areaOrder;
|
202
|
try {
|
203
|
if (orderAreas != null) {
|
204
|
areaOrder = TermOrder.valueOf(orderAreas);
|
205
|
} else {
|
206
|
areaOrder = TermOrder.IdInVoc;
|
207
|
}
|
208
|
} catch (IllegalArgumentException e) {
|
209
|
areaOrder = TermOrder.IdInVoc;
|
210
|
}
|
211
|
for (String itemLabel : areaOrderSelectionCombo.getItems()) {
|
212
|
if (itemLabel.equals(Messages.Preference_Use_Default) && orderAreas.equals(Messages.Preference_Use_Default)){
|
213
|
areaOrderSelectionCombo.select(index);
|
214
|
break;
|
215
|
}
|
216
|
if (itemLabel.startsWith(areaOrder.getLabel())) {
|
217
|
areaOrderSelectionCombo.select(index);
|
218
|
break;
|
219
|
}
|
220
|
|
221
|
index++;
|
222
|
}
|
223
|
|
224
|
areaOrderSelectionCombo.addSelectionListener(this);
|
225
|
|
226
|
if (isAdminPreference) {
|
227
|
allowOverrideOrderAreasButton = createAllowOverrideButton(child);
|
228
|
allowOverrideOrderAreasButton.setSelection(prefAreaSort != null? prefAreaSort.isAllowOverride(): true);
|
229
|
allowOverrideOrderAreasButton.addSelectionListener(new SelectionAdapter() {
|
230
|
@Override
|
231
|
public void widgetSelected(SelectionEvent e) {
|
232
|
setApply(true);
|
233
|
prefAreaSort.setAllowOverride(allowOverrideOrderAreasButton.getSelection());
|
234
|
}
|
235
|
});
|
236
|
}
|
237
|
|
238
|
separator = new Label(child, SWT.HORIZONTAL | SWT.SEPARATOR);
|
239
|
separator.setLayoutData(sepGrid);
|
240
|
areaDisplaySelectionCombo = createCombo(child, TermDisplayEnum.values(), PreferencePredicate.DisplayOfAreasInDistributionEditor, Messages.ChecklistEditorGeneralPreference_Configure_display_of_Areas, isAdminPreference);
|
241
|
|
242
|
|
243
|
index = 0;
|
244
|
TermDisplayEnum areaDisplay;
|
245
|
try {
|
246
|
if (displayArea != null) {
|
247
|
areaDisplay = TermDisplayEnum.valueOf(displayArea);
|
248
|
} else {
|
249
|
areaDisplay = TermDisplayEnum.Title;
|
250
|
}
|
251
|
} catch (IllegalArgumentException e) {
|
252
|
areaDisplay = TermDisplayEnum.Title;
|
253
|
}
|
254
|
for (String itemLabel : areaDisplaySelectionCombo.getItems()) {
|
255
|
if (itemLabel.equals(Messages.Preference_Use_Default) && displayArea.equals(Messages.Preference_Use_Default)){
|
256
|
areaDisplaySelectionCombo.select(index);
|
257
|
break;
|
258
|
}
|
259
|
if (itemLabel.startsWith(areaDisplay.getLabel())) {
|
260
|
areaDisplaySelectionCombo.select(index);
|
261
|
break;
|
262
|
}
|
263
|
|
264
|
index++;
|
265
|
}
|
266
|
areaDisplaySelectionCombo.addSelectionListener(this);
|
267
|
|
268
|
if (isAdminPreference) {
|
269
|
allowOverrideAreaDisplayButton = createAllowOverrideButton(child);
|
270
|
allowOverrideAreaDisplayButton.setSelection(prefAreaDisplay != null? prefAreaDisplay.isAllowOverride(): true);
|
271
|
allowOverrideAreaDisplayButton.addSelectionListener(new SelectionAdapter() {
|
272
|
@Override
|
273
|
public void widgetSelected(SelectionEvent e) {
|
274
|
setApply(true);
|
275
|
prefAreaDisplay.setAllowOverride(allowOverrideOrderAreasButton.getSelection());
|
276
|
}
|
277
|
});
|
278
|
}
|
279
|
|
280
|
statusDisplaySelectionCombo = createCombo(child, TermDisplayEnum.values(), PreferencePredicate.DisplayOfStatus, Messages.ChecklistEditorGeneralPreference_Configure_display_of_Status, isAdminPreference);
|
281
|
|
282
|
index = 0;
|
283
|
TermDisplayEnum statusDisplay;
|
284
|
try {
|
285
|
if (displayStatus != null) {
|
286
|
statusDisplay = TermDisplayEnum.valueOf(displayStatus);
|
287
|
} else {
|
288
|
statusDisplay = TermDisplayEnum.Title;
|
289
|
}
|
290
|
} catch (IllegalArgumentException e) {
|
291
|
statusDisplay = TermDisplayEnum.Title;
|
292
|
}
|
293
|
for (String itemLabel : statusDisplaySelectionCombo.getItems()) {
|
294
|
if (itemLabel.equals(Messages.Preference_Use_Default) && displayStatus.equals(Messages.Preference_Use_Default)){
|
295
|
statusDisplaySelectionCombo.select(index);
|
296
|
break;
|
297
|
}
|
298
|
if (itemLabel.startsWith(statusDisplay.getLabel())) {
|
299
|
statusDisplaySelectionCombo.select(index);
|
300
|
break;
|
301
|
}
|
302
|
|
303
|
index++;
|
304
|
}
|
305
|
|
306
|
statusDisplaySelectionCombo.addSelectionListener(this);
|
307
|
|
308
|
if (isAdminPreference) {
|
309
|
allowOverrideStatusDisplayButton = createAllowOverrideButton(child);
|
310
|
allowOverrideStatusDisplayButton.setSelection(prefStatusDisplay != null ? prefStatusDisplay.isAllowOverride(): true);
|
311
|
allowOverrideStatusDisplayButton.addSelectionListener(new SelectionAdapter() {
|
312
|
@Override
|
313
|
public void widgetSelected(SelectionEvent e) {
|
314
|
setApply(true);
|
315
|
prefStatusDisplay.setAllowOverride(allowOverrideStatusDisplayButton.getSelection());
|
316
|
}
|
317
|
});
|
318
|
}
|
319
|
|
320
|
final CLabel labelStatus = new CLabel(child, SWT.NULL);
|
321
|
labelStatus.setText(Messages.DistributionAdminPreferences_SELECT_STATUS);
|
322
|
labelStatus.setLayoutData(textGrid);
|
323
|
|
324
|
button_openStatusWizard = new CommandHandlerButton(child, SWT.PUSH, commandHandlerStringStatus);
|
325
|
|
326
|
button_openStatusWizard.setText(Messages.Distribution_status_selection);
|
327
|
button_openStatusWizard.addListener(SWT.Selection, new Listener() {
|
328
|
@Override
|
329
|
public void handleEvent(Event e) {
|
330
|
switch (e.type) {
|
331
|
case SWT.Selection:
|
332
|
setApply(true);
|
333
|
break;
|
334
|
}
|
335
|
}
|
336
|
});
|
337
|
|
338
|
final CLabel label = new CLabel(child, SWT.NULL);
|
339
|
label.setText(Messages.ChecklistEditorGeneralPreference_open_wizard);
|
340
|
label.setLayoutData(textGrid);
|
341
|
|
342
|
button_openSelectAreaVocabularies = new CommandHandlerButton(child, SWT.PUSH, commandHandlerString);
|
343
|
button_openSelectAreaVocabularies
|
344
|
.setText(Messages.ChecklistEditorGeneralPreference_open_distribution_selection);
|
345
|
|
346
|
if (!isAdminPreference) {
|
347
|
|
348
|
//PreferencesUtil.recursiveSetEnabled(child, isEditorActivated);
|
349
|
if (distributionEditorPref != null && !distributionEditorPref.isAllowOverride()){
|
350
|
activateComp.setEnabled(false);
|
351
|
}
|
352
|
|
353
|
if (prefAreaVoc != null && !prefAreaVoc.isAllowOverride()) {
|
354
|
button_openSelectAreaVocabularies.setButtonEnabled(false);
|
355
|
}
|
356
|
if (prefStatus != null && !prefStatus.isAllowOverride()) {
|
357
|
button_openStatusWizard.setButtonEnabled(false);
|
358
|
}
|
359
|
if (prefRank != null && !prefRank.isAllowOverride()) {
|
360
|
activateRankCombo.setEnabled(false);
|
361
|
}
|
362
|
if (prefAreaSort != null && !prefAreaSort.isAllowOverride()) {
|
363
|
areaOrderSelectionCombo.setEnabled(false);
|
364
|
//allowOverrideOrderAreasButton.setEnabled(false);
|
365
|
}
|
366
|
if (prefAreaDisplay != null && !prefAreaDisplay.isAllowOverride()) {
|
367
|
areaDisplaySelectionCombo.setEnabled(false);
|
368
|
}
|
369
|
if (prefStatusDisplay != null && !prefStatusDisplay.isAllowOverride()) {
|
370
|
statusDisplaySelectionCombo.setEnabled(false);
|
371
|
}
|
372
|
}
|
373
|
|
374
|
}
|
375
|
setValid(true);
|
376
|
return composite;
|
377
|
}
|
378
|
|
379
|
@Override
|
380
|
public boolean performOk() {
|
381
|
if (!isApply()){
|
382
|
return true;
|
383
|
}
|
384
|
boolean override = false;
|
385
|
if (isEditorActivated != null ) {
|
386
|
override = true;
|
387
|
PreferencesUtil.setStringValue(PreferencePredicate.DistributionEditorActivated.getKey(), isEditorActivated.toString());
|
388
|
}
|
389
|
PreferencesUtil.setBooleanValue(
|
390
|
PreferencesUtil.prefOverrideKey(PreferencePredicate.DistributionEditorActivated.getKey()),
|
391
|
override);
|
392
|
|
393
|
|
394
|
override = false;
|
395
|
if (!orderAreas.equals(Messages.Preference_Use_Default) ) {
|
396
|
override = true;
|
397
|
PreferencesUtil.setSortNamedAreasInDistributionEditor(orderAreas);
|
398
|
}
|
399
|
PreferencesUtil.setBooleanValue(
|
400
|
PreferencesUtil.prefOverrideKey(PreferencePredicate.AreasSortedInDistributionEditor.getKey()),
|
401
|
override);
|
402
|
|
403
|
|
404
|
|
405
|
|
406
|
|
407
|
override = false;
|
408
|
if (isShowRank != null ) {
|
409
|
override = true;
|
410
|
PreferencesUtil.setShowRankInChecklistEditor(isShowRank);
|
411
|
}
|
412
|
PreferencesUtil.setBooleanValue(
|
413
|
PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowRankInDistributionEditor.getKey()),
|
414
|
override);
|
415
|
|
416
|
|
417
|
override = false;
|
418
|
if (!displayStatus.equals(Messages.Preference_Use_Default)) {
|
419
|
override = true;
|
420
|
PreferencesUtil.setDisplayStatusInChecklistEditor(displayStatus);
|
421
|
}
|
422
|
PreferencesUtil.setBooleanValue(
|
423
|
PreferencesUtil.prefOverrideKey(PreferencePredicate.DisplayOfStatus.getKey()),
|
424
|
override);
|
425
|
|
426
|
|
427
|
|
428
|
|
429
|
override = false;
|
430
|
if (!displayArea.equals(Messages.Preference_Use_Default) ) {
|
431
|
override = true;
|
432
|
PreferencesUtil.setAreaDisplayInChecklistEditor(displayArea);
|
433
|
}
|
434
|
PreferencesUtil.setBooleanValue(PreferencesUtil.prefOverrideKey(
|
435
|
PreferencePredicate.DisplayOfAreasInDistributionEditor.getKey()), override);
|
436
|
|
437
|
|
438
|
|
439
|
|
440
|
PreferencesUtil.setOwnDescriptionForChecklistEditor(ownDescriptionForDistributionEditor);
|
441
|
PreferencesUtil.setBooleanValue(
|
442
|
PreferencesUtil.prefOverrideKey(PreferencePredicate.OwnDescriptionForDistributionEditor.getKey()),
|
443
|
true);
|
444
|
|
445
|
PreferencesUtil.firePreferencesChanged(this.getClass());
|
446
|
|
447
|
return true;
|
448
|
}
|
449
|
|
450
|
/**
|
451
|
* {@inheritDoc}
|
452
|
*/
|
453
|
@Override
|
454
|
public void widgetSelected(SelectionEvent e) {
|
455
|
setApply(true);
|
456
|
if (e.getSource().equals(statusDisplaySelectionCombo)) {
|
457
|
String text = statusDisplaySelectionCombo.getText();
|
458
|
if(text.equals(Messages.Preference_Use_Default)){
|
459
|
displayStatus = Messages.Preference_Use_Default;
|
460
|
if(isAdminPreference){
|
461
|
prefStatusDisplay.setAllowOverride(true);
|
462
|
allowOverrideStatusDisplayButton.setSelection(true);
|
463
|
}
|
464
|
|
465
|
return;
|
466
|
}
|
467
|
for (TermDisplayEnum display : TermDisplayEnum.values()) {
|
468
|
if (text.startsWith(display.getLabel())) {
|
469
|
displayStatus = display.getKey();
|
470
|
break;
|
471
|
}
|
472
|
|
473
|
}
|
474
|
}
|
475
|
if (e.getSource().equals(areaDisplaySelectionCombo)) {
|
476
|
String text = areaDisplaySelectionCombo.getText();
|
477
|
if(text.equals(Messages.Preference_Use_Default)){
|
478
|
displayArea = Messages.Preference_Use_Default;
|
479
|
if (isAdminPreference){
|
480
|
prefAreaDisplay.setAllowOverride(true);
|
481
|
allowOverrideAreaDisplayButton.setSelection(true);
|
482
|
}
|
483
|
return;
|
484
|
}
|
485
|
for (TermDisplayEnum display : TermDisplayEnum.values()) {
|
486
|
if (text.startsWith(display.getLabel())) {
|
487
|
displayArea = display.getKey();
|
488
|
break;
|
489
|
}
|
490
|
}
|
491
|
}
|
492
|
if (e.getSource().equals(areaOrderSelectionCombo)) {
|
493
|
String text = areaOrderSelectionCombo.getText();
|
494
|
if(text.equals(Messages.Preference_Use_Default)){
|
495
|
orderAreas = Messages.Preference_Use_Default;
|
496
|
if (isAdminPreference){
|
497
|
prefAreaSort.setAllowOverride(true);
|
498
|
allowOverrideOrderAreasButton.setSelection(true);
|
499
|
}
|
500
|
return;
|
501
|
}
|
502
|
for (TermOrder display : TermOrder.values()) {
|
503
|
if (text.startsWith(display.getLabel())) {
|
504
|
orderAreas = display.getKey();
|
505
|
break;
|
506
|
}
|
507
|
}
|
508
|
}
|
509
|
if (e.getSource().equals(this.activateRankCombo)) {
|
510
|
String text = activateRankCombo.getText();
|
511
|
if(text.equals(Messages.Preference_Use_Default)){
|
512
|
isShowRank = null;
|
513
|
if (isAdminPreference){
|
514
|
prefRank.setAllowOverride(true);
|
515
|
allowOverrideRankButton.setSelection(true);
|
516
|
}
|
517
|
return;
|
518
|
}
|
519
|
if (text.equals(SHOW_RANK)){
|
520
|
isShowRank = true;
|
521
|
}else{
|
522
|
isShowRank = false;
|
523
|
}
|
524
|
}
|
525
|
|
526
|
if (e.getSource().equals(this.activateCombo)) {
|
527
|
String text = activateCombo.getText();
|
528
|
if(text.equals(Messages.Preference_Use_Default)){
|
529
|
isEditorActivated = null;
|
530
|
if (isAdminPreference){
|
531
|
if (distributionEditorPref == null){
|
532
|
distributionEditorPref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.DistributionEditorActivated, PreferencePredicate.DistributionEditorActivated.getDefaultValue() != null ? PreferencePredicate.DistributionEditorActivated.getDefaultValue().toString(): null);
|
533
|
}
|
534
|
distributionEditorPref.setAllowOverride(true);
|
535
|
allowOverrideActivatedButton.setSelection(true);
|
536
|
}
|
537
|
return;
|
538
|
}
|
539
|
if (text.equals(ENABLE)){
|
540
|
isEditorActivated = true;
|
541
|
}else{
|
542
|
isEditorActivated = false;
|
543
|
}
|
544
|
|
545
|
}
|
546
|
//PreferencesUtil.recursiveSetEnabled(child, isEditorActivated);
|
547
|
}
|
548
|
|
549
|
/**
|
550
|
* {@inheritDoc}
|
551
|
*/
|
552
|
@Override
|
553
|
public void widgetDefaultSelected(SelectionEvent e) {
|
554
|
// TODO Auto-generated method stub
|
555
|
|
556
|
}
|
557
|
|
558
|
/**
|
559
|
* {@inheritDoc}
|
560
|
*/
|
561
|
@Override
|
562
|
public void getValues() {
|
563
|
isAdminPreference = false;
|
564
|
setPreferenceStore(PreferencesUtil.getPreferenceStore());
|
565
|
distributionEditorPref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.DistributionEditorActivated);
|
566
|
overrideActivated = PreferencesUtil.getBooleanValue(
|
567
|
PreferencesUtil.prefOverrideKey(PreferencePredicate.DistributionEditorActivated.getKey()), true);
|
568
|
|
569
|
if (distributionEditorPref != null) {
|
570
|
if (distributionEditorPref.isAllowOverride() ) {
|
571
|
if (overrideActivated){
|
572
|
isEditorActivated = PreferencesUtil.getBooleanValue(PreferencePredicate.DistributionEditorActivated.getKey(), true);
|
573
|
}
|
574
|
|
575
|
} else {
|
576
|
isEditorActivated = Boolean.valueOf(distributionEditorPref.getValue());
|
577
|
|
578
|
}
|
579
|
|
580
|
} else {
|
581
|
if(!overrideActivated){
|
582
|
isEditorActivated = null;
|
583
|
}else{
|
584
|
isEditorActivated = PreferencesUtil.getBooleanValue(PreferencePredicate.DistributionEditorActivated.getKey(), true);
|
585
|
}
|
586
|
//distributionEditorPref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.DistributionEditorActivated, PreferencePredicate.DistributionEditorActivated.getDefaultValue() != null ? PreferencePredicate.DistributionEditorActivated.getDefaultValue().toString(): null);
|
587
|
}
|
588
|
|
589
|
prefAreaVoc = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.AvailableDistributionAreaVocabularies);
|
590
|
if (prefAreaVoc == null){
|
591
|
prefAreaVoc = CdmPreference.NewTaxEditorInstance(PreferencePredicate.AvailableDistributionAreaVocabularies, PreferencePredicate.AvailableDistributionAreaVocabularies.getDefaultValue() != null ? PreferencePredicate.AvailableDistributionAreaVocabularies.getDefaultValue().toString(): null);
|
592
|
}
|
593
|
|
594
|
|
595
|
prefStatus = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.AvailableDistributionStatus);
|
596
|
if (prefStatus == null){
|
597
|
prefStatus = CdmPreference.NewTaxEditorInstance(PreferencePredicate.AvailableDistributionStatus, PreferencePredicate.AvailableDistributionStatus.getDefaultValue() != null ? PreferencePredicate.AvailableDistributionStatus.getDefaultValue().toString(): null);
|
598
|
}
|
599
|
|
600
|
|
601
|
prefAreaDisplay = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.DisplayOfAreasInDistributionEditor);
|
602
|
overrideAreaDisplay = PreferencesUtil.getBooleanValue(
|
603
|
PreferencesUtil.prefOverrideKey(PreferencePredicate.DisplayOfAreasInDistributionEditor.getKey()), true);
|
604
|
if (prefAreaDisplay != null) {
|
605
|
if (prefAreaDisplay.isAllowOverride()){
|
606
|
if (overrideActivated) {
|
607
|
displayArea = PreferencesUtil.displayAreaInChecklistEditor();
|
608
|
}else{
|
609
|
displayArea = Messages.Preference_Use_Default;
|
610
|
}
|
611
|
} else {
|
612
|
displayArea = prefAreaDisplay.getValue();
|
613
|
}
|
614
|
} else {
|
615
|
if (overrideAreaDisplay){
|
616
|
displayArea = PreferencesUtil.displayAreaInChecklistEditor();
|
617
|
} else{
|
618
|
displayArea = Messages.Preference_Use_Default;
|
619
|
}
|
620
|
//prefAreaDisplay = CdmPreference.NewTaxEditorInstance(PreferencePredicate.DisplayOfAreasInDistributionEditor, PreferencePredicate.DisplayOfAreasInDistributionEditor.getDefaultValue() != null ? PreferencePredicate.DisplayOfAreasInDistributionEditor.getDefaultValue().toString(): null);
|
621
|
}
|
622
|
|
623
|
prefStatusDisplay = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.DisplayOfStatus);
|
624
|
overrideStatusDisplay = PreferencesUtil
|
625
|
.getBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.DisplayOfStatus.getKey()), true);
|
626
|
if (prefStatusDisplay != null) {
|
627
|
if (prefStatusDisplay.isAllowOverride()){
|
628
|
if (overrideStatusDisplay) {
|
629
|
displayStatus = PreferencesUtil.displayStatusInChecklistEditor();
|
630
|
}else{
|
631
|
displayStatus = Messages.Preference_Use_Default;
|
632
|
}
|
633
|
} else {
|
634
|
this.displayStatus = prefStatusDisplay.getValue();
|
635
|
}
|
636
|
} else {
|
637
|
if (overrideStatusDisplay){
|
638
|
displayStatus = PreferencesUtil.displayStatusInChecklistEditor();
|
639
|
} else{
|
640
|
displayStatus = Messages.Preference_Use_Default;
|
641
|
}
|
642
|
//prefStatusDisplay = CdmPreference.NewTaxEditorInstance(PreferencePredicate.DisplayOfStatus, PreferencePredicate.DisplayOfStatus.getDefaultValue() != null ? PreferencePredicate.DisplayOfStatus.getDefaultValue().toString(): null);
|
643
|
}
|
644
|
|
645
|
prefAreaSort = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.AreasSortedInDistributionEditor);
|
646
|
overrideOrderAreas = PreferencesUtil.getBooleanValue(
|
647
|
PreferencesUtil.prefOverrideKey(PreferencePredicate.AreasSortedInDistributionEditor.getKey()), true);
|
648
|
if (prefAreaSort != null) {
|
649
|
if (prefAreaSort.isAllowOverride()){
|
650
|
if(overrideOrderAreas) {
|
651
|
orderAreas = PreferencesUtil.getSortNamedAreasInDistributionEditor();
|
652
|
}else{
|
653
|
orderAreas = Messages.Preference_Use_Default;
|
654
|
}
|
655
|
} else {
|
656
|
if (prefAreaSort.getValue() != null) {
|
657
|
orderAreas = prefAreaSort.getValue().toString();
|
658
|
} else {
|
659
|
orderAreas = ((TermOrder) PreferencePredicate.AreasSortedInDistributionEditor.getDefaultValue())
|
660
|
.getKey();
|
661
|
}
|
662
|
|
663
|
}
|
664
|
} else {
|
665
|
if (overrideOrderAreas){
|
666
|
orderAreas = PreferencesUtil.getSortNamedAreasInDistributionEditor();
|
667
|
}else{
|
668
|
orderAreas = Messages.Preference_Use_Default;
|
669
|
}
|
670
|
//prefAreaSort = CdmPreference.NewTaxEditorInstance(PreferencePredicate.AreasSortedInDistributionEditor, PreferencePredicate.AreasSortedInDistributionEditor.getDefaultValue() != null ? PreferencePredicate.AreasSortedInDistributionEditor.getDefaultValue().toString(): null);
|
671
|
}
|
672
|
|
673
|
prefRank = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.ShowRankInDistributionEditor);
|
674
|
overrideRank = PreferencesUtil.getBooleanValue(
|
675
|
PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowRankInDistributionEditor.getKey()), true);
|
676
|
if (prefRank != null) {
|
677
|
if (prefRank.isAllowOverride()){
|
678
|
if(overrideRank) {
|
679
|
isShowRank = PreferencesUtil.isShowRankInChecklistEditor();
|
680
|
}
|
681
|
|
682
|
} else {
|
683
|
this.isShowRank = Boolean.valueOf(prefRank.getValue().toString());
|
684
|
}
|
685
|
} else {
|
686
|
if (overrideRank){
|
687
|
isShowRank = PreferencesUtil.isShowRankInChecklistEditor();
|
688
|
} else {
|
689
|
isShowRank = null;
|
690
|
}
|
691
|
|
692
|
//refRank = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowRankInDistributionEditor, PreferencePredicate.ShowRankInDistributionEditor.getDefaultValue() != null ? PreferencePredicate.ShowRankInDistributionEditor.getDefaultValue().toString(): null);
|
693
|
}
|
694
|
|
695
|
prefOwnDescription = PreferencesUtil
|
696
|
.getPreferenceFromDB(PreferencePredicate.OwnDescriptionForDistributionEditor);
|
697
|
if (prefOwnDescription != null) {
|
698
|
if (prefOwnDescription.isAllowOverride()) {
|
699
|
ownDescriptionForDistributionEditor = PreferencesUtil.isOwnDescriptionForChecklistEditor();
|
700
|
} else {
|
701
|
ownDescriptionForDistributionEditor = Boolean.valueOf(prefOwnDescription.getValue().toString());
|
702
|
}
|
703
|
} else {
|
704
|
ownDescriptionForDistributionEditor = PreferencesUtil.isShowRankInChecklistEditor();
|
705
|
// allowOverrideOwnDescriptionForDistributionEditor = true;
|
706
|
overrideOwnDescriptionForDistributionEditor = PreferencesUtil.getBooleanValue(
|
707
|
PreferencesUtil.prefOverrideKey(PreferencePredicate.OwnDescriptionForDistributionEditor.getKey()), true);
|
708
|
//prefOwnDescription = CdmPreference.NewTaxEditorInstance(PreferencePredicate.OwnDescriptionForDistributionEditor, PreferencePredicate.OwnDescriptionForDistributionEditor.getDefaultValue() != null ? PreferencePredicate.OwnDescriptionForDistributionEditor.getDefaultValue().toString(): null);
|
709
|
}
|
710
|
|
711
|
commandHandlerString = "eu.etaxonomy.taxeditor.store.open.OpenDistributionEditorWizardHandler";
|
712
|
commandHandlerStringStatus = "eu.etaxonomy.taxeditor.store.open.OpenDistributionStatusWizardHandler";
|
713
|
}
|
714
|
|
715
|
@Override
|
716
|
protected void performDefaults() {
|
717
|
if (isAdminPreference){
|
718
|
isEditorActivated = (Boolean) PreferencePredicate.DistributionEditorActivated.getDefaultValue();
|
719
|
}else{
|
720
|
isEditorActivated = Boolean.parseBoolean(distributionEditorPref.getValue().toString());
|
721
|
}
|
722
|
if (isEditorActivated) {
|
723
|
activateCombo.select(0);
|
724
|
} else {
|
725
|
activateCombo.select(1);
|
726
|
}
|
727
|
|
728
|
if (isAdminPreference){
|
729
|
displayArea = ((TermDisplayEnum) PreferencePredicate.DisplayOfAreasInDistributionEditor.getDefaultValue())
|
730
|
.getKey();
|
731
|
}else{
|
732
|
displayArea = prefAreaDisplay.getValue().toString();
|
733
|
}
|
734
|
|
735
|
TermDisplayEnum areaDisplay;
|
736
|
try {
|
737
|
if (displayArea != null) {
|
738
|
areaDisplay = TermDisplayEnum.byKey(displayArea);
|
739
|
} else {
|
740
|
areaDisplay = TermDisplayEnum.Title;
|
741
|
}
|
742
|
} catch (IllegalArgumentException e) {
|
743
|
areaDisplay = TermDisplayEnum.Title;
|
744
|
}
|
745
|
int index = 0;
|
746
|
for (String itemLabel : areaDisplaySelectionCombo.getItems()) {
|
747
|
if (itemLabel.equalsIgnoreCase(areaDisplay.getLabel())) {
|
748
|
areaDisplaySelectionCombo.select(index);
|
749
|
break;
|
750
|
}
|
751
|
index++;
|
752
|
}
|
753
|
|
754
|
if (isAdminPreference){
|
755
|
displayStatus = ((TermDisplayEnum) PreferencePredicate.DisplayOfStatus.getDefaultValue()).getKey();
|
756
|
}else{
|
757
|
displayStatus = prefStatusDisplay.getValue().toString();
|
758
|
}
|
759
|
|
760
|
TermDisplayEnum statusDisplay;
|
761
|
try {
|
762
|
if (displayStatus != null) {
|
763
|
statusDisplay = TermDisplayEnum.byKey(displayStatus);
|
764
|
} else {
|
765
|
statusDisplay = TermDisplayEnum.Title;
|
766
|
}
|
767
|
} catch (IllegalArgumentException e) {
|
768
|
statusDisplay = TermDisplayEnum.Title;
|
769
|
}
|
770
|
index = 0;
|
771
|
for (String itemLabel : statusDisplaySelectionCombo.getItems()) {
|
772
|
if (itemLabel.equalsIgnoreCase(statusDisplay.getLabel())) {
|
773
|
statusDisplaySelectionCombo.select(index);
|
774
|
break;
|
775
|
}
|
776
|
index++;
|
777
|
}
|
778
|
if (isAdminPreference){
|
779
|
orderAreas = ((TermOrder) PreferencePredicate.AreasSortedInDistributionEditor.getDefaultValue()).getKey();
|
780
|
}else{
|
781
|
orderAreas = prefAreaSort.getValue().toString();
|
782
|
}
|
783
|
|
784
|
index = 0;
|
785
|
if (PreferencesUtil.getStringValue(PreferencePredicate.DistributionEditorActivated.getKey()) != null) {
|
786
|
TermOrder areaOrder;
|
787
|
try {
|
788
|
if (orderAreas != null) {
|
789
|
areaOrder = TermOrder.valueOf(orderAreas);
|
790
|
} else {
|
791
|
areaOrder = TermOrder.IdInVoc;
|
792
|
}
|
793
|
} catch (IllegalArgumentException e) {
|
794
|
areaOrder = TermOrder.IdInVoc;
|
795
|
}
|
796
|
for (String itemLabel : areaOrderSelectionCombo.getItems()) {
|
797
|
if (itemLabel.equalsIgnoreCase(areaOrder.getLabel())) {
|
798
|
areaOrderSelectionCombo.select(index);
|
799
|
break;
|
800
|
}
|
801
|
index++;
|
802
|
}
|
803
|
}
|
804
|
|
805
|
if (isAdminPreference){
|
806
|
isShowRank = Boolean.valueOf(PreferencePredicate.ShowRankInDistributionEditor.getDefaultValue().toString());
|
807
|
}else{
|
808
|
isShowRank = Boolean.parseBoolean(prefRank.getValue().toString());
|
809
|
}
|
810
|
|
811
|
if (isShowRank) {
|
812
|
activateRankCombo.select(0);
|
813
|
} else {
|
814
|
activateRankCombo.select(1);
|
815
|
}
|
816
|
|
817
|
ownDescriptionForDistributionEditor = Boolean
|
818
|
.valueOf(PreferencePredicate.OwnDescriptionForDistributionEditor.getDefaultValue().toString());
|
819
|
|
820
|
allowOverrideActivatedButton.setSelection(true);
|
821
|
overrideActivated = true;
|
822
|
|
823
|
overrideAreaDisplay = true;
|
824
|
allowOverrideAreaDisplayButton.setSelection(true);
|
825
|
|
826
|
overrideStatusDisplay = true;
|
827
|
allowOverrideStatusDisplayButton.setSelection(true);
|
828
|
|
829
|
overrideOrderAreas = true;
|
830
|
allowOverrideOrderAreasButton.setSelection(true);
|
831
|
|
832
|
overrideRank = true;
|
833
|
allowOverrideRankButton.setSelection(true);
|
834
|
|
835
|
overrideOwnDescriptionForDistributionEditor = true;
|
836
|
|
837
|
this.statusPref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.AvailableDistributionStatus, null);
|
838
|
this.areaVocPref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.AvailableDistributionAreaVocabularies,
|
839
|
null);
|
840
|
if (!isAdminPreference) {
|
841
|
PreferencesUtil.recursiveSetEnabled(child, isEditorActivated);
|
842
|
|
843
|
if (!prefAreaVoc.isAllowOverride()) {
|
844
|
button_openSelectAreaVocabularies.setButtonEnabled(false);
|
845
|
}
|
846
|
if (!prefStatus.isAllowOverride()) {
|
847
|
button_openStatusWizard.setButtonEnabled(false);
|
848
|
}
|
849
|
if (!prefRank.isAllowOverride()) {
|
850
|
activateRankCombo.setEnabled(false);
|
851
|
|
852
|
if (!prefAreaSort.isAllowOverride()) {
|
853
|
areaOrderSelectionCombo.setEnabled(false);
|
854
|
allowOverrideOrderAreasButton.setEnabled(false);
|
855
|
}
|
856
|
if (!prefAreaDisplay.isAllowOverride()) {
|
857
|
allowOverrideAreaDisplayButton.setEnabled(false);
|
858
|
}
|
859
|
if (!prefStatusDisplay.isAllowOverride()) {
|
860
|
allowOverrideStatusDisplayButton.setEnabled(false);
|
861
|
}
|
862
|
}
|
863
|
super.performDefaults();
|
864
|
}
|
865
|
}
|
866
|
|
867
|
}
|