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