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
.forms
;
13 import org
.eclipse
.jface
.util
.PropertyChangeEvent
;
14 import org
.joda
.time
.Partial
;
16 import eu
.etaxonomy
.cdm
.model
.common
.TimePeriod
;
19 * <p>DateDetailSection class.</p>
22 * @created Mar 31, 2010
25 public class DateDetailSection
extends AbstractFormSection
<TimePeriod
> {
27 private PartialElement partialElement_start
;
28 private PartialElement partialElement_end
;
31 * <p>Constructor for DateDetailSection.</p>
33 * @param formFactory a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory} object.
34 * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
37 protected DateDetailSection(CdmFormFactory formFactory
, ICdmFormElement parentElement
,
39 super(formFactory
, null, parentElement
, style
);
40 this.setText("Date Details");
42 partialElement_start
= formFactory
.createPartialElement(this, "Start: ", null, style
);
43 partialElement_end
= formFactory
.createPartialElement(this, "End: ", null, style
);
45 formFactory
.addPropertyChangeListener(this);
49 * <p>Setter for the field <code>timePeriod</code>.</p>
51 * @param timePeriod a {@link eu.etaxonomy.cdm.model.common.TimePeriod} object.
53 public void setEntity(TimePeriod timePeriod
) {
54 Partial start
= timePeriod
.getStart();
55 partialElement_start
.setPartial(start
);
56 Partial end
= timePeriod
.getEnd();
57 partialElement_end
.setPartial(end
);
59 super.setEntity(timePeriod
);
64 public void propertyChange(PropertyChangeEvent event
) {
68 Object eventSource
= event
.getSource();
70 if(getElements().contains(eventSource
)){
71 if(event
instanceof CdmPropertyChangeEvent
){
72 if(((CdmPropertyChangeEvent
) event
).hasException()){
73 handleException((CdmPropertyChangeEvent
) event
);
77 handleEvent(eventSource
);
84 private void handleException(CdmPropertyChangeEvent event
) {
85 firePropertyChangeEvent(new CdmPropertyChangeEvent(this, event
.getException()));
88 private void handleEvent(Object eventSource
){
89 if(eventSource
== partialElement_start
){
90 Partial start
= partialElement_start
.getPartial();
91 getEntity().setStart(start
);
92 }else if(eventSource
== partialElement_end
){
93 Partial end
= partialElement_end
.getPartial();
94 getEntity().setEnd(end
);
96 firePropertyChangeEvent(new CdmPropertyChangeEvent(this, null));
100 * @see eu.etaxonomy.taxeditor.forms.AbstractFormSection#dispose()
104 public void dispose() {
105 formFactory
.removePropertyChangeListener(this);