Project

General

Profile

Download (2.61 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 org.eclipse.swt.SWT;
14

    
15
import eu.etaxonomy.cdm.model.common.Language;
16
import eu.etaxonomy.cdm.model.description.CommonTaxonName;
17
import eu.etaxonomy.cdm.model.location.NamedArea;
18
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
19
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
20
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
21
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
22
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
23

    
24
/**
25
 * <p>CommonNameDetailElement class.</p>
26
 *
27
 * @author n.hoffmann
28
 * @created Jun 10, 2010
29
 * @version 1.0
30
 */
31
public class CommonNameDetailElement extends AbstractDetailedDescriptionDetailElement<CommonTaxonName> {
32
	
33
	private TermComboElement<Language> combo_language;
34
	private EntitySelectionElement<NamedArea> selection_namedArea;
35
	private TextWithLabelElement commonName;
36

    
37
	
38
	/**
39
	 * <p>Constructor for CommonNameDetailElement.</p>
40
	 *
41
	 * @param formFactory a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object.
42
	 * @param formElement a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} object.
43
	 * @param entity a {@link eu.etaxonomy.cdm.model.description.CommonTaxonName} object.
44
	 * @param style a int.
45
	 */
46
	public CommonNameDetailElement(CdmFormFactory formFactory,
47
			ICdmFormElement formElement, CommonTaxonName entity, int style) {
48
		super(formFactory, formElement, entity, style);
49
	}
50
	
51
	/** {@inheritDoc} */
52
	@Override
53
	protected void createControls(ICdmFormElement formElement,
54
			CommonTaxonName entity, int style) {
55
		commonName = formFactory.createTextWithLabelElement(this, "Common Name", entity.getName(), SWT.WRAP);
56

    
57
		combo_language = formFactory.createTermComboElement(Language.class, this, "Language", entity.getLanguage(), style);
58

    
59
		selection_namedArea = formFactory.createSelectionElement(NamedArea.class, getConversationHolder(),
60
				formElement, "Area",
61
				entity.getArea(), EntitySelectionElement.NOTHING, style);
62
	}
63

    
64
	/** {@inheritDoc} */
65
	@Override
66
	public void handleEvent(Object eventSource) {
67
		if(eventSource == combo_language){
68
			getEntity().setLanguage(combo_language.getSelection());
69
		}else if(eventSource == selection_namedArea){
70
			getEntity().setArea(selection_namedArea.getEntity());
71
		}else if(eventSource == commonName){
72
			getEntity().setName(commonName.getText());
73
		}
74
	}
75

    
76
}
(3-3/8)