- filtered combo dropdown for modifiers in details view (#4448)
authorPatric Plitzner <p.plitzner@bgbm.org>
Tue, 5 May 2015 09:54:48 +0000 (09:54 +0000)
committerPatric Plitzner <p.plitzner@bgbm.org>
Tue, 5 May 2015 09:54:48 +0000 (09:54 +0000)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/description/ModifierElement.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/description/StatisticalMeasurementValueElement.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/vocabulary/FeatureDetailElement.java

index a213340408c8588c0322f01c6a7eafb8615c3ea5..e5cefa90a8dfeeacfabb1e971033020790f09d2d 100644 (file)
@@ -11,6 +11,7 @@
 package eu.etaxonomy.taxeditor.ui.section.description;
 
 import java.util.ArrayList;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
@@ -20,6 +21,7 @@ import eu.etaxonomy.cdm.model.common.DefinedTerm;
 import eu.etaxonomy.cdm.model.common.TermType;
 import eu.etaxonomy.cdm.model.common.TermVocabulary;
 import eu.etaxonomy.cdm.model.description.StateData;
+import eu.etaxonomy.cdm.model.description.StatisticalMeasurementValue;
 import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
 import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
@@ -58,15 +60,20 @@ public class ModifierElement extends AbstractEntityCollectionElement<DefinedTerm
                this.entity = entity;
                if(getParentElement() instanceof ModifierSection){
                    ModifierSection parentSection = (ModifierSection) getParentElement();
+                   List<DefinedTerm> modifierTerms = new ArrayList<DefinedTerm>();
+            Set<TermVocabulary<DefinedTerm>> recommendedModifierEnumeration = new HashSet<TermVocabulary<DefinedTerm>>();
                    if(parentSection.getEntity() instanceof StateData){
                        StateData stateData = (StateData) parentSection.getEntity();
-                       List<DefinedTerm> modifierTerms = new ArrayList<DefinedTerm>();
-                       Set<TermVocabulary<DefinedTerm>> recommendedModifierEnumeration = stateData.getCategoricalData().getFeature().getRecommendedModifierEnumeration();
-                       for (TermVocabulary<DefinedTerm> termVocabulary : recommendedModifierEnumeration) {
-                           modifierTerms.addAll(termVocabulary.getTerms());
-                       }
-                       combo_modifier.setTerms(modifierTerms);
+                       recommendedModifierEnumeration = stateData.getCategoricalData().getFeature().getRecommendedModifierEnumeration();
                    }
+                   if(parentSection.getEntity() instanceof StatisticalMeasurementValue){
+                       StatisticalMeasurementValue statisticalMeasurementValue = (StatisticalMeasurementValue)parentSection.getEntity();
+                       recommendedModifierEnumeration = statisticalMeasurementValue.getQuantitativeData().getFeature().getRecommendedModifierEnumeration();
+                   }
+                   for (TermVocabulary<DefinedTerm> termVocabulary : recommendedModifierEnumeration) {
+                       modifierTerms.addAll(termVocabulary.getTerms());
+                   }
+                   combo_modifier.setTerms(modifierTerms);
                }
         if(entity.getId()>0){
             combo_modifier.setSelection(entity);
index ed8361ab8004a5eaae5fe6567f6ea089761bc413..921ba50fca997668150532b3e94c1b8e6270afd1 100644 (file)
@@ -10,6 +10,9 @@
 
 package eu.etaxonomy.taxeditor.ui.section.description;
 
+import java.util.ArrayList;
+import java.util.Set;
+
 import org.eclipse.swt.events.SelectionListener;
 import org.eclipse.ui.forms.widgets.ExpandableComposite;
 
@@ -57,8 +60,8 @@ public class StatisticalMeasurementValueElement extends
        @Override
        public void setEntity(StatisticalMeasurementValue entity) {
                this.entity = entity;
-//             List<StatisticalMeasure> statisiticalMeasures = getEntity().getQuantitativeData().getFeature().getRecommendedStatisticalMeasures();
-//        combo_type.setTerms(statisiticalMeasures);
+               Set<StatisticalMeasure> statisiticalMeasures = getEntity().getQuantitativeData().getFeature().getRecommendedStatisticalMeasures();
+        combo_type.setTerms(new ArrayList<StatisticalMeasure>(statisiticalMeasures));
                combo_type.setSelection(entity.getType());
                number_value.setNumber(entity.getValue());
                section_modifiers.setEntity(entity);
index 5bbd72f7fd7b390df49d7462bc480946bbbe2c6a..9bd5d82829f65a3566c10655ab6a39589f067f22 100644 (file)
@@ -65,7 +65,7 @@ public class FeatureDetailElement extends DefinedTermDetailElement<Feature> {
            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
@@ -77,9 +77,6 @@ public class FeatureDetailElement extends DefinedTermDetailElement<Feature> {
             sectionStateVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));\r
             sectionStateVocabularies.setEntity(getEntity());\r
 \r
-            sectionStateModifiers = formFactory.createStateModifierCollectionSection(getConversationHolder(), parentFormElement, ExpandableComposite.TWISTIE);\r
-            sectionStateModifiers.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));\r
-            sectionStateModifiers.setEntity(getEntity());\r
         }\r
         if(supportsQuantitativeData.getSelection()){\r
             sectionMeasurementUnits = formFactory.createMeasurementUnitCollectionSection(getConversationHolder(), parentFormElement, ExpandableComposite.TWISTIE);\r
@@ -90,6 +87,11 @@ public class FeatureDetailElement extends DefinedTermDetailElement<Feature> {
             sectionStatisticalMeasures.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));\r
             sectionStatisticalMeasures.setEntity(getEntity());\r
         }\r
+        if(supportsCategoricalData.getSelection() || supportsQuantitativeData.getSelection()){\r
+            sectionStateModifiers = formFactory.createStateModifierCollectionSection(getConversationHolder(), parentFormElement, ExpandableComposite.TWISTIE);\r
+            sectionStateModifiers.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));\r
+            sectionStateModifiers.setEntity(getEntity());\r
+        }\r
        }\r
 \r
        /* (non-Javadoc)\r
@@ -111,11 +113,20 @@ public class FeatureDetailElement extends DefinedTermDetailElement<Feature> {
                    sectionStatisticalMeasures = formFactory.createStatisticalMeasureCollectionSection(getConversationHolder(), parentFormElement, ExpandableComposite.TWISTIE);\r
                    sectionStatisticalMeasures.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));\r
                    sectionStatisticalMeasures.setEntity(getEntity());\r
+\r
+                   if(!supportsCategoricalData.getSelection()){\r
+                       sectionStateModifiers = formFactory.createStateModifierCollectionSection(getConversationHolder(), parentFormElement, ExpandableComposite.TWISTIE);\r
+                       sectionStateModifiers.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));\r
+                       sectionStateModifiers.setEntity(getEntity());\r
+                   }\r
                }\r
                else{\r
                    if(sectionMeasurementUnits!=null){\r
                        removeElementsAndControls(sectionMeasurementUnits);\r
                        removeElementsAndControls(sectionStatisticalMeasures);\r
+                       if(!supportsCategoricalData.getSelection()){\r
+                           removeElementsAndControls(sectionStateModifiers);\r
+                       }\r
                    }\r
                }\r
            }\r
@@ -135,14 +146,18 @@ public class FeatureDetailElement extends DefinedTermDetailElement<Feature> {
                    sectionStateVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));\r
                    sectionStateVocabularies.setEntity(getEntity());\r
 \r
-                   sectionStateModifiers = formFactory.createStateModifierCollectionSection(getConversationHolder(), parentFormElement, ExpandableComposite.TWISTIE);\r
-                   sectionStateModifiers.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));\r
-                   sectionStateModifiers.setEntity(getEntity());\r
+                   if(!supportsQuantitativeData.getSelection()){\r
+                       sectionStateModifiers = formFactory.createStateModifierCollectionSection(getConversationHolder(), parentFormElement, ExpandableComposite.TWISTIE);\r
+                       sectionStateModifiers.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));\r
+                       sectionStateModifiers.setEntity(getEntity());\r
+                   }\r
                }\r
                else{\r
                    if(sectionStateVocabularies!=null){\r
                        removeElementsAndControls(sectionStateVocabularies);\r
-                       removeElementsAndControls(sectionStateModifiers);\r
+                       if(!supportsQuantitativeData.getSelection()){\r
+                           removeElementsAndControls(sectionStateModifiers);\r
+                       }\r
                    }\r
                }\r
            }\r