1
|
/**
|
2
|
* Copyright (C) 2007 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
|
10
|
package eu.etaxonomy.taxeditor.ui.section.name;
|
11
|
|
12
|
import org.eclipse.swt.events.SelectionListener;
|
13
|
|
14
|
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
|
15
|
import eu.etaxonomy.cdm.model.name.NameTypeDesignation;
|
16
|
import eu.etaxonomy.cdm.model.name.NameTypeDesignationStatus;
|
17
|
import eu.etaxonomy.cdm.model.name.TaxonName;
|
18
|
import eu.etaxonomy.cdm.model.term.TermType;
|
19
|
import eu.etaxonomy.taxeditor.model.MessagingUtils;
|
20
|
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
|
21
|
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
|
22
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
23
|
import eu.etaxonomy.taxeditor.ui.element.CheckboxElement;
|
24
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
25
|
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
|
26
|
|
27
|
/**
|
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 CheckboxElement checkbox_rejectedType;
|
37
|
private CheckboxElement checkbox_conservedType;
|
38
|
private EntitySelectionElement<TaxonName> selection_typeName;
|
39
|
private TermComboElement<NameTypeDesignationStatus> combo_typeStatus;
|
40
|
|
41
|
public NameTypeDesignationElement(CdmFormFactory formFactory,
|
42
|
AbstractFormSection section, NameTypeDesignation entity,
|
43
|
SelectionListener removeListener, int style) {
|
44
|
super(formFactory, section, entity, removeListener, style);
|
45
|
}
|
46
|
|
47
|
/** {@inheritDoc} */
|
48
|
@Override
|
49
|
public void createControls(ICdmFormElement formElement, int style) {
|
50
|
|
51
|
checkbox_rejectedType = formFactory.createCheckbox(formElement,
|
52
|
"Rejected Type", false, style);
|
53
|
checkbox_conservedType = formFactory.createCheckbox(formElement,
|
54
|
"Conserved Type", false, style);
|
55
|
selection_typeName = formFactory
|
56
|
.createSelectionElement(TaxonName.class,//getConversationHolder(),
|
57
|
formElement, "Name", null,
|
58
|
EntitySelectionElement.ALL, style);
|
59
|
combo_typeStatus = formFactory.createDefinedTermComboElement(TermType.NameTypeDesignationStatus, formElement,
|
60
|
"Designation Status", null, style);
|
61
|
|
62
|
super.createControls(formElement, style);
|
63
|
}
|
64
|
|
65
|
/** {@inheritDoc} */
|
66
|
@Override
|
67
|
public void setEntity(NameTypeDesignation entity) {
|
68
|
super.setEntity(entity);
|
69
|
checkbox_conservedType.setSelection(entity.isConservedType());
|
70
|
checkbox_rejectedType.setSelection(entity.isRejectedType());
|
71
|
|
72
|
selection_typeName.setEntity(HibernateProxyHelper.deproxy(entity.getTypeName()));
|
73
|
|
74
|
combo_typeStatus.setSelection(HibernateProxyHelper.deproxy(entity.getTypeStatus(), NameTypeDesignationStatus.class));
|
75
|
|
76
|
checkbox_notDesignated.setSelection(entity.isNotDesignated());
|
77
|
}
|
78
|
|
79
|
/** {@inheritDoc} */
|
80
|
@Override
|
81
|
public void handleEvent(Object eventSource) {
|
82
|
if (eventSource == checkbox_conservedType) {
|
83
|
getEntity().setConservedType(checkbox_conservedType.getSelection());
|
84
|
} else if (eventSource == checkbox_rejectedType) {
|
85
|
getEntity().setRejectedType(checkbox_rejectedType.getSelection());
|
86
|
} else if (eventSource == selection_typeName) {
|
87
|
getEntity().setTypeName(selection_typeName.getEntity());
|
88
|
} else if (eventSource == combo_typeStatus) {
|
89
|
if (getEntity().getTypeStatus().isLectotype() && !combo_typeStatus.getSelection().isLectotype() && entity.getCitation() != null){
|
90
|
boolean ok = MessagingUtils.confirmDialog("Citation will be removed", "When changing the type from lectotype to a non lectotype the citation will be removed.Do you want to continue?");
|
91
|
if (!ok){
|
92
|
combo_typeStatus.setSelection(entity.getTypeStatus());
|
93
|
return;
|
94
|
}
|
95
|
}
|
96
|
getEntity().setTypeStatus(combo_typeStatus.getSelection());
|
97
|
|
98
|
setEntity(entity);
|
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
|
} else if (eventSource == text_referenceDetail) {
|
105
|
getEntity().setCitationMicroReference(
|
106
|
text_referenceDetail.getText());
|
107
|
}
|
108
|
}
|
109
|
}
|