1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2009 EDIT
|
4
|
* European Distributed Institute of Taxonomy
|
5
|
* http://www.e-taxonomy.eu
|
6
|
*
|
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.
|
9
|
*/
|
10
|
package eu.etaxonomy.taxeditor.ui.section.vocabulary;
|
11
|
|
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.element.CdmFormFactory;
|
18
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
19
|
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
|
20
|
import eu.etaxonomy.taxeditor.ui.element.UriWithLabelElement;
|
21
|
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
|
22
|
|
23
|
/**
|
24
|
* @author l.morris
|
25
|
* @date 20 Dec 2011
|
26
|
*
|
27
|
*/
|
28
|
public abstract class AbstractTermBaseDetailElement<T extends TermBase> extends AbstractCdmDetailElement<T> {
|
29
|
|
30
|
protected TextWithLabelElement text_label;
|
31
|
protected TextWithLabelElement text_description;
|
32
|
protected UriWithLabelElement uri_uri;
|
33
|
protected TextWithLabelElement text_abbreviatedLabel;
|
34
|
|
35
|
/**
|
36
|
* @param formFactory
|
37
|
* @param formElement
|
38
|
*/
|
39
|
public AbstractTermBaseDetailElement(CdmFormFactory formFactory,
|
40
|
ICdmFormElement formElement) {
|
41
|
super(formFactory, formElement);
|
42
|
}
|
43
|
|
44
|
/* (non-Javadoc)
|
45
|
* @see eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement#createControls(eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement, java.lang.Object, int)
|
46
|
*/
|
47
|
@Override
|
48
|
protected void createControls(ICdmFormElement formElement,
|
49
|
T entity, int style) {
|
50
|
Representation representation = getEntity().getRepresentation(CdmStore.getDefaultLanguage());
|
51
|
|
52
|
if(representation == null){
|
53
|
formFactory.createLabel(formElement, "No represantation for the current default Language");
|
54
|
return;
|
55
|
}
|
56
|
|
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);
|
62
|
|
63
|
}
|
64
|
|
65
|
@Override
|
66
|
public void setEntity(T entity) {
|
67
|
super.setEntity(entity);
|
68
|
setEnabled(TermBasePropertyTester.isModifiable(entity));
|
69
|
}
|
70
|
|
71
|
protected void handleRepresentation(Object eventSource){
|
72
|
T entity = getEntity();
|
73
|
Representation representation = entity.getRepresentation(CdmStore.getDefaultLanguage());
|
74
|
|
75
|
if (representation == null){
|
76
|
return;
|
77
|
}
|
78
|
|
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());
|
86
|
}
|
87
|
}
|
88
|
|
89
|
public abstract TermVocabulary getVocabulary();
|
90
|
|
91
|
}
|