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
;
19 import eu
.etaxonomy
.taxeditor
.ui
.campanula
.compatibility
.ICdmFormElement
;
23 * GatheringEventUnitElement class.
27 * @created 23 Jul. 2013
30 public class GatheringEventUnitElement
extends AbstractCdmFormElement
implements ISelectable
{
32 private final Label label
;
33 private final MinMaxTextSection section_minMaxText
;
37 * Constructor for TimePeriodElement.
43 * a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
45 * @param parentElement
46 * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
49 * a {@link java.lang.String} object.
51 * a {@link eu.etaxonomy.cdm.model.common.TimePeriod} object.
53 public GatheringEventUnitElement(CdmFormFactory formFactory
,
54 ICdmFormElement parentElement
,
56 DerivedUnitFacade gatheringEvent
,
57 MinMaxTextSection
.UnitType unitType
,
59 super(formFactory
, parentElement
);
61 label
= formFactory
.createLabel(getLayoutComposite(), labelString
);
64 section_minMaxText
= formFactory
.createMinMaxTextSection(this,
68 addControl(section_minMaxText
);
70 section_minMaxText
.setEntity(gatheringEvent
);
72 formFactory
.addPropertyChangeListener(this);
78 public void propertyChange(PropertyChangeEvent event
) {
82 Object eventSource
= event
.getSource();
84 if (getElements().contains(eventSource
)) {
85 handleEvent(eventSource
);
89 private void handleEvent(Object eventSource
) {
90 if (eventSource
== section_minMaxText
) {
91 firePropertyChangeEvent(new CdmPropertyChangeEvent(this, null));
97 public void setBackground(Color color
) {
98 label
.setBackground(color
);
99 section_minMaxText
.setBackground(color
);
103 public void setSelected(boolean selected
) {
104 setBackground(selected ? SELECTED
: getPersistentBackground());
107 public void setLabel(String string
) {
108 label
.setText(string
);