(no commit message)
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / vocabulary / DefinedTermDetailElement.java
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 /**
30 * @param formFactory
31 * @param formElement
32 */
33 public DefinedTermDetailElement(CdmFormFactory formFactory,
34 ICdmFormElement formElement) {
35 super(formFactory, formElement);
36 }
37
38 @Override
39 protected void createControls(ICdmFormElement formElement, T entity, int style) {
40 super.createControls(formElement, entity, style);
41 textIdInVocabulary = formFactory.createTextWithLabelElement(formElement, "ID in vocabulary", entity.getIdInVocabulary(), style);
42 };
43
44 /* (non-Javadoc)
45 * @see eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement#handleEvent(java.lang.Object)
46 */
47 @Override
48 public void handleEvent(Object eventSource) {
49 handleRepresentation(eventSource);
50 if(eventSource==textIdInVocabulary){
51 if (StringUtils.isBlank(textIdInVocabulary.getText())){
52 getEntity().setIdInVocabulary(null);
53 }else{
54 getEntity().setIdInVocabulary(textIdInVocabulary.getText());
55 }
56
57 }
58 }
59
60 /* (non-Javadoc)
61 * @see eu.etaxonomy.taxeditor.ui.section.vocabulary.AbstractTermBaseDetailElement#getVocabularyMarkers()
62 */
63 @Override
64 public TermVocabulary getVocabulary() {
65 return getEntity() != null ? getEntity().getVocabulary() : null;
66 }
67
68 }