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
.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
.model
.IElementHasDetails
;
22 import eu
.etaxonomy
.taxeditor
.model
.PolytomousKeyRelationship
;
23 import eu
.etaxonomy
.taxeditor
.preference
.PreferencesUtil
;
24 import eu
.etaxonomy
.taxeditor
.store
.StoreUtil
;
25 import eu
.etaxonomy
.taxeditor
.ui
.element
.AbstractCdmFormElement
;
26 import eu
.etaxonomy
.taxeditor
.ui
.element
.AbstractFormSection
;
27 import eu
.etaxonomy
.taxeditor
.ui
.section
.ITaxonBaseDetailSection
;
28 import eu
.etaxonomy
.taxeditor
.ui
.section
.occurrence
.IDerivedUnitFacadeDetailSection
;
32 * CdmSectionPart class.
36 * @created Feb 8, 2010
39 public class CdmSectionPart
<T
> extends SectionPart
implements
40 IPropertyChangeListener
{
42 private final AbstractFormSection
<T
> formSection
;
46 * Constructor for CdmSectionPart.
50 * a {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection}
55 public CdmSectionPart(AbstractFormSection
<T
> section
) {
57 formSection
= section
;
62 public boolean setFormInput(Object input
) {
63 if (input
instanceof IElementHasDetails
) {
64 input
= ((IElementHasDetails
) input
).getData();
66 if ((input
instanceof TaxonBase
)
67 && (formSection
instanceof ITaxonBaseDetailSection
)) {
68 ((ITaxonBaseDetailSection
) formSection
)
69 .setTaxonBase((TaxonBase
) input
);
72 if ((input
instanceof DerivedUnitBase
)
73 && (formSection
instanceof IDerivedUnitFacadeDetailSection
)) {
76 input
= DerivedUnitFacade
.NewInstance((DerivedUnitBase
) input
,
77 PreferencesUtil
.getDerivedUnitConfigurator());
78 } catch (DerivedUnitFacadeNotSupportedException e
) {
79 StoreUtil
.error(getClass(), e
);
82 if (input
instanceof PolytomousKeyRelationship
) {
83 input
= ((PolytomousKeyRelationship
) input
).getDestination();
86 formSection
.setEntity((T
) input
);
95 * org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse
96 * .jface.util.PropertyChangeEvent)
100 public void propertyChange(PropertyChangeEvent event
) {
103 Object eventSource
= event
.getSource();
105 if (formSection
.equals(eventSource
)){
109 (eventSource
instanceof AbstractCdmFormElement
)
110 && formSection
.containsFormElement((AbstractCdmFormElement
) eventSource
))