2 * Copyright (C) 2020 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.
9 package eu
.etaxonomy
.taxeditor
.ui
.section
.reference
;
11 import org
.eclipse
.swt
.widgets
.Label
;
12 import org
.eclipse
.ui
.forms
.widgets
.TableWrapData
;
14 import eu
.etaxonomy
.cdm
.hibernate
.HibernateProxyHelper
;
15 import eu
.etaxonomy
.cdm
.model
.common
.CdmBase
;
16 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionElementSource
;
17 import eu
.etaxonomy
.cdm
.model
.name
.TaxonName
;
18 import eu
.etaxonomy
.cdm
.model
.reference
.INomenclaturalReference
;
19 import eu
.etaxonomy
.cdm
.model
.reference
.OriginalSourceBase
;
20 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
21 import eu
.etaxonomy
.taxeditor
.model
.AbstractUtility
;
22 import eu
.etaxonomy
.taxeditor
.preference
.Resources
;
23 import eu
.etaxonomy
.taxeditor
.store
.StoreUtil
;
24 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
25 import eu
.etaxonomy
.taxeditor
.ui
.element
.ICdmFormElement
;
26 import eu
.etaxonomy
.taxeditor
.ui
.element
.LayoutConstants
;
27 import eu
.etaxonomy
.taxeditor
.ui
.section
.common
.ExternalLinksSection
;
28 import eu
.etaxonomy
.taxeditor
.ui
.selection
.EntitySelectionElement
;
29 import eu
.etaxonomy
.taxeditor
.ui
.selection
.EntitySelectionElementWithAbbreviatedTitle
;
35 public class NomenclaturalSourceElement
extends OriginalSourceElement
{
37 private EntitySelectionElementWithAbbreviatedTitle
<Reference
> selection_NomRef
;
38 protected String label
= "Source";
39 protected CdmBase cdmEntity
;
41 protected EntitySelectionElement
<TaxonName
> select_nameUsedInSource
;
42 protected ExternalLinksSection externalLinks
;
52 public NomenclaturalSourceElement(CdmFormFactory formFactory
, ICdmFormElement formElement
, CdmBase cdmEntity
,
54 super(formFactory
, formElement
, cdmEntity
, label
);
59 protected void createControls(ICdmFormElement formElement
, OriginalSourceBase entity
, int style
) {
61 entity
= HibernateProxyHelper
.deproxy(entity
);
63 selection_NomRef
= formFactory
.createSelectionElementWithAbbreviatedTitle(Reference
.class,
64 getConversationHolder(), formElement
, "Reference",
66 EntitySelectionElement
.ALL
, style
);
69 selection_NomRef
.setEntity(entity
.getCitation());
71 selection_NomRef
.setBackground(this.getPersistentBackground());
72 for (ICdmFormElement element
: selection_NomRef
.getElements()){
73 element
.setBackground(getPersistentBackground());
76 microReference
= formFactory
.createTextWithLabelElement(formElement
, "Details", entity
!= null? entity
.getCitationMicroReference(): "", style
);
78 Label sep
= formFactory
.createLabel(formElement
.getLayoutComposite(), "");
79 sep
.setLayoutData(LayoutConstants
.FILL_HORIZONTALLY(2, 1));
81 select_nameUsedInSource
= formFactory
.createSelectionElement(TaxonName
.class, formElement
, "Original Spelling", entity
!= null?
((DescriptionElementSource
)entity
).getNameUsedInSource(): null, EntitySelectionElement
.ALL
, style
);
83 externalLinks
= formFactory
.createExternalLinksSection(getConversationHolder(), formElement
, "Protologue/Original Publication", StoreUtil
.getSectionStyle(ExternalLinksSection
.class, DescriptionElementSource
.class.getCanonicalName()));
84 externalLinks
.setEmptySectionString("No protologue yet.");
85 externalLinks
.setLayoutData(LayoutConstants
.FILL_HORIZONTALLY(2, 3));
86 externalLinks
.setEntity(entity
);
87 externalLinks
.setFont(AbstractUtility
.getFont(Resources
.COLOR_FONT_DEFAULT
));
90 addControl(externalLinks
);
91 addElement(externalLinks
);
93 advancedSection
= formFactory
.createOriginalSourceAdvancedSection(getConversationHolder(), formElement
, null, StoreUtil
.getSectionStyle(OriginalSourceAdvancedSection
.class, INomenclaturalReference
.class.getCanonicalName()));
94 TableWrapData layoutData
= LayoutConstants
.FILL_HORIZONTALLY(2, 1);
96 advancedSection
.setLayoutData(layoutData
);
97 advancedSection
.setBackground(this.getPersistentBackground());
98 advancedSection
.setEntity(entity
);
99 advancedSection
.setFont(AbstractUtility
.getFont(Resources
.COLOR_FONT_DEFAULT
));
100 addControl(advancedSection
);
101 addElement(advancedSection
);
102 this.getLayoutComposite().layout();
107 public EntitySelectionElement
<Reference
> getReferenceSelectionElement(){
109 return selection_NomRef
;
115 public void handleEvent(Object eventSource
) {
116 if (eventSource
.equals(selection_NomRef
)){
117 getEntity().setCitation(selection_NomRef
.getEntity());
119 if (eventSource
.equals(microReference
)){
120 getEntity().setCitationMicroReference(microReference
.getText());
122 super.handleEvent(eventSource
);