Project

General

Profile

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

    
11
import eu.etaxonomy.cdm.model.common.Representation;
12
import eu.etaxonomy.cdm.model.common.TermType;
13
import eu.etaxonomy.cdm.model.location.NamedArea;
14
import eu.etaxonomy.cdm.model.location.NamedAreaLevel;
15
import eu.etaxonomy.cdm.model.location.NamedAreaType;
16
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
17
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
18
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
19
import eu.etaxonomy.taxeditor.ui.element.TimePeriodElement;
20

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

    
28
	// level
29
	// type
30
	private TermComboElement<NamedAreaType> combo_namedAreaType;
31
	private TermComboElement<NamedAreaLevel> combo_namedAreaLevel;
32
	// validPeriod
33
	private TimePeriodElement timePeriod_validPeriod;
34

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

    
44
	@Override
45
    public void createControls(ICdmFormElement formElement, NamedArea entity, int style) {
46
		super.createControls(formElement, entity, style);
47

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

    
52
	}
53

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

    
60
		if (eventSource == textIdInVocabulary){
61
			getEntity().setIdInVocabulary(textIdInVocabulary.getText());
62
		} else if (eventSource == element_Representation) {
63
			Representation selectedRepresentation = element_Representation.getSelectedRepresentation();
64
			if(selectedRepresentation!=null){
65
			    getEntity().setLabel(selectedRepresentation.getLabel(),  selectedRepresentation.getLanguage());
66
			    getEntity().getRepresentation(selectedRepresentation.getLanguage()).setAbbreviatedLabel(selectedRepresentation.getAbbreviatedLabel());
67
			    getEntity().getRepresentation(selectedRepresentation.getLanguage()).setText(selectedRepresentation.getDescription());
68
			}
69
			getEntity().setTitleCache(null);
70
		} else if (eventSource == uri_uri) {
71
			getEntity().setUri(uri_uri.parseText());
72
		} else if (eventSource == timePeriod_validPeriod) {
73
			getEntity().setValidPeriod(timePeriod_validPeriod.getTimePeriod());
74
		} else if (eventSource == combo_namedAreaType) {
75
			getEntity().setType(combo_namedAreaType.getSelection());
76
		} else if (eventSource == combo_namedAreaLevel) {
77
			getEntity().setLevel(combo_namedAreaLevel.getSelection());
78
		}
79

    
80

    
81
	}
82

    
83

    
84
}
(7-7/19)