3 * Copyright (C) 2009 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.taxeditor
.ui
.section
.vocabulary
;
12 import org
.apache
.commons
.lang
.StringUtils
;
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
;
25 public class DefinedTermDetailElement
<T
extends DefinedTermBase
> extends AbstractTermBaseDetailElement
<T
> {
27 protected TextWithLabelElement textIdInVocabulary
;
29 protected TextWithLabelElement textSymbol
;
36 public DefinedTermDetailElement(CdmFormFactory formFactory
,
37 ICdmFormElement formElement
) {
38 super(formFactory
, formElement
);
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
);
49 * @see eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement#handleEvent(java.lang.Object)
52 public void handleEvent(Object eventSource
) {
53 handleRepresentation(eventSource
);
54 if(eventSource
==textIdInVocabulary
){
55 if (StringUtils
.isBlank(textIdInVocabulary
.getText())){
56 getEntity().setIdInVocabulary(null);
58 getEntity().setIdInVocabulary(textIdInVocabulary
.getText());
62 if(eventSource
==textSymbol
){
63 if (StringUtils
.isBlank(textSymbol
.getText())){
64 getEntity().setSymbol(null);
66 getEntity().setSymbol(textIdInVocabulary
.getText());
73 * @see eu.etaxonomy.taxeditor.ui.section.vocabulary.AbstractTermBaseDetailElement#getVocabularyMarkers()
76 public TermVocabulary
getVocabulary() {
77 return getEntity() != null ?
getEntity().getVocabulary() : null;