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.l10n.Messages;
|
20
|
import eu.etaxonomy.taxeditor.model.MessagingUtils;
|
21
|
import eu.etaxonomy.taxeditor.ui.combo.term.TermComboElement;
|
22
|
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
|
23
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
24
|
import eu.etaxonomy.taxeditor.ui.element.CheckboxElement;
|
25
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
26
|
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
|
27
|
|
28
|
/**
|
29
|
*
|
30
|
* @author n.hoffmann
|
31
|
* @created May 17, 2010
|
32
|
* @version 1.0
|
33
|
*/
|
34
|
public class NameTypeDesignationElement extends
|
35
|
AbstractTypeDesignationElement<NameTypeDesignation> {
|
36
|
|
37
|
private CheckboxElement checkbox_rejectedType;
|
38
|
private CheckboxElement checkbox_conservedType;
|
39
|
private EntitySelectionElement<TaxonName> selection_typeName;
|
40
|
private TermComboElement<NameTypeDesignationStatus> combo_typeStatus;
|
41
|
|
42
|
public NameTypeDesignationElement(CdmFormFactory formFactory,
|
43
|
AbstractFormSection section, NameTypeDesignation entity,
|
44
|
SelectionListener removeListener, int style) {
|
45
|
super(formFactory, section, entity, removeListener, style);
|
46
|
}
|
47
|
|
48
|
/** {@inheritDoc} */
|
49
|
@Override
|
50
|
public void createControls(ICdmFormElement formElement, int style) {
|
51
|
|
52
|
checkbox_rejectedType = formFactory.createCheckbox(formElement,
|
53
|
"Rejected Type", false, style); //$NON-NLS-1$
|
54
|
checkbox_conservedType = formFactory.createCheckbox(formElement,
|
55
|
"Conserved Type", false, style); //$NON-NLS-1$
|
56
|
selection_typeName = formFactory
|
57
|
.createSelectionElement(TaxonName.class,//getConversationHolder(),
|
58
|
formElement, "Name", null, //$NON-NLS-1$
|
59
|
EntitySelectionElement.ALL, style);
|
60
|
combo_typeStatus = formFactory.createDefinedTermComboElement(TermType.NameTypeDesignationStatus, formElement,
|
61
|
"Designation Status", null, style); //$NON-NLS-1$
|
62
|
|
63
|
super.createControls(formElement, style);
|
64
|
}
|
65
|
|
66
|
/** {@inheritDoc} */
|
67
|
@Override
|
68
|
public void setEntity(NameTypeDesignation entity) {
|
69
|
super.setEntity(entity);
|
70
|
checkbox_conservedType.setSelection(entity.isConservedType());
|
71
|
checkbox_rejectedType.setSelection(entity.isRejectedType());
|
72
|
|
73
|
selection_typeName.setEntity(HibernateProxyHelper.deproxy(entity.getTypeName()));
|
74
|
|
75
|
combo_typeStatus.setSelection(HibernateProxyHelper.deproxy(entity.getTypeStatus(), NameTypeDesignationStatus.class));
|
76
|
|
77
|
checkbox_notDesignated.setSelection(entity.isNotDesignated());
|
78
|
}
|
79
|
|
80
|
/** {@inheritDoc} */
|
81
|
@Override
|
82
|
public void handleEvent(Object eventSource) {
|
83
|
if (eventSource == checkbox_conservedType) {
|
84
|
getEntity().setConservedType(checkbox_conservedType.getSelection());
|
85
|
} else if (eventSource == checkbox_rejectedType) {
|
86
|
getEntity().setRejectedType(checkbox_rejectedType.getSelection());
|
87
|
} else if (eventSource == selection_typeName) {
|
88
|
getEntity().setTypeName(selection_typeName.getEntity());
|
89
|
} else if (eventSource == combo_typeStatus) {
|
90
|
if ((combo_typeStatus.getSelection() == null && entity.getCitation() != null)){
|
91
|
boolean ok = MessagingUtils.confirmDialog(Messages.NameTypeDesignationElement_4, Messages.NameTypeDesignationElement_5);
|
92
|
if (!ok){
|
93
|
combo_typeStatus.setSelection(entity.getTypeStatus());
|
94
|
return;
|
95
|
}
|
96
|
}else if ( entity.getTypeStatus() != null && getEntity().getTypeStatus().isLectotype() && !combo_typeStatus.getSelection().isLectotype() && entity.getCitation() != null){
|
97
|
boolean ok = MessagingUtils.confirmDialog(Messages.NameTypeDesignationElement_4, Messages.NameTypeDesignationElement_5);
|
98
|
if (!ok){
|
99
|
combo_typeStatus.setSelection(entity.getTypeStatus());
|
100
|
return;
|
101
|
}
|
102
|
}
|
103
|
getEntity().setTypeStatus(combo_typeStatus.getSelection());
|
104
|
|
105
|
setEntity(entity);
|
106
|
} else if (eventSource == checkbox_notDesignated) {
|
107
|
getEntity().setNotDesignated(checkbox_notDesignated.getSelection());
|
108
|
}
|
109
|
else if (eventSource == selection_reference) {
|
110
|
getEntity().setCitation(selection_reference.getSelection());
|
111
|
} else if (eventSource == text_referenceDetail) {
|
112
|
getEntity().setCitationMicroReference(
|
113
|
text_referenceDetail.getText());
|
114
|
}
|
115
|
}
|
116
|
}
|