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.hibernate.HibernateProxyHelper;
|
19
|
import eu.etaxonomy.cdm.model.common.TermType;
|
20
|
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation;
|
21
|
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignationStatus;
|
22
|
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
|
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;
|
29
|
|
30
|
/**
|
31
|
* @author n.hoffmann
|
32
|
* @created May 17, 2010
|
33
|
* @version 1.0
|
34
|
*/
|
35
|
public class DerivedUnitTypeDesignationElement extends AbstractTypeDesignationElement<SpecimenTypeDesignation> {
|
36
|
|
37
|
private TermComboElement<SpecimenTypeDesignationStatus> combo_typeStatus;
|
38
|
|
39
|
private List<EntitySelectionElement<TaxonNameBase>> selectionTaxonNames;
|
40
|
private ICdmFormElement parentFormElement;
|
41
|
private int style;
|
42
|
|
43
|
private EntitySelectionElement<TaxonNameBase> selectionTaxonName;
|
44
|
|
45
|
public DerivedUnitTypeDesignationElement(CdmFormFactory formFactory,
|
46
|
AbstractFormSection section, SpecimenTypeDesignation entity,
|
47
|
SelectionListener removeListener, int style) {
|
48
|
super(formFactory, section, entity, removeListener, style);
|
49
|
}
|
50
|
|
51
|
@Override
|
52
|
public void setEntity(SpecimenTypeDesignation entity) {
|
53
|
super.setEntity(entity);
|
54
|
Set<TaxonNameBase> typifiedNames = entity.getTypifiedNames();
|
55
|
if(typifiedNames.size()==1){
|
56
|
selectionTaxonName.setEntity(typifiedNames.iterator().next());
|
57
|
}
|
58
|
else if(typifiedNames.size()>1){
|
59
|
formFactory.createLabel(getLayoutComposite(), "!!!!!!!!");
|
60
|
}
|
61
|
|
62
|
SpecimenTypeDesignationStatus typeStatus = (SpecimenTypeDesignationStatus) HibernateProxyHelper
|
63
|
.deproxy(entity.getTypeStatus());
|
64
|
combo_typeStatus.setSelection(typeStatus);
|
65
|
checkbox_notDesignated.setSelection(entity.isNotDesignated());
|
66
|
|
67
|
// for (TaxonNameBase taxonNameBase : typifiedNames) {
|
68
|
// EntitySelectionElement<TaxonNameBase> selectionElement = formFactory.createSelectionElement(
|
69
|
// TaxonNameBase.class, getConversationHolder(), parentFormElement, "Scientific Name", null,
|
70
|
// EntitySelectionElement.EDITABLE | EntitySelectionElement.SELECTABLE, style);
|
71
|
// selectionElement.setEntity(taxonNameBase);
|
72
|
// }
|
73
|
|
74
|
|
75
|
}
|
76
|
|
77
|
/** {@inheritDoc} */
|
78
|
@Override
|
79
|
public void createControls(ICdmFormElement element, int style) {
|
80
|
this.parentFormElement = element;
|
81
|
this.style = style;
|
82
|
|
83
|
selectionTaxonName = formFactory.createSelectionElement(
|
84
|
TaxonNameBase.class, getConversationHolder(), parentFormElement, "Scientific Name", null,
|
85
|
EntitySelectionElement.EDITABLE | EntitySelectionElement.SELECTABLE, style);
|
86
|
|
87
|
combo_typeStatus = formFactory.createDefinedTermComboElement(TermType.SpecimenTypeDesignationStatus,
|
88
|
parentFormElement, "Designation Status", null, style);
|
89
|
|
90
|
super.createControls(element, style);
|
91
|
}
|
92
|
|
93
|
/** {@inheritDoc} */
|
94
|
@Override
|
95
|
public void handleEvent(Object eventSource) {
|
96
|
if (eventSource == selectionTaxonName) {
|
97
|
selectionTaxonName.getSelection().addTypeDesignation(getEntity(), false);
|
98
|
} else if (eventSource == combo_typeStatus) {
|
99
|
getEntity().setTypeStatus(combo_typeStatus.getSelection());
|
100
|
} else if (eventSource == checkbox_notDesignated) {
|
101
|
getEntity().setNotDesignated(checkbox_notDesignated.getSelection());
|
102
|
} else if (eventSource == selection_reference) {
|
103
|
getEntity().setCitation(selection_reference.getSelection());
|
104
|
} else if (eventSource == text_referenceDetail) {
|
105
|
getEntity().setCitationMicroReference(
|
106
|
text_referenceDetail.getText());
|
107
|
}
|
108
|
}
|
109
|
|
110
|
}
|