11faf245cd4c00de7abb43ca4a00673a52425063
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / description / detail / TaxonInteractionDetailElement.java
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.ui.section.description.detail;
12
13 import org.eclipse.swt.SWT;
14
15 import eu.etaxonomy.cdm.model.description.TaxonInteraction;
16 import eu.etaxonomy.cdm.model.taxon.Taxon;
17 import eu.etaxonomy.taxeditor.store.CdmStore;
18 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
19 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
20 import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
21 import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
22
23 /**
24 * <p>
25 * TaxonInteractionDetailElement class.
26 * </p>
27 *
28 * @author n.hoffmann
29 * @created Jun 10, 2010
30 * @version 1.0
31 */
32 public class TaxonInteractionDetailElement extends
33 AbstractDetailedDescriptionDetailElement<TaxonInteraction> {
34
35 private EntitySelectionElement<Taxon> taxonSelection;
36 private TextWithLabelElement interactionDescription;
37
38 /**
39 * <p>
40 * Constructor for TaxonInteractionDetailElement.
41 * </p>
42 *
43 * @param formFactory
44 * a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
45 * object.
46 * @param formElement
47 * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
48 * object.
49 * @param entity
50 * a {@link eu.etaxonomy.cdm.model.description.TaxonInteraction}
51 * object.
52 * @param style
53 * a int.
54 */
55 public TaxonInteractionDetailElement(CdmFormFactory formFactory,
56 ICdmFormElement formElement, TaxonInteraction entity, int style) {
57 super(formFactory, formElement, entity, style);
58 }
59
60 /** {@inheritDoc} */
61 @Override
62 protected void createControls(ICdmFormElement formElement,
63 TaxonInteraction entity, int style) {
64 taxonSelection = formFactory
65 .createSelectionElement(Taxon.class,
66 getConversationHolder(), this, "Taxon",
67 entity.getTaxon2(), EntitySelectionElement.NOTHING,
68 SWT.WRAP);
69
70 interactionDescription = formFactory.createMultiLineTextWithLabel(this,
71 "Description for the taxon - taxon interaction", 200, SWT.WRAP);
72 interactionDescription.setText(entity.getDescription(CdmStore
73 .getDefaultLanguage()));
74 }
75
76 /** {@inheritDoc} */
77 @Override
78 public void handleEvent(Object eventSource) {
79 if (eventSource == taxonSelection) {
80 getEntity().setTaxon2(taxonSelection.getEntity());
81 } else if (eventSource == interactionDescription) {
82 getEntity().putDescription(CdmStore.getDefaultLanguage(), interactionDescription.getText());
83 }
84 }
85 }