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
|
package eu.etaxonomy.taxeditor.ui.section.description.detail;
|
10
|
|
11
|
import java.util.Map;
|
12
|
|
13
|
import eu.etaxonomy.cdm.model.common.CdmBase;
|
14
|
import eu.etaxonomy.cdm.model.common.Language;
|
15
|
import eu.etaxonomy.cdm.model.common.LanguageString;
|
16
|
import eu.etaxonomy.cdm.model.description.IndividualsAssociation;
|
17
|
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
|
18
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
19
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
20
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
21
|
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
|
22
|
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
|
23
|
|
24
|
/**
|
25
|
* @author n.hoffmann
|
26
|
* @created Jun 10, 2010
|
27
|
*/
|
28
|
public class IndividualsAssociationDetailElement extends
|
29
|
AbstractDetailedDescriptionDetailElement<IndividualsAssociation> {
|
30
|
|
31
|
private TextWithLabelElement text_description;
|
32
|
private EntitySelectionElement<SpecimenOrObservationBase> selection_derivedUnit;
|
33
|
|
34
|
public IndividualsAssociationDetailElement(CdmFormFactory formFactory,
|
35
|
ICdmFormElement formElement, IndividualsAssociation entity, boolean enabled,
|
36
|
int style) {
|
37
|
super(formFactory, formElement, entity, enabled, style);
|
38
|
}
|
39
|
|
40
|
@Override
|
41
|
protected void createControls(ICdmFormElement formElement,
|
42
|
IndividualsAssociation entity, int style) {
|
43
|
|
44
|
selection_derivedUnit = formFactory
|
45
|
.createSelectionElement(SpecimenOrObservationBase.class,
|
46
|
formElement, "Occurrence/Unit",
|
47
|
CdmBase.deproxy(entity.getAssociatedSpecimenOrObservation(),SpecimenOrObservationBase.class),
|
48
|
EntitySelectionElement.ALL, style);
|
49
|
|
50
|
text_description = formFactory.createMultiLineTextWithLabel(
|
51
|
formElement, "Relationship to the unit:", 80, style);
|
52
|
Map<Language, LanguageString> descriptions = entity.getDescription();
|
53
|
|
54
|
if (descriptions.get(CdmStore.getDefaultLanguage()) != null) {
|
55
|
text_description.setText(descriptions.get(
|
56
|
CdmStore.getDefaultLanguage()).getText());
|
57
|
}
|
58
|
|
59
|
createTimePeriod(formElement, entity, style);
|
60
|
if (entity.getFeature().getRecommendedModifierEnumeration() != null && !entity.getFeature().getRecommendedModifierEnumeration().isEmpty()){
|
61
|
createModifier(formElement, entity, style);
|
62
|
}else{
|
63
|
createFreetextModifier(formElement, entity, style);
|
64
|
}
|
65
|
}
|
66
|
|
67
|
@Override
|
68
|
public void handleEvent(Object eventSource) {
|
69
|
super.handleEvent(eventSource);
|
70
|
if (eventSource == selection_derivedUnit) {
|
71
|
getEntity().setAssociatedSpecimenOrObservation(
|
72
|
selection_derivedUnit.getEntity());
|
73
|
} else if (eventSource == text_description) {
|
74
|
getEntity().putDescription(CdmStore.getDefaultLanguage(), text_description.getText());
|
75
|
}
|
76
|
}
|
77
|
|
78
|
@Override
|
79
|
public void fillFields() {
|
80
|
if (getEntity()!= null) {
|
81
|
super.fillFields();
|
82
|
if (getEntity().getDescription() != null && getEntity().getDescription().get(CdmStore.getDefaultLanguage()) != null) {
|
83
|
text_description.setText(getEntity().getDescription().get(
|
84
|
CdmStore.getDefaultLanguage()).getText());
|
85
|
}
|
86
|
selection_derivedUnit.setEntity(getEntity().getAssociatedSpecimenOrObservation());
|
87
|
}
|
88
|
|
89
|
}
|
90
|
}
|