3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
11 package eu
.etaxonomy
.taxeditor
.ui
.section
.occurrence
.association
;
13 import java
.util
.List
;
16 import org
.eclipse
.swt
.events
.SelectionListener
;
18 import eu
.etaxonomy
.cdm
.hibernate
.HibernateProxyHelper
;
19 import eu
.etaxonomy
.cdm
.model
.common
.TermType
;
20 import eu
.etaxonomy
.cdm
.model
.name
.SpecimenTypeDesignation
;
21 import eu
.etaxonomy
.cdm
.model
.name
.SpecimenTypeDesignationStatus
;
22 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
23 import eu
.etaxonomy
.taxeditor
.ui
.combo
.TermComboElement
;
24 import eu
.etaxonomy
.taxeditor
.ui
.element
.AbstractFormSection
;
25 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
26 import eu
.etaxonomy
.taxeditor
.ui
.element
.ICdmFormElement
;
27 import eu
.etaxonomy
.taxeditor
.ui
.section
.name
.AbstractTypeDesignationElement
;
28 import eu
.etaxonomy
.taxeditor
.ui
.selection
.EntitySelectionElement
;
32 * @created May 17, 2010
35 public class DerivedUnitTypeDesignationElement
extends AbstractTypeDesignationElement
<SpecimenTypeDesignation
> {
37 private TermComboElement
<SpecimenTypeDesignationStatus
> combo_typeStatus
;
39 private List
<EntitySelectionElement
<TaxonNameBase
>> selectionTaxonNames
;
40 private ICdmFormElement parentFormElement
;
43 private EntitySelectionElement
<TaxonNameBase
> selectionTaxonName
;
45 public DerivedUnitTypeDesignationElement(CdmFormFactory formFactory
,
46 AbstractFormSection section
, SpecimenTypeDesignation entity
,
47 SelectionListener removeListener
, int style
) {
48 super(formFactory
, section
, entity
, removeListener
, style
);
52 public void setEntity(SpecimenTypeDesignation entity
) {
53 super.setEntity(entity
);
54 Set
<TaxonNameBase
> typifiedNames
= entity
.getTypifiedNames();
55 if(typifiedNames
.size()==1){
56 selectionTaxonName
.setEntity(typifiedNames
.iterator().next());
58 else if(typifiedNames
.size()>1){
59 formFactory
.createLabel(getLayoutComposite(), "!!!!!!!!");
62 SpecimenTypeDesignationStatus typeStatus
= (SpecimenTypeDesignationStatus
) HibernateProxyHelper
63 .deproxy(entity
.getTypeStatus());
64 combo_typeStatus
.setSelection(typeStatus
);
65 checkbox_notDesignated
.setSelection(entity
.isNotDesignated());
67 // for (TaxonNameBase taxonNameBase : typifiedNames) {
68 // EntitySelectionElement<TaxonNameBase> selectionElement = formFactory.createSelectionElement(
69 // TaxonNameBase.class, getConversationHolder(), parentFormElement, "Scientific Name", null,
70 // EntitySelectionElement.EDITABLE | EntitySelectionElement.SELECTABLE, style);
71 // selectionElement.setEntity(taxonNameBase);
79 public void createControls(ICdmFormElement element
, int style
) {
80 this.parentFormElement
= element
;
83 selectionTaxonName
= formFactory
.createSelectionElement(
84 TaxonNameBase
.class, getConversationHolder(), parentFormElement
, "Scientific Name", null,
85 EntitySelectionElement
.EDITABLE
| EntitySelectionElement
.SELECTABLE
, style
);
87 combo_typeStatus
= formFactory
.createDefinedTermComboElement(TermType
.SpecimenTypeDesignationStatus
,
88 parentFormElement
, "Designation Status", null, style
);
90 super.createControls(element
, style
);
95 public void handleEvent(Object eventSource
) {
96 if (eventSource
== selectionTaxonName
) {
97 selectionTaxonName
.getSelection().addTypeDesignation(getEntity(), false);
98 } else if (eventSource
== combo_typeStatus
) {
99 getEntity().setTypeStatus(combo_typeStatus
.getSelection());
100 } else if (eventSource
== checkbox_notDesignated
) {
101 getEntity().setNotDesignated(checkbox_notDesignated
.getSelection());
102 } else if (eventSource
== selection_reference
) {
103 getEntity().setCitation(selection_reference
.getSelection());
104 } else if (eventSource
== text_referenceDetail
) {
105 getEntity().setCitationMicroReference(
106 text_referenceDetail
.getText());