Revision 0122459a
Added by Katja Luther over 3 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/reference/AdvancedSourceElement.java | ||
---|---|---|
12 | 12 |
import org.eclipse.swt.graphics.Color; |
13 | 13 |
import org.eclipse.swt.widgets.Display; |
14 | 14 |
|
15 |
import eu.etaxonomy.cdm.model.media.ExternalLink; |
|
15 |
import eu.etaxonomy.cdm.model.common.ReferencedEntityBase; |
|
16 |
import eu.etaxonomy.cdm.model.description.DescriptionElementSource; |
|
16 | 17 |
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate; |
17 | 18 |
import eu.etaxonomy.cdm.model.reference.OriginalSourceBase; |
18 | 19 |
import eu.etaxonomy.taxeditor.preference.PreferencesUtil; |
... | ... | |
28 | 29 |
* @author k.luther |
29 | 30 |
* @since Jul 2, 2020 |
30 | 31 |
*/ |
31 |
public class AdvancedSourceElement extends AbstractCdmDetailElement<OriginalSourceBase> {
|
|
32 |
public class AdvancedSourceElement extends AbstractCdmDetailElement<ReferencedEntityBase > {
|
|
32 | 33 |
|
33 | 34 |
protected TextWithLabelElement text_idInSource; |
34 | 35 |
protected TextWithLabelElement text_idNamespace; |
... | ... | |
45 | 46 |
|
46 | 47 |
|
47 | 48 |
@Override |
48 |
protected void createControls(ICdmFormElement formElement, OriginalSourceBase entity, int style) {
|
|
49 |
protected void createControls(ICdmFormElement formElement, ReferencedEntityBase entity, int style) {
|
|
49 | 50 |
Display display = Display.getCurrent(); |
50 | 51 |
Color background = display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND); |
51 | 52 |
|
52 | 53 |
if (PreferencesUtil.getBooleanValue(PreferencePredicate.ShowIdInSource.getKey())){ |
53 |
text_idInSource = formFactory.createTextWithLabelElement(formElement, "ID in Source", entity != null?entity.getIdInSource():null, style); |
|
54 |
|
|
55 |
text_idInSource = formFactory.createTextWithLabelElement(formElement, "ID in Source", entity != null?((OriginalSourceBase)entity).getIdInSource():null, style); |
|
54 | 56 |
text_idInSource.setBackground(background); |
55 | 57 |
} |
56 | 58 |
if (PreferencesUtil.getBooleanValue(PreferencePredicate.ShowNamespaceInSource.getKey())){ |
57 |
text_idNamespace = formFactory.createTextWithLabelElement(formElement, "ID Namespace", entity != null?entity.getIdNamespace():null, style);
|
|
59 |
text_idNamespace = formFactory.createTextWithLabelElement(formElement, "ID Namespace", entity != null?((OriginalSourceBase)entity).getIdNamespace():null, style);
|
|
58 | 60 |
text_idNamespace.setBackground(background); |
59 | 61 |
} |
60 | 62 |
text_originaleNameString = formFactory.createTextWithLabelElement( |
... | ... | |
63 | 65 |
text_originaleNameString.setBackground(background); |
64 | 66 |
// text_cdmsource = formFactory.createTextWithLabelElement( |
65 | 67 |
// formElement, "CDM Source", entity != null?entity.getCdmSource():null, SWT.NULL); |
66 |
externalLinks = formFactory.createExternalLinksSection(getConversationHolder(), formElement, StoreUtil.getSectionStyle(ExternalLinksSection.class, ExternalLink.class.getCanonicalName()));
|
|
67 |
externalLinks.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
|
68 |
externalLinks.setEntity(entity);
|
|
68 |
externalLinks = formFactory.createExternalLinksSection(getConversationHolder(), formElement, StoreUtil.getSectionStyle(ExternalLinksSection.class, DescriptionElementSource.class.getCanonicalName()));
|
|
69 |
externalLinks.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 3));
|
|
70 |
externalLinks.setEntity( ((OriginalSourceBase)entity));
|
|
69 | 71 |
addControl(externalLinks); |
70 | 72 |
addElement(externalLinks); |
71 | 73 |
|
72 | 74 |
|
73 | 75 |
} |
74 | 76 |
|
77 |
@Override |
|
78 |
public void setEntity(ReferencedEntityBase entity) { |
|
79 |
super.setEntity(entity); |
|
80 |
externalLinks.setEntity((OriginalSourceBase)entity); |
|
81 |
} |
|
82 |
|
|
75 | 83 |
@Override |
76 | 84 |
public void handleEvent(Object eventSource) { |
77 | 85 |
if (eventSource.equals(text_idInSource)){ |
78 |
getEntity().setIdInSource(text_idInSource.getText());
|
|
86 |
((OriginalSourceBase)getEntity()).setIdInSource(text_idInSource.getText());
|
|
79 | 87 |
}else if (eventSource.equals(text_idNamespace)){ |
80 |
getEntity().setIdNamespace(text_idNamespace.getText());
|
|
88 |
((OriginalSourceBase)getEntity()).setIdNamespace(text_idNamespace.getText());
|
|
81 | 89 |
}else if (eventSource.equals(text_originaleNameString)){ |
82 |
getEntity().setOriginalNameString(text_originaleNameString.getText());
|
|
90 |
((OriginalSourceBase)getEntity()).setOriginalNameString(text_originaleNameString.getText());
|
|
83 | 91 |
} |
84 | 92 |
|
85 | 93 |
} |
Also available in: Unified diff
ref #9116: add single source element to taxon node details and restructure the wizard