2 * Copyright (C) 2020 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.taxeditor
.ui
.section
.reference
;
11 import org
.eclipse
.swt
.SWT
;
12 import org
.eclipse
.swt
.graphics
.Color
;
13 import org
.eclipse
.swt
.widgets
.Display
;
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
;
30 public class AdvancedSourceElement
extends AbstractCdmDetailElement
<OriginalSourceBase
> {
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
;
38 // protected ExternalLinksSection externalLinks;
40 public AdvancedSourceElement(CdmFormFactory formFactory
, ICdmFormElement formElement
) {
41 super(formFactory
, formElement
);
45 protected void createControls(ICdmFormElement formElement
, OriginalSourceBase entity
, int style
) {
46 Display display
= Display
.getCurrent();
47 Color background
= display
.getSystemColor(SWT
.COLOR_WIDGET_BACKGROUND
);
50 if (entity
instanceof DescriptionElementSource
){
51 select_nameUsedInSource
= formFactory
.createSelectionElement(TaxonName
.class, formElement
, "Name in Source", entity
!= null?
((DescriptionElementSource
)entity
).getNameUsedInSource(): null, EntitySelectionElement
.DELETABLE
, style
);
52 select_nameUsedInSource
.setBackground(background
);
54 text_originaleNameString
= formFactory
.createTextWithLabelElement(
55 formElement
, "Original Information", entity
!= null?entity
.getOriginalNameString():null, SWT
.NULL
);
57 text_originaleNameString
.setBackground(background
);
59 if (PreferencesUtil
.getBooleanValue(PreferencePredicate
.ShowNamespaceInSource
.getKey())){
60 text_idNamespace
= formFactory
.createTextWithLabelElement(formElement
, "ID Namespace", entity
!= null?entity
.getIdNamespace():null, style
);
61 text_idNamespace
.setBackground(background
);
63 if (PreferencesUtil
.getBooleanValue(PreferencePredicate
.ShowIdInSource
.getKey())){
64 text_idInSource
= formFactory
.createTextWithLabelElement(formElement
, "ID in Source", entity
!= null?entity
.getIdInSource():null, style
);
65 text_idInSource
.setBackground(background
);
72 public void setEntity(OriginalSourceBase entity
) {
73 super.setEntity(entity
);
77 public void handleEvent(Object eventSource
) {
78 if (eventSource
.equals(text_idInSource
)){
79 getEntity().setIdInSource(text_idInSource
.getText());
80 }else if (eventSource
.equals(text_idNamespace
)){
81 getEntity().setIdNamespace(text_idNamespace
.getText());
82 }else if (eventSource
.equals(text_originaleNameString
)){
83 getEntity().setOriginalNameString(text_originaleNameString
.getText());
84 }else if (eventSource
.equals(select_nameUsedInSource
)){
85 ((DescriptionElementSource
)getEntity()).setNameUsedInSource(select_nameUsedInSource
.getEntity());