implementation and generalization of a form framework to be used in the tabbed proper...
[taxeditor.git] / taxeditor-editor / src / main / java / eu / etaxonomy / taxeditor / editor / descriptiontree / detailpage / TaxonInteractionDetailsSection.java
1 /**
2 *
3 */
4 package eu.etaxonomy.taxeditor.editor.descriptiontree.detailpage;
5
6 import org.eclipse.jface.util.PropertyChangeEvent;
7 import org.eclipse.swt.SWT;
8 import org.eclipse.swt.widgets.Composite;
9
10 import eu.etaxonomy.cdm.model.description.Feature;
11 import eu.etaxonomy.cdm.model.description.TaxonInteraction;
12 import eu.etaxonomy.cdm.model.taxon.Taxon;
13 import eu.etaxonomy.taxeditor.forms.MultilineTextWithLabel;
14 import eu.etaxonomy.taxeditor.forms.selectioncomposites.TaxonSelectionComposite;
15 import eu.etaxonomy.taxeditor.store.CdmStore;
16
17 /**
18 * @author nho
19 *
20 */
21 public class TaxonInteractionDetailsSection extends
22 AbstractDescriptionDetailSection{
23
24 private TaxonSelectionComposite taxonSelection;
25 private MultilineTextWithLabel interactionDescription;
26
27 /**
28 * @param parent
29 * @param page
30 * @param sectionStyle
31 */
32 public TaxonInteractionDetailsSection(Composite parent,
33 AbstractDescriptionDetailsPage page, int sectionStyle) {
34 super(parent, page, sectionStyle);
35
36 taxonSelection = toolkit.createTaxonSelectionComposite(getClient(), null, SWT.WRAP);
37 taxonSelection.addPropertyChangeListener(this);
38
39 interactionDescription = toolkit.createMultilineTextWithLabel(getClient(), "Description", 200, SWT.WRAP);
40 interactionDescription.addPropertyChangeListener(this);
41 }
42
43 /* (non-Javadoc)
44 * @see eu.etaxonomy.taxeditor.editor.descriptiontree.detailpage.AbstractDescriptionDetailSection#updateSection()
45 */
46 @Override
47 public void updateSection() {
48 Feature feature = getDescriptionElement().getFeature();
49 this.setText(feature.getLabel() + " Details"); //$NON-NLS-1$
50
51 taxonSelection.setSelection(getTaxonInteraction().getTaxon2());
52 interactionDescription.setText(getTaxonInteraction().getDescription(CdmStore.getDefaultLanguage()));
53 }
54
55 /* (non-Javadoc)
56 * @see eu.etaxonomy.taxeditor.editor.descriptiontree.detailpage.AbstractDescriptionDetailSection#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
57 */
58 @Override
59 public void propertyChange(PropertyChangeEvent event) {
60 super.propertyChange(event);
61 getTaxonInteraction().addDescription(interactionDescription.getText(), CdmStore.getDefaultLanguage());
62 getTaxonInteraction().setTaxon2((Taxon) taxonSelection.getSelection());
63 }
64
65 public TaxonInteraction getTaxonInteraction(){
66 return (TaxonInteraction) getDescriptionElement();
67 }
68
69 }