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
.Representation
;
13 import eu
.etaxonomy
.cdm
.model
.common
.TermBase
;
14 import eu
.etaxonomy
.cdm
.model
.common
.TermVocabulary
;
15 import eu
.etaxonomy
.taxeditor
.editor
.definedterm
.TermBasePropertyTester
;
16 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
17 import eu
.etaxonomy
.taxeditor
.ui
.campanula
.compatibility
.ICdmFormElement
;
18 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
19 import eu
.etaxonomy
.taxeditor
.ui
.element
.TextWithLabelElement
;
20 import eu
.etaxonomy
.taxeditor
.ui
.element
.UriWithLabelElement
;
21 import eu
.etaxonomy
.taxeditor
.ui
.section
.AbstractCdmDetailElement
;
28 public abstract class AbstractTermBaseDetailElement
<T
extends TermBase
> extends AbstractCdmDetailElement
<T
> {
30 protected TextWithLabelElement text_label
;
31 protected TextWithLabelElement text_description
;
32 protected UriWithLabelElement uri_uri
;
33 protected TextWithLabelElement text_abbreviatedLabel
;
39 public AbstractTermBaseDetailElement(CdmFormFactory formFactory
,
40 ICdmFormElement formElement
) {
41 super(formFactory
, formElement
);
45 * @see eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement#createControls(eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement, java.lang.Object, int)
48 protected void createControls(ICdmFormElement formElement
,
49 T entity
, int style
) {
50 Representation representation
= getEntity().getRepresentation(CdmStore
.getDefaultLanguage());
52 if(representation
== null){
53 formFactory
.createLabel(formElement
, "No represantation for the current default Language");
57 text_label
= formFactory
.createTextWithLabelElement(formElement
, "Label", representation
.getLabel(), style
);
58 text_abbreviatedLabel
= formFactory
.createTextWithLabelElement(formElement
, "Abbrev. Label", representation
.getAbbreviatedLabel(), style
);
59 text_description
= formFactory
.createMultilineTextWithLabel(formElement
, "Description", 100, style
);
60 text_description
.setText(representation
.getDescription());
61 uri_uri
= formFactory
.createUriWithLabelElement(formElement
, "URI", getEntity().getUri(), style
);
66 public void setEntity(T entity
) {
67 super.setEntity(entity
);
68 setEnabled(TermBasePropertyTester
.isModifiable(entity
));
71 protected void handleRepresentation(Object eventSource
){
72 T entity
= getEntity();
73 Representation representation
= entity
.getRepresentation(CdmStore
.getDefaultLanguage());
75 if (representation
== null){
79 if (eventSource
== text_label
){
80 representation
.setLabel(text_label
.getText());
81 entity
.setLabel(text_label
.getText());
82 }else if (eventSource
== text_abbreviatedLabel
){
83 representation
.setAbbreviatedLabel(text_abbreviatedLabel
.getText());
84 }else if (eventSource
== text_description
){
85 representation
.setText(text_description
.getText());
89 public abstract TermVocabulary
getVocabulary();