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
.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
.cdm
.model
.occurrence
.DerivedUnit
;
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
;
38 private EntitySelectionElement
<DerivedUnit
> selection_typeSpecimen
;
40 private List
<EntitySelectionElement
<TaxonNameBase
>> selectionTaxonNames
;
41 private ICdmFormElement parentFormElement
;
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
) {
53 Set
<TaxonNameBase
> typifiedNames
= entity
.getTypifiedNames();
54 if(typifiedNames
.isEmpty()){
55 formFactory
.createSelectionElement(
56 TaxonNameBase
.class, getConversationHolder(), parentFormElement
, "Scientific Name", null,
57 EntitySelectionElement
.EDITABLE
| EntitySelectionElement
.SELECTABLE
, style
);
60 for (TaxonNameBase taxonNameBase
: typifiedNames
) {
61 EntitySelectionElement
<TaxonNameBase
> selectionElement
= formFactory
.createSelectionElement(
62 TaxonNameBase
.class, getConversationHolder(), parentFormElement
, "Scientific Name", null,
63 EntitySelectionElement
.EDITABLE
| EntitySelectionElement
.SELECTABLE
, style
);
64 selectionElement
.setEntity(taxonNameBase
);
68 checkbox_notDesignated
= formFactory
.createCheckbox(parentFormElement
, "Not Designated", false, style
);
70 selection_typeSpecimen
= formFactory
71 .createSelectionElement(DerivedUnit
.class,
72 getConversationHolder(), parentFormElement
, "Specimen", null,
73 EntitySelectionElement
.ALL
, style
);
74 combo_typeStatus
= formFactory
.createDefinedTermComboElement(TermType
.SpecimenTypeDesignationStatus
,
75 parentFormElement
, "Designation Status", null, style
);
81 public void createControls(ICdmFormElement element
, int style
) {
82 this.parentFormElement
= element
;
84 super.createControls(element
, style
);
89 public void handleEvent(Object eventSource
) {
90 if (selectionTaxonNames
.contains(eventSource
)) {
91 ((EntitySelectionElement
<TaxonNameBase
>) eventSource
).getSelection().addTypeDesignation(getEntity(), false);
93 else if (eventSource
== combo_typeStatus
) {
94 getEntity().setTypeStatus(combo_typeStatus
.getSelection());
95 } else if (eventSource
== selection_typeSpecimen
) {
96 getEntity().setTypeSpecimen(selection_typeSpecimen
.getSelection());
97 } else if (eventSource
== checkbox_notDesignated
) {
98 getEntity().setNotDesignated(checkbox_notDesignated
.getSelection());