2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.taxeditor
.ui
.section
.name
;
12 import org
.eclipse
.swt
.events
.SelectionListener
;
14 import eu
.etaxonomy
.cdm
.hibernate
.HibernateProxyHelper
;
15 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionElementSource
;
16 import eu
.etaxonomy
.cdm
.model
.name
.NameTypeDesignation
;
17 import eu
.etaxonomy
.cdm
.model
.name
.NameTypeDesignationStatus
;
18 import eu
.etaxonomy
.cdm
.model
.name
.TaxonName
;
19 import eu
.etaxonomy
.cdm
.model
.term
.TermType
;
20 import eu
.etaxonomy
.taxeditor
.l10n
.Messages
;
21 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
22 import eu
.etaxonomy
.taxeditor
.ui
.combo
.term
.TermComboElement
;
23 import eu
.etaxonomy
.taxeditor
.ui
.element
.AbstractFormSection
;
24 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
25 import eu
.etaxonomy
.taxeditor
.ui
.element
.CheckboxElement
;
26 import eu
.etaxonomy
.taxeditor
.ui
.element
.ICdmFormElement
;
27 import eu
.etaxonomy
.taxeditor
.ui
.selection
.EntitySelectionElement
;
32 * @created May 17, 2010
35 public class NameTypeDesignationElement
extends
36 AbstractTypeDesignationElement
<NameTypeDesignation
> {
38 private CheckboxElement checkbox_rejectedType
;
39 private CheckboxElement checkbox_conservedType
;
40 private EntitySelectionElement
<TaxonName
> selection_typeName
;
41 private TermComboElement
<NameTypeDesignationStatus
> combo_typeStatus
;
43 public NameTypeDesignationElement(CdmFormFactory formFactory
,
44 AbstractFormSection section
, NameTypeDesignation entity
,
45 SelectionListener removeListener
, int style
) {
46 super(formFactory
, section
, entity
, removeListener
, style
);
51 public void createControls(ICdmFormElement formElement
, int style
) {
53 checkbox_rejectedType
= formFactory
.createCheckbox(formElement
,
54 "Rejected Type", false, style
); //$NON-NLS-1$
55 checkbox_conservedType
= formFactory
.createCheckbox(formElement
,
56 "Conserved Type", false, style
); //$NON-NLS-1$
57 selection_typeName
= formFactory
58 .createSelectionElement(TaxonName
.class,//getConversationHolder(),
59 formElement
, "Name", null, //$NON-NLS-1$
60 EntitySelectionElement
.ALL
, style
);
61 combo_typeStatus
= formFactory
.createDefinedTermComboElement(TermType
.NameTypeDesignationStatus
, formElement
,
62 "Designation Status", null, style
); //$NON-NLS-1$
64 super.createControls(formElement
, style
);
69 public void setEntity(NameTypeDesignation entity
) {
70 super.setEntity(entity
);
71 checkbox_conservedType
.setSelection(entity
.isConservedType());
72 checkbox_rejectedType
.setSelection(entity
.isRejectedType());
74 selection_typeName
.setEntity(HibernateProxyHelper
.deproxy(entity
.getTypeName()));
76 combo_typeStatus
.setSelection(HibernateProxyHelper
.deproxy(entity
.getTypeStatus(), NameTypeDesignationStatus
.class));
78 checkbox_notDesignated
.setSelection(entity
.isNotDesignated());
84 public void handleEvent(Object eventSource
) {
85 if (eventSource
== checkbox_conservedType
) {
86 getEntity().setConservedType(checkbox_conservedType
.getSelection());
87 } else if (eventSource
== checkbox_rejectedType
) {
88 getEntity().setRejectedType(checkbox_rejectedType
.getSelection());
89 } else if (eventSource
== selection_typeName
) {
90 getEntity().setTypeName(selection_typeName
.getEntity());
91 } else if (eventSource
== combo_typeStatus
) {
92 if ((combo_typeStatus
.getSelection() == null && entity
.getCitation() != null)){
93 boolean ok
= MessagingUtils
.confirmDialog(Messages
.NameTypeDesignationElement_4
, Messages
.NameTypeDesignationElement_5
);
95 combo_typeStatus
.setSelection(entity
.getTypeStatus());
98 }else if ( entity
.getTypeStatus() != null && getEntity().getTypeStatus().hasDesignationSource() && !combo_typeStatus
.getSelection().hasDesignationSource() && entity
.getCitation() != null){
99 boolean ok
= MessagingUtils
.confirmDialog(Messages
.NameTypeDesignationElement_4
, Messages
.NameTypeDesignationElement_5
);
101 combo_typeStatus
.setSelection(entity
.getTypeStatus());
105 getEntity().setTypeStatus(combo_typeStatus
.getSelection());
106 if (getEntity().hasDesignationSource()){
107 DescriptionElementSource source
= DescriptionElementSource
.NewPrimarySourceInstance(null, null);
108 entity
.setSource(source
);
112 } else if (eventSource
== checkbox_notDesignated
) {
113 getEntity().setNotDesignated(checkbox_notDesignated
.getSelection());
115 // else if (eventSource == selection_reference) {
116 // getEntity().setCitation(selection_reference.getSelection());
117 // } else if (eventSource == text_referenceDetail) {
118 // getEntity().setCitationMicroReference(
119 // text_referenceDetail.getText());