package eu.etaxonomy.taxeditor.ui.section.description;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.ui.forms.widgets.ExpandableComposite;
import eu.etaxonomy.cdm.model.common.LanguageString;
+import eu.etaxonomy.cdm.model.common.TermType;
+import eu.etaxonomy.cdm.model.common.TermVocabulary;
import eu.etaxonomy.cdm.model.description.State;
import eu.etaxonomy.cdm.model.description.StateData;
import eu.etaxonomy.taxeditor.store.CdmStore;
-import eu.etaxonomy.taxeditor.ui.campanula.compatibility.ICdmFormElement;
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
+import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement;
@Override
public void setEntity(StateData entity) {
this.entity = entity;
+ List<State> stateTerms = new ArrayList<State>();
+ Set<TermVocabulary<State>> stateVocabularies = getEntity().getCategoricalData().getFeature().getSupportedCategoricalEnumerations();
+ for (TermVocabulary<State> termVocabulary : stateVocabularies) {
+ stateTerms.addAll(termVocabulary.getTerms());
+ }
+ combo_state.setTerms(stateTerms);
combo_state.setSelection(entity.getState());
section_modifiers.setEntity(entity);
+ section_modifiers.setExpanded(!entity.getModifiers().isEmpty());
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.createTermComboElement(State.class, element, "State", null, style);
- section_modifiers = formFactory.createModifierSection(getConversationHolder(), element, ExpandableComposite.TWISTIE);
+ 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);
}
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()));