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
.name
.SpecimenTypeDesignation
;
19 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
20 import eu
.etaxonomy
.taxeditor
.ui
.element
.AbstractFormSection
;
21 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
22 import eu
.etaxonomy
.taxeditor
.ui
.element
.ICdmFormElement
;
23 import eu
.etaxonomy
.taxeditor
.ui
.section
.AbstractEntityCollectionElement
;
24 import eu
.etaxonomy
.taxeditor
.ui
.selection
.EntitySelectionElement
;
28 * @created May 17, 2010
31 public class DerivedUnitTypeDesignationElement
extends
32 AbstractEntityCollectionElement
<SpecimenTypeDesignation
> {
34 private List
<EntitySelectionElement
<TaxonNameBase
>> selectionTaxonNames
;
35 private ICdmFormElement parentFormElement
;
38 public DerivedUnitTypeDesignationElement(CdmFormFactory formFactory
,
39 AbstractFormSection section
, SpecimenTypeDesignation entity
,
40 SelectionListener removeListener
, int style
) {
41 super(formFactory
, section
, entity
, removeListener
, null, style
);
45 public void setEntity(SpecimenTypeDesignation entity
) {
47 Set
<TaxonNameBase
> typifiedNames
= entity
.getTypifiedNames();
48 if(typifiedNames
.isEmpty()){
49 formFactory
.createSelectionElement(
50 TaxonNameBase
.class, getConversationHolder(), parentFormElement
, "Taxon Name", null,
51 EntitySelectionElement
.EDITABLE
| EntitySelectionElement
.SELECTABLE
, style
);
54 for (TaxonNameBase taxonNameBase
: typifiedNames
) {
55 EntitySelectionElement
<TaxonNameBase
> selectionElement
= formFactory
.createSelectionElement(
56 TaxonNameBase
.class, getConversationHolder(), parentFormElement
, "Taxon Name", null,
57 EntitySelectionElement
.EDITABLE
| EntitySelectionElement
.SELECTABLE
, style
);
58 selectionElement
.setEntity(taxonNameBase
);
65 public void createControls(ICdmFormElement element
, int style
) {
66 this.parentFormElement
= element
;
72 public void handleEvent(Object eventSource
) {
73 if (eventSource
instanceof EntitySelectionElement
) {
74 ((EntitySelectionElement
<TaxonNameBase
>) eventSource
).getSelection().addTypeDesignation(getEntity(), false);