2 * Copyright (C) 2009 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.taxeditor
.ui
.section
.vocabulary
;
11 import org
.eclipse
.swt
.widgets
.Button
;
13 import eu
.etaxonomy
.cdm
.model
.common
.Language
;
14 import eu
.etaxonomy
.cdm
.model
.term
.Representation
;
15 import eu
.etaxonomy
.cdm
.model
.term
.TermBase
;
16 import eu
.etaxonomy
.cdm
.model
.term
.TermVocabulary
;
17 import eu
.etaxonomy
.taxeditor
.editor
.definedterm
.TermBasePropertyTester
;
18 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
19 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
20 import eu
.etaxonomy
.taxeditor
.ui
.element
.ICdmFormElement
;
21 import eu
.etaxonomy
.taxeditor
.ui
.element
.RepresentationElement
;
22 import eu
.etaxonomy
.taxeditor
.ui
.element
.UriWithLabelElement
;
23 import eu
.etaxonomy
.taxeditor
.ui
.section
.AbstractCdmDetailElement
;
30 public abstract class AbstractTermBaseDetailElement
<T
extends TermBase
> extends AbstractCdmDetailElement
<T
> {
32 protected UriWithLabelElement uri_uri
;
33 protected RepresentationElement element_Representation
;
34 private Button button
;
37 public AbstractTermBaseDetailElement(CdmFormFactory formFactory
,
38 ICdmFormElement formElement
) {
39 super(formFactory
, formElement
);
43 protected void createControls(ICdmFormElement formElement
,
44 T entity
, int style
) {
45 element_Representation
= formFactory
.createTranslatableRepresentationElement(formElement
, getEntity().getPreferredRepresentation(CdmStore
.getDefaultLanguage()),getEntity(), 100, style
, true);
46 uri_uri
= formFactory
.createUriWithLabelElement(formElement
, "URI", getEntity().getUri(), style
);
50 public void setEntity(T entity
) {
51 super.setEntity(entity
);
52 setEnabled(TermBasePropertyTester
.isModifiable(entity
));
56 public void handleEvent(Object eventSource
) {
57 if (eventSource
== uri_uri
) {
58 getEntity().setUri(uri_uri
.parseText());
60 else if (eventSource
== element_Representation
) {
61 Representation selectedRepresentation
= element_Representation
.getSelectedRepresentation();
62 if(selectedRepresentation
!=null){
63 Language representationLanguage
= selectedRepresentation
.getLanguage();
64 if(representationLanguage
==null){
65 representationLanguage
= Language
.getDefaultLanguage();
67 getEntity().setLabel(selectedRepresentation
.getLabel(), representationLanguage
);
68 getEntity().getRepresentation(representationLanguage
).setAbbreviatedLabel(selectedRepresentation
.getAbbreviatedLabel());
69 getEntity().getRepresentation(representationLanguage
).setText(selectedRepresentation
.getDescription());
71 getEntity().setTitleCache(null);
75 public abstract TermVocabulary
getVocabulary();