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 protected void createControls(ICdmFormElement formElement
,
47 T entity
, int style
) {
49 Representation representation
= getEntity().getPreferredRepresentation(CdmStore
.getDefaultLanguage());
51 text_label
= formFactory
.createTextWithLabelElement(formElement
, "Label", representation
.getLabel(), style
);
52 text_abbreviatedLabel
= formFactory
.createTextWithLabelElement(formElement
, "Abbrev. Label", representation
.getAbbreviatedLabel(), style
);
53 text_description
= formFactory
.createMultilineTextWithLabel(formElement
, "Description", 100, style
);
54 text_description
.setText(representation
.getDescription());
55 uri_uri
= formFactory
.createUriWithLabelElement(formElement
, "URI", getEntity().getUri(), style
);
60 public void setEntity(T entity
) {
61 super.setEntity(entity
);
62 setEnabled(TermBasePropertyTester
.isModifiable(entity
));
65 protected void handleRepresentation(Object eventSource
){
66 T entity
= getEntity();
67 Representation representation
= entity
.getRepresentation(CdmStore
.getDefaultLanguage());
69 if (representation
== null){
73 if (eventSource
== text_label
){
74 representation
.setLabel(text_label
.getText());
75 entity
.setLabel(text_label
.getText());
76 }else if (eventSource
== text_abbreviatedLabel
){
77 representation
.setAbbreviatedLabel(text_abbreviatedLabel
.getText());
78 }else if (eventSource
== text_description
){
79 representation
.setText(text_description
.getText());
83 public abstract TermVocabulary
getVocabulary();