Revision db98babc
Added by Patrick Plitzner over 7 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/association/DerivedUnitTypeDesignationElement.java | ||
---|---|---|
15 | 15 |
|
16 | 16 |
import org.eclipse.swt.events.SelectionListener; |
17 | 17 |
|
18 |
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper; |
|
18 | 19 |
import eu.etaxonomy.cdm.model.common.TermType; |
19 | 20 |
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation; |
20 | 21 |
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignationStatus; |
21 | 22 |
import eu.etaxonomy.cdm.model.name.TaxonNameBase; |
22 |
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit; |
|
23 | 23 |
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement; |
24 | 24 |
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection; |
25 | 25 |
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory; |
... | ... | |
35 | 35 |
public class DerivedUnitTypeDesignationElement extends AbstractTypeDesignationElement<SpecimenTypeDesignation> { |
36 | 36 |
|
37 | 37 |
private TermComboElement<SpecimenTypeDesignationStatus> combo_typeStatus; |
38 |
private EntitySelectionElement<DerivedUnit> selection_typeSpecimen; |
|
39 | 38 |
|
40 | 39 |
private List<EntitySelectionElement<TaxonNameBase>> selectionTaxonNames; |
41 | 40 |
private ICdmFormElement parentFormElement; |
42 | 41 |
private int style; |
43 | 42 |
|
43 |
private EntitySelectionElement<TaxonNameBase> selectionTaxonName; |
|
44 |
|
|
44 | 45 |
public DerivedUnitTypeDesignationElement(CdmFormFactory formFactory, |
45 | 46 |
AbstractFormSection section, SpecimenTypeDesignation entity, |
46 | 47 |
SelectionListener removeListener, int style) { |
... | ... | |
49 | 50 |
|
50 | 51 |
@Override |
51 | 52 |
public void setEntity(SpecimenTypeDesignation entity) { |
52 |
this.entity = entity;
|
|
53 |
super.setEntity(entity);
|
|
53 | 54 |
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); |
|
55 |
if(typifiedNames.size()==1){ |
|
56 |
selectionTaxonName.setEntity(typifiedNames.iterator().next()); |
|
58 | 57 |
} |
59 |
else{ |
|
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); |
|
65 |
} |
|
58 |
else if(typifiedNames.size()>1){ |
|
59 |
formFactory.createLabel(getLayoutComposite(), "!!!!!!!!"); |
|
66 | 60 |
} |
67 | 61 |
|
68 |
checkbox_notDesignated = formFactory.createCheckbox(parentFormElement, "Not Designated", false, style); |
|
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 |
// } |
|
69 | 73 |
|
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); |
|
76 | 74 |
|
77 | 75 |
} |
78 | 76 |
|
... | ... | |
81 | 79 |
public void createControls(ICdmFormElement element, int style) { |
82 | 80 |
this.parentFormElement = element; |
83 | 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 |
|
|
84 | 90 |
super.createControls(element, style); |
85 | 91 |
} |
86 | 92 |
|
87 | 93 |
/** {@inheritDoc} */ |
88 | 94 |
@Override |
89 | 95 |
public void handleEvent(Object eventSource) { |
90 |
if (selectionTaxonNames.contains(eventSource)) { |
|
91 |
((EntitySelectionElement<TaxonNameBase>) eventSource).getSelection().addTypeDesignation(getEntity(), false); |
|
92 |
} |
|
93 |
else if (eventSource == combo_typeStatus) { |
|
96 |
if (eventSource == selectionTaxonName) { |
|
97 |
selectionTaxonName.getSelection().addTypeDesignation(getEntity(), false); |
|
98 |
} else if (eventSource == combo_typeStatus) { |
|
94 | 99 |
getEntity().setTypeStatus(combo_typeStatus.getSelection()); |
95 |
} else if (eventSource == selection_typeSpecimen) { |
|
96 |
getEntity().setTypeSpecimen(selection_typeSpecimen.getSelection()); |
|
97 |
} else if (eventSource == checkbox_notDesignated) { |
|
100 |
} else if (eventSource == checkbox_notDesignated) { |
|
98 | 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()); |
|
99 | 107 |
} |
100 | 108 |
} |
101 | 109 |
|
Also available in: Unified diff
Initialize TypeDesignationSection