1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2007 EDIT
|
4
|
* European Distributed Institute of Taxonomy
|
5
|
* http://www.e-taxonomy.eu
|
6
|
*
|
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.
|
9
|
*/
|
10
|
|
11
|
package eu.etaxonomy.taxeditor.ui.section.occurrence.association;
|
12
|
|
13
|
import java.util.List;
|
14
|
import java.util.Set;
|
15
|
|
16
|
import org.eclipse.swt.events.SelectionListener;
|
17
|
|
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;
|
25
|
|
26
|
/**
|
27
|
* @author n.hoffmann
|
28
|
* @created May 17, 2010
|
29
|
* @version 1.0
|
30
|
*/
|
31
|
public class DerivedUnitTypeDesignationElement extends
|
32
|
AbstractEntityCollectionElement<SpecimenTypeDesignation> {
|
33
|
|
34
|
private List<EntitySelectionElement<TaxonNameBase>> selectionTaxonNames;
|
35
|
private ICdmFormElement parentFormElement;
|
36
|
private int style;
|
37
|
|
38
|
public DerivedUnitTypeDesignationElement(CdmFormFactory formFactory,
|
39
|
AbstractFormSection section, SpecimenTypeDesignation entity,
|
40
|
SelectionListener removeListener, int style) {
|
41
|
super(formFactory, section, entity, removeListener, null, style);
|
42
|
}
|
43
|
|
44
|
@Override
|
45
|
public void setEntity(SpecimenTypeDesignation entity) {
|
46
|
this.entity = 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);
|
52
|
}
|
53
|
else{
|
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);
|
59
|
}
|
60
|
}
|
61
|
}
|
62
|
|
63
|
/** {@inheritDoc} */
|
64
|
@Override
|
65
|
public void createControls(ICdmFormElement element, int style) {
|
66
|
this.parentFormElement = element;
|
67
|
this.style = style;
|
68
|
}
|
69
|
|
70
|
/** {@inheritDoc} */
|
71
|
@Override
|
72
|
public void handleEvent(Object eventSource) {
|
73
|
if (eventSource instanceof EntitySelectionElement) {
|
74
|
((EntitySelectionElement<TaxonNameBase>) eventSource).getSelection().addTypeDesignation(getEntity(), false);
|
75
|
}
|
76
|
}
|
77
|
|
78
|
}
|