Project

General

Profile

Download (3.02 KB) Statistics
| Branch: | Tag: | Revision:
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.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;
23

    
24
/**
25
 * @author l.morris
26
 * @date 20 Dec 2011
27
 *
28
 */
29
public abstract class AbstractTermBaseDetailElement<T extends TermBase> extends AbstractCdmDetailElement<T> {
30

    
31
	protected TextWithLabelElement text_label;
32
	protected TextWithLabelElement text_description;
33
	protected UriWithLabelElement uri_uri;
34
	protected TextWithLabelElement text_abbreviatedLabel;
35
	
36
	/**
37
	 * @param formFactory
38
	 * @param formElement
39
	 */
40
	public AbstractTermBaseDetailElement(CdmFormFactory formFactory,
41
			ICdmFormElement formElement) {
42
		super(formFactory, formElement);
43
	}
44
	
45
	@Override
46
	protected void createControls(ICdmFormElement formElement,
47
			T entity, int style) {
48
		
49
		Representation representation = getEntity().getPreferredRepresentation(CdmStore.getDefaultLanguage());
50
		
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);
56
		
57
	}
58

    
59
	@Override
60
	public void setEntity(T entity) {
61
		super.setEntity(entity);
62
		setEnabled(TermBasePropertyTester.isModifiable(entity));
63
	}
64
	
65
	protected void handleRepresentation(Object eventSource){
66
		T entity = getEntity();
67
		Representation representation = entity.getRepresentation(CdmStore.getDefaultLanguage());
68
		
69
		if (representation == null){
70
			return;
71
		}
72
		
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());
80
		}
81
	}
82

    
83
	public abstract TermVocabulary getVocabulary();
84
		
85
}
(1-1/9)