- combo dropdowns intitially show an empty field which is now removed when selecting...
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / vocabulary / FeatureDetailElement.java
index 78c0d19c31626d93f19c08524342789c939f0a5f..9e254f723a4b9a4283e2579002a3e9909a35fb54 100644 (file)
@@ -9,10 +9,13 @@
 */\r
 package eu.etaxonomy.taxeditor.ui.section.vocabulary;\r
 \r
+import org.eclipse.ui.forms.widgets.ExpandableComposite;\r
+\r
 import eu.etaxonomy.cdm.model.description.Feature;\r
-import eu.etaxonomy.taxeditor.ui.campanula.compatibility.ICdmFormElement;\r
 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;\r
 import eu.etaxonomy.taxeditor.ui.element.CheckboxElement;\r
+import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;\r
+import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;\r
 \r
 /**\r
  * @author l.morris\r
@@ -21,6 +24,8 @@ import eu.etaxonomy.taxeditor.ui.element.CheckboxElement;
  */\r
 public class FeatureDetailElement extends DefinedTermDetailElement<Feature> {\r
 \r
+    private ICdmFormElement parentFormElement;\r
+\r
     private CheckboxElement supportsTextData;\r
 \r
     private CheckboxElement supportsQuantitativeData;\r
@@ -35,6 +40,14 @@ public class FeatureDetailElement extends DefinedTermDetailElement<Feature> {
 \r
     private CheckboxElement supportsCommonTaxonName;\r
 \r
+    private StateVocabularyCollectionSection sectionStateVocabularies;\r
+\r
+    private MeasurementUnitCollectionSection sectionMeasurementUnits;\r
+\r
+    private StatisticalMeasureCollectionSection sectionStatisticalMeasures;\r
+\r
+    private RecommendedModifierVocabulariesCollectionSection sectionModifierVocabularies;\r
+\r
     /**\r
         * @param formFactory\r
         * @param formElement\r
@@ -50,14 +63,41 @@ public class FeatureDetailElement extends DefinedTermDetailElement<Feature> {
        @Override\r
        protected void createControls(ICdmFormElement formElement, Feature entity, int style) {\r
            super.createControls(formElement, entity, style);\r
+           this.parentFormElement = formElement;\r
            supportsTextData = formFactory.createCheckbox(formElement, "Supports Text Data", entity.isSupportsTextData(), style);\r
-           supportsQuantitativeData = formFactory.createCheckbox(formElement, "Supports Quantitive Data", entity.isSupportsQuantitativeData(), style);\r
+           supportsQuantitativeData = formFactory.createCheckbox(formElement, "Supports Quantitative Data", entity.isSupportsQuantitativeData(), style);\r
            supportsDistribution = formFactory.createCheckbox(formElement, "Supports Distribution", entity.isSupportsDistribution(), style);\r
            supportsIndividualAssociation = formFactory.createCheckbox(formElement, "Supports Individual Association", entity.isSupportsIndividualAssociation(), style);\r
            supportsTaxonInteraction = formFactory.createCheckbox(formElement, "Supports Taxon Interaction", entity.isSupportsTaxonInteraction(), style);\r
            supportsCategoricalData = formFactory.createCheckbox(formElement, "Supports Categorical Data", entity.isSupportsCategoricalData(), style);\r
            supportsCommonTaxonName = formFactory.createCheckbox(formElement, "Supports Common Taxon Name", entity.isSupportsCommonTaxonName(), style);\r
-       }\r
+\r
+        if (supportsCategoricalData.getSelection()) {\r
+            sectionStateVocabularies = formFactory.createStateVocabulariesSection(getConversationHolder(),\r
+                    parentFormElement, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);\r
+            sectionStateVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));\r
+            sectionStateVocabularies.setEntity(getEntity());\r
+\r
+        }\r
+        if (supportsQuantitativeData.getSelection()) {\r
+            sectionMeasurementUnits = formFactory.createMeasurementUnitCollectionSection(getConversationHolder(),\r
+                    parentFormElement, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);\r
+            sectionMeasurementUnits.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));\r
+            sectionMeasurementUnits.setEntity(getEntity());\r
+\r
+            sectionStatisticalMeasures = formFactory.createStatisticalMeasureCollectionSection(getConversationHolder(),\r
+                    parentFormElement, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);\r
+            sectionStatisticalMeasures.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));\r
+            sectionStatisticalMeasures.setEntity(getEntity());\r
+        }\r
+        if (supportsCategoricalData.getSelection() || supportsQuantitativeData.getSelection()) {\r
+            sectionModifierVocabularies = formFactory.createRecommendedModifierVocabulariesCollectionSection(\r
+                    getConversationHolder(), parentFormElement, ExpandableComposite.TWISTIE\r
+                            | ExpandableComposite.EXPANDED);\r
+            sectionModifierVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));\r
+            sectionModifierVocabularies.setEntity(getEntity());\r
+        }\r
+    }\r
 \r
        /* (non-Javadoc)\r
         * @see eu.etaxonomy.taxeditor.ui.section.vocabulary.DefinedTermDetailElement#handleEvent(java.lang.Object)\r
@@ -70,6 +110,34 @@ public class FeatureDetailElement extends DefinedTermDetailElement<Feature> {
            }\r
            else if(eventSource == supportsQuantitativeData){\r
                getEntity().setSupportsQuantitativeData(supportsQuantitativeData.getSelection());\r
+               if(supportsQuantitativeData.getSelection()){\r
+                removeElementsAndControls(supportsDistribution);\r
+                sectionMeasurementUnits = formFactory.createMeasurementUnitCollectionSection(getConversationHolder(),\r
+                        parentFormElement, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);\r
+                sectionMeasurementUnits.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));\r
+                sectionMeasurementUnits.setEntity(getEntity());\r
+\r
+                sectionStatisticalMeasures = formFactory.createStatisticalMeasureCollectionSection(\r
+                        getConversationHolder(), parentFormElement, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);\r
+                sectionStatisticalMeasures.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));\r
+                sectionStatisticalMeasures.setEntity(getEntity());\r
+\r
+                if (!supportsCategoricalData.getSelection()) {\r
+                    sectionModifierVocabularies = formFactory.createRecommendedModifierVocabulariesCollectionSection(\r
+                            getConversationHolder(), parentFormElement, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);\r
+                    sectionModifierVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));\r
+                    sectionModifierVocabularies.setEntity(getEntity());\r
+                }\r
+               }\r
+               else{\r
+                   if(sectionMeasurementUnits!=null){\r
+                       removeElementsAndControls(sectionMeasurementUnits);\r
+                       removeElementsAndControls(sectionStatisticalMeasures);\r
+                       if(!supportsCategoricalData.getSelection()){\r
+                           removeElementsAndControls(sectionModifierVocabularies);\r
+                       }\r
+                   }\r
+               }\r
            }\r
            else if(eventSource == supportsDistribution){\r
                getEntity().setSupportsDistribution(supportsDistribution.getSelection());\r
@@ -82,6 +150,27 @@ public class FeatureDetailElement extends DefinedTermDetailElement<Feature> {
            }\r
            else if(eventSource == supportsCategoricalData){\r
                getEntity().setSupportsCategoricalData(supportsCategoricalData.getSelection());\r
+            if (supportsCategoricalData.getSelection()) {\r
+                sectionStateVocabularies = formFactory.createStateVocabulariesSection(getConversationHolder(),\r
+                        parentFormElement, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);\r
+                sectionStateVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));\r
+                sectionStateVocabularies.setEntity(getEntity());\r
+\r
+                if (!supportsQuantitativeData.getSelection()) {\r
+                    sectionModifierVocabularies = formFactory.createRecommendedModifierVocabulariesCollectionSection(\r
+                            getConversationHolder(), parentFormElement, ExpandableComposite.TWISTIE| ExpandableComposite.EXPANDED);\r
+                    sectionModifierVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));\r
+                    sectionModifierVocabularies.setEntity(getEntity());\r
+                }\r
+            }\r
+               else{\r
+                   if(sectionStateVocabularies!=null){\r
+                       removeElementsAndControls(sectionStateVocabularies);\r
+                       if(!supportsQuantitativeData.getSelection()){\r
+                           removeElementsAndControls(sectionModifierVocabularies);\r
+                       }\r
+                   }\r
+               }\r
            }\r
            else if(eventSource == supportsCommonTaxonName){\r
                getEntity().setSupportsCommonTaxonName(supportsCommonTaxonName.getSelection());\r