had to rename the packages to make them compliant with buckminster
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / name / NameTypeDesignationElement.java
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.apache.log4j.Logger;
14 import org.eclipse.swt.events.SelectionListener;
15
16 import eu.etaxonomy.cdm.model.name.NameTypeDesignation;
17 import eu.etaxonomy.taxeditor.ui.forms.AbstractFormSection;
18 import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory;
19 import eu.etaxonomy.taxeditor.ui.forms.CheckboxElement;
20 import eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement;
21 import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.SelectionType;
22 import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.TermComboType;
23 import eu.etaxonomy.taxeditor.ui.selection.NameSelectionElement;
24 import eu.etaxonomy.taxeditor.ui.term.NameTypeDesignationStatusComboElement;
25
26 /**
27 * <p>NameTypeDesignationElement class.</p>
28 *
29 * @author n.hoffmann
30 * @created May 17, 2010
31 * @version 1.0
32 */
33 public class NameTypeDesignationElement extends
34 AbstractTypeDesignationElement<NameTypeDesignation> {
35
36 private static final Logger logger = Logger
37 .getLogger(NameTypeDesignationElement.class);
38 private CheckboxElement checkbox_rejectedType;
39 private CheckboxElement checkbox_conservedType;
40 private NameSelectionElement selection_typeName;
41 private NameTypeDesignationStatusComboElement combo_typeStatus;
42
43 /**
44 * <p>Constructor for NameTypeDesignationElement.</p>
45 *
46 * @param formFactory a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory} object.
47 * @param section a {@link eu.etaxonomy.taxeditor.ui.forms.AbstractFormSection} object.
48 * @param entity a {@link eu.etaxonomy.cdm.model.name.NameTypeDesignation} object.
49 * @param removeListener a {@link org.eclipse.swt.events.SelectionListener} object.
50 * @param style a int.
51 */
52 public NameTypeDesignationElement(CdmFormFactory formFactory,
53 AbstractFormSection section, NameTypeDesignation entity,
54 SelectionListener removeListener, int style) {
55 super(formFactory, section, entity, removeListener, style);
56 }
57
58 /** {@inheritDoc} */
59 @Override
60 public void createControls(ICdmFormElement formElement, int style) {
61
62 checkbox_rejectedType = formFactory.createCheckbox(formElement, "Rejected Type", false, style);
63 checkbox_conservedType = formFactory.createCheckbox(formElement, "Conserved Type", false, style);
64 selection_typeName = (NameSelectionElement) formFactory.createSelectionElement(SelectionType.NAME, getConversationHolder(), formElement, "Name", null, style);
65 combo_typeStatus = (NameTypeDesignationStatusComboElement) formFactory.createTermComboElement(TermComboType.NAMETYPEDESIGNATIONSTATUS, formElement, "Designation Status", null, style);
66
67 super.createControls(formElement, style);
68 }
69
70 /** {@inheritDoc} */
71 @Override
72 public void setEntity(NameTypeDesignation entity) {
73 super.setEntity(entity);
74 checkbox_conservedType.setSelection(entity.isConservedType());
75 checkbox_rejectedType.setSelection(entity.isRejectedType());
76
77 selection_typeName.setEntity(entity.getTypeName());
78
79 combo_typeStatus.setSelection(entity.getTypeStatus());
80
81 checkbox_notDesignated.setSelection(entity.isNotDesignated());
82 }
83
84 /** {@inheritDoc} */
85 @Override
86 public void handleEvent(Object eventSource) {
87 if(eventSource == checkbox_conservedType){
88 getEntity().setConservedType(checkbox_conservedType.getSelection());
89 }
90 else if(eventSource == checkbox_rejectedType){
91 getEntity().setRejectedType(checkbox_rejectedType.getSelection());
92 }
93 else if(eventSource == selection_typeName){
94 getEntity().setTypeName(selection_typeName.getEntity());
95 }
96 else if(eventSource == combo_typeStatus){
97 getEntity().setTypeStatus(combo_typeStatus.getSelection());
98 }
99 else if(eventSource == checkbox_notDesignated){
100 getEntity().setNotDesignated(checkbox_notDesignated.getSelection());
101 }
102 else if(eventSource == selection_reference){
103 getEntity().setCitation(selection_reference.getSelection());
104 }
105 else if(eventSource == text_referenceDetail){
106 getEntity().setCitationMicroReference(text_referenceDetail.getText());
107 }
108 else if(eventSource == text_originaleNameString){
109 getEntity().setOriginalNameString(text_originaleNameString.getText());
110 }
111 }
112 }