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