Project

General

Profile

Download (3.83 KB) Statistics
| Branch: | Tag: | Revision:
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

    
49

    
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);
53
        }
54
        text_originaleNameString = formFactory.createTextWithLabelElement(
55
                formElement, "Original Information", entity != null?entity.getOriginalNameString():null, SWT.NULL);
56

    
57
        text_originaleNameString.setBackground(background);
58

    
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);
62
        }
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);
66
        }
67
    }
68

    
69
    @Override
70
    public void setEntity(OriginalSourceBase entity) {
71
        super.setEntity(entity);
72
    }
73

    
74
    @Override
75
    public void handleEvent(Object eventSource) {
76
        if (eventSource.equals(text_idInSource)){
77
             getEntity().setIdInSource(text_idInSource.getText());
78
         }else if (eventSource.equals(text_idNamespace)){
79
             getEntity().setIdNamespace(text_idNamespace.getText());
80
         }else if (eventSource.equals(text_originaleNameString)){
81
             getEntity().setOriginalNameString(text_originaleNameString.getText());
82
         }else if (eventSource.equals(select_nameUsedInSource)){
83
             ((DescriptionElementSource)getEntity()).setNameUsedInSource(select_nameUsedInSource.getEntity());
84
         }
85
    }
86
}
(2-2/12)