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.SWT;
|
12
|
import org.eclipse.swt.graphics.Color;
|
13
|
import org.eclipse.swt.widgets.Display;
|
14
|
|
15
|
import eu.etaxonomy.cdm.model.description.DescriptionElementSource;
|
16
|
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
|
17
|
import eu.etaxonomy.cdm.model.name.TaxonName;
|
18
|
import eu.etaxonomy.cdm.model.reference.OriginalSourceBase;
|
19
|
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
|
20
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
21
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
22
|
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
|
23
|
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
|
24
|
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
|
25
|
|
26
|
/**
|
27
|
* @author k.luther
|
28
|
* @since Jul 2, 2020
|
29
|
*/
|
30
|
public class AdvancedSourceElement extends AbstractCdmDetailElement<OriginalSourceBase> {
|
31
|
|
32
|
protected TextWithLabelElement text_idInSource;
|
33
|
protected TextWithLabelElement text_idNamespace;
|
34
|
protected TextWithLabelElement text_originaleNameString;
|
35
|
protected TextWithLabelElement text_cdmsource;
|
36
|
protected EntitySelectionElement<TaxonName> select_nameUsedInSource;
|
37
|
|
38
|
// protected ExternalLinksSection externalLinks;
|
39
|
|
40
|
public AdvancedSourceElement(CdmFormFactory formFactory, ICdmFormElement formElement) {
|
41
|
super(formFactory, formElement);
|
42
|
}
|
43
|
|
44
|
@Override
|
45
|
protected void createControls(ICdmFormElement formElement, OriginalSourceBase entity, int style) {
|
46
|
Display display = Display.getCurrent();
|
47
|
Color background = display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
|
48
|
if (entity instanceof DescriptionElementSource){
|
49
|
select_nameUsedInSource = formFactory.createSelectionElement(TaxonName.class, formElement, "Name in Source", entity != null? ((DescriptionElementSource)entity).getNameUsedInSource(): null, EntitySelectionElement.DELETABLE, style);
|
50
|
select_nameUsedInSource.setBackground(background);
|
51
|
}
|
52
|
|
53
|
if (PreferencesUtil.getBooleanValue(PreferencePredicate.ShowNamespaceInSource.getKey())){
|
54
|
text_idNamespace = formFactory.createTextWithLabelElement(formElement, "ID Namespace", entity != null?entity.getIdNamespace():null, style);
|
55
|
text_idNamespace.setBackground(background);
|
56
|
}
|
57
|
if (PreferencesUtil.getBooleanValue(PreferencePredicate.ShowIdInSource.getKey())){
|
58
|
text_idInSource = formFactory.createTextWithLabelElement(formElement, "ID in Source", entity != null?entity.getIdInSource():null, style);
|
59
|
text_idInSource.setBackground(background);
|
60
|
|
61
|
}
|
62
|
|
63
|
text_originaleNameString = formFactory.createTextWithLabelElement(
|
64
|
formElement, "Original Information", entity != null?entity.getOriginalNameString():null, SWT.NULL);
|
65
|
|
66
|
text_originaleNameString.setBackground(background);
|
67
|
|
68
|
|
69
|
|
70
|
// externalLinks = formFactory.createExternalLinksSection(getConversationHolder(), formElement, StoreUtil.getSectionStyle(ExternalLinksSection.class, DescriptionElementSource.class.getCanonicalName()));
|
71
|
// externalLinks.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 3));
|
72
|
// externalLinks.setEntity(entity);
|
73
|
//
|
74
|
// externalLinks.setBackground(background);
|
75
|
// addControl(externalLinks);
|
76
|
// addElement(externalLinks);
|
77
|
}
|
78
|
|
79
|
@Override
|
80
|
public void setEntity(OriginalSourceBase entity) {
|
81
|
super.setEntity(entity);
|
82
|
}
|
83
|
|
84
|
@Override
|
85
|
public void handleEvent(Object eventSource) {
|
86
|
if (eventSource.equals(text_idInSource)){
|
87
|
getEntity().setIdInSource(text_idInSource.getText());
|
88
|
}else if (eventSource.equals(text_idNamespace)){
|
89
|
getEntity().setIdNamespace(text_idNamespace.getText());
|
90
|
}else if (eventSource.equals(text_originaleNameString)){
|
91
|
getEntity().setOriginalNameString(text_originaleNameString.getText());
|
92
|
}else if (eventSource.equals(select_nameUsedInSource)){
|
93
|
((DescriptionElementSource)getEntity()).setNameUsedInSource(select_nameUsedInSource.getEntity());
|
94
|
}
|
95
|
}
|
96
|
}
|