// $Id$
/**
-* Copyright (C) 2007 EDIT
-* 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.
-*/
+ * Copyright (C) 2007 EDIT
+ * 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.forms;
import eu.etaxonomy.cdm.model.common.TimePeriod;
/**
- * <p>TimePeriodElement class.</p>
- *
+ * <p>
+ * TimePeriodElement class.
+ * </p>
+ *
* @author n.hoffmann
* @created Nov 17, 2009
* @version 1.0
*/
-public class TimePeriodElement extends AbstractCdmFormElement{
+public class TimePeriodElement extends AbstractCdmFormElement {
private TimePeriod timePeriod;
- private Label label;
- private DateDetailSection section_dateDetails;
-
+ 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.forms.CdmFormFactory} object.
- * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
- * @param labelString a {@link java.lang.String} object.
- * @param timePeriod a {@link eu.etaxonomy.cdm.model.common.TimePeriod} object.
+ * <p>
+ * Constructor for TimePeriodElement.
+ * </p>
+ *
+ * @param style
+ * a int.
+ * @param formFactory
+ * a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory}
+ * object.
+ * @param parentElement
+ * a {@link eu.etaxonomy.taxeditor.ui.forms.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) {
+ public TimePeriodElement(CdmFormFactory formFactory,
+ ICdmFormElement parentElement, String labelString,
+ TimePeriod timePeriod, final int style) {
super(formFactory, parentElement);
label = formFactory.createLabel(getLayoutComposite(), labelString);
-
- section_dateDetails = formFactory.createDateDetailSection(this, Section.TWISTIE);
+ addControl(label);
+
+ section_dateDetails = formFactory.createDateDetailSection(this,
+ Section.TWISTIE);
addControl(section_dateDetails);
-
+
setTimePeriod(timePeriod);
-
+
formFactory.addPropertyChangeListener(this);
}
/** {@inheritDoc} */
+ @Override
public void setSelected(boolean selected) {
setBackground(getColor(selected));
}
/**
- * <p>setEntity</p>
- *
- * @param timePeriod a {@link eu.etaxonomy.cdm.model.common.TimePeriod} object.
+ * <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){
+ if (event == null) {
return;
}
Object eventSource = event.getSource();
-
- if(getElements().contains(eventSource)){
+
+ if (getElements().contains(eventSource)) {
handleEvent(eventSource);
}
}
-
- private void handleEvent(Object eventSource){
-
-// if(eventSource == text_freeText){
-// String freeText = text_freeText.getText();
-// timePeriod = TimePeriod.parseString(freeText);
-// section_dateDetails.setEntity(timePeriod);
-//
- if(eventSource == section_dateDetails){
+
+ private void handleEvent(Object eventSource) {
+
+ // if(eventSource == text_freeText){
+ // String freeText = text_freeText.getText();
+ // timePeriod = TimePeriod.parseString(freeText);
+ // section_dateDetails.setEntity(timePeriod);
+ //
+ if (eventSource == section_dateDetails) {
firePropertyChangeEvent(new CdmPropertyChangeEvent(this, null));
}
-
-
+
}
/**
- * <p>Setter for the field <code>timePeriod</code>.</p>
- *
- * @param timePeriod the timePeriod to set
+ * <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){
+ if (timePeriod != null) {
section_dateDetails.setEntity(timePeriod);
}
}
/**
- * <p>Getter for the field <code>timePeriod</code>.</p>
- *
+ * <p>
+ * Getter for the field <code>timePeriod</code>.
+ * </p>
+ *
* @return the timePeriod
*/
public TimePeriod getTimePeriod() {
return timePeriod;
}
-
+
/** {@inheritDoc} */
@Override
public void setBackground(Color color) {