1
|
/**
|
2
|
* Copyright (C) 2020 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
package eu.etaxonomy.taxeditor.ui.section.reference;
|
10
|
|
11
|
import org.eclipse.swt.widgets.Label;
|
12
|
import org.eclipse.ui.forms.widgets.TableWrapData;
|
13
|
|
14
|
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
|
15
|
import eu.etaxonomy.cdm.model.common.CdmBase;
|
16
|
import eu.etaxonomy.cdm.model.description.DescriptionElementSource;
|
17
|
import eu.etaxonomy.cdm.model.name.NomenclaturalSource;
|
18
|
import eu.etaxonomy.cdm.model.name.TaxonName;
|
19
|
import eu.etaxonomy.cdm.model.reference.INomenclaturalReference;
|
20
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
21
|
import eu.etaxonomy.taxeditor.model.AbstractUtility;
|
22
|
import eu.etaxonomy.taxeditor.preference.Resources;
|
23
|
import eu.etaxonomy.taxeditor.store.StoreUtil;
|
24
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
25
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
26
|
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
|
27
|
import eu.etaxonomy.taxeditor.ui.section.common.ExternalLinksSection;
|
28
|
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
|
29
|
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElementWithAbbreviatedTitle;
|
30
|
|
31
|
/**
|
32
|
* @author k.luther
|
33
|
* @since Nov 11, 2020
|
34
|
*/
|
35
|
public class NomenclaturalSourceElement extends OriginalSourceElement<NomenclaturalSource> {
|
36
|
|
37
|
private EntitySelectionElementWithAbbreviatedTitle<Reference> selection_NomRef;
|
38
|
protected String label = "Source";
|
39
|
protected CdmBase cdmEntity;
|
40
|
|
41
|
protected EntitySelectionElement<TaxonName> select_nameUsedInSource;
|
42
|
protected ExternalLinksSection externalLinks;
|
43
|
|
44
|
public NomenclaturalSourceElement(CdmFormFactory formFactory, ICdmFormElement formElement, CdmBase cdmEntity,
|
45
|
String label) {
|
46
|
super(formFactory, formElement, cdmEntity, label);
|
47
|
}
|
48
|
|
49
|
@Override
|
50
|
protected void createControls(ICdmFormElement formElement, NomenclaturalSource entity, int style) {
|
51
|
|
52
|
entity = HibernateProxyHelper.deproxy(entity);
|
53
|
|
54
|
selection_NomRef = formFactory.createSelectionElementWithAbbreviatedTitle(Reference.class,
|
55
|
getConversationHolder(), formElement, "Reference",
|
56
|
null,
|
57
|
EntitySelectionElement.ALL, style);
|
58
|
|
59
|
if (entity != null){
|
60
|
selection_NomRef.setEntity(entity.getCitation());
|
61
|
}
|
62
|
selection_NomRef.setBackground(this.getPersistentBackground());
|
63
|
for (ICdmFormElement element: selection_NomRef.getElements()){
|
64
|
element.setBackground(getPersistentBackground());
|
65
|
}
|
66
|
|
67
|
microReference = formFactory.createTextWithLabelElement(formElement, "Details", entity != null? entity.getCitationMicroReference(): "", style);
|
68
|
|
69
|
Label sep = formFactory.createLabel(formElement.getLayoutComposite(), "");
|
70
|
sep.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
71
|
|
72
|
select_nameUsedInSource = formFactory.createSelectionElement(TaxonName.class, formElement, "Original Spelling", entity != null? entity.getNameUsedInSource(): null, EntitySelectionElement.ALL, style);
|
73
|
|
74
|
externalLinks = formFactory.createExternalLinksSection(getConversationHolder(), formElement, "Protologue/Original Publication", StoreUtil.getSectionStyle(ExternalLinksSection.class, DescriptionElementSource.class.getCanonicalName()));
|
75
|
externalLinks.setEmptySectionString("No protologue yet.");
|
76
|
externalLinks.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 3));
|
77
|
externalLinks.setEntity(entity);
|
78
|
externalLinks.setFont(AbstractUtility.getFont(Resources.COLOR_FONT_DEFAULT));
|
79
|
|
80
|
|
81
|
addControl(externalLinks);
|
82
|
addElement(externalLinks);
|
83
|
|
84
|
advancedSection = formFactory.createOriginalSourceAdvancedSection(getConversationHolder(), formElement, null, StoreUtil.getSectionStyle(OriginalSourceAdvancedSection.class, INomenclaturalReference.class.getCanonicalName()));
|
85
|
TableWrapData layoutData = LayoutConstants.FILL_HORIZONTALLY(2, 1);
|
86
|
|
87
|
advancedSection.setLayoutData(layoutData);
|
88
|
advancedSection.setBackground(this.getPersistentBackground());
|
89
|
advancedSection.setEntity(entity);
|
90
|
advancedSection.setFont(AbstractUtility.getFont(Resources.COLOR_FONT_DEFAULT));
|
91
|
addControl(advancedSection);
|
92
|
addElement(advancedSection);
|
93
|
this.getLayoutComposite().layout();
|
94
|
}
|
95
|
|
96
|
@Override
|
97
|
public EntitySelectionElement<Reference> getReferenceSelectionElement(){
|
98
|
return selection_NomRef;
|
99
|
}
|
100
|
|
101
|
@Override
|
102
|
public void handleEvent(Object eventSource) {
|
103
|
if (eventSource.equals(selection_NomRef)){
|
104
|
getEntity().setCitation(selection_NomRef.getEntity());
|
105
|
}
|
106
|
if (eventSource.equals(microReference)){
|
107
|
getEntity().setCitationMicroReference(microReference.getText());
|
108
|
}
|
109
|
if (eventSource.equals(select_nameUsedInSource)){
|
110
|
(getEntity()).setNameUsedInSource(select_nameUsedInSource.getEntity());
|
111
|
}
|
112
|
super.handleEvent(eventSource);
|
113
|
}
|
114
|
}
|