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
|
super.createControls(formElement, entity, style);
|
47
|
selection_derivedUnit = formFactory
|
48
|
.createSelectionElement(SpecimenOrObservationBase.class,
|
49
|
//getConversationHolder(),
|
50
|
formElement, "Occurrence/Unit",
|
51
|
CdmBase.deproxy(entity.getAssociatedSpecimenOrObservation(),SpecimenOrObservationBase.class),
|
52
|
EntitySelectionElement.ALL, style);
|
53
|
|
54
|
text_description = formFactory.createMultiLineTextWithLabel(
|
55
|
formElement, "Relationship to the unit:", 80, style);
|
56
|
Map<Language, LanguageString> descriptions = entity.getDescription();
|
57
|
|
58
|
if (descriptions.get(CdmStore.getDefaultLanguage()) != null) {
|
59
|
text_description.setText(descriptions.get(
|
60
|
CdmStore.getDefaultLanguage()).getText());
|
61
|
}
|
62
|
}
|
63
|
|
64
|
/** {@inheritDoc} */
|
65
|
@Override
|
66
|
public void handleEvent(Object eventSource) {
|
67
|
if (eventSource == selection_derivedUnit) {
|
68
|
getEntity().setAssociatedSpecimenOrObservation(
|
69
|
selection_derivedUnit.getEntity());
|
70
|
} else if (eventSource == text_description) {
|
71
|
getEntity().putDescription(CdmStore.getDefaultLanguage(), text_description.getText());
|
72
|
}
|
73
|
|
74
|
}
|
75
|
}
|