3 * Copyright (C) 2014 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.taxeditor
.ui
.section
.occurrence
.dna
;
12 import org
.eclipse
.swt
.SWT
;
13 import org
.eclipse
.swt
.events
.SelectionListener
;
15 import eu
.etaxonomy
.cdm
.model
.molecular
.Sequence
;
16 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
17 import eu
.etaxonomy
.taxeditor
.ui
.element
.AbstractFormSection
;
18 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
19 import eu
.etaxonomy
.taxeditor
.ui
.element
.ICdmFormElement
;
20 import eu
.etaxonomy
.taxeditor
.ui
.element
.TextWithLabelElement
;
21 import eu
.etaxonomy
.taxeditor
.ui
.section
.AbstractEntityCollectionElement
;
22 import eu
.etaxonomy
.taxeditor
.ui
.selection
.EntitySelectionElement
;
29 public class SequenceReferenceCollectionDetailElement
extends AbstractEntityCollectionElement
<Reference
>{
31 protected EntitySelectionElement
<Reference
> selection_reference
;
32 protected TextWithLabelElement text_referenceDetail
;
33 private Sequence sequence
;
37 * Constructor for AbstractReferencedEntityElement.
41 * a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
44 * a {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection}
48 * @param removeListener
49 * a {@link org.eclipse.swt.events.SelectionListener} object.
55 public SequenceReferenceCollectionDetailElement(CdmFormFactory formFactory
,
56 AbstractFormSection section
, Reference entity
,
57 SelectionListener removeListener
, int style
) {
58 super(formFactory
, section
, entity
, removeListener
, null, style
);
59 if(section
instanceof SequenceReferenceCollectionDetailSection
){
60 sequence
= (Sequence
) section
.getEntity();
68 * eu.etaxonomy.taxeditor.forms.section.AbstractEntityCollectionElement#
69 * createControls(eu.etaxonomy.taxeditor.forms.ICdmFormElement, int)
73 public void createControls(ICdmFormElement formElement
, int style
) {
74 selection_reference
= formFactory
75 .createSelectionElement(Reference
.class,
76 getConversationHolder(), formElement
, "Reference",
77 null, EntitySelectionElement
.SELECTABLE
|EntitySelectionElement
.EDITABLE
, style
);
78 text_referenceDetail
= formFactory
.createTextWithLabelElement(
79 formElement
, "Reference Detail", null, SWT
.NULL
);
91 public void setEntity(Reference entity
) {
93 selection_reference
.setEntity(entity
);
94 text_referenceDetail
.setText(entity
.getReferenceAbstract());
98 * @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement#handleEvent(java.lang.Object)
101 public void handleEvent(Object eventSource
) {
102 if(eventSource
==selection_reference
){
103 sequence
.removeCitation(entity
);
104 Reference newCitation
= selection_reference
.getSelection();
105 sequence
.addCitation(newCitation
);
106 entity
= newCitation
;
107 text_referenceDetail
.setEnabled(true);
108 } else if(eventSource
==text_referenceDetail
){
109 entity
.setReferenceAbstract(text_referenceDetail
.getText());