Merge branch 'develop' into LibrAlign
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / vocabulary / DefinedTermDetailElement.java
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 //handleRepresentation(eventSource);
53 if(eventSource==textIdInVocabulary){
54 if (StringUtils.isBlank(textIdInVocabulary.getText())){
55 getEntity().setIdInVocabulary(null);
56 }else{
57 getEntity().setIdInVocabulary(textIdInVocabulary.getText());
58 }
59
60 }
61 if(eventSource==textSymbol){
62 if (StringUtils.isBlank(textSymbol.getText())){
63 getEntity().setSymbol(null);
64 }else{
65 getEntity().setSymbol(textSymbol.getText());
66 }
67
68 }
69 }
70
71 /* (non-Javadoc)
72 * @see eu.etaxonomy.taxeditor.ui.section.vocabulary.AbstractTermBaseDetailElement#getVocabularyMarkers()
73 */
74 @Override
75 public TermVocabulary getVocabulary() {
76 return getEntity() != null ? getEntity().getVocabulary() : null;
77 }
78
79 }