Project

General

Profile

Download (4.44 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.name;
12

    
13
import org.eclipse.swt.events.SelectionListener;
14

    
15
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
16
import eu.etaxonomy.cdm.model.name.NameTypeDesignation;
17
import eu.etaxonomy.cdm.model.name.NameTypeDesignationStatus;
18
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
19
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
20
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
21
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
22
import eu.etaxonomy.taxeditor.ui.element.CheckboxElement;
23
import eu.etaxonomy.taxeditor.ui.section.campanula.compatibility.ICdmFormElement;
24
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
25

    
26
/**
27
 * <p>
28
 * NameTypeDesignationElement class.
29
 * </p>
30
 * 
31
 * @author n.hoffmann
32
 * @created May 17, 2010
33
 * @version 1.0
34
 */
35
public class NameTypeDesignationElement extends
36
		AbstractTypeDesignationElement<NameTypeDesignation> {
37

    
38
	private CheckboxElement checkbox_rejectedType;
39
	private CheckboxElement checkbox_conservedType;
40
	private EntitySelectionElement<TaxonNameBase> selection_typeName;
41
	private TermComboElement<NameTypeDesignationStatus> combo_typeStatus;
42

    
43
	/**
44
	 * <p>
45
	 * Constructor for NameTypeDesignationElement.
46
	 * </p>
47
	 * 
48
	 * @param formFactory
49
	 *            a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
50
	 *            object.
51
	 * @param section
52
	 *            a {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection}
53
	 *            object.
54
	 * @param entity
55
	 *            a {@link eu.etaxonomy.cdm.model.name.NameTypeDesignation}
56
	 *            object.
57
	 * @param removeListener
58
	 *            a {@link org.eclipse.swt.events.SelectionListener} object.
59
	 * @param style
60
	 *            a int.
61
	 */
62
	public NameTypeDesignationElement(CdmFormFactory formFactory,
63
			AbstractFormSection section, NameTypeDesignation entity,
64
			SelectionListener removeListener, int style) {
65
		super(formFactory, section, entity, removeListener, style);
66
	}
67

    
68
	/** {@inheritDoc} */
69
	@Override
70
	public void createControls(ICdmFormElement formElement, int style) {
71

    
72
		checkbox_rejectedType = formFactory.createCheckbox(formElement,
73
				"Rejected Type", false, style);
74
		checkbox_conservedType = formFactory.createCheckbox(formElement,
75
				"Conserved Type", false, style);
76
		selection_typeName = formFactory
77
				.createSelectionElement(TaxonNameBase.class,
78
						getConversationHolder(), formElement, "Name", null,
79
						EntitySelectionElement.ALL, style);
80
		combo_typeStatus = formFactory.createTermComboElement(
81
				NameTypeDesignationStatus.class, formElement,
82
						"Designation Status", null, style);
83

    
84
		super.createControls(formElement, style);
85
	}
86

    
87
	/** {@inheritDoc} */
88
	@Override
89
	public void setEntity(NameTypeDesignation entity) {
90
		super.setEntity(entity);
91
		checkbox_conservedType.setSelection(entity.isConservedType());
92
		checkbox_rejectedType.setSelection(entity.isRejectedType());
93

    
94
		selection_typeName.setEntity((TaxonNameBase) HibernateProxyHelper.deproxy(entity.getTypeName()));
95

    
96
		combo_typeStatus.setSelection((NameTypeDesignationStatus) HibernateProxyHelper.deproxy(entity.getTypeStatus()));
97

    
98
		checkbox_notDesignated.setSelection(entity.isNotDesignated());
99
	}
100

    
101
	/** {@inheritDoc} */
102
	@Override
103
	public void handleEvent(Object eventSource) {
104
		if (eventSource == checkbox_conservedType) {
105
			getEntity().setConservedType(checkbox_conservedType.getSelection());
106
		} else if (eventSource == checkbox_rejectedType) {
107
			getEntity().setRejectedType(checkbox_rejectedType.getSelection());
108
		} else if (eventSource == selection_typeName) {
109
			getEntity().setTypeName(selection_typeName.getEntity());
110
		} else if (eventSource == combo_typeStatus) {
111
			getEntity().setTypeStatus(combo_typeStatus.getSelection());
112
		} else if (eventSource == checkbox_notDesignated) {
113
			getEntity().setNotDesignated(checkbox_notDesignated.getSelection());
114
		} else if (eventSource == selection_reference) {
115
			getEntity().setCitation(selection_reference.getSelection());
116
		} else if (eventSource == text_referenceDetail) {
117
			getEntity().setCitationMicroReference(
118
					text_referenceDetail.getText());
119
		} else if (eventSource == text_originaleNameString) {
120
			getEntity().setOriginalNameString(
121
					text_originaleNameString.getText());
122
		}
123
	}
124
}
(12-12/21)