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