3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
11 package eu
.etaxonomy
.taxeditor
.ui
.element
;
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
;
18 import eu
.etaxonomy
.cdm
.api
.facade
.DerivedUnitFacade
;
22 * GatheringEventUnitElement class.
26 * @created 23 Jul. 2013
29 public class GatheringEventUnitElement
extends AbstractCdmFormElement
implements ISelectable
{
31 private final Label label
;
32 private final MinMaxTextSection section_minMaxText
;
36 * Constructor for TimePeriodElement.
42 * a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
44 * @param parentElement
45 * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
48 * a {@link java.lang.String} object.
50 * a {@link eu.etaxonomy.cdm.model.common.TimePeriod} object.
52 public GatheringEventUnitElement(CdmFormFactory formFactory
,
53 ICdmFormElement parentElement
,
55 DerivedUnitFacade gatheringEvent
,
56 MinMaxTextSection
.UnitType unitType
,
58 super(formFactory
, parentElement
);
60 label
= formFactory
.createLabel(getLayoutComposite(), labelString
);
63 section_minMaxText
= formFactory
.createMinMaxTextSection(this,
67 addControl(section_minMaxText
);
69 section_minMaxText
.setEntity(gatheringEvent
);
71 formFactory
.addPropertyChangeListener(this);
77 public void propertyChange(PropertyChangeEvent event
) {
81 Object eventSource
= event
.getSource();
83 if (getElements().contains(eventSource
)) {
84 handleEvent(eventSource
);
88 private void handleEvent(Object eventSource
) {
89 if (eventSource
== section_minMaxText
) {
90 firePropertyChangeEvent(new CdmPropertyChangeEvent(this, null));
96 public void setBackground(Color color
) {
97 label
.setBackground(color
);
98 section_minMaxText
.setBackground(color
);
102 public void setSelected(boolean selected
) {
103 setBackground(selected ? SELECTED
: getPersistentBackground());
106 public void setLabel(String string
) {
107 label
.setText(string
);