1 |
4b61c2b2
|
Patrick Plitzner
|
// $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 |
db98babc
|
Patrick Plitzner
|
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
|
19 |
d21a66e3
|
Patrick Plitzner
|
import eu.etaxonomy.cdm.model.common.TermType;
|
20 |
4b61c2b2
|
Patrick Plitzner
|
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation;
|
21 |
d21a66e3
|
Patrick Plitzner
|
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignationStatus;
|
22 |
4b61c2b2
|
Patrick Plitzner
|
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
|
23 |
d21a66e3
|
Patrick Plitzner
|
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
|
24 |
4b61c2b2
|
Patrick Plitzner
|
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
|
25 |
|
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
26 |
|
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
27 |
d21a66e3
|
Patrick Plitzner
|
import eu.etaxonomy.taxeditor.ui.section.name.AbstractTypeDesignationElement;
|
28 |
4b61c2b2
|
Patrick Plitzner
|
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
|
29 |
|
|
|
30 |
|
|
/**
|
31 |
|
|
* @author n.hoffmann
|
32 |
|
|
* @created May 17, 2010
|
33 |
|
|
* @version 1.0
|
34 |
|
|
*/
|
35 |
d21a66e3
|
Patrick Plitzner
|
public class DerivedUnitTypeDesignationElement extends AbstractTypeDesignationElement<SpecimenTypeDesignation> {
|
36 |
|
|
|
37 |
|
|
private TermComboElement<SpecimenTypeDesignationStatus> combo_typeStatus;
|
38 |
4b61c2b2
|
Patrick Plitzner
|
|
39 |
|
|
private List<EntitySelectionElement<TaxonNameBase>> selectionTaxonNames;
|
40 |
|
|
private ICdmFormElement parentFormElement;
|
41 |
|
|
private int style;
|
42 |
|
|
|
43 |
db98babc
|
Patrick Plitzner
|
private EntitySelectionElement<TaxonNameBase> selectionTaxonName;
|
44 |
|
|
|
45 |
4b61c2b2
|
Patrick Plitzner
|
public DerivedUnitTypeDesignationElement(CdmFormFactory formFactory,
|
46 |
|
|
AbstractFormSection section, SpecimenTypeDesignation entity,
|
47 |
|
|
SelectionListener removeListener, int style) {
|
48 |
d21a66e3
|
Patrick Plitzner
|
super(formFactory, section, entity, removeListener, style);
|
49 |
4b61c2b2
|
Patrick Plitzner
|
}
|
50 |
|
|
|
51 |
|
|
@Override
|
52 |
|
|
public void setEntity(SpecimenTypeDesignation entity) {
|
53 |
db98babc
|
Patrick Plitzner
|
super.setEntity(entity);
|
54 |
4b61c2b2
|
Patrick Plitzner
|
Set<TaxonNameBase> typifiedNames = entity.getTypifiedNames();
|
55 |
db98babc
|
Patrick Plitzner
|
if(typifiedNames.size()==1){
|
56 |
|
|
selectionTaxonName.setEntity(typifiedNames.iterator().next());
|
57 |
4b61c2b2
|
Patrick Plitzner
|
}
|
58 |
db98babc
|
Patrick Plitzner
|
else if(typifiedNames.size()>1){
|
59 |
|
|
formFactory.createLabel(getLayoutComposite(), "!!!!!!!!");
|
60 |
4b61c2b2
|
Patrick Plitzner
|
}
|
61 |
d21a66e3
|
Patrick Plitzner
|
|
62 |
db98babc
|
Patrick Plitzner
|
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 |
d21a66e3
|
Patrick Plitzner
|
|
74 |
|
|
|
75 |
4b61c2b2
|
Patrick Plitzner
|
}
|
76 |
|
|
|
77 |
|
|
/** {@inheritDoc} */
|
78 |
|
|
@Override
|
79 |
|
|
public void createControls(ICdmFormElement element, int style) {
|
80 |
|
|
this.parentFormElement = element;
|
81 |
|
|
this.style = style;
|
82 |
db98babc
|
Patrick Plitzner
|
|
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 |
d21a66e3
|
Patrick Plitzner
|
super.createControls(element, style);
|
91 |
4b61c2b2
|
Patrick Plitzner
|
}
|
92 |
|
|
|
93 |
|
|
/** {@inheritDoc} */
|
94 |
|
|
@Override
|
95 |
|
|
public void handleEvent(Object eventSource) {
|
96 |
db98babc
|
Patrick Plitzner
|
if (eventSource == selectionTaxonName) {
|
97 |
|
|
selectionTaxonName.getSelection().addTypeDesignation(getEntity(), false);
|
98 |
|
|
} else if (eventSource == combo_typeStatus) {
|
99 |
d21a66e3
|
Patrick Plitzner
|
getEntity().setTypeStatus(combo_typeStatus.getSelection());
|
100 |
db98babc
|
Patrick Plitzner
|
} else if (eventSource == checkbox_notDesignated) {
|
101 |
d21a66e3
|
Patrick Plitzner
|
getEntity().setNotDesignated(checkbox_notDesignated.getSelection());
|
102 |
db98babc
|
Patrick Plitzner
|
} 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 |
d21a66e3
|
Patrick Plitzner
|
}
|
108 |
4b61c2b2
|
Patrick Plitzner
|
}
|
109 |
|
|
|
110 |
|
|
}
|