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
.description
.PolytomousKeyNode
;
20 import eu
.etaxonomy
.cdm
.model
.occurrence
.DerivedUnit
;
21 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonBase
;
22 import eu
.etaxonomy
.taxeditor
.model
.IElementHasDetails
;
23 import eu
.etaxonomy
.taxeditor
.model
.PolytomousKeyRelationship
;
24 import eu
.etaxonomy
.taxeditor
.preference
.PreferencesUtil
;
25 import eu
.etaxonomy
.taxeditor
.store
.StoreUtil
;
26 import eu
.etaxonomy
.taxeditor
.ui
.campanula
.compatibility
.ICdmFormElement
;
27 import eu
.etaxonomy
.taxeditor
.ui
.element
.AbstractFormSection
;
28 import eu
.etaxonomy
.taxeditor
.ui
.section
.ITaxonBaseDetailSection
;
29 import eu
.etaxonomy
.taxeditor
.ui
.section
.key
.GeographicalScopeDetailSection
;
30 import eu
.etaxonomy
.taxeditor
.ui
.section
.key
.PolytomousKeyDetailSection
;
31 import eu
.etaxonomy
.taxeditor
.ui
.section
.key
.ScopeRestrictionSection
;
32 import eu
.etaxonomy
.taxeditor
.ui
.section
.key
.TaxonomicScopeSection
;
33 import eu
.etaxonomy
.taxeditor
.ui
.section
.occurrence
.IDerivedUnitFacadeDetailSection
;
37 * CdmSectionPart class.
41 * @created Feb 8, 2010
44 public class CdmSectionPart
<T
> extends SectionPart
implements
45 IPropertyChangeListener
{
47 private final AbstractFormSection
<T
> formSection
;
51 * Constructor for CdmSectionPart.
55 * a {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection}
60 public CdmSectionPart(AbstractFormSection
<T
> section
) {
62 formSection
= section
;
67 public boolean setFormInput(Object input
) {
68 //FIXME (CM): Need to fix this part of the design.
69 //The design seems to be locked to the idea that only one
70 // entity (either from the navigator or the editor) drives
71 // the detail view. In the case of multiple inputs the only workaround
72 // is checking the type and extracting relevant objects.
73 if (input
instanceof IElementHasDetails
) {
74 input
= ((IElementHasDetails
) input
).getData();
76 if ((input
instanceof TaxonBase
)
77 && (formSection
instanceof ITaxonBaseDetailSection
)) {
78 ((ITaxonBaseDetailSection
) formSection
)
79 .setTaxonBase((TaxonBase
) input
);
82 if ((input
instanceof DerivedUnit
)
83 && (formSection
instanceof IDerivedUnitFacadeDetailSection
)) {
86 input
= DerivedUnitFacade
.NewInstance((DerivedUnit
) input
,
87 PreferencesUtil
.getDerivedUnitConfigurator());
88 } catch (DerivedUnitFacadeNotSupportedException e
) {
89 StoreUtil
.error(getClass(), e
);
92 if (input
instanceof PolytomousKeyRelationship
) {
93 input
= ((PolytomousKeyRelationship
) input
).getDestination();
96 if ((input
instanceof PolytomousKeyNode
) &&
97 (formSection
instanceof PolytomousKeyDetailSection
||
98 formSection
instanceof GeographicalScopeDetailSection
||
99 formSection
instanceof ScopeRestrictionSection
||
100 formSection
instanceof TaxonomicScopeSection
)) {
101 input
= ((PolytomousKeyNode
)input
).getKey();
105 formSection
.setEntity((T
) input
);
114 * org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse
115 * .jface.util.PropertyChangeEvent)
119 public void propertyChange(PropertyChangeEvent event
) {
122 Object eventSource
= event
.getSource();
124 if (formSection
.equals(eventSource
)){
128 (eventSource
instanceof ICdmFormElement
)
129 && formSection
.containsFormElement((ICdmFormElement
) eventSource
))