1
|
/**
|
2
|
* Copyright (C) 2007 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
|
|
10
|
package eu.etaxonomy.taxeditor.ui.element;
|
11
|
|
12
|
import org.eclipse.jface.util.PropertyChangeEvent;
|
13
|
import org.eclipse.swt.graphics.Color;
|
14
|
import org.eclipse.swt.widgets.Label;
|
15
|
import org.eclipse.ui.forms.widgets.Section;
|
16
|
|
17
|
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
|
18
|
|
19
|
/**
|
20
|
* <p>
|
21
|
* GatheringEventUnitElement class.
|
22
|
* </p>
|
23
|
*
|
24
|
* @author c.mathew
|
25
|
* @created 23 Jul. 2013
|
26
|
* @version 1.0
|
27
|
*/
|
28
|
public class GatheringEventUnitElement extends AbstractCdmFormElement implements ISelectable {
|
29
|
|
30
|
private final Label label;
|
31
|
private final MinMaxTextSection section_minMaxText;
|
32
|
|
33
|
/**
|
34
|
* <p>
|
35
|
* Constructor for TimePeriodElement.
|
36
|
* </p>
|
37
|
*
|
38
|
* @param style
|
39
|
* a int.
|
40
|
* @param formFactory
|
41
|
* a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
|
42
|
* object.
|
43
|
* @param parentElement
|
44
|
* a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
|
45
|
* object.
|
46
|
* @param labelString
|
47
|
* a {@link java.lang.String} object.
|
48
|
* @param timePeriod
|
49
|
* a {@link eu.etaxonomy.cdm.model.common.TimePeriod} object.
|
50
|
*/
|
51
|
public GatheringEventUnitElement(CdmFormFactory formFactory,
|
52
|
ICdmFormElement parentElement,
|
53
|
String labelString,
|
54
|
DerivedUnitFacade gatheringEvent,
|
55
|
MinMaxTextSection.UnitType unitType,
|
56
|
final int style) {
|
57
|
super(formFactory, parentElement);
|
58
|
|
59
|
label = formFactory.createLabel(getLayoutComposite(), labelString);
|
60
|
addControl(label);
|
61
|
|
62
|
section_minMaxText = formFactory.createMinMaxTextSection(this,
|
63
|
unitType,
|
64
|
Section.TWISTIE);
|
65
|
|
66
|
addControl(section_minMaxText);
|
67
|
|
68
|
section_minMaxText.setEntity(gatheringEvent);
|
69
|
|
70
|
formFactory.addPropertyChangeListener(this);
|
71
|
}
|
72
|
|
73
|
|
74
|
/** {@inheritDoc} */
|
75
|
@Override
|
76
|
public void propertyChange(PropertyChangeEvent event) {
|
77
|
if (event == null) {
|
78
|
return;
|
79
|
}
|
80
|
Object eventSource = event.getSource();
|
81
|
|
82
|
if (getElements().contains(eventSource)) {
|
83
|
handleEvent(eventSource);
|
84
|
}
|
85
|
}
|
86
|
|
87
|
private void handleEvent(Object eventSource) {
|
88
|
if (eventSource == section_minMaxText) {
|
89
|
firePropertyChangeEvent(new CdmPropertyChangeEvent(this, null));
|
90
|
}
|
91
|
}
|
92
|
|
93
|
/** {@inheritDoc} */
|
94
|
@Override
|
95
|
public void setBackground(Color color) {
|
96
|
label.setBackground(color);
|
97
|
section_minMaxText.setBackground(color);
|
98
|
}
|
99
|
|
100
|
@Override
|
101
|
public void setSelected(boolean selected) {
|
102
|
setBackground(selected ? SELECTED : getPersistentBackground());
|
103
|
}
|
104
|
|
105
|
public void setLabel(String string) {
|
106
|
label.setText(string);
|
107
|
}
|
108
|
}
|
109
|
|