Project

General

Profile

Download (4.1 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2021 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.widgets.Label;
12

    
13
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
14
import eu.etaxonomy.cdm.model.common.CdmBase;
15
import eu.etaxonomy.cdm.model.common.TimePeriod;
16
import eu.etaxonomy.cdm.model.description.DescriptionElementSource;
17
import eu.etaxonomy.cdm.model.name.TaxonName;
18
import eu.etaxonomy.cdm.model.reference.NamedSourceBase;
19
import eu.etaxonomy.cdm.model.reference.Reference;
20
import eu.etaxonomy.cdm.model.taxon.SecundumSource;
21
import eu.etaxonomy.cdm.model.taxon.Taxon;
22
import eu.etaxonomy.taxeditor.model.AbstractUtility;
23
import eu.etaxonomy.taxeditor.preference.Resources;
24
import eu.etaxonomy.taxeditor.store.StoreUtil;
25
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
26
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
27
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
28
import eu.etaxonomy.taxeditor.ui.section.common.ExternalLinksSection;
29
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
30

    
31
/**
32
 * @author k.luther
33
 * @since Mar 24, 2021
34
 */
35
public class SecundumSourceElement extends OriginalSourceElement<SecundumSource> {
36

    
37
	protected EntitySelectionElement<TaxonName> select_nameUsedInSource;
38

    
39
	public SecundumSourceElement(CdmFormFactory formFactory, ICdmFormElement formElement, CdmBase cdmEntity,
40
            String label) {
41
        super(formFactory, formElement, cdmEntity, label);
42
    }
43

    
44
    @Override
45
    protected void createControls(ICdmFormElement formElement, SecundumSource entity,  int style) {
46

    
47
        setEntityWithoutUpdate(HibernateProxyHelper.deproxy(entity));
48

    
49
        this.selection_Ref = formFactory.createSelectionElement(Reference.class, formElement, "Secundum", getEntity()!= null? getEntity().getCitation(): null, EntitySelectionElement.ALL, style);
50
        if (entity.getCitation() != null) {
51
        	refType = entity.getCitation().getType();
52
        }
53
        selection_Ref.setBackground(this.getPersistentBackground());
54
        for (ICdmFormElement element: selection_Ref.getElements()){
55
            element.setBackground(getPersistentBackground());
56
        }
57

    
58
        microReference = formFactory.createTextWithLabelElement(formElement, "Detail", getEntity() != null? getEntity().getCitationMicroReference(): "", style);
59

    
60
        //TODO preliminary #10057
61
        if (entity != null && entity.getCitation() != null && entity.getCitation().isDynamic()){
62
            TimePeriod acc =entity.getAccessed(); // (entity != null? entity.getAccessed(): null);
63
            accessed = formFactory.createTimePeriodElement(formElement, "Accessed", acc, style);
64
        }
65

    
66
        Label sep = formFactory.createLabel(formElement.getLayoutComposite(), "");
67
        sep.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
68
        if (this.cdmEntity instanceof Taxon){
69
        	select_nameUsedInSource = formFactory.createSelectionElement(TaxonName.class, formElement, "Name in Source", entity != null? ((NamedSourceBase)entity).getNameUsedInSource(): null, EntitySelectionElement.DELETABLE, style);
70
        }
71

    
72
        externalLinks = formFactory.createExternalLinksSection(formElement, "Links", false, StoreUtil.getSectionStyle(ExternalLinksSection.class, DescriptionElementSource.class.getCanonicalName()));
73
        externalLinks.setEmptySectionString("No links yet.");
74
        externalLinks.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 3));
75
        externalLinks.setEntity(getEntity());
76
        externalLinks.setFont(AbstractUtility.getFont(Resources.COLOR_FONT_DEFAULT));
77

    
78
        addControl(externalLinks);
79
        addElement(externalLinks);
80
        this.getLayoutComposite().layout();
81
    }
82

    
83
    @Override
84
    public void handleEvent(Object eventSource) {
85
        if (eventSource.equals(select_nameUsedInSource)){
86
        	getEntity().setNameUsedInSource(select_nameUsedInSource.getEntity());
87
        }else{
88
        	super.handleEvent(eventSource);
89
        }
90
    }
91
}
(13-13/15)