- combo dropdowns intitially show an empty field which is now removed when selecting...
authorPatric Plitzner <p.plitzner@bgbm.org>
Wed, 27 May 2015 06:54:07 +0000 (06:54 +0000)
committerPatric Plitzner <p.plitzner@bgbm.org>
Wed, 27 May 2015 06:54:07 +0000 (06:54 +0000)
 - added vocabulary information to term label #4448

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/combo/TermComboElement.java
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/StateDataElement.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/description/detail/QuantitativeDataDetailElement.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/vocabulary/FeatureDetailElement.java

index 6f80b90d835853f1e4a67ae7f2ed89467667c51f..c93943155657c8ce6167c6d7e411df4a337f257a 100644 (file)
@@ -4,6 +4,7 @@
 package eu.etaxonomy.taxeditor.ui.combo;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.List;
@@ -281,7 +282,11 @@ public class TermComboElement<T extends DefinedTermBase>
                if (term == null){
                        return "";
                }else{
-                       return term.getLabel(CdmStore.getDefaultLanguage());
+                       String termLabel = term.getLabel(CdmStore.getDefaultLanguage());
+                       if(term.getVocabulary()!=null){
+                           termLabel += " ["+term.getVocabulary().getLabel(CdmStore.getDefaultLanguage())+"]";
+                       }
+            return termLabel;
                }
        }
 
@@ -429,8 +434,12 @@ public class TermComboElement<T extends DefinedTermBase>
 
        public void removeEmptyElement(){
            if(addEmptyElement){
-               terms.remove(emptyElement);
-               combo.remove(EMPTY_ELEMENT_LABEL);
+               if(terms.contains(emptyElement)){
+                   terms.remove(emptyElement);
+               }
+               if(Arrays.asList(combo.getItems()).contains(EMPTY_ELEMENT_LABEL)){
+                   combo.remove(EMPTY_ELEMENT_LABEL);
+               }
            }
        }
 }
index 8b3219d888f034502206e4d8120d2d0713ec1404..f182ca831bd41415e9f39e8aaab596ec3e870a44 100644 (file)
@@ -77,28 +77,37 @@ public class ModifierElement extends AbstractEntityCollectionElement<DefinedTerm
                }
         if(entity.getId()>0){
             combo_modifier.setSelection(entity);
+            combo_modifier.removeEmptyElement();
         }
        }
 
        /** {@inheritDoc} */
        @Override
        public void createControls(ICdmFormElement element, int style) {
-               combo_modifier = formFactory.createDefinedTermComboElement(TermType.Modifier, element, "Modifier", getEntity(), false, style);
+               combo_modifier = formFactory.createDefinedTermComboElement(TermType.Modifier, element, "Modifier", getEntity(), style);
        }
 
        /** {@inheritDoc} */
        @Override
        public void handleEvent(Object eventSource) {
            if(eventSource==combo_modifier && combo_modifier.getSelection()!=null){
-               if(getParentElement() instanceof ModifierSection){
-                   ModifierSection parentSection = (ModifierSection) getParentElement();
-                   if((parentSection).getEntity() instanceof StateData){
+               combo_modifier.removeEmptyElement();
+               if(getParentElement() instanceof AbstractFormSection){
+                   AbstractFormSection<?> parentSection = (AbstractFormSection<?>) getParentElement();
+                   if(parentSection.getEntity() instanceof StateData){
                        StateData stateData = (StateData) parentSection.getEntity();
                        stateData.removeModifier(entity);
                        DefinedTerm term = combo_modifier.getSelection();
                        stateData.addModifier(term);
                        entity = term;
                    }
+                   else if(parentSection.getEntity() instanceof StatisticalMeasurementValue){
+                       StatisticalMeasurementValue parentEntity = (StatisticalMeasurementValue) parentSection.getEntity();
+                       parentEntity.removeModifier(entity);
+                       DefinedTerm term = combo_modifier.getSelection();
+                       parentEntity.addModifier(term);
+                       entity = term;
+                   }
                }
            }
        }
index 1c4752c0e63b89f822b7c7c370fc87472974e5c2..a1b051415875bf5d7a641c7387b0a9e6ef9993ec 100644 (file)
@@ -75,12 +75,15 @@ public class StateDataElement extends AbstractEntityCollectionElement<StateData>
                if(getEntity().getModifyingText().get(CdmStore.getDefaultLanguage()) != null) {
             text_modifyingText.setText(getEntity().getModifyingText().get(CdmStore.getDefaultLanguage()).getText());
         }
+               if(getEntity().getId()>0){
+                   combo_state.removeEmptyElement();
+               }
        }
 
        /** {@inheritDoc} */
        @Override
        public void createControls(ICdmFormElement element, int style) {
-               combo_state = formFactory.createDefinedTermComboElement(TermType.State, element, "State", null, false, style);
+               combo_state = formFactory.createDefinedTermComboElement(TermType.State, element, "State", null, style);
                section_modifiers = formFactory.createModifierSection(getConversationHolder(), element, ExpandableComposite.TWISTIE|ExpandableComposite.EXPANDED);
                section_modifiers.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
                text_modifyingText = formFactory.createTextWithLabelElement(element, "Modifying Text", null, style);
@@ -91,6 +94,7 @@ public class StateDataElement extends AbstractEntityCollectionElement<StateData>
        public void handleEvent(Object eventSource) {
                if(eventSource == combo_state){
                        getEntity().setState(combo_state.getSelection());
+                       combo_state.removeEmptyElement();
                }
                if(eventSource == text_modifyingText){
                        getEntity().putModifyingText(LanguageString.NewInstance(text_modifyingText.getText(), CdmStore.getDefaultLanguage()));
index 921ba50fca997668150532b3e94c1b8e6270afd1..48f02ad77880782246c19913894aa03e1333b5ee 100644 (file)
@@ -90,6 +90,7 @@ public class StatisticalMeasurementValueElement extends
                }
                else if(eventSource == combo_type){
                        getEntity().setType(combo_type.getSelection());
+                       combo_type.removeEmptyElement();
                }
        }
 }
index 0cd3452c522306d7c319de99d321bb1b8a3b36ce..0da2bb3c209f118d01d73293a63d2a9cd3f3cd37 100644 (file)
@@ -58,6 +58,7 @@ public class QuantitativeDataDetailElement extends
        public void handleEvent(Object eventSource) {
                if(eventSource == comboMeasurementUnit){
                        getEntity().setUnit(comboMeasurementUnit.getSelection());
+                       comboMeasurementUnit.removeEmptyElement();
                }else if (eventSource == section_statisticalMeasurementValues){
                        // FIXME
                }
index 0ccf6e48495832ccb9cc8ea7936879e16a992322..9e254f723a4b9a4283e2579002a3e9909a35fb54 100644 (file)
@@ -72,27 +72,32 @@ public class FeatureDetailElement extends DefinedTermDetailElement<Feature> {
            supportsCategoricalData = formFactory.createCheckbox(formElement, "Supports Categorical Data", entity.isSupportsCategoricalData(), style);\r
            supportsCommonTaxonName = formFactory.createCheckbox(formElement, "Supports Common Taxon Name", entity.isSupportsCommonTaxonName(), style);\r
 \r
-        if(supportsCategoricalData.getSelection()){\r
-            sectionStateVocabularies = formFactory.createStateVocabulariesSection(getConversationHolder(), parentFormElement, ExpandableComposite.TWISTIE);\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(), parentFormElement, ExpandableComposite.TWISTIE);\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(), parentFormElement, ExpandableComposite.TWISTIE);\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(getConversationHolder(), parentFormElement, ExpandableComposite.TWISTIE);\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
 \r
        /* (non-Javadoc)\r
         * @see eu.etaxonomy.taxeditor.ui.section.vocabulary.DefinedTermDetailElement#handleEvent(java.lang.Object)\r
@@ -106,19 +111,23 @@ public class FeatureDetailElement extends DefinedTermDetailElement<Feature> {
            else if(eventSource == supportsQuantitativeData){\r
                getEntity().setSupportsQuantitativeData(supportsQuantitativeData.getSelection());\r
                if(supportsQuantitativeData.getSelection()){\r
-                   sectionMeasurementUnits = formFactory.createMeasurementUnitCollectionSection(getConversationHolder(), parentFormElement, ExpandableComposite.TWISTIE);\r
-                   sectionMeasurementUnits.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));\r
-                   sectionMeasurementUnits.setEntity(getEntity());\r
-\r
-                   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
-                       sectionModifierVocabularies = formFactory.createRecommendedModifierVocabulariesCollectionSection(getConversationHolder(), parentFormElement, ExpandableComposite.TWISTIE);\r
-                       sectionModifierVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));\r
-                       sectionModifierVocabularies.setEntity(getEntity());\r
-                   }\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
@@ -141,17 +150,19 @@ 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(), parentFormElement, ExpandableComposite.TWISTIE);\r
-                   sectionStateVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));\r
-                   sectionStateVocabularies.setEntity(getEntity());\r
-\r
-                   if(!supportsQuantitativeData.getSelection()){\r
-                       sectionModifierVocabularies = formFactory.createRecommendedModifierVocabulariesCollectionSection(getConversationHolder(), parentFormElement, ExpandableComposite.TWISTIE);\r
-                       sectionModifierVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));\r
-                       sectionModifierVocabularies.setEntity(getEntity());\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
+                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