automated build configuration is on its way
[taxeditor.git] / 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.forms.CdmFormFactory;
19 import eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement;
20 import eu.etaxonomy.taxeditor.ui.forms.TextWithLabelElement;
21 import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.SelectionType;
22 import eu.etaxonomy.taxeditor.ui.selection.TaxonSelectionElement;
23
24 /**
25 * <p>TaxonInteractionDetailElement class.</p>
26 *
27 * @author n.hoffmann
28 * @created Jun 10, 2010
29 * @version 1.0
30 */
31 public class TaxonInteractionDetailElement extends AbstractDetailedDescriptionDetailElement<TaxonInteraction>{
32
33 private TaxonSelectionElement taxonSelection;
34 private TextWithLabelElement interactionDescription;
35
36 /**
37 * <p>Constructor for TaxonInteractionDetailElement.</p>
38 *
39 * @param formFactory a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory} object.
40 * @param formElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
41 * @param entity a {@link eu.etaxonomy.cdm.model.description.TaxonInteraction} object.
42 * @param style a int.
43 */
44 public TaxonInteractionDetailElement(CdmFormFactory formFactory,
45 ICdmFormElement formElement, TaxonInteraction entity, int style) {
46 super(formFactory, formElement, entity, style);
47 }
48
49 /** {@inheritDoc} */
50 @Override
51 protected void createControls(ICdmFormElement formElement,
52 TaxonInteraction entity, int style) {
53 taxonSelection = (TaxonSelectionElement) formFactory.createSelectionElement(SelectionType.TAXON, getConversationHolder(), this, null, entity.getTaxon2(), SWT.WRAP);
54
55 interactionDescription = formFactory.createMultilineTextWithLabel(this, "Description", 200, SWT.WRAP);
56 interactionDescription.setText(entity.getDescription(CdmStore.getDefaultLanguage()));
57 }
58
59
60 /** {@inheritDoc} */
61 @Override
62 public void handleEvent(Object eventSource) {
63 if(eventSource == taxonSelection){
64 getEntity().setTaxon2( (Taxon) taxonSelection.getEntity());
65 }else if(eventSource == interactionDescription){
66 getEntity().addDescription(interactionDescription.getText(), CdmStore.getDefaultLanguage());
67 }
68 }
69 }