2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.taxeditor
.ui
.element
;
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
;
17 import eu
.etaxonomy
.cdm
.api
.facade
.DerivedUnitFacade
;
21 * GatheringEventUnitElement class.
25 * @created 23 Jul. 2013
28 public class GatheringEventUnitElement
extends AbstractCdmFormElement
implements ISelectable
{
30 private final Label label
;
31 private final MinMaxTextSection section_minMaxText
;
35 * Constructor for TimePeriodElement.
41 * a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
43 * @param parentElement
44 * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
47 * a {@link java.lang.String} object.
49 * a {@link eu.etaxonomy.cdm.model.common.TimePeriod} object.
51 public GatheringEventUnitElement(CdmFormFactory formFactory
,
52 ICdmFormElement parentElement
,
54 DerivedUnitFacade gatheringEvent
,
55 MinMaxTextSection
.UnitType unitType
,
57 super(formFactory
, parentElement
);
59 label
= formFactory
.createLabel(getLayoutComposite(), labelString
);
62 section_minMaxText
= formFactory
.createMinMaxTextSection(this,
66 addControl(section_minMaxText
);
68 section_minMaxText
.setEntity(gatheringEvent
);
70 formFactory
.addPropertyChangeListener(this);
76 public void propertyChange(PropertyChangeEvent event
) {
80 Object eventSource
= event
.getSource();
82 if (getElements().contains(eventSource
)) {
83 handleEvent(eventSource
);
87 private void handleEvent(Object eventSource
) {
88 if (eventSource
== section_minMaxText
) {
89 firePropertyChangeEvent(new CdmPropertyChangeEvent(this, null));
95 public void setBackground(Color color
) {
96 label
.setBackground(color
);
97 section_minMaxText
.setBackground(color
);
101 public void setSelected(boolean selected
) {
102 setBackground(selected ? SELECTED
: getPersistentBackground());
105 public void setLabel(String string
) {
106 label
.setText(string
);