Project

General

Profile

Download (3.42 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.apache.log4j.Logger;
14
import org.eclipse.swt.SWT;
15

    
16
import eu.etaxonomy.cdm.model.common.LanguageString;
17
import eu.etaxonomy.cdm.model.taxon.Classification;
18
import eu.etaxonomy.taxeditor.singlesource.ui.forms.TextWithLabelElementFacade;
19
import eu.etaxonomy.taxeditor.store.CdmStore;
20
import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory;
21
import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.SelectionType;
22
import eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement;
23
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
24
import eu.etaxonomy.taxeditor.ui.selection.ReferenceSelectionElement;
25

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

    
38
	private static final Logger logger = Logger
39
			.getLogger(ClassificationDetailElement.class);
40

    
41
	private TextWithLabelElementFacade text_treeLabel;
42

    
43
	private ReferenceSelectionElement selection_reference;
44

    
45
	private TextWithLabelElementFacade text_microReference;
46

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

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

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