Project

General

Profile

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

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

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

    
27
    protected TextWithLabelElement textIdInVocabulary;
28

    
29
    protected TextWithLabelElement textSymbol;
30

    
31

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

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

    
48
	/* (non-Javadoc)
49
	 * @see eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement#handleEvent(java.lang.Object)
50
	 */
51
	@Override
52
	public void handleEvent(Object 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)