Project

General

Profile

Download (2.81 KB) Statistics
| Branch: | Tag: | Revision:
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

    
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
		createTimePeriod(formElement, entity, style);
64
		if (entity.getFeature().getRecommendedModifierEnumeration() != null){
65
            createModifier(formElement, entity, style);
66
        }
67
	}
68

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

    
80
	}
81
}
(5-5/8)