Project

General

Profile

Download (2.54 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.agent;
12

    
13
import eu.etaxonomy.cdm.model.agent.Institution;
14
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
15
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
16
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
17
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
18
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
19

    
20
/**
21
 * @author n.hoffmann
22
 * @created Dec 15, 2010
23
 * @version 1.0
24
 */
25
public class InstitutionDetailElement extends
26
		AbstractCdmDetailElement<Institution> {
27

    
28
	private TextWithLabelElement text_name;
29

    
30
	private TextWithLabelElement text_code;
31

    
32
	// private InstitutionTypeSection section_institutionTypes;
33

    
34
	private EntitySelectionElement<Institution> selection_partOfInstitution;
35

    
36
	/**
37
	 * @param formFactory
38
	 * @param formElement
39
	 */
40
	public InstitutionDetailElement(CdmFormFactory formFactory,
41
			ICdmFormElement formElement) {
42
		super(formFactory, formElement);
43
	}
44

    
45
	/*
46
	 * (non-Javadoc)
47
	 * 
48
	 * @see
49
	 * eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#createControls
50
	 * (eu.etaxonomy.taxeditor.forms.ICdmFormElement, java.lang.Object, int)
51
	 */
52
	@Override
53
	protected void createControls(ICdmFormElement formElement,
54
			Institution entity, int style) {
55
		text_name = formFactory.createTextWithLabelElement(formElement, "Name",
56
				entity.getName(), style);
57
		text_code = formFactory.createTextWithLabelElement(formElement, "Code",
58
				entity.getCode(), style);
59
		// section_institutionTypes
60
		selection_partOfInstitution = formFactory
61
				.createSelectionElement(Institution.class,
62
						getConversationHolder(), formElement, "Is Part Of",
63
						entity.getIsPartOf(),
64
						EntitySelectionElement.EDITABLE | EntitySelectionElement.SELECTABLE | EntitySelectionElement.DELETABLE, 
65
						style);
66
	}
67

    
68
	/*
69
	 * (non-Javadoc)
70
	 * 
71
	 * @see
72
	 * eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#handleEvent(java
73
	 * .lang.Object)
74
	 */
75
	@Override
76
	public void handleEvent(Object eventSource) {
77
		if (eventSource == text_name) {
78
			getEntity().setName(text_name.getText());
79
		} else if (eventSource == text_code) {
80
			getEntity().setCode(text_code.getText());
81
		} else if (eventSource == selection_partOfInstitution) {
82
			getEntity().setIsPartOf(selection_partOfInstitution.getSelection());
83
		}
84
	}
85

    
86
}
(1-1/12)