ref #6190 removing svn property place holder in first line of code - java files
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / description / detail / IndividualsAssociationDetailElement.java
1 /**
2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
8 */
9
10 package eu.etaxonomy.taxeditor.ui.section.description.detail;
11
12 import java.util.Map;
13
14 import eu.etaxonomy.cdm.model.common.CdmBase;
15 import eu.etaxonomy.cdm.model.common.Language;
16 import eu.etaxonomy.cdm.model.common.LanguageString;
17 import eu.etaxonomy.cdm.model.description.IndividualsAssociation;
18 import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
19 import eu.etaxonomy.taxeditor.store.CdmStore;
20 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
21 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
22 import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
23 import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
24
25 /**
26 * @author n.hoffmann
27 * @created Jun 10, 2010
28 * @version 1.0
29 */
30 public class IndividualsAssociationDetailElement extends
31 AbstractDetailedDescriptionDetailElement<IndividualsAssociation> {
32
33 private TextWithLabelElement text_description;
34 private EntitySelectionElement<SpecimenOrObservationBase> selection_derivedUnit;
35
36 public IndividualsAssociationDetailElement(CdmFormFactory formFactory,
37 ICdmFormElement formElement, IndividualsAssociation entity,
38 int style) {
39 super(formFactory, formElement, entity, style);
40 }
41
42 /** {@inheritDoc} */
43 @Override
44 protected void createControls(ICdmFormElement formElement,
45 IndividualsAssociation entity, int style) {
46 selection_derivedUnit = formFactory
47 .createSelectionElement(SpecimenOrObservationBase.class,
48 getConversationHolder(), formElement, "Occurrence/Unit",
49 CdmBase.deproxy(entity.getAssociatedSpecimenOrObservation(),SpecimenOrObservationBase.class),
50 EntitySelectionElement.ALL, style);
51
52 text_description = formFactory.createMultiLineTextWithLabel(
53 formElement, "Relationship to the unit:", 200, style);
54 Map<Language, LanguageString> descriptions = entity.getDescription();
55
56 if (descriptions.get(CdmStore.getDefaultLanguage()) != null) {
57 text_description.setText(descriptions.get(
58 CdmStore.getDefaultLanguage()).getText());
59 }
60 }
61
62 /** {@inheritDoc} */
63 @Override
64 public void handleEvent(Object eventSource) {
65 if (eventSource == selection_derivedUnit) {
66 getEntity().setAssociatedSpecimenOrObservation(
67 selection_derivedUnit.getEntity());
68 } else if (eventSource == text_description) {
69 getEntity().putDescription(CdmStore.getDefaultLanguage(), text_description.getText());
70 }
71
72 }
73 }