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