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 eu
.etaxonomy
.cdm
.model
.common
.Language
;
13 import eu
.etaxonomy
.cdm
.model
.common
.Representation
;
14 import eu
.etaxonomy
.cdm
.model
.common
.TermBase
;
15 import eu
.etaxonomy
.cdm
.model
.common
.TermVocabulary
;
16 import eu
.etaxonomy
.taxeditor
.editor
.definedterm
.TermBasePropertyTester
;
17 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
18 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
19 import eu
.etaxonomy
.taxeditor
.ui
.element
.ICdmFormElement
;
20 import eu
.etaxonomy
.taxeditor
.ui
.element
.TextWithLabelElement
;
21 import eu
.etaxonomy
.taxeditor
.ui
.element
.UriWithLabelElement
;
22 import eu
.etaxonomy
.taxeditor
.ui
.section
.AbstractCdmDetailElement
;
29 public abstract class AbstractTermBaseDetailElement
<T
extends TermBase
> extends AbstractCdmDetailElement
<T
> {
31 protected TextWithLabelElement text_label
;
32 protected TextWithLabelElement text_description
;
33 protected UriWithLabelElement uri_uri
;
34 protected TextWithLabelElement text_abbreviatedLabel
;
40 public AbstractTermBaseDetailElement(CdmFormFactory formFactory
,
41 ICdmFormElement formElement
) {
42 super(formFactory
, formElement
);
46 * @see eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement#createControls(eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement, java.lang.Object, int)
49 protected void createControls(ICdmFormElement formElement
,
50 T entity
, int style
) {
52 Representation representation
= getEntity().getRepresentation(CdmStore
.getDefaultLanguage());
54 if(representation
== null){
55 //formFactory.createLabel(formElement, "No represantation for the current default Language, english version is used.");
56 representation
= getEntity().getRepresentation(Language
.ENGLISH());
59 text_label
= formFactory
.createTextWithLabelElement(formElement
, "Label", representation
.getLabel(), style
);
60 text_abbreviatedLabel
= formFactory
.createTextWithLabelElement(formElement
, "Abbrev. Label", representation
.getAbbreviatedLabel(), style
);
61 text_description
= formFactory
.createMultilineTextWithLabel(formElement
, "Description", 100, style
);
62 text_description
.setText(representation
.getDescription());
63 uri_uri
= formFactory
.createUriWithLabelElement(formElement
, "URI", getEntity().getUri(), style
);
68 public void setEntity(T entity
) {
69 super.setEntity(entity
);
70 setEnabled(TermBasePropertyTester
.isModifiable(entity
));
73 protected void handleRepresentation(Object eventSource
){
74 T entity
= getEntity();
75 Representation representation
= entity
.getRepresentation(CdmStore
.getDefaultLanguage());
77 if (representation
== null){
81 if (eventSource
== text_label
){
82 representation
.setLabel(text_label
.getText());
83 entity
.setLabel(text_label
.getText());
84 }else if (eventSource
== text_abbreviatedLabel
){
85 representation
.setAbbreviatedLabel(text_abbreviatedLabel
.getText());
86 }else if (eventSource
== text_description
){
87 representation
.setText(text_description
.getText());
91 public abstract TermVocabulary
getVocabulary();