Project

General

Profile

« Previous | Next » 

Revision f561b00c

Added by Niels Hoffmann about 13 years ago

Refactoring selection elements so they can be configured

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/description/detail/IndividualsAssociationDetailElement.java
1 1
// $Id$
2 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
*/
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 10

  
11 11
package eu.etaxonomy.taxeditor.ui.section.description.detail;
12 12

  
......
19 19
import eu.etaxonomy.cdm.model.description.IndividualsAssociation;
20 20
import eu.etaxonomy.taxeditor.store.CdmStore;
21 21
import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory;
22
import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.SelectionType;
22 23
import eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement;
23 24
import eu.etaxonomy.taxeditor.ui.forms.TextWithLabelElement;
24
import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.SelectionType;
25 25
import eu.etaxonomy.taxeditor.ui.selection.DerivedUnitBaseSelectionElement;
26 26

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

  
36 39
	private static final Logger logger = Logger
37 40
			.getLogger(IndividualsAssociationDetailElement.class);
38 41
	private TextWithLabelElement text_description;
39 42
	private DerivedUnitBaseSelectionElement selection_derivedUnit;
40
	
43

  
41 44
	/**
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.
45
	 * <p>
46
	 * Constructor for IndividualsAssociationDetailElement.
47
	 * </p>
48
	 * 
49
	 * @param formFactory
50
	 *            a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory}
51
	 *            object.
52
	 * @param formElement
53
	 *            a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
54
	 *            object.
55
	 * @param entity
56
	 *            a
57
	 *            {@link eu.etaxonomy.cdm.model.description.IndividualsAssociation}
58
	 *            object.
59
	 * @param style
60
	 *            a int.
48 61
	 */
49 62
	public IndividualsAssociationDetailElement(CdmFormFactory formFactory,
50
			ICdmFormElement formElement, IndividualsAssociation entity, int style) {
63
			ICdmFormElement formElement, IndividualsAssociation entity,
64
			int style) {
51 65
		super(formFactory, formElement, entity, style);
52 66
	}
53 67

  
......
55 69
	@Override
56 70
	protected void createControls(ICdmFormElement formElement,
57 71
			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);
72
		selection_derivedUnit = (DerivedUnitBaseSelectionElement) formFactory
73
				.createSelectionElement(SelectionType.DERIVED_UNIT,
74
						getConversationHolder(), formElement, "Unit",
75
						entity.getAssociatedSpecimenOrObservation(),
76
						DerivedUnitBaseSelectionElement.DEFAULT, style);
77

  
78
		text_description = formFactory.createMultilineTextWithLabel(
79
				formElement, "Description", 200, style);
61 80
		Map<Language, LanguageString> descriptions = entity.getDescription();
62
		
63
		if(descriptions.get(CdmStore.getDefaultLanguage()) != null){
64
			text_description.setText(descriptions.get(CdmStore.getDefaultLanguage()).getText());
65
		}		
81

  
82
		if (descriptions.get(CdmStore.getDefaultLanguage()) != null) {
83
			text_description.setText(descriptions.get(
84
					CdmStore.getDefaultLanguage()).getText());
85
		}
66 86
	}
67 87

  
68 88
	/** {@inheritDoc} */
69 89
	@Override
70 90
	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());
91
		if (eventSource == selection_derivedUnit) {
92
			getEntity().setAssociatedSpecimenOrObservation(
93
					selection_derivedUnit.getEntity());
94
		} else if (eventSource == text_description) {
95
			getEntity().addDescription(text_description.getText(),
96
					CdmStore.getDefaultLanguage());
75 97
		}
76
		
98

  
77 99
	}
78 100
}

Also available in: Unified diff