2 * Copyright (C) 2014 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.taxeditor
.preference
;
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
;
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
;
36 public class ChecklistEditorGeneralPreference
extends CdmPreferencePage
implements SelectionListener
{
40 protected Boolean isEditorActivated
;
42 protected boolean overrideActivated
;
44 protected Boolean isShowRank
;
45 protected TermOrder orderAreas
;
46 protected TermDisplayEnum displayStatus
;
47 protected TermComboEnum displayStatusCombo
;
48 protected TermDisplayEnum displayArea
;
49 protected Boolean ownDescriptionForDistributionEditor
;
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
;
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
;
69 protected CdmPreference distributionEditorPref
;
71 protected CdmPreference prefStatusDisplay
;
72 protected CdmPreference prefAreaDisplay
;
74 protected CdmPreference prefStatusDisplayInCombo
;
75 protected CdmPreference prefAreaSort
;
76 protected CdmPreference prefRank
;
77 protected CdmPreference prefOwnDescription
;
80 protected Combo activateCombo
;
81 protected Button allowOverrideActivatedButton
;
82 final String ENABLE
= "Enable";
83 final String DISABLE
= "Disable";
85 protected Combo activateRankCombo
;
86 protected Button allowOverrideRankButton
;
87 final String SHOW_RANK
= "Yes";
88 final String NO_RANK
= "No";
94 protected Control
createContents(Composite parent
) {
96 Composite composite
= new Composite(parent
, SWT
.NULL
);
97 composite
.setLayout(new GridLayout());
98 if (!isAdminPreference
&& distributionEditorPref
!= null && !distributionEditorPref
.isAllowOverride()&& isEditorActivated
!= null && !isEditorActivated
) {
99 Label label
= new Label(composite
, SWT
.NONE
);
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);
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
);
114 activateCombo
= createBooleanCombo(activateComp
, ENABLE
, DISABLE
, PreferencePredicate
.DistributionEditorActivated
, Messages
.ChecklistEditorGeneralPreference_enable
, isAdminPreference
);
117 for (String itemLabel
: activateCombo
.getItems()) {
118 if (isEditorActivated
== null && itemLabel
.startsWith(Messages
.Preference_Use_Default
)) {
119 activateCombo
.select(index
);
122 if (isEditorActivated
!= null && itemLabel
.equals(ENABLE
) && isEditorActivated
){
123 activateCombo
.select(index
);
126 if (isEditorActivated
!= null && itemLabel
.equals(DISABLE
) && !isEditorActivated
){
127 activateCombo
.select(index
);
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() {
140 public void widgetSelected(SelectionEvent e
) {
142 if (distributionEditorPref
== null){
143 distributionEditorPref
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.DistributionEditorActivated
, PreferencePredicate
.DistributionEditorActivated
.getDefaultValue() != null ? PreferencePredicate
.DistributionEditorActivated
.getDefaultValue().toString(): null);
145 distributionEditorPref
.setAllowOverride(!distributionEditorPref
.isAllowOverride());
149 child
= createComposite(composite
);
151 if (!isAdminPreference
) {
152 if (isEditorActivated
!= null){
153 child
.setEnabled(isEditorActivated
);
155 child
.setEnabled(distributionEditorPref
.getValue() != null?Boolean
.parseBoolean(distributionEditorPref
.getValue().toString()): true);
158 separator
= new Label(child
, SWT
.HORIZONTAL
| SWT
.SEPARATOR
);
159 sepGrid
= createTextGridData();
160 separator
.setLayoutData(sepGrid
);
162 activateRankCombo
= createBooleanCombo(child
, SHOW_RANK
, NO_RANK
,
163 PreferencePredicate
.ShowRankInDistributionEditor
, Messages
.ChecklistEditorGeneralPreference_show_rank
, isAdminPreference
);
165 for (String itemLabel
: activateRankCombo
.getItems()) {
166 if (isShowRank
== null && itemLabel
.startsWith(Messages
.Preference_Use_Default
)) {
167 activateRankCombo
.select(index
);
170 if (isShowRank
!= null && itemLabel
.equals(SHOW_RANK
) && isShowRank
){
171 activateRankCombo
.select(index
);
174 if (isShowRank
!= null && itemLabel
.equals(NO_RANK
) && !isShowRank
){
175 activateRankCombo
.select(index
);
180 activateRankCombo
.addSelectionListener(this);
181 if (isAdminPreference
) {
182 allowOverrideRankButton
= createAllowOverrideButton(child
);
183 allowOverrideRankButton
.setSelection(prefRank
!= null? prefRank
.isAllowOverride():true);
184 // allowOverrideRankButton.setEnabled(prefRank != null);
185 allowOverrideRankButton
.addSelectionListener(new SelectionAdapter() {
187 public void widgetSelected(SelectionEvent e
) {
189 if (prefRank
== null){
190 prefRank
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.ShowRankInDistributionEditor
, PreferencePredicate
.ShowRankInDistributionEditor
.getDefaultValue() != null ? PreferencePredicate
.ShowRankInDistributionEditor
.getDefaultValue().toString(): null);
192 prefRank
.setAllowOverride(allowOverrideRankButton
.getSelection());
196 areaOrderSelectionCombo
= createCombo(child
, TermOrder
.values(), PreferencePredicate
.AreasSortedInDistributionEditor
, Messages
.ChecklistEditorGeneralPreference_Configure_area_order
, isAdminPreference
);
200 for (String itemLabel
: areaOrderSelectionCombo
.getItems()) {
201 if (itemLabel
.startsWith(Messages
.Preference_Use_Default
) && orderAreas
== null){
202 areaOrderSelectionCombo
.select(index
);
205 if (itemLabel
.equals(orderAreas
.getLabel())) {
206 areaOrderSelectionCombo
.select(index
);
213 areaOrderSelectionCombo
.addSelectionListener(this);
215 if (isAdminPreference
) {
216 allowOverrideOrderAreasButton
= createAllowOverrideButton(child
);
217 allowOverrideOrderAreasButton
.setSelection(prefAreaSort
!= null? prefAreaSort
.isAllowOverride(): true);
218 //allowOverrideOrderAreasButton.setEnabled(prefAreaSort != null);
219 allowOverrideOrderAreasButton
.addSelectionListener(new SelectionAdapter() {
221 public void widgetSelected(SelectionEvent e
) {
223 if (prefAreaSort
== null){
224 prefAreaSort
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.AreasSortedInDistributionEditor
, PreferencePredicate
.AreasSortedInDistributionEditor
.getDefaultValue() != null ? PreferencePredicate
.AreasSortedInDistributionEditor
.getDefaultValue().toString(): null);
226 prefAreaSort
.setAllowOverride(allowOverrideOrderAreasButton
.getSelection());
231 separator
= new Label(child
, SWT
.HORIZONTAL
| SWT
.SEPARATOR
);
232 separator
.setLayoutData(sepGrid
);
233 areaDisplaySelectionCombo
= createCombo(child
, TermDisplayEnum
.values(), PreferencePredicate
.DisplayOfAreasInDistributionEditor
, Messages
.ChecklistEditorGeneralPreference_Configure_display_of_Areas
, isAdminPreference
);
238 for (String itemLabel
: areaDisplaySelectionCombo
.getItems()) {
239 if (itemLabel
.startsWith(Messages
.Preference_Use_Default
) && displayArea
== null){
240 areaDisplaySelectionCombo
.select(index
);
242 }else if (itemLabel
.equals(displayArea
.getLabel())) {
243 areaDisplaySelectionCombo
.select(index
);
249 areaDisplaySelectionCombo
.addSelectionListener(this);
251 if (isAdminPreference
) {
252 allowOverrideAreaDisplayButton
= createAllowOverrideButton(child
);
253 allowOverrideAreaDisplayButton
.setSelection(prefAreaDisplay
!= null? prefAreaDisplay
.isAllowOverride(): true);
254 //allowOverrideAreaDisplayButton.setEnabled(prefAreaDisplay != null);
255 allowOverrideAreaDisplayButton
.addSelectionListener(new SelectionAdapter() {
257 public void widgetSelected(SelectionEvent e
) {
259 if (prefAreaDisplay
== null){
260 prefAreaDisplay
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.DisplayOfAreasInDistributionEditor
, PreferencePredicate
.DisplayOfAreasInDistributionEditor
.getDefaultValue() != null ? PreferencePredicate
.DisplayOfAreasInDistributionEditor
.getDefaultValue().toString(): null);
262 prefAreaDisplay
.setAllowOverride(allowOverrideOrderAreasButton
.getSelection());
267 statusDisplaySelectionCombo
= createCombo(child
, TermDisplayEnum
.values(), PreferencePredicate
.DisplayOfStatus
, Messages
.ChecklistEditorGeneralPreference_Configure_display_of_Status
, isAdminPreference
);
271 for (String itemLabel
: statusDisplaySelectionCombo
.getItems()) {
272 if (itemLabel
.startsWith(Messages
.Preference_Use_Default
) && displayStatus
== null){
273 statusDisplaySelectionCombo
.select(index
);
276 if (itemLabel
.equals(displayStatus
.getLabel())) {
277 statusDisplaySelectionCombo
.select(index
);
284 statusDisplaySelectionCombo
.addSelectionListener(this);
286 if (isAdminPreference
) {
287 allowOverrideStatusDisplayButton
= createAllowOverrideButton(child
);
288 allowOverrideStatusDisplayButton
.setSelection(prefStatusDisplay
!= null ? prefStatusDisplay
.isAllowOverride(): true);
289 //allowOverrideStatusDisplayButton.setEnabled(prefStatusDisplay != null);
290 allowOverrideStatusDisplayButton
.addSelectionListener(new SelectionAdapter() {
292 public void widgetSelected(SelectionEvent e
) {
294 if (prefStatusDisplay
== null){
295 prefStatusDisplay
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.DisplayOfStatus
, PreferencePredicate
.DisplayOfStatus
.getDefaultValue() != null ? PreferencePredicate
.DisplayOfStatus
.getDefaultValue().toString(): null);
297 prefStatusDisplay
.setAllowOverride(allowOverrideStatusDisplayButton
.getSelection());
302 statusDisplayInComboSelectionCombo
= createCombo(child
, TermComboEnum
.values(), PreferencePredicate
.DisplayOfStatusInCombo
, Messages
.ChecklistEditorGeneralPreference_Configure_display_of_Status_in_Combo
, isAdminPreference
);
306 for (String itemLabel
: statusDisplayInComboSelectionCombo
.getItems()) {
307 if (itemLabel
.startsWith(Messages
.Preference_Use_Default
) && displayStatusCombo
== null){
308 statusDisplayInComboSelectionCombo
.select(index
);
311 if (itemLabel
.equals(displayStatusCombo
.getLabel())) {
312 statusDisplayInComboSelectionCombo
.select(index
);
319 statusDisplayInComboSelectionCombo
.addSelectionListener(this);
321 if (isAdminPreference
) {
322 allowOverrideStatusDisplayInComboButton
= createAllowOverrideButton(child
);
323 allowOverrideStatusDisplayInComboButton
.setSelection(prefStatusDisplayInCombo
!= null ? prefStatusDisplayInCombo
.isAllowOverride(): true);
324 //allowOverrideStatusDisplayInComboButton.setEnabled(prefStatusDisplayInCombo != null);
325 allowOverrideStatusDisplayInComboButton
.addSelectionListener(new SelectionAdapter() {
327 public void widgetSelected(SelectionEvent e
) {
329 if (prefStatusDisplayInCombo
== null){
330 prefStatusDisplayInCombo
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.DisplayOfStatusInCombo
, PreferencePredicate
.DisplayOfStatusInCombo
.getDefaultValue() != null ? PreferencePredicate
.DisplayOfStatusInCombo
.getDefaultValue().toString(): null);
332 prefStatusDisplayInCombo
.setAllowOverride(allowOverrideStatusDisplayInComboButton
.getSelection());
340 if (!isAdminPreference
) {
343 if (distributionEditorPref
!= null && !distributionEditorPref
.isAllowOverride()){
344 activateComp
.setEnabled(false);
348 if (prefRank
!= null && !prefRank
.isAllowOverride()) {
349 activateRankCombo
.setEnabled(false);
351 if (prefAreaSort
!= null && !prefAreaSort
.isAllowOverride()) {
352 areaOrderSelectionCombo
.setEnabled(false);
354 if (prefAreaDisplay
!= null && !prefAreaDisplay
.isAllowOverride()) {
355 areaDisplaySelectionCombo
.setEnabled(false);
357 if (prefStatusDisplay
!= null && !prefStatusDisplay
.isAllowOverride()) {
358 statusDisplaySelectionCombo
.setEnabled(false);
360 if (prefStatusDisplayInCombo
!= null && !prefStatusDisplayInCombo
.isAllowOverride()) {
361 statusDisplayInComboSelectionCombo
.setEnabled(false);
371 public boolean performOk() {
375 boolean override
= false;
376 if (isEditorActivated
!= null ) {
378 PreferencesUtil
.setStringValue(PreferencePredicate
.DistributionEditorActivated
.getKey(), isEditorActivated
.toString());
380 PreferencesUtil
.setBooleanValue(
381 PreferencesUtil
.prefOverrideKey(PreferencePredicate
.DistributionEditorActivated
.getKey()),
386 if (orderAreas
!= null ) {
388 PreferencesUtil
.setSortNamedAreasInDistributionEditor(orderAreas
.getKey());
390 PreferencesUtil
.setBooleanValue(
391 PreferencesUtil
.prefOverrideKey(PreferencePredicate
.AreasSortedInDistributionEditor
.getKey()),
395 if (isShowRank
!= null ) {
397 PreferencesUtil
.setShowRankInChecklistEditor(isShowRank
);
399 PreferencesUtil
.setBooleanValue(
400 PreferencesUtil
.prefOverrideKey(PreferencePredicate
.ShowRankInDistributionEditor
.getKey()),
405 if (displayStatus
!= null) {
407 PreferencesUtil
.setDisplayStatusInChecklistEditor(displayStatus
.getKey());
409 PreferencesUtil
.setBooleanValue(
410 PreferencesUtil
.prefOverrideKey(PreferencePredicate
.DisplayOfStatus
.getKey()),
414 if (displayStatusCombo
!= null) {
416 PreferencesUtil
.setStringValue(PreferencePredicate
.DisplayOfStatusInCombo
.getKey(), displayStatusCombo
.getKey());
418 PreferencesUtil
.setBooleanValue(
419 PreferencesUtil
.prefOverrideKey(PreferencePredicate
.DisplayOfStatusInCombo
.getKey()),
425 if (displayArea
!= null) {
427 PreferencesUtil
.setAreaDisplayInChecklistEditor(displayArea
.getKey());
429 PreferencesUtil
.setBooleanValue(PreferencesUtil
.prefOverrideKey(
430 PreferencePredicate
.DisplayOfAreasInDistributionEditor
.getKey()), override
);
433 PreferencesUtil
.firePreferencesChanged(this.getClass());
442 public void widgetSelected(SelectionEvent e
) {
444 if (e
.getSource().equals(statusDisplaySelectionCombo
)) {
445 String text
= statusDisplaySelectionCombo
.getText();
446 if(text
.startsWith(Messages
.Preference_Use_Default
)){
447 displayStatus
= null;
451 for (TermDisplayEnum display
: TermDisplayEnum
.values()) {
452 if (text
.startsWith(display
.getLabel())) {
453 displayStatus
= display
;
459 if (e
.getSource().equals(statusDisplayInComboSelectionCombo
)) {
460 String text
= statusDisplayInComboSelectionCombo
.getText();
461 if(text
.startsWith(Messages
.Preference_Use_Default
)){
462 displayStatusCombo
= null;
466 for (TermComboEnum display
: TermComboEnum
.values()) {
467 if (text
.startsWith(display
.getLabel())) {
468 displayStatusCombo
= display
;
474 if (e
.getSource().equals(areaDisplaySelectionCombo
)) {
475 String text
= areaDisplaySelectionCombo
.getText();
476 if(text
.startsWith(Messages
.Preference_Use_Default
)){
481 for (TermDisplayEnum display
: TermDisplayEnum
.values()) {
482 if (text
.startsWith(display
.getLabel())) {
483 displayArea
= display
;
488 if (e
.getSource().equals(areaOrderSelectionCombo
)) {
489 String text
= areaOrderSelectionCombo
.getText();
490 if(text
.startsWith(Messages
.Preference_Use_Default
)){
495 for (TermOrder display
: TermOrder
.values()) {
496 if (text
.startsWith(display
.getLabel())) {
497 orderAreas
= display
;
502 if (e
.getSource().equals(this.activateRankCombo
)) {
503 String text
= activateRankCombo
.getText();
504 if(text
.startsWith(Messages
.Preference_Use_Default
)){
509 if (text
.equals(SHOW_RANK
)){
516 if (e
.getSource().equals(this.activateCombo
)) {
517 String text
= activateCombo
.getText();
518 if(text
.startsWith(Messages
.Preference_Use_Default
)){
519 isEditorActivated
= null;
520 if (!isAdminPreference
) {
521 if (isEditorActivated
!= null){
522 child
.setEnabled(isEditorActivated
);
524 child
.setEnabled(distributionEditorPref
.getValue() != null?Boolean
.parseBoolean(distributionEditorPref
.getValue().toString()): true);
530 if (text
.equals(ENABLE
)){
531 isEditorActivated
= true;
533 isEditorActivated
= false;
535 if (!isAdminPreference
) {
536 if (isEditorActivated
!= null){
537 child
.setEnabled(isEditorActivated
);
539 child
.setEnabled(distributionEditorPref
.getValue() != null?Boolean
.parseBoolean(distributionEditorPref
.getValue().toString()): true);
551 public void widgetDefaultSelected(SelectionEvent e
) {
552 // TODO Auto-generated method stub
560 public void getValues() {
561 isAdminPreference
= false;
562 setPreferenceStore(PreferencesUtil
.getPreferenceStore());
563 distributionEditorPref
= PreferencesUtil
.getPreferenceFromDB(PreferencePredicate
.DistributionEditorActivated
);
564 overrideActivated
= PreferencesUtil
.getBooleanValue(
565 PreferencesUtil
.prefOverrideKey(PreferencePredicate
.DistributionEditorActivated
.getKey()), true) != null? PreferencesUtil
.getBooleanValue(
566 PreferencesUtil
.prefOverrideKey(PreferencePredicate
.DistributionEditorActivated
.getKey()), true):false;
568 if (distributionEditorPref
!= null) {
569 if (distributionEditorPref
.isAllowOverride() ) {
570 if (overrideActivated
){
571 isEditorActivated
= PreferencesUtil
.getBooleanValue(PreferencePredicate
.DistributionEditorActivated
.getKey(), true);
575 isEditorActivated
= distributionEditorPref
.getValue() != null? Boolean
.valueOf(distributionEditorPref
.getValue()): null;
579 if(!overrideActivated
){
580 isEditorActivated
= null;
582 isEditorActivated
= PreferencesUtil
.getBooleanValue(PreferencePredicate
.DistributionEditorActivated
.getKey(), true);
584 distributionEditorPref
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.DistributionEditorActivated
, PreferencePredicate
.DistributionEditorActivated
.getDefaultValue() != null ? PreferencePredicate
.DistributionEditorActivated
.getDefaultValue().toString(): null);
590 prefAreaDisplay
= PreferencesUtil
.getPreferenceFromDB(PreferencePredicate
.DisplayOfAreasInDistributionEditor
);
591 overrideAreaDisplay
= PreferencesUtil
.getBooleanValue(
592 PreferencesUtil
.prefOverrideKey(PreferencePredicate
.DisplayOfAreasInDistributionEditor
.getKey()), true) != null? PreferencesUtil
.getBooleanValue(
593 PreferencesUtil
.prefOverrideKey(PreferencePredicate
.DisplayOfAreasInDistributionEditor
.getKey()), true): false;
595 if (prefAreaDisplay
!= null) {
596 if (prefAreaDisplay
.isAllowOverride()){
597 if (overrideActivated
) {
598 displayArea
= PreferencesUtil
.displayAreaInChecklistEditor();
603 displayArea
= prefAreaDisplay
.getValue() != null? TermDisplayEnum
.byKey(prefAreaDisplay
.getValue()): null;
606 if (overrideAreaDisplay
){
607 displayArea
= PreferencesUtil
.displayAreaInChecklistEditor();
611 //prefAreaDisplay = CdmPreference.NewTaxEditorInstance(PreferencePredicate.DisplayOfAreasInDistributionEditor, PreferencePredicate.DisplayOfAreasInDistributionEditor.getDefaultValue() != null ? PreferencePredicate.DisplayOfAreasInDistributionEditor.getDefaultValue().toString(): null);
614 prefStatusDisplay
= PreferencesUtil
.getPreferenceFromDB(PreferencePredicate
.DisplayOfStatus
);
615 overrideStatusDisplay
= PreferencesUtil
616 .getBooleanValue(PreferencesUtil
.prefOverrideKey(PreferencePredicate
.DisplayOfStatus
.getKey()), true) != null? PreferencesUtil
617 .getBooleanValue(PreferencesUtil
.prefOverrideKey(PreferencePredicate
.DisplayOfStatus
.getKey()), true): false;
618 if (prefStatusDisplay
!= null) {
619 if (prefStatusDisplay
.isAllowOverride()){
620 if (overrideStatusDisplay
) {
621 displayStatus
= PreferencesUtil
.displayStatusInChecklistEditor();
623 displayStatus
= null;
626 this.displayStatus
= prefStatusDisplay
.getValue() != null? TermDisplayEnum
.byKey(prefStatusDisplay
.getValue()): null;
629 if (overrideStatusDisplay
){
630 displayStatus
= PreferencesUtil
.displayStatusInChecklistEditor();
632 displayStatus
= null;
634 //prefStatusDisplay = CdmPreference.NewTaxEditorInstance(PreferencePredicate.DisplayOfStatus, PreferencePredicate.DisplayOfStatus.getDefaultValue() != null ? PreferencePredicate.DisplayOfStatus.getDefaultValue().toString(): null);
637 prefStatusDisplayInCombo
= PreferencesUtil
.getPreferenceFromDB(PreferencePredicate
.DisplayOfStatusInCombo
);
638 overrideStatusDisplayCombo
= PreferencesUtil
639 .getBooleanValue(PreferencesUtil
.prefOverrideKey(PreferencePredicate
.DisplayOfStatusInCombo
.getKey()), true) != null? PreferencesUtil
640 .getBooleanValue(PreferencesUtil
.prefOverrideKey(PreferencePredicate
.DisplayOfStatusInCombo
.getKey()), true): false;
641 if (prefStatusDisplayInCombo
!= null) {
642 if (prefStatusDisplayInCombo
.isAllowOverride()){
643 if (overrideStatusDisplayCombo
) {
644 displayStatusCombo
= TermComboEnum
.byKey(PreferencesUtil
.getStringValue(PreferencePredicate
.DisplayOfStatusInCombo
.getKey()));
646 displayStatusCombo
= null;
649 this.displayStatusCombo
= prefStatusDisplayInCombo
.getValue() != null? TermComboEnum
.byKey(prefStatusDisplayInCombo
.getValue()): null;
652 if (overrideStatusDisplayCombo
){
653 displayStatusCombo
= TermComboEnum
.byKey(PreferencesUtil
.getStringValue(PreferencePredicate
.DisplayOfStatusInCombo
.getKey()));
655 displayStatusCombo
= null;
661 prefAreaSort
= PreferencesUtil
.getPreferenceFromDB(PreferencePredicate
.AreasSortedInDistributionEditor
);
662 overrideOrderAreas
= PreferencesUtil
.getBooleanValue(
663 PreferencesUtil
.prefOverrideKey(PreferencePredicate
.AreasSortedInDistributionEditor
.getKey()), true) != null? PreferencesUtil
.getBooleanValue(
664 PreferencesUtil
.prefOverrideKey(PreferencePredicate
.AreasSortedInDistributionEditor
.getKey()), true): false;
665 if (prefAreaSort
!= null) {
666 if (prefAreaSort
.isAllowOverride()){
667 if(overrideOrderAreas
) {
668 orderAreas
= PreferencesUtil
.getSortNamedAreasInDistributionEditor();
673 if (prefAreaSort
.getValue() != null) {
674 orderAreas
= prefAreaSort
.getValue() != null? TermOrder
.valueOf(prefAreaSort
.getValue().toString()): null;
676 orderAreas
= ((TermOrder
) PreferencePredicate
.AreasSortedInDistributionEditor
.getDefaultValue());
681 if (overrideOrderAreas
){
682 orderAreas
= PreferencesUtil
.getSortNamedAreasInDistributionEditor();
686 //prefAreaSort = CdmPreference.NewTaxEditorInstance(PreferencePredicate.AreasSortedInDistributionEditor, PreferencePredicate.AreasSortedInDistributionEditor.getDefaultValue() != null ? PreferencePredicate.AreasSortedInDistributionEditor.getDefaultValue().toString(): null);
689 prefRank
= PreferencesUtil
.getPreferenceFromDB(PreferencePredicate
.ShowRankInDistributionEditor
);
690 overrideRank
= PreferencesUtil
.getBooleanValue(
691 PreferencesUtil
.prefOverrideKey(PreferencePredicate
.ShowRankInDistributionEditor
.getKey()), true) != null? PreferencesUtil
.getBooleanValue(
692 PreferencesUtil
.prefOverrideKey(PreferencePredicate
.ShowRankInDistributionEditor
.getKey()), true): false;
693 if (prefRank
!= null) {
694 if (prefRank
.isAllowOverride()){
696 isShowRank
= PreferencesUtil
.isShowRankInChecklistEditor();
700 this.isShowRank
= prefRank
.getValue() != null? Boolean
.valueOf(prefRank
.getValue().toString()): null;
704 isShowRank
= PreferencesUtil
.isShowRankInChecklistEditor();
709 //refRank = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowRankInDistributionEditor, PreferencePredicate.ShowRankInDistributionEditor.getDefaultValue() != null ? PreferencePredicate.ShowRankInDistributionEditor.getDefaultValue().toString(): null);
712 prefOwnDescription
= PreferencesUtil
713 .getPreferenceFromDB(PreferencePredicate
.OwnDescriptionForDistributionEditor
);
714 if (prefOwnDescription
!= null) {
715 if (prefOwnDescription
.isAllowOverride()) {
716 ownDescriptionForDistributionEditor
= PreferencesUtil
.isOwnDescriptionForChecklistEditor();
718 ownDescriptionForDistributionEditor
= prefOwnDescription
.getValue() != null? Boolean
.valueOf(prefOwnDescription
.getValue().toString()): null;
721 ownDescriptionForDistributionEditor
= PreferencesUtil
.isShowRankInChecklistEditor();
722 // allowOverrideOwnDescriptionForDistributionEditor = true;
723 overrideOwnDescriptionForDistributionEditor
= PreferencesUtil
.getBooleanValue(
724 PreferencesUtil
.prefOverrideKey(PreferencePredicate
.OwnDescriptionForDistributionEditor
.getKey()), true) != null? PreferencesUtil
.getBooleanValue(
725 PreferencesUtil
.prefOverrideKey(PreferencePredicate
.OwnDescriptionForDistributionEditor
.getKey()), true): false;
726 //prefOwnDescription = CdmPreference.NewTaxEditorInstance(PreferencePredicate.OwnDescriptionForDistributionEditor, PreferencePredicate.OwnDescriptionForDistributionEditor.getDefaultValue() != null ? PreferencePredicate.OwnDescriptionForDistributionEditor.getDefaultValue().toString(): null);
733 protected void performDefaults() {
736 isEditorActivated
= null;
737 activateCombo
.select(0);
743 for (String itemLabel
: areaDisplaySelectionCombo
.getItems()) {
744 if (itemLabel
.startsWith(Messages
.Preference_Use_Default
)) {
745 areaDisplaySelectionCombo
.select(index
);
751 displayStatus
= null;
756 for (String itemLabel
: statusDisplaySelectionCombo
.getItems()) {
757 if (itemLabel
.startsWith(Messages
.Preference_Use_Default
)) {
758 statusDisplaySelectionCombo
.select(index
);
768 for (String itemLabel
: areaOrderSelectionCombo
.getItems()) {
769 if (itemLabel
.startsWith(Messages
.Preference_Use_Default
)) {
770 areaOrderSelectionCombo
.select(index
);
780 for (String itemLabel
: activateRankCombo
.getItems()) {
781 if (itemLabel
.startsWith(Messages
.Preference_Use_Default
)) {
782 activateRankCombo
.select(index
);
788 displayStatusCombo
= null;
790 for (String itemLabel
: statusDisplayInComboSelectionCombo
.getItems()) {
791 if (itemLabel
.startsWith(Messages
.Preference_Use_Default
)) {
792 statusDisplayInComboSelectionCombo
.select(index
);
798 ownDescriptionForDistributionEditor
= null;
800 if (isAdminPreference
){
801 allowOverrideActivatedButton
.setSelection(true);
802 allowOverrideAreaDisplayButton
.setSelection(true);
803 allowOverrideStatusDisplayButton
.setSelection(true);
804 allowOverrideOrderAreasButton
.setSelection(true);
805 allowOverrideRankButton
.setSelection(true);
807 overrideActivated
= true;
808 overrideAreaDisplay
= true;
809 overrideStatusDisplay
= true;
810 overrideOrderAreas
= true;
812 overrideOwnDescriptionForDistributionEditor
= true;
815 if (!isAdminPreference
) {
816 PreferencesUtil
.recursiveSetEnabled(child
, Boolean
.parseBoolean(distributionEditorPref
.getValue()));
817 // if (!prefRank.isAllowOverride()) {
818 // activateRankCombo.setEnabled(false);
820 // if (!prefAreaSort.isAllowOverride()) {
821 // areaOrderSelectionCombo.setEnabled(false);
823 // if (!prefAreaDisplay.isAllowOverride()) {
824 // allowOverrideAreaDisplayButton.setEnabled(false);
826 // if (!prefStatusDisplay.isAllowOverride()) {
827 // allowOverrideStatusDisplayButton.setEnabled(false);
830 super.performDefaults();