-// $Id$
/**
* Copyright (C) 2007 EDIT
- * European Distributed Institute of Taxonomy
+ * European Distributed Institute of Taxonomy
* http://www.e-taxonomy.eu
- *
+ *
* The contents of this file are subject to the Mozilla Public License Version 1.1
* See LICENSE.TXT at the top of this package for the full license terms.
*/
package eu.etaxonomy.taxeditor.ui.element;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.forms.widgets.Section;
import eu.etaxonomy.cdm.model.common.TimePeriod;
-import eu.etaxonomy.taxeditor.ui.campanula.compatibility.ICdmFormElement;
/**
* <p>
* TimePeriodElement class.
* </p>
- *
+ *
* @author n.hoffmann
* @created Nov 17, 2009
- * @version 1.0
*/
-public class TimePeriodElement extends AbstractCdmFormElement implements ISelectable {
+public class TimePeriodElement
+ extends TimePeriodElementBase<TimePeriod> {
- private TimePeriod timePeriod;
- private final Label label;
- private final DateDetailSection section_dateDetails;
-
- /**
- * <p>
- * Constructor for TimePeriodElement.
- * </p>
- *
- * @param style
- * a int.
- * @param formFactory
- * a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
- * object.
- * @param parentElement
- * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
- * object.
- * @param labelString
- * a {@link java.lang.String} object.
- * @param timePeriod
- * a {@link eu.etaxonomy.cdm.model.common.TimePeriod} object.
- */
- public TimePeriodElement(CdmFormFactory formFactory,
- ICdmFormElement parentElement, String labelString,
- TimePeriod timePeriod, final int style) {
- super(formFactory, parentElement);
-
- label = formFactory.createLabel(getLayoutComposite(), labelString);
- addControl(label);
-
- section_dateDetails = formFactory.createDateDetailSection(this,
- Section.TWISTIE);
- addControl(section_dateDetails);
-
- setTimePeriod(timePeriod);
-
- formFactory.addPropertyChangeListener(this);
+
+ public TimePeriodElement(CdmFormFactory formFactory, ICdmFormElement parentElement, String labelString,
+ TimePeriod timePeriod, int style) {
+ super(formFactory, parentElement, labelString, timePeriod, style);
}
- /**
- * <p>
- * setEntity
- * </p>
- *
- * @param timePeriod
- * a {@link eu.etaxonomy.cdm.model.common.TimePeriod} object.
- */
- public void setEntity(TimePeriod timePeriod) {
- setTimePeriod(timePeriod);
- }
-
- /** {@inheritDoc} */
@Override
- public void propertyChange(PropertyChangeEvent event) {
- if (event == null) {
- return;
- }
- Object eventSource = event.getSource();
-
- if (getElements().contains(eventSource)) {
- handleEvent(eventSource);
- }
- }
-
- private void handleEvent(Object eventSource) {
- if (eventSource == section_dateDetails) {
- timePeriod = section_dateDetails.getEntity();
- firePropertyChangeEvent(new CdmPropertyChangeEvent(this, null));
- }
- }
-
- /**
- * <p>
- * Setter for the field <code>timePeriod</code>.
- * </p>
- *
- * @param timePeriod
- * the timePeriod to set
- */
- public void setTimePeriod(TimePeriod timePeriod) {
- this.timePeriod = timePeriod;
- if (timePeriod != null) {
- section_dateDetails.setEntity(timePeriod);
- }
- }
-
- /**
- * <p>
- * Getter for the field <code>timePeriod</code>.
- * </p>
- *
- * @return the timePeriod
- */
- public TimePeriod getTimePeriod() {
- return timePeriod;
+ protected DateDetailSection<TimePeriod> createDateDetailSection() {
+ return formFactory.createDateDetailSection(this,
+ Section.TWISTIE);
}
- /** {@inheritDoc} */
- @Override
- public void setBackground(Color color) {
- label.setBackground(color);
- section_dateDetails.setBackground(color);
- }
-
- @Override
- public void setSelected(boolean selected) {
- setBackground(selected ? SELECTED : getPersistentBackground());
- }
- public void setLabel(String string) {
- label.setText(string);
- }
}