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
.editor
.view
.detail
;
13 import org
.eclipse
.jface
.util
.IPropertyChangeListener
;
14 import org
.eclipse
.jface
.util
.PropertyChangeEvent
;
15 import org
.eclipse
.ui
.forms
.SectionPart
;
17 import eu
.etaxonomy
.cdm
.api
.facade
.DerivedUnitFacade
;
18 import eu
.etaxonomy
.cdm
.api
.facade
.DerivedUnitFacadeNotSupportedException
;
19 import eu
.etaxonomy
.cdm
.model
.occurrence
.DerivedUnitBase
;
20 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonBase
;
21 import eu
.etaxonomy
.taxeditor
.editor
.EditorUtil
;
22 import eu
.etaxonomy
.taxeditor
.editor
.name
.container
.AbstractGroupedContainer
;
23 import eu
.etaxonomy
.taxeditor
.forms
.AbstractFormSection
;
24 import eu
.etaxonomy
.taxeditor
.forms
.ICdmFormElement
;
25 import eu
.etaxonomy
.taxeditor
.preference
.PreferencesUtil
;
26 import eu
.etaxonomy
.taxeditor
.section
.ITaxonBaseDetailSection
;
27 import eu
.etaxonomy
.taxeditor
.section
.occurrence
.IDerivedUnitFacadeDetailSection
;
30 * <p>CdmSectionPart class.</p>
33 * @created Feb 8, 2010
36 public class CdmSectionPart
<T
> extends SectionPart
implements IPropertyChangeListener
{
38 private AbstractFormSection
<T
> formSection
;
41 * <p>Constructor for CdmSectionPart.</p>
43 * @param section a {@link eu.etaxonomy.taxeditor.forms.AbstractFormSection} object.
44 * @param <T> a T object.
46 public CdmSectionPart(AbstractFormSection
<T
> section
) {
48 formSection
= section
;
53 public boolean setFormInput(Object input
) {
54 if(input
instanceof AbstractGroupedContainer
){
55 input
= ((AbstractGroupedContainer
) input
).getData();
57 if((input
instanceof TaxonBase
) && (formSection
instanceof ITaxonBaseDetailSection
)){
58 ((ITaxonBaseDetailSection
) formSection
).setTaxonBase((TaxonBase
) input
);
61 if((input
instanceof DerivedUnitBase
) && (formSection
instanceof IDerivedUnitFacadeDetailSection
)){
64 input
= DerivedUnitFacade
.NewInstance((DerivedUnitBase
) input
, PreferencesUtil
.getDerivedUnitConfigurator());
65 } catch (DerivedUnitFacadeNotSupportedException e
) {
66 EditorUtil
.error(getClass(), e
);
70 formSection
.setEntity((T
) input
);
76 * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
79 public void propertyChange(PropertyChangeEvent event
) {
82 Object eventSource
= event
.getSource();
84 if(formSection
.equals(eventSource
)
85 || (eventSource
instanceof ICdmFormElement
&& formSection
.containsFormElement((ICdmFormElement
)eventSource
))){