1 |
b868d5a8
|
Katja Luther
|
/**
|
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 |
bad3c6c5
|
Katja Luther
|
import org.eclipse.ui.forms.widgets.TableWrapData;
|
13 |
b868d5a8
|
Katja Luther
|
|
14 |
0122459a
|
Katja Luther
|
import eu.etaxonomy.cdm.model.common.CdmBase;
|
15 |
|
|
import eu.etaxonomy.cdm.model.common.ReferencedEntityBase;
|
16 |
|
|
import eu.etaxonomy.cdm.model.description.DescriptionElementSource;
|
17 |
b868d5a8
|
Katja Luther
|
import eu.etaxonomy.cdm.model.reference.INomenclaturalReference;
|
18 |
|
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
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 |
bad3c6c5
|
Katja Luther
|
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
|
25 |
b868d5a8
|
Katja Luther
|
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
|
26 |
|
|
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
|
27 |
|
|
|
28 |
|
|
/**
|
29 |
|
|
* @author k.luther
|
30 |
|
|
* @since Jul 1, 2020
|
31 |
|
|
*/
|
32 |
0122459a
|
Katja Luther
|
public class OriginalSourceElement extends AbstractCdmDetailElement<ReferencedEntityBase> implements IPropertyChangeListener{
|
33 |
b868d5a8
|
Katja Luther
|
|
34 |
|
|
private EntitySelectionElement<Reference> selection_Ref;
|
35 |
bad3c6c5
|
Katja Luther
|
private TextWithLabelElement microReference;
|
36 |
b868d5a8
|
Katja Luther
|
private OriginalSourceAdvancedSection advancedSection;
|
37 |
|
|
|
38 |
0122459a
|
Katja Luther
|
private CdmBase cdmEntity;
|
39 |
|
|
|
40 |
b868d5a8
|
Katja Luther
|
|
41 |
0122459a
|
Katja Luther
|
public OriginalSourceElement(CdmFormFactory formFactory, ICdmFormElement formElement, CdmBase cdmEntity) {
|
42 |
b868d5a8
|
Katja Luther
|
super(formFactory, formElement);
|
43 |
0122459a
|
Katja Luther
|
this.cdmEntity = cdmEntity;
|
44 |
b868d5a8
|
Katja Luther
|
// selectionArbitrator = formFactory.createSelectionArbitrator(this);
|
45 |
|
|
}
|
46 |
|
|
|
47 |
|
|
@Override
|
48 |
0122459a
|
Katja Luther
|
protected void createControls(ICdmFormElement formElement, ReferencedEntityBase entity, int style) {
|
49 |
b868d5a8
|
Katja Luther
|
|
50 |
|
|
selection_Ref = formFactory.createSelectionElement(Reference.class,
|
51 |
|
|
formElement, Messages.TaxonNodeWizardPage_PLACEMENT_SOURCE, null,
|
52 |
|
|
EntitySelectionElement.DELETABLE, style, 100);
|
53 |
|
|
|
54 |
|
|
if (entity != null){
|
55 |
|
|
selection_Ref.setEntity(entity.getCitation());
|
56 |
|
|
}
|
57 |
|
|
selection_Ref.setBackground(this.getPersistentBackground());
|
58 |
bad3c6c5
|
Katja Luther
|
microReference = formFactory.createTextWithLabelElement(formElement, "Details", entity != null? entity.getCitationMicroReference(): "", style);
|
59 |
eccc9d31
|
Katja Luther
|
|
60 |
|
|
|
61 |
b868d5a8
|
Katja Luther
|
for (ICdmFormElement element: selection_Ref.getElements()){
|
62 |
|
|
element.setBackground(getPersistentBackground());
|
63 |
|
|
}
|
64 |
bad3c6c5
|
Katja Luther
|
|
65 |
b868d5a8
|
Katja Luther
|
advancedSection = formFactory.createOriginalSourceAdvancedSection(getConversationHolder(), formElement, null, StoreUtil.getSectionStyle(OriginalSourceAdvancedSection.class, INomenclaturalReference.class.getCanonicalName()));
|
66 |
bad3c6c5
|
Katja Luther
|
TableWrapData layoutData = LayoutConstants.FILL_HORIZONTALLY(2, 1);
|
67 |
eccc9d31
|
Katja Luther
|
layoutData.indent = 10;
|
68 |
bad3c6c5
|
Katja Luther
|
|
69 |
|
|
advancedSection.setLayoutData(layoutData);
|
70 |
b868d5a8
|
Katja Luther
|
|
71 |
|
|
addControl(advancedSection);
|
72 |
|
|
addElement(advancedSection);
|
73 |
|
|
advancedSection.setBackground(this.getPersistentBackground());
|
74 |
|
|
advancedSection.setEntity(entity);
|
75 |
eccc9d31
|
Katja Luther
|
if (!((DescriptionElementSource)entity).checkEmpty()){
|
76 |
|
|
advancedSection.setExpanded(true);
|
77 |
|
|
}else{
|
78 |
|
|
advancedSection.setExpanded(false);
|
79 |
|
|
}
|
80 |
b868d5a8
|
Katja Luther
|
|
81 |
|
|
}
|
82 |
|
|
|
83 |
|
|
@Override
|
84 |
|
|
public void handleEvent(Object eventSource) {
|
85 |
|
|
if (eventSource.equals(selection_Ref)){
|
86 |
|
|
getEntity().setCitation(selection_Ref.getEntity());
|
87 |
bad3c6c5
|
Katja Luther
|
}else if (eventSource.equals(microReference)){
|
88 |
|
|
getEntity().setCitationMicroReference(microReference.getText());
|
89 |
|
|
|
90 |
b868d5a8
|
Katja Luther
|
}
|
91 |
|
|
|
92 |
|
|
}
|
93 |
|
|
|
94 |
0122459a
|
Katja Luther
|
/**
|
95 |
|
|
* @param cdmEntity2
|
96 |
|
|
*/
|
97 |
|
|
public void setCdmEntity(CdmBase cdmEntity) {
|
98 |
|
|
this.cdmEntity = cdmEntity;
|
99 |
|
|
|
100 |
|
|
}
|
101 |
|
|
|
102 |
b868d5a8
|
Katja Luther
|
|
103 |
|
|
|
104 |
|
|
}
|