Project

General

Profile

Download (3.01 KB) Statistics
| Branch: | Tag: | Revision:
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 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.DerivedUnitBase;
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
 * IndividualsAssociationDetailElement class.
28
 * </p>
29
 * 
30
 * @author n.hoffmann
31
 * @created Jun 10, 2010
32
 * @version 1.0
33
 */
34
public class IndividualsAssociationDetailElement extends
35
		AbstractDetailedDescriptionDetailElement<IndividualsAssociation> {
36

    
37
	private TextWithLabelElement text_description;
38
	private EntitySelectionElement<DerivedUnitBase> selection_derivedUnit;
39

    
40
	/**
41
	 * <p>
42
	 * Constructor for IndividualsAssociationDetailElement.
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
53
	 *            {@link eu.etaxonomy.cdm.model.description.IndividualsAssociation}
54
	 *            object.
55
	 * @param style
56
	 *            a int.
57
	 */
58
	public IndividualsAssociationDetailElement(CdmFormFactory formFactory,
59
			ICdmFormElement formElement, IndividualsAssociation entity,
60
			int style) {
61
		super(formFactory, formElement, entity, style);
62
	}
63

    
64
	/** {@inheritDoc} */
65
	@Override
66
	protected void createControls(ICdmFormElement formElement,
67
			IndividualsAssociation entity, int style) {
68
		selection_derivedUnit = formFactory
69
				.createSelectionElement(DerivedUnitBase.class,
70
						getConversationHolder(), formElement, "Unit",
71
						(DerivedUnitBase) entity.getAssociatedSpecimenOrObservation(),
72
						EntitySelectionElement.ALL, style);
73

    
74
		text_description = formFactory.createMultilineTextWithLabel(
75
				formElement, "Description", 200, style);
76
		Map<Language, LanguageString> descriptions = entity.getDescription();
77

    
78
		if (descriptions.get(CdmStore.getDefaultLanguage()) != null) {
79
			text_description.setText(descriptions.get(
80
					CdmStore.getDefaultLanguage()).getText());
81
		}
82
	}
83

    
84
	/** {@inheritDoc} */
85
	@Override
86
	public void handleEvent(Object eventSource) {
87
		if (eventSource == selection_derivedUnit) {
88
			getEntity().setAssociatedSpecimenOrObservation(
89
					selection_derivedUnit.getEntity());
90
		} else if (eventSource == text_description) {
91
			getEntity().putDescription(CdmStore.getDefaultLanguage(), text_description.getText());
92
		}
93

    
94
	}
95
}
(5-5/8)