dc61752d6f974a62e4fcd126e4515a40fcd1cb04
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / description / detail / IndividualsAssociationDetailElement.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 java.util.Map;
14
15 import eu.etaxonomy.cdm.model.common.CdmBase;
16 import eu.etaxonomy.cdm.model.common.Language;
17 import eu.etaxonomy.cdm.model.common.LanguageString;
18 import eu.etaxonomy.cdm.model.description.IndividualsAssociation;
19 import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
20 import eu.etaxonomy.taxeditor.store.CdmStore;
21 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
22 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
23 import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
24 import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
25
26 /**
27 * <p>
28 * IndividualsAssociationDetailElement class.
29 * </p>
30 *
31 * @author n.hoffmann
32 * @created Jun 10, 2010
33 * @version 1.0
34 */
35 public class IndividualsAssociationDetailElement extends
36 AbstractDetailedDescriptionDetailElement<IndividualsAssociation> {
37
38 private TextWithLabelElement text_description;
39 private EntitySelectionElement<DerivedUnit> selection_derivedUnit;
40
41 /**
42 * <p>
43 * Constructor for IndividualsAssociationDetailElement.
44 * </p>
45 *
46 * @param formFactory
47 * a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
48 * object.
49 * @param formElement
50 * a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
51 * object.
52 * @param entity
53 * a
54 * {@link eu.etaxonomy.cdm.model.description.IndividualsAssociation}
55 * object.
56 * @param style
57 * a int.
58 */
59 public IndividualsAssociationDetailElement(CdmFormFactory formFactory,
60 ICdmFormElement formElement, IndividualsAssociation entity,
61 int style) {
62 super(formFactory, formElement, entity, style);
63 }
64
65 /** {@inheritDoc} */
66 @Override
67 protected void createControls(ICdmFormElement formElement,
68 IndividualsAssociation entity, int style) {
69 selection_derivedUnit = formFactory
70 .createSelectionElement(DerivedUnit.class,
71 getConversationHolder(), formElement, "Unit",
72 CdmBase.deproxy(entity.getAssociatedSpecimenOrObservation(),DerivedUnit.class),
73 EntitySelectionElement.ALL, style);
74
75 text_description = formFactory.createMultiLineTextWithLabel(
76 formElement, "Description for taxon - individual association", 200, style);
77 Map<Language, LanguageString> descriptions = entity.getDescription();
78
79 if (descriptions.get(CdmStore.getDefaultLanguage()) != null) {
80 text_description.setText(descriptions.get(
81 CdmStore.getDefaultLanguage()).getText());
82 }
83 }
84
85 /** {@inheritDoc} */
86 @Override
87 public void handleEvent(Object eventSource) {
88 if (eventSource == selection_derivedUnit) {
89 getEntity().setAssociatedSpecimenOrObservation(
90 selection_derivedUnit.getEntity());
91 } else if (eventSource == text_description) {
92 getEntity().putDescription(CdmStore.getDefaultLanguage(), text_description.getText());
93 }
94
95 }
96 }