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
.custom
.CLabel
;
13 import org
.eclipse
.swt
.events
.ModifyEvent
;
14 import org
.eclipse
.swt
.events
.ModifyListener
;
15 import org
.eclipse
.swt
.events
.SelectionAdapter
;
16 import org
.eclipse
.swt
.events
.SelectionEvent
;
17 import org
.eclipse
.swt
.events
.SelectionListener
;
18 import org
.eclipse
.swt
.layout
.GridData
;
19 import org
.eclipse
.swt
.layout
.GridLayout
;
20 import org
.eclipse
.swt
.widgets
.Button
;
21 import org
.eclipse
.swt
.widgets
.Combo
;
22 import org
.eclipse
.swt
.widgets
.Composite
;
23 import org
.eclipse
.swt
.widgets
.Control
;
24 import org
.eclipse
.swt
.widgets
.Display
;
25 import org
.eclipse
.swt
.widgets
.Label
;
26 import org
.eclipse
.swt
.widgets
.Text
;
28 import eu
.etaxonomy
.cdm
.model
.metadata
.CdmPreference
;
29 import eu
.etaxonomy
.cdm
.model
.metadata
.PreferencePredicate
;
30 import eu
.etaxonomy
.cdm
.model
.metadata
.TermComboEnum
;
31 import eu
.etaxonomy
.cdm
.model
.metadata
.TermDisplayEnum
;
32 import eu
.etaxonomy
.cdm
.model
.metadata
.TermOrder
;
33 import eu
.etaxonomy
.taxeditor
.l10n
.Messages
;
34 import eu
.etaxonomy
.taxeditor
.preference
.menu
.CdmPreferencePage
;
41 public class ChecklistEditorGeneralPreference
extends CdmPreferencePage
implements SelectionListener
{
45 protected Boolean isEditorActivated
;
47 protected boolean overrideActivated
;
49 protected Boolean isShowRank
;
50 protected TermOrder orderAreas
;
51 protected TermOrder orderStatus
;
52 protected TermDisplayEnum displayStatus
;
53 protected TermComboEnum displayStatusCombo
;
54 protected TermDisplayEnum displayArea
;
55 protected Boolean ownDescriptionForDistributionEditor
;
56 protected Integer numberOfStatus
;
58 protected boolean overrideOwnDescriptionForDistributionEditor
;
59 protected boolean overrideAreaVoc
;
60 protected boolean overrideRank
;
61 protected boolean overrideOrderAreas
;
62 protected boolean overrideAreaDisplay
;
63 protected boolean overrideStatusDisplay
;
64 protected boolean overrideStatusDisplayCombo
;
65 protected boolean overrideNumberOfStatus
;
66 protected boolean overrideOrderStatus
;
68 protected Combo areaOrderSelectionCombo
;
69 protected Button allowOverrideOrderAreasButton
;
70 protected Combo statusDisplaySelectionCombo
;
71 protected Button allowOverrideStatusDisplayButton
;
72 protected Combo statusDisplayInComboSelectionCombo
;
73 protected Button allowOverrideStatusDisplayInComboButton
;
74 protected Combo areaDisplaySelectionCombo
;
75 protected Button allowOverrideAreaDisplayButton
;
76 protected Combo statusSortSelectionCombo
;
77 protected Button allowOverrideStatusSortButton
;
80 protected Text numberOfStatusText
;
81 protected Button allowOverrideNumberOfStatusButton
;
82 protected Label numberFormatExceptionLabel
;
84 protected CdmPreference distributionEditorPref
;
86 protected CdmPreference prefStatusDisplay
;
87 protected CdmPreference prefAreaDisplay
;
89 protected CdmPreference prefStatusDisplayInCombo
;
90 protected CdmPreference prefAreaSort
;
91 protected CdmPreference prefRank
;
92 protected CdmPreference prefOwnDescription
;
93 protected CdmPreference prefNumberStatus
;
94 protected CdmPreference prefStatusSort
;
97 protected Combo activateCombo
;
98 protected Button allowOverrideActivatedButton
;
99 final String ENABLE
= "Enable";
100 final String DISABLE
= "Disable";
102 protected Combo activateRankCombo
;
103 protected Button allowOverrideRankButton
;
104 final String SHOW_RANK
= "Yes";
105 final String NO_RANK
= "No";
111 protected Control
createContents(Composite parent
) {
113 Composite composite
= new Composite(parent
, SWT
.NULL
);
114 composite
.setLayout(new GridLayout());
115 if (!isAdminPreference
&& distributionEditorPref
!= null && !distributionEditorPref
.isAllowOverride() ) {
116 Label label
= new Label(composite
, SWT
.NONE
);
118 "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.");
119 this.setDefaultButtonActivated(false);
121 Composite activateComp
= createComposite(composite
);
122 Label separator
= new Label(activateComp
, SWT
.HORIZONTAL
| SWT
.SEPARATOR
);
123 GridData sepGrid
= createTextGridData();
124 separator
.setLayoutData(sepGrid
);
125 separator
.setVisible(false);
126 CdmPreference dbPref
;
127 GridData textGrid
= createTextGridData();
128 textGrid
.verticalSpan
= 2;
129 separator
.setLayoutData(sepGrid
);
131 activateCombo
= createBooleanCombo(activateComp
, ENABLE
, DISABLE
, PreferencePredicate
.DistributionEditorActivated
, Messages
.ChecklistEditorGeneralPreference_enable
, isAdminPreference
);
134 for (String itemLabel
: activateCombo
.getItems()) {
135 if (isEditorActivated
== null && itemLabel
.startsWith(Messages
.Preference_Use_Default
)) {
136 activateCombo
.select(index
);
139 if (isEditorActivated
!= null && itemLabel
.equals(ENABLE
) && isEditorActivated
){
140 activateCombo
.select(index
);
143 if (isEditorActivated
!= null && itemLabel
.equals(DISABLE
) && !isEditorActivated
){
144 activateCombo
.select(index
);
151 activateCombo
.addSelectionListener(this);
152 if (isAdminPreference
) {
153 allowOverrideActivatedButton
= createAllowOverrideButton(activateComp
);
154 allowOverrideActivatedButton
.setSelection(this.distributionEditorPref
!= null?
this.distributionEditorPref
.isAllowOverride(): true);
155 allowOverrideActivatedButton
.addSelectionListener(new SelectionAdapter() {
157 public void widgetSelected(SelectionEvent e
) {
159 if (distributionEditorPref
== null){
160 distributionEditorPref
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.DistributionEditorActivated
, PreferencePredicate
.DistributionEditorActivated
.getDefaultValue() != null ? PreferencePredicate
.DistributionEditorActivated
.getDefaultValue().toString(): null);
162 distributionEditorPref
.setAllowOverride(!distributionEditorPref
.isAllowOverride());
166 child
= createComposite(composite
);
168 if (!isAdminPreference
) {
169 if (isEditorActivated
!= null){
170 child
.setEnabled(isEditorActivated
);
172 child
.setEnabled(distributionEditorPref
.getValue() != null?Boolean
.parseBoolean(distributionEditorPref
.getValue().toString()): true);
175 separator
= new Label(child
, SWT
.HORIZONTAL
| SWT
.SEPARATOR
);
176 sepGrid
= createTextGridData();
177 separator
.setLayoutData(sepGrid
);
179 activateRankCombo
= createBooleanCombo(child
, SHOW_RANK
, NO_RANK
,
180 PreferencePredicate
.ShowRankInDistributionEditor
, Messages
.ChecklistEditorGeneralPreference_show_rank
, isAdminPreference
);
182 for (String itemLabel
: activateRankCombo
.getItems()) {
183 if (isShowRank
== null && itemLabel
.startsWith(Messages
.Preference_Use_Default
)) {
184 activateRankCombo
.select(index
);
187 if (isShowRank
!= null && itemLabel
.equals(SHOW_RANK
) && isShowRank
){
188 activateRankCombo
.select(index
);
191 if (isShowRank
!= null && itemLabel
.equals(NO_RANK
) && !isShowRank
){
192 activateRankCombo
.select(index
);
197 activateRankCombo
.addSelectionListener(this);
198 if (isAdminPreference
) {
199 allowOverrideRankButton
= createAllowOverrideButton(child
);
200 allowOverrideRankButton
.setSelection(prefRank
!= null? prefRank
.isAllowOverride():true);
201 allowOverrideRankButton
.addSelectionListener(new SelectionAdapter() {
203 public void widgetSelected(SelectionEvent e
) {
205 if (prefRank
== null){
206 prefRank
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.ShowRankInDistributionEditor
, PreferencePredicate
.ShowRankInDistributionEditor
.getDefaultValue() != null ? PreferencePredicate
.ShowRankInDistributionEditor
.getDefaultValue().toString(): null);
208 prefRank
.setAllowOverride(allowOverrideRankButton
.getSelection());
212 separator
= new Label(child
, SWT
.HORIZONTAL
| SWT
.SEPARATOR
);
213 sepGrid
= createTextGridData();
214 separator
.setLayoutData(sepGrid
);
216 areaOrderSelectionCombo
= createCombo(child
, TermOrder
.values(), PreferencePredicate
.AreasSortedInDistributionEditor
, Messages
.ChecklistEditorGeneralPreference_Configure_area_order
, isAdminPreference
);
220 for (String itemLabel
: areaOrderSelectionCombo
.getItems()) {
221 if (itemLabel
.startsWith(Messages
.Preference_Use_Default
) && orderAreas
== null){
222 areaOrderSelectionCombo
.select(index
);
225 if (itemLabel
.equals(orderAreas
.getLabel())) {
226 areaOrderSelectionCombo
.select(index
);
233 areaOrderSelectionCombo
.addSelectionListener(this);
235 if (isAdminPreference
) {
236 allowOverrideOrderAreasButton
= createAllowOverrideButton(child
);
237 allowOverrideOrderAreasButton
.setSelection(prefAreaSort
!= null? prefAreaSort
.isAllowOverride(): true);
238 allowOverrideOrderAreasButton
.addSelectionListener(new SelectionAdapter() {
240 public void widgetSelected(SelectionEvent e
) {
242 if (prefAreaSort
== null){
243 prefAreaSort
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.AreasSortedInDistributionEditor
, PreferencePredicate
.AreasSortedInDistributionEditor
.getDefaultValue() != null ? PreferencePredicate
.AreasSortedInDistributionEditor
.getDefaultValue().toString(): null);
245 prefAreaSort
.setAllowOverride(allowOverrideOrderAreasButton
.getSelection());
251 areaDisplaySelectionCombo
= createCombo(child
, TermDisplayEnum
.values(), PreferencePredicate
.DisplayOfAreasInDistributionEditor
, Messages
.ChecklistEditorGeneralPreference_Configure_display_of_Areas
, isAdminPreference
);
256 for (String itemLabel
: areaDisplaySelectionCombo
.getItems()) {
257 if (itemLabel
.startsWith(Messages
.Preference_Use_Default
) && displayArea
== null){
258 areaDisplaySelectionCombo
.select(index
);
260 }else if (itemLabel
.equals(displayArea
.getLabel())) {
261 areaDisplaySelectionCombo
.select(index
);
267 areaDisplaySelectionCombo
.addSelectionListener(this);
269 if (isAdminPreference
) {
270 allowOverrideAreaDisplayButton
= createAllowOverrideButton(child
);
271 allowOverrideAreaDisplayButton
.setSelection(prefAreaDisplay
!= null? prefAreaDisplay
.isAllowOverride(): true);
272 allowOverrideAreaDisplayButton
.addSelectionListener(new SelectionAdapter() {
274 public void widgetSelected(SelectionEvent e
) {
276 if (prefAreaDisplay
== null){
277 prefAreaDisplay
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.DisplayOfAreasInDistributionEditor
, PreferencePredicate
.DisplayOfAreasInDistributionEditor
.getDefaultValue() != null ? PreferencePredicate
.DisplayOfAreasInDistributionEditor
.getDefaultValue().toString(): null);
279 prefAreaDisplay
.setAllowOverride(allowOverrideOrderAreasButton
.getSelection());
284 separator
= new Label(child
, SWT
.HORIZONTAL
| SWT
.SEPARATOR
);
285 separator
.setLayoutData(sepGrid
);
287 statusDisplaySelectionCombo
= createCombo(child
, TermDisplayEnum
.values(), PreferencePredicate
.DisplayOfStatus
, Messages
.ChecklistEditorGeneralPreference_Configure_display_of_Status
, isAdminPreference
);
291 for (String itemLabel
: statusDisplaySelectionCombo
.getItems()) {
292 if (itemLabel
.startsWith(Messages
.Preference_Use_Default
) && displayStatus
== null){
293 statusDisplaySelectionCombo
.select(index
);
296 if (itemLabel
.equals(displayStatus
.getLabel())) {
297 statusDisplaySelectionCombo
.select(index
);
304 statusDisplaySelectionCombo
.addSelectionListener(this);
306 if (isAdminPreference
) {
307 allowOverrideStatusDisplayButton
= createAllowOverrideButton(child
);
308 allowOverrideStatusDisplayButton
.setSelection(prefStatusDisplay
!= null ? prefStatusDisplay
.isAllowOverride(): true);
309 allowOverrideStatusDisplayButton
.addSelectionListener(new SelectionAdapter() {
311 public void widgetSelected(SelectionEvent e
) {
313 if (prefStatusDisplay
== null){
314 prefStatusDisplay
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.DisplayOfStatus
, PreferencePredicate
.DisplayOfStatus
.getDefaultValue() != null ? PreferencePredicate
.DisplayOfStatus
.getDefaultValue().toString(): null);
316 prefStatusDisplay
.setAllowOverride(allowOverrideStatusDisplayButton
.getSelection());
321 statusDisplayInComboSelectionCombo
= createCombo(child
, TermComboEnum
.values(), PreferencePredicate
.DisplayOfStatusInCombo
, Messages
.ChecklistEditorGeneralPreference_Configure_display_of_Status_in_Combo
, isAdminPreference
);
325 for (String itemLabel
: statusDisplayInComboSelectionCombo
.getItems()) {
326 if (itemLabel
.startsWith(Messages
.Preference_Use_Default
) && displayStatusCombo
== null){
327 statusDisplayInComboSelectionCombo
.select(index
);
330 if (itemLabel
.equals(displayStatusCombo
.getLabel())) {
331 statusDisplayInComboSelectionCombo
.select(index
);
338 statusDisplayInComboSelectionCombo
.addSelectionListener(this);
340 if (isAdminPreference
) {
341 allowOverrideStatusDisplayInComboButton
= createAllowOverrideButton(child
);
342 allowOverrideStatusDisplayInComboButton
.setSelection(prefStatusDisplayInCombo
!= null ? prefStatusDisplayInCombo
.isAllowOverride(): true);
343 //allowOverrideStatusDisplayInComboButton.setEnabled(prefStatusDisplayInCombo != null);
344 allowOverrideStatusDisplayInComboButton
.addSelectionListener(new SelectionAdapter() {
346 public void widgetSelected(SelectionEvent e
) {
348 if (prefStatusDisplayInCombo
== null){
349 prefStatusDisplayInCombo
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.DisplayOfStatusInCombo
, PreferencePredicate
.DisplayOfStatusInCombo
.getDefaultValue() != null ? PreferencePredicate
.DisplayOfStatusInCombo
.getDefaultValue().toString(): null);
351 prefStatusDisplayInCombo
.setAllowOverride(allowOverrideStatusDisplayInComboButton
.getSelection());
356 statusSortSelectionCombo
= createCombo(child
, TermOrder
.values(), PreferencePredicate
.StatusSortedInDistributionEditor
, Messages
.ChecklistEditorGeneralPreference_Configure_status_order
, isAdminPreference
);
360 for (String itemLabel
: statusSortSelectionCombo
.getItems()) {
361 if (itemLabel
.startsWith(Messages
.Preference_Use_Default
) && orderStatus
== null){
362 statusSortSelectionCombo
.select(index
);
365 if (itemLabel
.equals(orderStatus
.getLabel())) {
366 statusSortSelectionCombo
.select(index
);
373 statusSortSelectionCombo
.addSelectionListener(this);
375 if (isAdminPreference
) {
376 allowOverrideStatusSortButton
= createAllowOverrideButton(child
);
377 allowOverrideStatusSortButton
.setSelection(prefStatusSort
!= null? prefStatusSort
.isAllowOverride(): true);
378 allowOverrideStatusSortButton
.addSelectionListener(new SelectionAdapter() {
380 public void widgetSelected(SelectionEvent e
) {
382 if (prefStatusSort
== null){
383 prefStatusSort
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.StatusSortedInDistributionEditor
, PreferencePredicate
.StatusSortedInDistributionEditor
.getDefaultValue() != null ? PreferencePredicate
.StatusSortedInDistributionEditor
.getDefaultValue().toString(): null);
385 prefStatusSort
.setAllowOverride(allowOverrideStatusSortButton
.getSelection());
392 final CLabel description
= new CLabel(child
, SWT
.NULL
);
393 description
.setText(Messages
.ChecklistEditorGeneralPreference_numberOfStatus
);
394 GridData numberOfStatusGrid
= createTextGridData();
395 // numberOfStatusGrid.verticalSpan = 1;
396 description
.setLayoutData(numberOfStatusGrid
);
397 description
.setToolTipText(Messages
.ChecklistEditorGeneralPreference_tooltip_numberOfStatus
);
399 numberOfStatusText
= new Text(child
, SWT
.BORDER
);
400 // numberOfStatusText.setSize(30, numberOfStatusText.getSize().y);
401 numberOfStatusText
.setLayoutData(new GridData(20,15));
403 if (numberOfStatus
!= null){
404 numberOfStatusText
.setText(this.numberOfStatus
.toString());
406 numberOfStatusText
.setText(PreferencePredicate
.NumberOfVisibleStatusInDropDown
.getDefaultValue().toString());
409 numberOfStatusText
.addModifyListener(new ModifyListener() {
412 public void modifyText(ModifyEvent e
) {
414 String text
= numberOfStatusText
.getText();
416 Integer tempNumber
= Integer
.valueOf(text
);
418 throw new NumberFormatException();
420 numberOfStatus
= tempNumber
;
421 numberFormatExceptionLabel
.setVisible(false);
422 numberOfStatusText
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
423 }catch(NumberFormatException ex
){
424 numberOfStatusText
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_RED
));
425 numberFormatExceptionLabel
.setVisible(true);
426 numberFormatExceptionLabel
.setText(Messages
.ChecklistEditorGeneralPreference_numberFormatExceptionLabel
);
433 if (isAdminPreference
) {
434 allowOverrideNumberOfStatusButton
= createAllowOverrideButton(child
);
435 allowOverrideNumberOfStatusButton
.setSelection(this.prefNumberStatus
!= null?
this.prefNumberStatus
.isAllowOverride(): true);
436 allowOverrideNumberOfStatusButton
.addSelectionListener(new SelectionAdapter() {
438 public void widgetSelected(SelectionEvent e
) {
440 if (prefNumberStatus
== null){
441 prefNumberStatus
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.NumberOfVisibleStatusInDropDown
, PreferencePredicate
.NumberOfVisibleStatusInDropDown
.getDefaultValue() != null ? PreferencePredicate
.NumberOfVisibleStatusInDropDown
.getDefaultValue().toString(): null);
443 prefNumberStatus
.setAllowOverride(!prefNumberStatus
.isAllowOverride());
448 numberFormatExceptionLabel
= new Label(child
, SWT
.NULL
);
449 numberFormatExceptionLabel
.setForeground(Display
.getCurrent().getSystemColor(SWT
.COLOR_RED
));
450 numberFormatExceptionLabel
.setVisible(false);
451 description
.setText(Messages
.ChecklistEditorGeneralPreference_numberOfStatus
);
452 GridData numberOfStatusExceptionGrid
= createTextGridData();
453 // numberOfStatusGrid.verticalSpan = 1;
454 numberFormatExceptionLabel
.setLayoutData(numberOfStatusExceptionGrid
);
455 numberFormatExceptionLabel
.setText(Messages
.ChecklistEditorGeneralPreference_numberFormatExceptionLabel
);
456 if (!isAdminPreference
) {
458 if (distributionEditorPref
!= null && !distributionEditorPref
.isAllowOverride()){
459 activateComp
.setEnabled(false);
463 if (prefRank
!= null && !prefRank
.isAllowOverride()) {
464 activateRankCombo
.setEnabled(false);
466 if (prefAreaSort
!= null && !prefAreaSort
.isAllowOverride()) {
467 areaOrderSelectionCombo
.setEnabled(false);
469 if (prefAreaDisplay
!= null && !prefAreaDisplay
.isAllowOverride()) {
470 areaDisplaySelectionCombo
.setEnabled(false);
472 if (prefStatusDisplay
!= null && !prefStatusDisplay
.isAllowOverride()) {
473 statusDisplaySelectionCombo
.setEnabled(false);
475 if (prefStatusSort
!= null && !prefStatusSort
.isAllowOverride()) {
476 statusSortSelectionCombo
.setEnabled(false);
478 if (prefStatusDisplayInCombo
!= null && !prefStatusDisplayInCombo
.isAllowOverride()) {
479 statusDisplayInComboSelectionCombo
.setEnabled(false);
481 if (prefNumberStatus
!= null && !prefNumberStatus
.isAllowOverride()){
482 numberOfStatusText
.setEnabled(false);
492 public boolean performOk() {
496 boolean override
= false;
497 if (isEditorActivated
!= null ) {
499 PreferencesUtil
.setStringValue(PreferencePredicate
.DistributionEditorActivated
.getKey(), isEditorActivated
.toString());
501 PreferencesUtil
.setBooleanValue(
502 PreferencesUtil
.prefOverrideKey(PreferencePredicate
.DistributionEditorActivated
.getKey()),
507 if (orderAreas
!= null ) {
509 PreferencesUtil
.setSortNamedAreasInDistributionEditor(orderAreas
.getKey());
511 PreferencesUtil
.setBooleanValue(
512 PreferencesUtil
.prefOverrideKey(PreferencePredicate
.AreasSortedInDistributionEditor
.getKey()),
516 if (isShowRank
!= null ) {
518 PreferencesUtil
.setShowRankInChecklistEditor(isShowRank
);
520 PreferencesUtil
.setBooleanValue(
521 PreferencesUtil
.prefOverrideKey(PreferencePredicate
.ShowRankInDistributionEditor
.getKey()),
526 if (displayStatus
!= null) {
528 PreferencesUtil
.setDisplayStatusInChecklistEditor(displayStatus
.getKey());
530 PreferencesUtil
.setBooleanValue(
531 PreferencesUtil
.prefOverrideKey(PreferencePredicate
.DisplayOfStatus
.getKey()),
535 if (displayStatusCombo
!= null) {
537 PreferencesUtil
.setStringValue(PreferencePredicate
.DisplayOfStatusInCombo
.getKey(), displayStatusCombo
.getKey());
539 PreferencesUtil
.setBooleanValue(
540 PreferencesUtil
.prefOverrideKey(PreferencePredicate
.DisplayOfStatusInCombo
.getKey()),
546 if (displayArea
!= null) {
548 PreferencesUtil
.setAreaDisplayInChecklistEditor(displayArea
.getKey());
550 PreferencesUtil
.setBooleanValue(PreferencesUtil
.prefOverrideKey(
551 PreferencePredicate
.DisplayOfAreasInDistributionEditor
.getKey()), override
);
554 PreferencesUtil
.firePreferencesChanged(this.getClass());
557 if (orderStatus
!= null) {
559 PreferencesUtil
.setStringValue(PreferencePredicate
.StatusSortedInDistributionEditor
.getKey(), orderStatus
.getKey());
561 PreferencesUtil
.setBooleanValue(
562 PreferencesUtil
.prefOverrideKey(PreferencePredicate
.StatusSortedInDistributionEditor
.getKey()),
566 if (numberOfStatus
!= null) {
568 PreferencesUtil
.setIntValue(PreferencePredicate
.NumberOfVisibleStatusInDropDown
.getKey(), numberOfStatus
);
570 PreferencesUtil
.setBooleanValue(PreferencesUtil
.prefOverrideKey(
571 PreferencePredicate
.NumberOfVisibleStatusInDropDown
.getKey()), override
);
574 PreferencesUtil
.firePreferencesChanged(this.getClass());
583 public void widgetSelected(SelectionEvent e
) {
585 if (e
.getSource().equals(statusDisplaySelectionCombo
)) {
586 String text
= statusDisplaySelectionCombo
.getText();
587 if(text
.startsWith(Messages
.Preference_Use_Default
)){
588 displayStatus
= null;
592 for (TermDisplayEnum display
: TermDisplayEnum
.values()) {
593 if (text
.startsWith(display
.getLabel())) {
594 displayStatus
= display
;
600 if (e
.getSource().equals(statusDisplayInComboSelectionCombo
)) {
601 String text
= statusDisplayInComboSelectionCombo
.getText();
602 if(text
.startsWith(Messages
.Preference_Use_Default
)){
603 displayStatusCombo
= null;
607 for (TermComboEnum display
: TermComboEnum
.values()) {
608 if (text
.startsWith(display
.getLabel())) {
609 displayStatusCombo
= display
;
615 if (e
.getSource().equals(areaDisplaySelectionCombo
)) {
616 String text
= areaDisplaySelectionCombo
.getText();
617 if(text
.startsWith(Messages
.Preference_Use_Default
)){
622 for (TermDisplayEnum display
: TermDisplayEnum
.values()) {
623 if (text
.startsWith(display
.getLabel())) {
624 displayArea
= display
;
629 if (e
.getSource().equals(areaOrderSelectionCombo
)) {
630 String text
= areaOrderSelectionCombo
.getText();
631 if(text
.startsWith(Messages
.Preference_Use_Default
)){
636 for (TermOrder display
: TermOrder
.values()) {
637 if (text
.startsWith(display
.getLabel())) {
638 orderAreas
= display
;
644 if (e
.getSource().equals(statusSortSelectionCombo
)) {
645 String text
= statusSortSelectionCombo
.getText();
646 if(text
.startsWith(Messages
.Preference_Use_Default
)){
651 for (TermOrder display
: TermOrder
.values()) {
652 if (text
.startsWith(display
.getLabel())) {
653 orderStatus
= display
;
658 if (e
.getSource().equals(this.activateRankCombo
)) {
659 String text
= activateRankCombo
.getText();
660 if(text
.startsWith(Messages
.Preference_Use_Default
)){
665 if (text
.equals(SHOW_RANK
)){
673 if (e
.getSource().equals(this.activateCombo
)) {
674 String text
= activateCombo
.getText();
675 if(text
.startsWith(Messages
.Preference_Use_Default
)){
676 isEditorActivated
= null;
677 if (!isAdminPreference
) {
678 if (isEditorActivated
!= null){
679 child
.setEnabled(isEditorActivated
);
681 child
.setEnabled(distributionEditorPref
.getValue() != null?Boolean
.parseBoolean(distributionEditorPref
.getValue().toString()): true);
687 if (text
.equals(ENABLE
)){
688 isEditorActivated
= true;
690 isEditorActivated
= false;
692 if (!isAdminPreference
) {
693 if (isEditorActivated
!= null){
694 child
.setEnabled(isEditorActivated
);
696 child
.setEnabled(distributionEditorPref
.getValue() != null?Boolean
.parseBoolean(distributionEditorPref
.getValue().toString()): true);
708 public void widgetDefaultSelected(SelectionEvent e
) {
709 // TODO Auto-generated method stub
717 public void getValues() {
718 isAdminPreference
= false;
719 setPreferenceStore(PreferencesUtil
.getPreferenceStore());
720 distributionEditorPref
= PreferencesUtil
.getPreferenceFromDB(PreferencePredicate
.DistributionEditorActivated
);
721 overrideActivated
= PreferencesUtil
.getBooleanValue(
722 PreferencesUtil
.prefOverrideKey(PreferencePredicate
.DistributionEditorActivated
.getKey()), true) != null? PreferencesUtil
.getBooleanValue(
723 PreferencesUtil
.prefOverrideKey(PreferencePredicate
.DistributionEditorActivated
.getKey()), true):false;
725 if (distributionEditorPref
!= null) {
726 if (distributionEditorPref
.isAllowOverride() ) {
727 if (overrideActivated
){
728 isEditorActivated
= PreferencesUtil
.getBooleanValue(PreferencePredicate
.DistributionEditorActivated
.getKey(), true);
732 isEditorActivated
= distributionEditorPref
.getValue() != null? Boolean
.valueOf(distributionEditorPref
.getValue()): null;
736 if(!overrideActivated
){
737 isEditorActivated
= null;
739 isEditorActivated
= PreferencesUtil
.getBooleanValue(PreferencePredicate
.DistributionEditorActivated
.getKey(), true);
741 distributionEditorPref
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.DistributionEditorActivated
, PreferencePredicate
.DistributionEditorActivated
.getDefaultValue() != null ? PreferencePredicate
.DistributionEditorActivated
.getDefaultValue().toString(): null);
747 prefAreaDisplay
= PreferencesUtil
.getPreferenceFromDB(PreferencePredicate
.DisplayOfAreasInDistributionEditor
);
748 overrideAreaDisplay
= PreferencesUtil
.getBooleanValue(
749 PreferencesUtil
.prefOverrideKey(PreferencePredicate
.DisplayOfAreasInDistributionEditor
.getKey()), true) != null? PreferencesUtil
.getBooleanValue(
750 PreferencesUtil
.prefOverrideKey(PreferencePredicate
.DisplayOfAreasInDistributionEditor
.getKey()), true): false;
752 if (prefAreaDisplay
!= null) {
753 if (prefAreaDisplay
.isAllowOverride()){
754 if (overrideActivated
) {
755 displayArea
= PreferencesUtil
.displayAreaInChecklistEditor();
760 displayArea
= prefAreaDisplay
.getValue() != null? TermDisplayEnum
.byKey(prefAreaDisplay
.getValue()): null;
763 if (overrideAreaDisplay
){
764 displayArea
= PreferencesUtil
.displayAreaInChecklistEditor();
768 //prefAreaDisplay = CdmPreference.NewTaxEditorInstance(PreferencePredicate.DisplayOfAreasInDistributionEditor, PreferencePredicate.DisplayOfAreasInDistributionEditor.getDefaultValue() != null ? PreferencePredicate.DisplayOfAreasInDistributionEditor.getDefaultValue().toString(): null);
771 prefStatusDisplay
= PreferencesUtil
.getPreferenceFromDB(PreferencePredicate
.DisplayOfStatus
);
772 overrideStatusDisplay
= PreferencesUtil
773 .getBooleanValue(PreferencesUtil
.prefOverrideKey(PreferencePredicate
.DisplayOfStatus
.getKey()), true) != null? PreferencesUtil
774 .getBooleanValue(PreferencesUtil
.prefOverrideKey(PreferencePredicate
.DisplayOfStatus
.getKey()), true): false;
775 if (prefStatusDisplay
!= null) {
776 if (prefStatusDisplay
.isAllowOverride()){
777 if (overrideStatusDisplay
) {
778 displayStatus
= PreferencesUtil
.displayStatusInChecklistEditor();
780 displayStatus
= null;
783 this.displayStatus
= prefStatusDisplay
.getValue() != null? TermDisplayEnum
.byKey(prefStatusDisplay
.getValue()): null;
786 if (overrideStatusDisplay
){
787 displayStatus
= PreferencesUtil
.displayStatusInChecklistEditor();
789 displayStatus
= null;
791 //prefStatusDisplay = CdmPreference.NewTaxEditorInstance(PreferencePredicate.DisplayOfStatus, PreferencePredicate.DisplayOfStatus.getDefaultValue() != null ? PreferencePredicate.DisplayOfStatus.getDefaultValue().toString(): null);
794 prefStatusDisplayInCombo
= PreferencesUtil
.getPreferenceFromDB(PreferencePredicate
.DisplayOfStatusInCombo
);
795 overrideStatusDisplayCombo
= PreferencesUtil
796 .getBooleanValue(PreferencesUtil
.prefOverrideKey(PreferencePredicate
.DisplayOfStatusInCombo
.getKey()), true) != null? PreferencesUtil
797 .getBooleanValue(PreferencesUtil
.prefOverrideKey(PreferencePredicate
.DisplayOfStatusInCombo
.getKey()), true): false;
798 if (prefStatusDisplayInCombo
!= null) {
799 if (prefStatusDisplayInCombo
.isAllowOverride()){
800 if (overrideStatusDisplayCombo
) {
801 displayStatusCombo
= TermComboEnum
.byKey(PreferencesUtil
.getStringValue(PreferencePredicate
.DisplayOfStatusInCombo
.getKey()));
803 displayStatusCombo
= null;
806 this.displayStatusCombo
= prefStatusDisplayInCombo
.getValue() != null? TermComboEnum
.byKey(prefStatusDisplayInCombo
.getValue()): null;
809 if (overrideStatusDisplayCombo
){
810 displayStatusCombo
= TermComboEnum
.byKey(PreferencesUtil
.getStringValue(PreferencePredicate
.DisplayOfStatusInCombo
.getKey()));
812 displayStatusCombo
= null;
818 prefAreaSort
= PreferencesUtil
.getPreferenceFromDB(PreferencePredicate
.AreasSortedInDistributionEditor
);
819 overrideOrderAreas
= PreferencesUtil
.getBooleanValue(
820 PreferencesUtil
.prefOverrideKey(PreferencePredicate
.AreasSortedInDistributionEditor
.getKey()), true) != null? PreferencesUtil
.getBooleanValue(
821 PreferencesUtil
.prefOverrideKey(PreferencePredicate
.AreasSortedInDistributionEditor
.getKey()), true): false;
822 if (prefAreaSort
!= null) {
823 if (prefAreaSort
.isAllowOverride()){
824 if(overrideOrderAreas
) {
825 orderAreas
= PreferencesUtil
.getSortNamedAreasInDistributionEditor();
830 if (prefAreaSort
.getValue() != null) {
831 orderAreas
= prefAreaSort
.getValue() != null? TermOrder
.valueOf(prefAreaSort
.getValue().toString()): null;
833 orderAreas
= ((TermOrder
) PreferencePredicate
.AreasSortedInDistributionEditor
.getDefaultValue());
838 if (overrideOrderAreas
){
839 orderAreas
= PreferencesUtil
.getSortNamedAreasInDistributionEditor();
843 //prefAreaSort = CdmPreference.NewTaxEditorInstance(PreferencePredicate.AreasSortedInDistributionEditor, PreferencePredicate.AreasSortedInDistributionEditor.getDefaultValue() != null ? PreferencePredicate.AreasSortedInDistributionEditor.getDefaultValue().toString(): null);
846 prefStatusSort
= PreferencesUtil
.getPreferenceFromDB(PreferencePredicate
.StatusSortedInDistributionEditor
);
847 overrideOrderStatus
= PreferencesUtil
.getBooleanValue(
848 PreferencesUtil
.prefOverrideKey(PreferencePredicate
.StatusSortedInDistributionEditor
.getKey()), true) != null? PreferencesUtil
.getBooleanValue(
849 PreferencesUtil
.prefOverrideKey(PreferencePredicate
.StatusSortedInDistributionEditor
.getKey()), true): false;
850 if (prefStatusSort
!= null) {
851 if (prefStatusSort
.isAllowOverride()){
852 if(overrideOrderStatus
) {
853 orderStatus
= TermOrder
.valueOf(PreferencesUtil
.getStringValue(PreferencePredicate
.StatusSortedInDistributionEditor
.getKey()));
858 if (prefStatusSort
.getValue() != null) {
859 orderStatus
= prefStatusSort
.getValue() != null? TermOrder
.valueOf(prefStatusSort
.getValue().toString()): null;
861 orderStatus
= ((TermOrder
) PreferencePredicate
.StatusSortedInDistributionEditor
.getDefaultValue());
866 if (overrideOrderStatus
){
867 orderStatus
= TermOrder
.valueOf(PreferencesUtil
.getStringValue(PreferencePredicate
.StatusSortedInDistributionEditor
.getKey()));
871 //prefAreaSort = CdmPreference.NewTaxEditorInstance(PreferencePredicate.AreasSortedInDistributionEditor, PreferencePredicate.AreasSortedInDistributionEditor.getDefaultValue() != null ? PreferencePredicate.AreasSortedInDistributionEditor.getDefaultValue().toString(): null);
874 prefRank
= PreferencesUtil
.getPreferenceFromDB(PreferencePredicate
.ShowRankInDistributionEditor
);
875 overrideRank
= PreferencesUtil
.getBooleanValue(
876 PreferencesUtil
.prefOverrideKey(PreferencePredicate
.ShowRankInDistributionEditor
.getKey()), true) != null? PreferencesUtil
.getBooleanValue(
877 PreferencesUtil
.prefOverrideKey(PreferencePredicate
.ShowRankInDistributionEditor
.getKey()), true): false;
878 if (prefRank
!= null) {
879 if (prefRank
.isAllowOverride()){
881 isShowRank
= PreferencesUtil
.isShowRankInChecklistEditor();
885 this.isShowRank
= prefRank
.getValue() != null? Boolean
.valueOf(prefRank
.getValue().toString()): null;
889 isShowRank
= PreferencesUtil
.isShowRankInChecklistEditor();
896 prefNumberStatus
= PreferencesUtil
.getPreferenceFromDB(PreferencePredicate
.NumberOfVisibleStatusInDropDown
);
897 overrideNumberOfStatus
= PreferencesUtil
.getBooleanValue(
898 PreferencesUtil
.prefOverrideKey(PreferencePredicate
.NumberOfVisibleStatusInDropDown
.getKey()), true) != null? PreferencesUtil
.getBooleanValue(
899 PreferencesUtil
.prefOverrideKey(PreferencePredicate
.NumberOfVisibleStatusInDropDown
.getKey()), true): false;
900 if (prefNumberStatus
!= null) {
901 if (prefNumberStatus
.isAllowOverride()){
902 if(overrideNumberOfStatus
) {
903 numberOfStatus
= PreferencesUtil
.getIntValue(PreferencePredicate
.NumberOfVisibleStatusInDropDown
.getKey(), true);
907 this.numberOfStatus
= prefNumberStatus
.getValue() != null? Integer
.valueOf(prefNumberStatus
.getValue().toString()): null;
910 if (overrideNumberOfStatus
){
911 numberOfStatus
= PreferencesUtil
.getIntValue(PreferencePredicate
.NumberOfVisibleStatusInDropDown
.getKey(), true);
913 numberOfStatus
= null;
918 prefOwnDescription
= PreferencesUtil
919 .getPreferenceFromDB(PreferencePredicate
.OwnDescriptionForDistributionEditor
);
920 if (prefOwnDescription
!= null) {
921 if (prefOwnDescription
.isAllowOverride()) {
922 ownDescriptionForDistributionEditor
= PreferencesUtil
.isOwnDescriptionForChecklistEditor();
924 ownDescriptionForDistributionEditor
= prefOwnDescription
.getValue() != null? Boolean
.valueOf(prefOwnDescription
.getValue().toString()): null;
927 ownDescriptionForDistributionEditor
= PreferencesUtil
.isShowRankInChecklistEditor();
928 // allowOverrideOwnDescriptionForDistributionEditor = true;
929 overrideOwnDescriptionForDistributionEditor
= PreferencesUtil
.getBooleanValue(
930 PreferencesUtil
.prefOverrideKey(PreferencePredicate
.OwnDescriptionForDistributionEditor
.getKey()), true) != null? PreferencesUtil
.getBooleanValue(
931 PreferencesUtil
.prefOverrideKey(PreferencePredicate
.OwnDescriptionForDistributionEditor
.getKey()), true): false;
932 //prefOwnDescription = CdmPreference.NewTaxEditorInstance(PreferencePredicate.OwnDescriptionForDistributionEditor, PreferencePredicate.OwnDescriptionForDistributionEditor.getDefaultValue() != null ? PreferencePredicate.OwnDescriptionForDistributionEditor.getDefaultValue().toString(): null);
939 protected void performDefaults() {
942 isEditorActivated
= null;
943 activateCombo
.select(0);
949 for (String itemLabel
: areaDisplaySelectionCombo
.getItems()) {
950 if (itemLabel
.startsWith(Messages
.Preference_Use_Default
)) {
951 areaDisplaySelectionCombo
.select(index
);
957 displayStatus
= null;
962 for (String itemLabel
: statusDisplaySelectionCombo
.getItems()) {
963 if (itemLabel
.startsWith(Messages
.Preference_Use_Default
)) {
964 statusDisplaySelectionCombo
.select(index
);
974 for (String itemLabel
: areaOrderSelectionCombo
.getItems()) {
975 if (itemLabel
.startsWith(Messages
.Preference_Use_Default
)) {
976 areaOrderSelectionCombo
.select(index
);
985 for (String itemLabel
: statusSortSelectionCombo
.getItems()) {
986 if (itemLabel
.startsWith(Messages
.Preference_Use_Default
)) {
987 statusSortSelectionCombo
.select(index
);
996 for (String itemLabel
: activateRankCombo
.getItems()) {
997 if (itemLabel
.startsWith(Messages
.Preference_Use_Default
)) {
998 activateRankCombo
.select(index
);
1004 displayStatusCombo
= null;
1006 for (String itemLabel
: statusDisplayInComboSelectionCombo
.getItems()) {
1007 if (itemLabel
.startsWith(Messages
.Preference_Use_Default
)) {
1008 statusDisplayInComboSelectionCombo
.select(index
);
1014 ownDescriptionForDistributionEditor
= null;
1015 if (prefNumberStatus
== null){
1016 numberOfStatusText
.setText(PreferencePredicate
.NumberOfVisibleStatusInDropDown
.getDefaultValue().toString());
1018 numberOfStatusText
.setText(prefNumberStatus
.getValue().toString());
1020 numberOfStatus
= null;
1021 if (prefNumberStatus
!= null && !prefNumberStatus
.isAllowOverride() && !isAdminPreference
){
1022 numberOfStatusText
.setEnabled(false);
1025 if (isAdminPreference
){
1026 allowOverrideActivatedButton
.setSelection(true);
1027 allowOverrideAreaDisplayButton
.setSelection(true);
1028 allowOverrideStatusDisplayButton
.setSelection(true);
1029 allowOverrideOrderAreasButton
.setSelection(true);
1030 allowOverrideRankButton
.setSelection(true);
1031 allowOverrideNumberOfStatusButton
.setSelection(true);
1033 overrideActivated
= true;
1034 overrideAreaDisplay
= true;
1035 overrideStatusDisplay
= true;
1036 overrideOrderAreas
= true;
1037 overrideRank
= true;
1038 overrideOwnDescriptionForDistributionEditor
= true;
1039 overrideNumberOfStatus
= true;
1041 if (!isAdminPreference
) {
1042 // PreferencesUtil.recursiveSetEnabled(child, Boolean.parseBoolean(distributionEditorPref.getValue()));
1043 // if (!prefRank.isAllowOverride()) {
1044 // activateRankCombo.setEnabled(false);
1046 // if (!prefAreaSort.isAllowOverride()) {
1047 // areaOrderSelectionCombo.setEnabled(false);
1049 // if (!prefAreaDisplay.isAllowOverride()) {
1050 // allowOverrideAreaDisplayButton.setEnabled(false);
1052 // if (!prefStatusDisplay.isAllowOverride()) {
1053 // allowOverrideStatusDisplayButton.setEnabled(false);
1056 super.performDefaults();