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.jface.util.IPropertyChangeListener;
|
12
|
|
13
|
import eu.etaxonomy.cdm.model.common.CdmBase;
|
14
|
import eu.etaxonomy.cdm.model.common.ReferencedEntityBase;
|
15
|
import eu.etaxonomy.cdm.model.description.DescriptionElementSource;
|
16
|
import eu.etaxonomy.cdm.model.reference.INomenclaturalReference;
|
17
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
18
|
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
|
19
|
import eu.etaxonomy.taxeditor.l10n.Messages;
|
20
|
import eu.etaxonomy.taxeditor.store.StoreUtil;
|
21
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
22
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
23
|
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
|
24
|
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
|
25
|
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
|
26
|
|
27
|
/**
|
28
|
* @author k.luther
|
29
|
* @since Jul 1, 2020
|
30
|
*/
|
31
|
public class OriginalSourceElement extends AbstractCdmDetailElement<ReferencedEntityBase> implements IPropertyChangeListener{
|
32
|
|
33
|
// protected EnumComboElement<OriginalSourceType> combo_origsourcetype;
|
34
|
|
35
|
private EntitySelectionElement<Reference> selection_Ref;
|
36
|
private OriginalSourceAdvancedSection advancedSection;
|
37
|
|
38
|
private CdmBase cdmEntity;
|
39
|
|
40
|
|
41
|
// protected EntitySelectionElement<Reference> selection_reference;
|
42
|
// protected TextWithLabelElement text_referenceDetail;
|
43
|
|
44
|
|
45
|
public OriginalSourceElement(CdmFormFactory formFactory, ICdmFormElement formElement, CdmBase cdmEntity) {
|
46
|
super(formFactory, formElement);
|
47
|
this.cdmEntity = cdmEntity;
|
48
|
// selectionArbitrator = formFactory.createSelectionArbitrator(this);
|
49
|
}
|
50
|
|
51
|
@Override
|
52
|
protected void createControls(ICdmFormElement formElement, ReferencedEntityBase entity, int style) {
|
53
|
|
54
|
selection_Ref = formFactory.createSelectionElement(Reference.class,
|
55
|
formElement, Messages.TaxonNodeWizardPage_PLACEMENT_SOURCE, null,
|
56
|
EntitySelectionElement.DELETABLE, style, 100);
|
57
|
|
58
|
if (entity != null){
|
59
|
selection_Ref.setEntity(entity.getCitation());
|
60
|
}
|
61
|
selection_Ref.setBackground(this.getPersistentBackground());
|
62
|
for (ICdmFormElement element: selection_Ref.getElements()){
|
63
|
element.setBackground(getPersistentBackground());
|
64
|
}
|
65
|
advancedSection = formFactory.createOriginalSourceAdvancedSection(getConversationHolder(), formElement, null, StoreUtil.getSectionStyle(OriginalSourceAdvancedSection.class, INomenclaturalReference.class.getCanonicalName()));
|
66
|
advancedSection.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
67
|
|
68
|
addControl(advancedSection);
|
69
|
addElement(advancedSection);
|
70
|
advancedSection.setBackground(this.getPersistentBackground());
|
71
|
advancedSection.setEntity(entity);
|
72
|
|
73
|
}
|
74
|
|
75
|
@Override
|
76
|
public void handleEvent(Object eventSource) {
|
77
|
if (eventSource.equals(selection_Ref)){
|
78
|
|
79
|
if (getEntity() == null){
|
80
|
Reference ref = selection_Ref.getEntity();
|
81
|
DescriptionElementSource source = DescriptionElementSource.NewPrimarySourceInstance(null, null);
|
82
|
setEntity(source);
|
83
|
selection_Ref.setEntity(ref);
|
84
|
if (cdmEntity != null && cdmEntity instanceof TaxonNode){
|
85
|
((TaxonNode)cdmEntity).setSource(source);
|
86
|
}
|
87
|
}
|
88
|
//TODO: why is this null????ß
|
89
|
getEntity().setCitation(selection_Ref.getEntity());
|
90
|
|
91
|
}
|
92
|
|
93
|
}
|
94
|
|
95
|
/**
|
96
|
* @param cdmEntity2
|
97
|
*/
|
98
|
public void setCdmEntity(CdmBase cdmEntity) {
|
99
|
this.cdmEntity = cdmEntity;
|
100
|
|
101
|
}
|
102
|
|
103
|
|
104
|
|
105
|
}
|