Project

General

Profile

Download (3.25 KB) Statistics
| Branch: | Tag: | Revision:
1
// $Id$
2
/**
3
 * Copyright (C) 2007 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

    
11
package eu.etaxonomy.taxeditor.ui.section.classification;
12

    
13
import org.eclipse.swt.SWT;
14

    
15
import eu.etaxonomy.cdm.model.common.LanguageString;
16
import eu.etaxonomy.cdm.model.reference.Reference;
17
import eu.etaxonomy.cdm.model.taxon.Classification;
18
import eu.etaxonomy.taxeditor.store.CdmStore;
19
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
20
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
21
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
22
import eu.etaxonomy.taxeditor.ui.section.campanula.compatibility.ICdmFormElement;
23
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
24

    
25
/**
26
 * <p>
27
 * ClassificationDetailElement class.
28
 * </p>
29
 * 
30
 * @author n.hoffmann
31
 * @created Sep 27, 2010
32
 * @version 1.0
33
 */
34
public class ClassificationDetailElement extends
35
		AbstractCdmDetailElement<Classification> {
36

    
37
	private TextWithLabelElement text_treeLabel;
38

    
39
	private EntitySelectionElement<Reference> selection_reference;
40

    
41
	private TextWithLabelElement text_microReference;
42

    
43
	/**
44
	 * <p>
45
	 * Constructor for ClassificationDetailElement.
46
	 * </p>
47
	 * 
48
	 * @param formFactory
49
	 *            a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
50
	 *            object.
51
	 * @param formElement
52
	 *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
53
	 *            object.
54
	 */
55
	public ClassificationDetailElement(CdmFormFactory formFactory,
56
			ICdmFormElement formElement) {
57
		super(formFactory, formElement);
58
	}
59

    
60
	/*
61
	 * (non-Javadoc)
62
	 * 
63
	 * @see
64
	 * eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#createControls
65
	 * (eu.etaxonomy.taxeditor.forms.ICdmFormElement,
66
	 * eu.etaxonomy.cdm.model.common.IAnnotatableEntity, int)
67
	 */
68
	/** {@inheritDoc} */
69
	@Override
70
	protected void createControls(ICdmFormElement formElement,
71
			Classification entity, int style) {
72
		text_treeLabel = formFactory.createTextWithLabelElement(formElement,
73
				"Label", entity != null ? entity.getTitleCache() : null,
74
				SWT.NULL);
75
		selection_reference = formFactory
76
				.createSelectionElement(Reference.class,
77
						getConversationHolder(), formElement, "Reference",
78
						entity != null ? entity.getReference() : null,
79
						EntitySelectionElement.ALL, SWT.NULL);
80
		text_microReference = formFactory.createTextWithLabelElement(
81
				formElement, "Reference Detail",
82
				entity != null ? entity.getMicroReference() : null, SWT.NULL);
83
	}
84

    
85
	/*
86
	 * (non-Javadoc)
87
	 * 
88
	 * @see
89
	 * eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#handleEvent(java
90
	 * .lang.Object)
91
	 */
92
	/** {@inheritDoc} */
93
	@Override
94
	public void handleEvent(Object eventSource) {
95
		if (eventSource == text_treeLabel) {
96
			LanguageString languageString = LanguageString.NewInstance(
97
					text_treeLabel.getText(), CdmStore.getDefaultLanguage());
98
			getEntity().setName(languageString);
99
		} else if (eventSource == selection_reference) {
100
			getEntity().setReference(selection_reference.getEntity());
101
		} else if (eventSource == text_microReference) {
102
			getEntity().setMicroReference(text_microReference.getText());
103
		}
104
	}
105
}
(1-1/6)