From 5a52b8a4b3a588778c747cff6d337f02e94623f6 Mon Sep 17 00:00:00 2001 From: Patric Plitzner Date: Wed, 27 May 2015 06:54:07 +0000 Subject: [PATCH] - combo dropdowns intitially show an empty field which is now removed when selecting any other entry - added vocabulary information to term label #4448 --- .../taxeditor/ui/combo/TermComboElement.java | 15 +++- .../section/description/ModifierElement.java | 17 ++++- .../section/description/StateDataElement.java | 6 +- .../StatisticalMeasurementValueElement.java | 1 + .../detail/QuantitativeDataDetailElement.java | 1 + .../vocabulary/FeatureDetailElement.java | 75 +++++++++++-------- 6 files changed, 75 insertions(+), 40 deletions(-) diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/combo/TermComboElement.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/combo/TermComboElement.java index 6f80b90d8..c93943155 100644 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/combo/TermComboElement.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/combo/TermComboElement.java @@ -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 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 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); + } } } } diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/description/ModifierElement.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/description/ModifierElement.java index 8b3219d88..f182ca831 100644 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/description/ModifierElement.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/description/ModifierElement.java @@ -77,28 +77,37 @@ public class ModifierElement extends AbstractEntityCollectionElement0){ 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; + } } } } diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/description/StateDataElement.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/description/StateDataElement.java index 1c4752c0e..a1b051415 100644 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/description/StateDataElement.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/description/StateDataElement.java @@ -75,12 +75,15 @@ public class StateDataElement extends AbstractEntityCollectionElement 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 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())); diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/description/StatisticalMeasurementValueElement.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/description/StatisticalMeasurementValueElement.java index 921ba50fc..48f02ad77 100644 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/description/StatisticalMeasurementValueElement.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/description/StatisticalMeasurementValueElement.java @@ -90,6 +90,7 @@ public class StatisticalMeasurementValueElement extends } else if(eventSource == combo_type){ getEntity().setType(combo_type.getSelection()); + combo_type.removeEmptyElement(); } } } diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/description/detail/QuantitativeDataDetailElement.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/description/detail/QuantitativeDataDetailElement.java index 0cd3452c5..0da2bb3c2 100644 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/description/detail/QuantitativeDataDetailElement.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/description/detail/QuantitativeDataDetailElement.java @@ -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 } diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/vocabulary/FeatureDetailElement.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/vocabulary/FeatureDetailElement.java index 0ccf6e484..9e254f723 100644 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/vocabulary/FeatureDetailElement.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/vocabulary/FeatureDetailElement.java @@ -72,27 +72,32 @@ public class FeatureDetailElement extends DefinedTermDetailElement { supportsCategoricalData = formFactory.createCheckbox(formElement, "Supports Categorical Data", entity.isSupportsCategoricalData(), style); supportsCommonTaxonName = formFactory.createCheckbox(formElement, "Supports Common Taxon Name", entity.isSupportsCommonTaxonName(), style); - if(supportsCategoricalData.getSelection()){ - sectionStateVocabularies = formFactory.createStateVocabulariesSection(getConversationHolder(), parentFormElement, ExpandableComposite.TWISTIE); + if (supportsCategoricalData.getSelection()) { + sectionStateVocabularies = formFactory.createStateVocabulariesSection(getConversationHolder(), + parentFormElement, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); sectionStateVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1)); sectionStateVocabularies.setEntity(getEntity()); } - if(supportsQuantitativeData.getSelection()){ - sectionMeasurementUnits = formFactory.createMeasurementUnitCollectionSection(getConversationHolder(), parentFormElement, ExpandableComposite.TWISTIE); + if (supportsQuantitativeData.getSelection()) { + sectionMeasurementUnits = formFactory.createMeasurementUnitCollectionSection(getConversationHolder(), + parentFormElement, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); sectionMeasurementUnits.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1)); sectionMeasurementUnits.setEntity(getEntity()); - sectionStatisticalMeasures = formFactory.createStatisticalMeasureCollectionSection(getConversationHolder(), parentFormElement, ExpandableComposite.TWISTIE); + sectionStatisticalMeasures = formFactory.createStatisticalMeasureCollectionSection(getConversationHolder(), + parentFormElement, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); sectionStatisticalMeasures.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1)); sectionStatisticalMeasures.setEntity(getEntity()); } - if(supportsCategoricalData.getSelection() || supportsQuantitativeData.getSelection()){ - sectionModifierVocabularies = formFactory.createRecommendedModifierVocabulariesCollectionSection(getConversationHolder(), parentFormElement, ExpandableComposite.TWISTIE); + if (supportsCategoricalData.getSelection() || supportsQuantitativeData.getSelection()) { + sectionModifierVocabularies = formFactory.createRecommendedModifierVocabulariesCollectionSection( + getConversationHolder(), parentFormElement, ExpandableComposite.TWISTIE + | ExpandableComposite.EXPANDED); sectionModifierVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1)); sectionModifierVocabularies.setEntity(getEntity()); } - } + } /* (non-Javadoc) * @see eu.etaxonomy.taxeditor.ui.section.vocabulary.DefinedTermDetailElement#handleEvent(java.lang.Object) @@ -106,19 +111,23 @@ public class FeatureDetailElement extends DefinedTermDetailElement { else if(eventSource == supportsQuantitativeData){ getEntity().setSupportsQuantitativeData(supportsQuantitativeData.getSelection()); if(supportsQuantitativeData.getSelection()){ - sectionMeasurementUnits = formFactory.createMeasurementUnitCollectionSection(getConversationHolder(), parentFormElement, ExpandableComposite.TWISTIE); - sectionMeasurementUnits.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1)); - sectionMeasurementUnits.setEntity(getEntity()); - - sectionStatisticalMeasures = formFactory.createStatisticalMeasureCollectionSection(getConversationHolder(), parentFormElement, ExpandableComposite.TWISTIE); - sectionStatisticalMeasures.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1)); - sectionStatisticalMeasures.setEntity(getEntity()); - - if(!supportsCategoricalData.getSelection()){ - sectionModifierVocabularies = formFactory.createRecommendedModifierVocabulariesCollectionSection(getConversationHolder(), parentFormElement, ExpandableComposite.TWISTIE); - sectionModifierVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1)); - sectionModifierVocabularies.setEntity(getEntity()); - } + removeElementsAndControls(supportsDistribution); + sectionMeasurementUnits = formFactory.createMeasurementUnitCollectionSection(getConversationHolder(), + parentFormElement, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); + sectionMeasurementUnits.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1)); + sectionMeasurementUnits.setEntity(getEntity()); + + sectionStatisticalMeasures = formFactory.createStatisticalMeasureCollectionSection( + getConversationHolder(), parentFormElement, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); + sectionStatisticalMeasures.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1)); + sectionStatisticalMeasures.setEntity(getEntity()); + + if (!supportsCategoricalData.getSelection()) { + sectionModifierVocabularies = formFactory.createRecommendedModifierVocabulariesCollectionSection( + getConversationHolder(), parentFormElement, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); + sectionModifierVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1)); + sectionModifierVocabularies.setEntity(getEntity()); + } } else{ if(sectionMeasurementUnits!=null){ @@ -141,17 +150,19 @@ public class FeatureDetailElement extends DefinedTermDetailElement { } else if(eventSource == supportsCategoricalData){ getEntity().setSupportsCategoricalData(supportsCategoricalData.getSelection()); - if(supportsCategoricalData.getSelection()){ - sectionStateVocabularies = formFactory.createStateVocabulariesSection(getConversationHolder(), parentFormElement, ExpandableComposite.TWISTIE); - sectionStateVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1)); - sectionStateVocabularies.setEntity(getEntity()); - - if(!supportsQuantitativeData.getSelection()){ - sectionModifierVocabularies = formFactory.createRecommendedModifierVocabulariesCollectionSection(getConversationHolder(), parentFormElement, ExpandableComposite.TWISTIE); - sectionModifierVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1)); - sectionModifierVocabularies.setEntity(getEntity()); - } - } + if (supportsCategoricalData.getSelection()) { + sectionStateVocabularies = formFactory.createStateVocabulariesSection(getConversationHolder(), + parentFormElement, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); + sectionStateVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1)); + sectionStateVocabularies.setEntity(getEntity()); + + if (!supportsQuantitativeData.getSelection()) { + sectionModifierVocabularies = formFactory.createRecommendedModifierVocabulariesCollectionSection( + getConversationHolder(), parentFormElement, ExpandableComposite.TWISTIE| ExpandableComposite.EXPANDED); + sectionModifierVocabularies.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1)); + sectionModifierVocabularies.setEntity(getEntity()); + } + } else{ if(sectionStateVocabularies!=null){ removeElementsAndControls(sectionStateVocabularies); -- 2.34.1