Project

General

Profile

Download (2.96 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 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.store.CdmStore;
21
import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory;
22
import eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement;
23
import eu.etaxonomy.taxeditor.ui.forms.TextWithLabelElement;
24
import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.SelectionType;
25
import eu.etaxonomy.taxeditor.ui.selection.DerivedUnitBaseSelectionElement;
26

    
27
/**
28
 * <p>IndividualsAssociationDetailElement class.</p>
29
 *
30
 * @author n.hoffmann
31
 * @created Jun 10, 2010
32
 * @version 1.0
33
 */
34
public class IndividualsAssociationDetailElement extends AbstractDetailedDescriptionDetailElement<IndividualsAssociation>{
35

    
36
	private static final Logger logger = Logger
37
			.getLogger(IndividualsAssociationDetailElement.class);
38
	private TextWithLabelElement text_description;
39
	private DerivedUnitBaseSelectionElement selection_derivedUnit;
40
	
41
	/**
42
	 * <p>Constructor for IndividualsAssociationDetailElement.</p>
43
	 *
44
	 * @param formFactory a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory} object.
45
	 * @param formElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
46
	 * @param entity a {@link eu.etaxonomy.cdm.model.description.IndividualsAssociation} object.
47
	 * @param style a int.
48
	 */
49
	public IndividualsAssociationDetailElement(CdmFormFactory formFactory,
50
			ICdmFormElement formElement, IndividualsAssociation entity, int style) {
51
		super(formFactory, formElement, entity, style);
52
	}
53

    
54
	/** {@inheritDoc} */
55
	@Override
56
	protected void createControls(ICdmFormElement formElement,
57
			IndividualsAssociation entity, int style) {
58
		selection_derivedUnit = (DerivedUnitBaseSelectionElement) formFactory.createSelectionElement(SelectionType.DERIVED_UNIT, getConversationHolder(), formElement, "Unit", entity.getAssociatedSpecimenOrObservation(), style);
59
		
60
		text_description = formFactory.createMultilineTextWithLabel(formElement, "Description", 200, style);
61
		Map<Language, LanguageString> descriptions = entity.getDescription();
62
		
63
		if(descriptions.get(CdmStore.getDefaultLanguage()) != null){
64
			text_description.setText(descriptions.get(CdmStore.getDefaultLanguage()).getText());
65
		}		
66
	}
67

    
68
	/** {@inheritDoc} */
69
	@Override
70
	public void handleEvent(Object eventSource) {
71
		if(eventSource == selection_derivedUnit){
72
			getEntity().setAssociatedSpecimenOrObservation(selection_derivedUnit.getEntity());
73
		}else if(eventSource == text_description){
74
			getEntity().addDescription(text_description.getText(), CdmStore.getDefaultLanguage());
75
		}
76
		
77
	}
78
}
(5-5/8)