1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2007 EDIT
|
4
|
* European Distributed Institute of Taxonomy
|
5
|
* http://www.e-taxonomy.eu
|
6
|
*
|
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.
|
9
|
*/
|
10
|
|
11
|
package eu.etaxonomy.taxeditor.editor.view.detail;
|
12
|
|
13
|
import org.apache.log4j.Logger;
|
14
|
import org.eclipse.jface.util.IPropertyChangeListener;
|
15
|
import org.eclipse.jface.util.PropertyChangeEvent;
|
16
|
import org.eclipse.ui.forms.SectionPart;
|
17
|
|
18
|
import eu.etaxonomy.cdm.model.common.IVersionableEntity;
|
19
|
import eu.etaxonomy.cdm.model.common.VersionableEntity;
|
20
|
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
|
21
|
import eu.etaxonomy.taxeditor.editor.name.AbstractGroupedContainer;
|
22
|
import eu.etaxonomy.taxeditor.forms.AbstractFormSection;
|
23
|
import eu.etaxonomy.taxeditor.forms.ICdmFormElement;
|
24
|
import eu.etaxonomy.taxeditor.section.ITaxonDetailSection;
|
25
|
|
26
|
/**
|
27
|
* <p>CdmSectionPart class.</p>
|
28
|
*
|
29
|
* @author n.hoffmann
|
30
|
* @created Feb 8, 2010
|
31
|
* @version 1.0
|
32
|
*/
|
33
|
public class CdmSectionPart<T extends IVersionableEntity> extends SectionPart implements IPropertyChangeListener{
|
34
|
|
35
|
private static final Logger logger = Logger
|
36
|
.getLogger(CdmSectionPart.class);
|
37
|
|
38
|
private AbstractFormSection<T> formSection;
|
39
|
|
40
|
/**
|
41
|
* <p>Constructor for CdmSectionPart.</p>
|
42
|
*
|
43
|
* @param section a {@link eu.etaxonomy.taxeditor.forms.AbstractFormSection} object.
|
44
|
* @param <T> a T object.
|
45
|
*/
|
46
|
public CdmSectionPart(AbstractFormSection<T> section) {
|
47
|
super(section);
|
48
|
formSection = section;
|
49
|
}
|
50
|
|
51
|
/** {@inheritDoc} */
|
52
|
@Override
|
53
|
public boolean setFormInput(Object input) {
|
54
|
if(input instanceof AbstractGroupedContainer){
|
55
|
input = ((AbstractGroupedContainer) input).getData();
|
56
|
}
|
57
|
if(input instanceof IVersionableEntity){
|
58
|
logger.trace("Setting input for section: " + formSection.getClass().getSimpleName());
|
59
|
if((input instanceof TaxonBase) && (formSection instanceof ITaxonDetailSection)){
|
60
|
((ITaxonDetailSection) formSection).setTaxon((TaxonBase) input);
|
61
|
}else{
|
62
|
formSection.setEntity((T) input);
|
63
|
}
|
64
|
}
|
65
|
return super.setFormInput(input);
|
66
|
}
|
67
|
|
68
|
/* (non-Javadoc)
|
69
|
* @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
|
70
|
*/
|
71
|
/** {@inheritDoc} */
|
72
|
public void propertyChange(PropertyChangeEvent event) {
|
73
|
if (event != null){
|
74
|
|
75
|
Object eventSource = event.getSource();
|
76
|
|
77
|
if(eventSource instanceof ICdmFormElement){
|
78
|
if(formSection.containsFormElement((ICdmFormElement)eventSource)){
|
79
|
markDirty();
|
80
|
}
|
81
|
}
|
82
|
}
|
83
|
}
|
84
|
|
85
|
|
86
|
|
87
|
}
|