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 org.apache.log4j.Logger;
|
16
|
|
17
|
import eu.etaxonomy.cdm.model.common.Language;
|
18
|
import eu.etaxonomy.cdm.model.common.LanguageString;
|
19
|
import eu.etaxonomy.cdm.model.description.IndividualsAssociation;
|
20
|
import eu.etaxonomy.taxeditor.singlesource.ui.forms.TextWithLabelElementFacade;
|
21
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
22
|
import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory;
|
23
|
import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.SelectionType;
|
24
|
import eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement;
|
25
|
import eu.etaxonomy.taxeditor.ui.selection.DerivedUnitBaseSelectionElement;
|
26
|
|
27
|
/**
|
28
|
* <p>
|
29
|
* IndividualsAssociationDetailElement class.
|
30
|
* </p>
|
31
|
*
|
32
|
* @author n.hoffmann
|
33
|
* @created Jun 10, 2010
|
34
|
* @version 1.0
|
35
|
*/
|
36
|
public class IndividualsAssociationDetailElement extends
|
37
|
AbstractDetailedDescriptionDetailElement<IndividualsAssociation> {
|
38
|
|
39
|
private static final Logger logger = Logger
|
40
|
.getLogger(IndividualsAssociationDetailElement.class);
|
41
|
private TextWithLabelElementFacade text_description;
|
42
|
private DerivedUnitBaseSelectionElement selection_derivedUnit;
|
43
|
|
44
|
/**
|
45
|
* <p>
|
46
|
* Constructor for IndividualsAssociationDetailElement.
|
47
|
* </p>
|
48
|
*
|
49
|
* @param formFactory
|
50
|
* a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory}
|
51
|
* object.
|
52
|
* @param formElement
|
53
|
* a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
|
54
|
* object.
|
55
|
* @param entity
|
56
|
* a
|
57
|
* {@link eu.etaxonomy.cdm.model.description.IndividualsAssociation}
|
58
|
* object.
|
59
|
* @param style
|
60
|
* a int.
|
61
|
*/
|
62
|
public IndividualsAssociationDetailElement(CdmFormFactory formFactory,
|
63
|
ICdmFormElement formElement, IndividualsAssociation entity,
|
64
|
int style) {
|
65
|
super(formFactory, formElement, entity, style);
|
66
|
}
|
67
|
|
68
|
/** {@inheritDoc} */
|
69
|
@Override
|
70
|
protected void createControls(ICdmFormElement formElement,
|
71
|
IndividualsAssociation entity, int style) {
|
72
|
selection_derivedUnit = (DerivedUnitBaseSelectionElement) formFactory
|
73
|
.createSelectionElement(SelectionType.DERIVED_UNIT,
|
74
|
getConversationHolder(), formElement, "Unit",
|
75
|
entity.getAssociatedSpecimenOrObservation(),
|
76
|
DerivedUnitBaseSelectionElement.DEFAULT, style);
|
77
|
|
78
|
text_description = formFactory.createMultilineTextWithLabel(
|
79
|
formElement, "Description", 200, style);
|
80
|
Map<Language, LanguageString> descriptions = entity.getDescription();
|
81
|
|
82
|
if (descriptions.get(CdmStore.getDefaultLanguage()) != null) {
|
83
|
text_description.setText(descriptions.get(
|
84
|
CdmStore.getDefaultLanguage()).getText());
|
85
|
}
|
86
|
}
|
87
|
|
88
|
/** {@inheritDoc} */
|
89
|
@Override
|
90
|
public void handleEvent(Object eventSource) {
|
91
|
if (eventSource == selection_derivedUnit) {
|
92
|
getEntity().setAssociatedSpecimenOrObservation(
|
93
|
selection_derivedUnit.getEntity());
|
94
|
} else if (eventSource == text_description) {
|
95
|
getEntity().addDescription(text_description.getText(),
|
96
|
CdmStore.getDefaultLanguage());
|
97
|
}
|
98
|
|
99
|
}
|
100
|
}
|