Project

General

Profile

Download (2.11 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.element;
10

    
11
import org.eclipse.swt.SWT;
12
import org.eclipse.swt.graphics.Color;
13
import org.eclipse.swt.widgets.Label;
14

    
15
import eu.etaxonomy.cdm.model.common.ExtendedTimePeriod;
16

    
17
/**
18
 * @author k.luther
19
 * @since Jun 12, 2020
20
 */
21
public class ExtendedTimePeriodElement extends AbstractCdmFormElement implements ISelectable {
22

    
23
    protected ExtendedTimePeriod timePeriod;
24
    protected Label label;
25
    protected ExtendedTimeDetailSection section_dateDetails;
26

    
27
    /**
28
     * @param formFactory
29
     * @param parentElement
30
     * @param labelString
31
     * @param timePeriod
32
     * @param style
33
     */
34
    public ExtendedTimePeriodElement(CdmFormFactory formFactory, ICdmFormElement parentElement, String labelString,
35
            ExtendedTimePeriod timePeriod, int style) {
36
        super(formFactory, parentElement);
37
        label = formFactory.createLabel(getLayoutComposite(), labelString);
38

    
39
        addControl(label);
40

    
41
        section_dateDetails = createDateDetailSection();
42
        addControl(section_dateDetails);
43

    
44
        setTimePeriod(timePeriod);
45

    
46
        formFactory.addPropertyChangeListener(this);
47
    }
48

    
49
    protected ExtendedTimeDetailSection createDateDetailSection() {
50
        return formFactory.createExtendedTimeDetailSection(this,
51
                SWT.NULL);
52
    }
53

    
54
    @Override
55
    public void setBackground(Color color) {
56
        label.setBackground(color);
57
        section_dateDetails.setBackground(color);
58
    }
59

    
60
    @Override
61
    public void setSelected(boolean selected) {
62
        setBackground(selected ? SELECTED : getPersistentBackground());
63
    }
64

    
65
    public void setLabel(String string) {
66
        label.setText(string);
67
    }
68

    
69
    public void setTimePeriod(ExtendedTimePeriod timePeriod) {
70
        this.timePeriod = timePeriod;
71
        if (timePeriod != null) {
72
            section_dateDetails.setEntity(timePeriod);
73
        }
74
    }
75

    
76
}
(18-18/57)