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.TaxonInteraction;
|
18
|
import eu.etaxonomy.cdm.model.taxon.Taxon;
|
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
|
* <p>
|
27
|
* TaxonInteractionDetailElement class.
|
28
|
* </p>
|
29
|
*
|
30
|
* @author n.hoffmann
|
31
|
* @created Jun 10, 2010
|
32
|
* @version 1.0
|
33
|
*/
|
34
|
public class TaxonInteractionDetailElement extends
|
35
|
AbstractDetailedDescriptionDetailElement<TaxonInteraction> {
|
36
|
|
37
|
private EntitySelectionElement<Taxon> taxonSelection;
|
38
|
private TextWithLabelElement interactionDescription;
|
39
|
|
40
|
/**
|
41
|
* <p>
|
42
|
* Constructor for TaxonInteractionDetailElement.
|
43
|
* </p>
|
44
|
*
|
45
|
* @param formFactory
|
46
|
* a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
|
47
|
* object.
|
48
|
* @param formElement
|
49
|
* a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
|
50
|
* object.
|
51
|
* @param entity
|
52
|
* a {@link eu.etaxonomy.cdm.model.description.TaxonInteraction}
|
53
|
* object.
|
54
|
* @param style
|
55
|
* a int.
|
56
|
*/
|
57
|
public TaxonInteractionDetailElement(CdmFormFactory formFactory,
|
58
|
ICdmFormElement formElement, TaxonInteraction entity, int style) {
|
59
|
super(formFactory, formElement, entity, style);
|
60
|
}
|
61
|
|
62
|
/** {@inheritDoc} */
|
63
|
@Override
|
64
|
protected void createControls(ICdmFormElement formElement,
|
65
|
TaxonInteraction entity, int style) {
|
66
|
|
67
|
taxonSelection = formFactory
|
68
|
.createSelectionElement(Taxon.class,//getConversationHolder(),
|
69
|
formElement, "Taxon",
|
70
|
CdmBase.deproxy(entity.getTaxon2(),Taxon.class),
|
71
|
EntitySelectionElement.ALL, style);
|
72
|
|
73
|
interactionDescription = formFactory.createMultiLineTextWithLabel(
|
74
|
formElement, "Relationship to the unit:", 200, style);
|
75
|
Map<Language, LanguageString> descriptions = entity.getDescription();
|
76
|
|
77
|
if (descriptions.get(CdmStore.getDefaultLanguage()) != null) {
|
78
|
interactionDescription.setText(descriptions.get(
|
79
|
CdmStore.getDefaultLanguage()).getText());
|
80
|
}
|
81
|
createTimePeriod(formElement, entity, style);
|
82
|
createModifier(formElement, entity, style);
|
83
|
}
|
84
|
|
85
|
/** {@inheritDoc} */
|
86
|
@Override
|
87
|
public void handleEvent(Object eventSource) {
|
88
|
super.handleEvent(eventSource);
|
89
|
if (eventSource == taxonSelection) {
|
90
|
getEntity().setTaxon2(taxonSelection.getEntity());
|
91
|
} else if (eventSource == interactionDescription) {
|
92
|
getEntity().putDescription(CdmStore.getDefaultLanguage(), interactionDescription.getText());
|
93
|
}
|
94
|
}
|
95
|
}
|