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
;
14 import org
.eclipse
.swt
.events
.SelectionListener
;
16 import eu
.etaxonomy
.cdm
.hibernate
.HibernateProxyHelper
;
17 import eu
.etaxonomy
.cdm
.model
.common
.TermType
;
18 import eu
.etaxonomy
.cdm
.model
.name
.SpecimenTypeDesignation
;
19 import eu
.etaxonomy
.cdm
.model
.name
.SpecimenTypeDesignationStatus
;
20 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
21 import eu
.etaxonomy
.taxeditor
.ui
.combo
.TermComboElement
;
22 import eu
.etaxonomy
.taxeditor
.ui
.element
.AbstractFormSection
;
23 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
24 import eu
.etaxonomy
.taxeditor
.ui
.element
.ICdmFormElement
;
25 import eu
.etaxonomy
.taxeditor
.ui
.section
.name
.AbstractTypeDesignationElement
;
26 import eu
.etaxonomy
.taxeditor
.ui
.selection
.EntitySelectionElement
;
30 * @created May 17, 2010
32 public class DerivedUnitTypeDesignationElement
extends AbstractTypeDesignationElement
<SpecimenTypeDesignation
> {
34 private TermComboElement
<SpecimenTypeDesignationStatus
> combo_typeStatus
;
36 // private List<EntitySelectionElement<TaxonNameBase>> selectionTaxonNames;
37 private ICdmFormElement parentFormElement
;
40 private EntitySelectionElement
<TaxonNameBase
> selectionTaxonName
;
42 public DerivedUnitTypeDesignationElement(CdmFormFactory formFactory
,
43 AbstractFormSection section
, SpecimenTypeDesignation entity
,
44 SelectionListener removeListener
, int style
) {
45 super(formFactory
, section
, entity
, removeListener
, style
);
49 public void setEntity(SpecimenTypeDesignation entity
) {
50 super.setEntity(entity
);
51 Set
<TaxonNameBase
> typifiedNames
= entity
.getTypifiedNames();
52 if(typifiedNames
.size()==1){
53 selectionTaxonName
.setEntity(typifiedNames
.iterator().next());
55 else if(typifiedNames
.size()>1){
56 formFactory
.createLabel(getLayoutComposite(), "!!!!!!!!");
59 SpecimenTypeDesignationStatus typeStatus
= HibernateProxyHelper
60 .deproxy(entity
.getTypeStatus());
61 combo_typeStatus
.setSelection(typeStatus
);
62 checkbox_notDesignated
.setSelection(entity
.isNotDesignated());
64 // for (TaxonNameBase taxonNameBase : typifiedNames) {
65 // EntitySelectionElement<TaxonNameBase> selectionElement = formFactory.createSelectionElement(
66 // TaxonNameBase.class, getConversationHolder(), parentFormElement, "Scientific Name", null,
67 // EntitySelectionElement.EDITABLE | EntitySelectionElement.SELECTABLE, style);
68 // selectionElement.setEntity(taxonNameBase);
76 public void createControls(ICdmFormElement element
, int style
) {
77 this.parentFormElement
= element
;
80 selectionTaxonName
= formFactory
.createSelectionElement(
81 TaxonNameBase
.class, getConversationHolder(), parentFormElement
, "Scientific Name", null,
82 EntitySelectionElement
.EDITABLE
| EntitySelectionElement
.SELECTABLE
, style
);
84 combo_typeStatus
= formFactory
.createDefinedTermComboElement(TermType
.SpecimenTypeDesignationStatus
,
85 parentFormElement
, "Designation Status", null, style
);
87 super.createControls(element
, style
);
92 public void handleEvent(Object eventSource
) {
93 if (eventSource
== selectionTaxonName
) {
94 selectionTaxonName
.getSelection().addTypeDesignation(getEntity(), false);
95 } else if (eventSource
== combo_typeStatus
) {
96 getEntity().setTypeStatus(combo_typeStatus
.getSelection());
97 } else if (eventSource
== checkbox_notDesignated
) {
98 getEntity().setNotDesignated(checkbox_notDesignated
.getSelection());
99 } else if (eventSource
== selection_reference
) {
100 getEntity().setCitation(selection_reference
.getSelection());
101 } else if (eventSource
== text_referenceDetail
) {
102 getEntity().setCitationMicroReference(
103 text_referenceDetail
.getText());