// $Id$
/**
* Copyright (C) 2007 EDIT
- * European Distributed Institute of Taxonomy
+ * 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.
*/
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacadeNotSupportedException;
-import eu.etaxonomy.cdm.model.occurrence.DerivedUnitBase;
+import eu.etaxonomy.cdm.model.description.PolytomousKeyNode;
+import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
import eu.etaxonomy.taxeditor.model.IElementHasDetails;
import eu.etaxonomy.taxeditor.model.PolytomousKeyRelationship;
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
import eu.etaxonomy.taxeditor.store.StoreUtil;
-import eu.etaxonomy.taxeditor.ui.forms.AbstractCdmFormElement;
-import eu.etaxonomy.taxeditor.ui.forms.AbstractFormSection;
-import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
+import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
+import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
import eu.etaxonomy.taxeditor.ui.section.ITaxonBaseDetailSection;
+import eu.etaxonomy.taxeditor.ui.section.key.GeographicalScopeDetailSection;
+import eu.etaxonomy.taxeditor.ui.section.key.PolytomousKeyDetailSection;
+import eu.etaxonomy.taxeditor.ui.section.key.ScopeRestrictionSection;
+import eu.etaxonomy.taxeditor.ui.section.key.TaxonomicScopeSection;
import eu.etaxonomy.taxeditor.ui.section.occurrence.IDerivedUnitFacadeDetailSection;
/**
* <p>
* CdmSectionPart class.
* </p>
- *
+ *
* @author n.hoffmann
* @created Feb 8, 2010
* @version 1.0
* <p>
* Constructor for CdmSectionPart.
* </p>
- *
+ *
* @param section
- * a {@link eu.etaxonomy.taxeditor.ui.forms.AbstractFormSection}
+ * a {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection}
* object.
* @param <T>
* a T object.
/** {@inheritDoc} */
@Override
public boolean setFormInput(Object input) {
+ //FIXME (CM): Need to fix this part of the design.
+ //The design seems to be locked to the idea that only one
+ // entity (either from the navigator or the editor) drives
+ // the detail view. In the case of multiple inputs the only workaround
+ // is checking the type and extracting relevant objects.
if (input instanceof IElementHasDetails) {
input = ((IElementHasDetails) input).getData();
}
.setTaxonBase((TaxonBase) input);
return true;
}
- if ((input instanceof DerivedUnitBase)
+ else if (input.getClass().equals(DerivedUnit.class)
&& (formSection instanceof IDerivedUnitFacadeDetailSection)) {
try {
- input = DerivedUnitFacade.NewInstance((DerivedUnitBase) input,
+ input = DerivedUnitFacade.NewInstance((DerivedUnit) input,
PreferencesUtil.getDerivedUnitConfigurator());
} catch (DerivedUnitFacadeNotSupportedException e) {
StoreUtil.error(getClass(), e);
}
}
- if (input instanceof PolytomousKeyRelationship) {
+ else if (input instanceof PolytomousKeyRelationship) {
input = ((PolytomousKeyRelationship) input).getDestination();
}
+ else if ((input instanceof PolytomousKeyNode) &&
+ (formSection instanceof PolytomousKeyDetailSection ||
+ formSection instanceof GeographicalScopeDetailSection ||
+ formSection instanceof ScopeRestrictionSection ||
+ formSection instanceof TaxonomicScopeSection)) {
+ input = ((PolytomousKeyNode)input).getKey();
+ }
+
+
formSection.setEntity((T) input);
return true;
/*
* (non-Javadoc)
- *
+ *
* @see
* org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse
* .jface.util.PropertyChangeEvent)
public void propertyChange(PropertyChangeEvent event) {
if (event != null) {
- Object eventSource = event.getSource();
-
+ Object eventSource = event.getSource();
+
if (formSection.equals(eventSource)){
markDirty();
}
if((
- (eventSource instanceof AbstractCdmFormElement)
- && formSection.containsFormElement((AbstractCdmFormElement) eventSource))
+ (eventSource instanceof ICdmFormElement)
+ && formSection.containsFormElement((ICdmFormElement) eventSource))
) {
markDirty();
}