import org.eclipse.swt.events.SelectionListener;
+import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
import eu.etaxonomy.cdm.model.common.TermType;
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation;
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignationStatus;
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
-import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
public class DerivedUnitTypeDesignationElement extends AbstractTypeDesignationElement<SpecimenTypeDesignation> {
private TermComboElement<SpecimenTypeDesignationStatus> combo_typeStatus;
- private EntitySelectionElement<DerivedUnit> selection_typeSpecimen;
private List<EntitySelectionElement<TaxonNameBase>> selectionTaxonNames;
private ICdmFormElement parentFormElement;
private int style;
+ private EntitySelectionElement<TaxonNameBase> selectionTaxonName;
+
public DerivedUnitTypeDesignationElement(CdmFormFactory formFactory,
AbstractFormSection section, SpecimenTypeDesignation entity,
SelectionListener removeListener, int style) {
@Override
public void setEntity(SpecimenTypeDesignation entity) {
- this.entity = entity;
+ super.setEntity(entity);
Set<TaxonNameBase> typifiedNames = entity.getTypifiedNames();
- if(typifiedNames.isEmpty()){
- formFactory.createSelectionElement(
- TaxonNameBase.class, getConversationHolder(), parentFormElement, "Scientific Name", null,
- EntitySelectionElement.EDITABLE | EntitySelectionElement.SELECTABLE, style);
+ if(typifiedNames.size()==1){
+ selectionTaxonName.setEntity(typifiedNames.iterator().next());
}
- else{
- for (TaxonNameBase taxonNameBase : typifiedNames) {
- EntitySelectionElement<TaxonNameBase> selectionElement = formFactory.createSelectionElement(
- TaxonNameBase.class, getConversationHolder(), parentFormElement, "Scientific Name", null,
- EntitySelectionElement.EDITABLE | EntitySelectionElement.SELECTABLE, style);
- selectionElement.setEntity(taxonNameBase);
- }
+ else if(typifiedNames.size()>1){
+ formFactory.createLabel(getLayoutComposite(), "!!!!!!!!");
}
- checkbox_notDesignated = formFactory.createCheckbox(parentFormElement, "Not Designated", false, style);
+ SpecimenTypeDesignationStatus typeStatus = (SpecimenTypeDesignationStatus) HibernateProxyHelper
+ .deproxy(entity.getTypeStatus());
+ combo_typeStatus.setSelection(typeStatus);
+ checkbox_notDesignated.setSelection(entity.isNotDesignated());
+
+// for (TaxonNameBase taxonNameBase : typifiedNames) {
+// EntitySelectionElement<TaxonNameBase> selectionElement = formFactory.createSelectionElement(
+// TaxonNameBase.class, getConversationHolder(), parentFormElement, "Scientific Name", null,
+// EntitySelectionElement.EDITABLE | EntitySelectionElement.SELECTABLE, style);
+// selectionElement.setEntity(taxonNameBase);
+// }
- selection_typeSpecimen = formFactory
- .createSelectionElement(DerivedUnit.class,
- getConversationHolder(), parentFormElement, "Specimen", null,
- EntitySelectionElement.ALL, style);
- combo_typeStatus = formFactory.createDefinedTermComboElement(TermType.SpecimenTypeDesignationStatus,
- parentFormElement, "Designation Status", null, style);
}
public void createControls(ICdmFormElement element, int style) {
this.parentFormElement = element;
this.style = style;
+
+ selectionTaxonName = formFactory.createSelectionElement(
+ TaxonNameBase.class, getConversationHolder(), parentFormElement, "Scientific Name", null,
+ EntitySelectionElement.EDITABLE | EntitySelectionElement.SELECTABLE, style);
+
+ combo_typeStatus = formFactory.createDefinedTermComboElement(TermType.SpecimenTypeDesignationStatus,
+ parentFormElement, "Designation Status", null, style);
+
super.createControls(element, style);
}
/** {@inheritDoc} */
@Override
public void handleEvent(Object eventSource) {
- if (selectionTaxonNames.contains(eventSource)) {
- ((EntitySelectionElement<TaxonNameBase>) eventSource).getSelection().addTypeDesignation(getEntity(), false);
- }
- else if (eventSource == combo_typeStatus) {
+ if (eventSource == selectionTaxonName) {
+ selectionTaxonName.getSelection().addTypeDesignation(getEntity(), false);
+ } else if (eventSource == combo_typeStatus) {
getEntity().setTypeStatus(combo_typeStatus.getSelection());
- } else if (eventSource == selection_typeSpecimen) {
- getEntity().setTypeSpecimen(selection_typeSpecimen.getSelection());
- } else if (eventSource == checkbox_notDesignated) {
+ } else if (eventSource == checkbox_notDesignated) {
getEntity().setNotDesignated(checkbox_notDesignated.getSelection());
+ } else if (eventSource == selection_reference) {
+ getEntity().setCitation(selection_reference.getSelection());
+ } else if (eventSource == text_referenceDetail) {
+ getEntity().setCitationMicroReference(
+ text_referenceDetail.getText());
}
}