Project

General

Profile

Download (3.25 KB) Statistics
| Branch: | Tag: | Revision:
1
// $Id$
2
/**
3
* Copyright (C) 2009 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
package eu.etaxonomy.taxeditor.ui.section.vocabulary;
11

    
12
import java.net.URISyntaxException;
13

    
14
import eu.etaxonomy.cdm.model.common.Language;
15
import eu.etaxonomy.cdm.model.common.TermType;
16
import eu.etaxonomy.cdm.model.location.NamedArea;
17
import eu.etaxonomy.cdm.model.location.NamedAreaLevel;
18
import eu.etaxonomy.cdm.model.location.NamedAreaType;
19
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
20
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
21
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
22
import eu.etaxonomy.taxeditor.ui.element.TimePeriodElement;
23

    
24
/**
25
 * @author l.morris
26
 * @date 20 Dec 2011
27
 *
28
 */
29
public class NamedAreaDetailElement extends DefinedTermDetailElement<NamedArea> {
30

    
31
	// level
32
	// type
33
	private TermComboElement<NamedAreaType> combo_namedAreaType;
34
	private TermComboElement<NamedAreaLevel> combo_namedAreaLevel;
35
	// validPeriod
36
	private TimePeriodElement timePeriod_validPeriod;
37

    
38
	/**
39
	 * @param formFactory
40
	 * @param formElement
41
	 */
42
	public NamedAreaDetailElement(CdmFormFactory formFactory,
43
			ICdmFormElement formElement) {
44
		super(formFactory, formElement);
45
	}
46

    
47
	@Override
48
    public void createControls(ICdmFormElement formElement, NamedArea entity, int style) {
49
		super.createControls(formElement, entity, style);
50

    
51
		timePeriod_validPeriod = formFactory.createTimePeriodElement(formElement, "Valid Period", getEntity().getValidPeriod(), style);
52
		combo_namedAreaType = formFactory.createDefinedTermComboElement(TermType.NamedAreaType, formElement, "Named Area Type", getEntity().getType(), style);
53
		combo_namedAreaLevel = formFactory.createDefinedTermComboElement(TermType.NamedAreaLevel, formElement, "Named Area Level", getEntity().getLevel(), style);
54

    
55
	}
56

    
57
	/* (non-Javadoc)
58
	 * @see eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement#handleEvent(java.lang.Object)
59
	 */
60
	@Override
61
	public void handleEvent(Object eventSource) {
62

    
63
		if (eventSource == textIdInVocabulary){
64
			getEntity().setIdInVocabulary(textIdInVocabulary.getText());
65
		} else if (eventSource == text_label) {
66
			getEntity().setLabel(text_label.getText());
67
			getEntity().setTitleCache(null);
68
		} else if (eventSource == text_description) {
69

    
70
			getEntity().getRepresentation(Language.getDefaultLanguage()).setText(text_description.getText());
71

    
72
		} else if (eventSource == uri_uri) {
73

    
74
			try {
75
				getEntity().setUri(uri_uri.getUri());
76
			} catch (URISyntaxException e) {
77

    
78
				e.printStackTrace();
79
			}
80
		} else if (eventSource == text_abbreviatedLabel) {
81
			getEntity().getRepresentation(Language.getDefaultLanguage()).setAbbreviatedLabel(text_abbreviatedLabel.getText());
82
		} else if (eventSource == timePeriod_validPeriod) {
83
			getEntity().setValidPeriod(timePeriod_validPeriod.getTimePeriod());
84
		} else if (eventSource == combo_namedAreaType) {
85
			getEntity().setType(combo_namedAreaType.getSelection());
86
		} else if (eventSource == combo_namedAreaLevel) {
87
			getEntity().setLevel(combo_namedAreaLevel.getSelection());
88
		}
89

    
90

    
91
	}
92

    
93

    
94
}
(5-5/9)