Project

General

Profile

Download (2.5 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 org.apache.commons.lang.StringUtils;
12

    
13
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
14
import eu.etaxonomy.cdm.model.common.TermVocabulary;
15
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
16
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
17
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
18

    
19
/**
20
 * @author l.morris
21
 * @date 20 Dec 2011
22
 *
23
 */
24
public class DefinedTermDetailElement<T extends DefinedTermBase> extends AbstractTermBaseDetailElement<T> {
25

    
26
    protected TextWithLabelElement textIdInVocabulary;
27

    
28
    protected TextWithLabelElement textSymbol;
29

    
30

    
31
	/**
32
	 * @param formFactory
33
	 * @param formElement
34
	 */
35
	public DefinedTermDetailElement(CdmFormFactory formFactory,
36
			ICdmFormElement formElement) {
37
		super(formFactory, formElement);
38
	}
39

    
40
	@Override
41
    protected void createControls(ICdmFormElement formElement, T entity, int style) {
42
	    super.createControls(formElement, entity, style);
43
	    textIdInVocabulary = formFactory.createTextWithLabelElement(formElement, "ID in vocabulary", entity.getIdInVocabulary(), style);
44
	    textSymbol = formFactory.createTextWithLabelElement(formElement, "Symbol", entity.getSymbol(), style);
45
	};
46

    
47
	/* (non-Javadoc)
48
	 * @see eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement#handleEvent(java.lang.Object)
49
	 */
50
	@Override
51
	public void handleEvent(Object eventSource) {
52
	    super.handleEvent(eventSource);
53
		//handleRepresentation(eventSource);
54
		if(eventSource==textIdInVocabulary){
55
			if (StringUtils.isBlank(textIdInVocabulary.getText())){
56
				getEntity().setIdInVocabulary(null);
57
			}else{
58
				getEntity().setIdInVocabulary(textIdInVocabulary.getText());
59
			}
60

    
61
		}
62
		if(eventSource==textSymbol){
63
            if (StringUtils.isBlank(textSymbol.getText())){
64
                getEntity().setSymbol(null);
65
            }else{
66
                getEntity().setSymbol(textSymbol.getText());
67
            }
68

    
69
        }
70
	}
71

    
72
	/* (non-Javadoc)
73
	 * @see eu.etaxonomy.taxeditor.ui.section.vocabulary.AbstractTermBaseDetailElement#getVocabularyMarkers()
74
	 */
75
	@Override
76
	public TermVocabulary getVocabulary() {
77
		return getEntity() != null ? getEntity().getVocabulary() : null;
78
	}
79

    
80
}
(2-2/19)