4 package eu
.etaxonomy
.taxeditor
.ui
.section
.description
.detail
;
6 import java
.util
.Comparator
;
8 import eu
.etaxonomy
.cdm
.common
.CdmUtils
;
9 import eu
.etaxonomy
.cdm
.model
.description
.CategoricalData
;
10 import eu
.etaxonomy
.cdm
.model
.description
.NoDescriptiveDataStatus
;
11 import eu
.etaxonomy
.taxeditor
.preference
.PreferencesUtil
;
12 import eu
.etaxonomy
.taxeditor
.store
.StoreUtil
;
13 import eu
.etaxonomy
.taxeditor
.ui
.combo
.EnumComboElement
;
14 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
15 import eu
.etaxonomy
.taxeditor
.ui
.element
.CheckboxElement
;
16 import eu
.etaxonomy
.taxeditor
.ui
.element
.ICdmFormElement
;
17 import eu
.etaxonomy
.taxeditor
.ui
.element
.LayoutConstants
;
18 import eu
.etaxonomy
.taxeditor
.ui
.section
.description
.StateDataSection
;
21 * <p>CategoricalDataDetailElement class.</p>
25 public class CategoricalDataDetailElement
extends AbstractDetailedDescriptionDetailElement
<CategoricalData
> {
27 private CheckboxElement checkbox_orderRelevant
;
28 private StateDataSection section_stateData
;
30 private EnumComboElement
<NoDescriptiveDataStatus
> noDataStatusCombo
;
31 private CategoricalData tempData
;
33 * <p>Constructor for CategoricalDataDetailElement.</p>
35 * @param formFactory a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object.
36 * @param formElement a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} object.
37 * @param entity a {@link eu.etaxonomy.cdm.model.description.CategoricalData} object.
40 public CategoricalDataDetailElement(CdmFormFactory formFactory
,
41 ICdmFormElement formElement
, CategoricalData entity
, boolean enabled
, int style
) {
42 super(formFactory
, formElement
, entity
, enabled
, style
);
47 protected void createControls(ICdmFormElement formElement
,
48 CategoricalData entity
, int style
) {
49 Comparator
<NoDescriptiveDataStatus
> comp
= new Comparator
<NoDescriptiveDataStatus
>() {
52 public int compare(NoDescriptiveDataStatus o1
, NoDescriptiveDataStatus o2
) {
53 return o1
.getLabel(PreferencesUtil
.getGlobalLanguage()).compareTo(o2
.getLabel(PreferencesUtil
.getGlobalLanguage()));
56 noDataStatusCombo
= formFactory
.createEnumComboElement(NoDescriptiveDataStatus
.class, formElement
, comp
, style
, true);
57 noDataStatusCombo
.setSelection(entity
.getNoDataStatus());
59 checkbox_orderRelevant
= formFactory
.createCheckbox(formElement
, "Order Relevant", entity
.getOrderRelevant(), style
);
60 section_stateData
= formFactory
.createStateDataSection(formElement
, StoreUtil
.getSectionStyle(StateDataSection
.class, entity
.getClass().getCanonicalName(), true));
61 section_stateData
.setEntity(entity
);
62 section_stateData
.setLayoutData(LayoutConstants
.FILL_HORIZONTALLY(2, 1));
63 section_stateData
.setEnabled(enabled
);
64 createTimePeriod(formElement
, entity
, style
);
65 if (!CdmUtils
.isNullSafeEmpty(entity
.getFeature().getRecommendedModifierEnumeration()) || !CdmUtils
.isNullSafeEmpty(entity
.getModifiers())){
66 createModifier(formElement
, entity
, style
);
68 createFreetextModifier(formElement
, entity
, style
);
73 public void handleEvent(Object eventSource
) {
74 super.handleEvent(eventSource
);
75 if(eventSource
== checkbox_orderRelevant
){
76 getEntity().setOrderRelevant(checkbox_orderRelevant
.getSelection());
77 } else if (eventSource
== noDataStatusCombo
) {
78 getEntity().setNoDataStatus(noDataStatusCombo
.getSelection());
79 if (noDataStatusCombo
.getSelection() != null) {
80 this.setEnabled(false);
81 if (!this.getEntity().getStateData().isEmpty()) {
82 tempData
= this.getEntity().clone();
84 this.getEntity().getStateData().clear();
86 if (tempData
!= null) {
87 this.getEntity().getStateData().addAll(tempData
.getStateData());
89 this.setEnabled(true);
91 noDataStatusCombo
.setEnabled(true);
96 public void fillFields() {
97 if (getEntity()!= null) {
99 checkbox_orderRelevant
.setEnabled(getEntity().getOrderRelevant());
100 section_stateData
.setEntity(getEntity());
101 noDataStatusCombo
.setSelection(getEntity().getNoDataStatus());