2 * Copyright (C) 2014 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
.occurrence
.dna
;
11 import eu
.etaxonomy
.cdm
.model
.molecular
.Primer
;
12 import eu
.etaxonomy
.cdm
.model
.molecular
.SequenceString
;
13 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
14 import eu
.etaxonomy
.cdm
.model
.term
.DefinedTerm
;
15 import eu
.etaxonomy
.cdm
.model
.term
.TermType
;
16 import eu
.etaxonomy
.taxeditor
.store
.StoreUtil
;
17 import eu
.etaxonomy
.taxeditor
.ui
.combo
.term
.TermComboElement
;
18 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
19 import eu
.etaxonomy
.taxeditor
.ui
.element
.ICdmFormElement
;
20 import eu
.etaxonomy
.taxeditor
.ui
.element
.LayoutConstants
;
21 import eu
.etaxonomy
.taxeditor
.ui
.element
.TextWithLabelElement
;
22 import eu
.etaxonomy
.taxeditor
.ui
.section
.AbstractCdmDetailElement
;
23 import eu
.etaxonomy
.taxeditor
.ui
.section
.supplemental
.AnnotationSection
;
24 import eu
.etaxonomy
.taxeditor
.ui
.selection
.EntitySelectionElement
;
30 public class PrimerGeneralDetailElement
extends AbstractCdmDetailElement
<Primer
> {
33 private TextWithLabelElement textPrimerName
;
34 // we are using a basic text field which is backed up by a Sequence object modelwise.
35 // This is a bit of a overhead as we may just need the sequence string. This may change in future in both directions:
36 // either extending this view to support the remaining fields of Sequence or by switching to the more basic SequenceString model element
37 private TextWithLabelElement textPrimerSequence
;
38 private TermComboElement
<DefinedTerm
> comboMarker
;
39 private EntitySelectionElement
<Reference
> selectionReference
;
41 public PrimerGeneralDetailElement(CdmFormFactory formFactory
, ICdmFormElement formElement
) {
42 super(formFactory
, formElement
);
46 protected void createControls(ICdmFormElement formElement
, Primer entity
, int style
) {
47 textPrimerName
= formFactory
.createTextWithLabelElement(formElement
, "Primer Name", entity
.getLabel(), style
);
48 String sequenceString
= null;
49 if(entity
.getSequence()!=null){
50 sequenceString
= entity
.getSequence().getString();
52 textPrimerSequence
= formFactory
.createTextWithLabelElement(formElement
, "Primer seq. 5'->3'", sequenceString
, style
);
54 comboMarker
= formFactory
.createDefinedTermComboElement(TermType
.DnaMarker
, formElement
, "DNA Marker", entity
.getDnaMarker(), style
);
56 selectionReference
= formFactory
57 .createSelectionElement(Reference
.class,
58 formElement
, "Reference",
59 entity
.getPublishedIn(),
60 EntitySelectionElement
.ALL
, style
);
62 AnnotationSection annotationSection
= formFactory
.createAnnotationSection(formElement
, StoreUtil
.getSectionStyle(AnnotationSection
.class, entity
.getClass().getCanonicalName()));
63 annotationSection
.setLayoutData(LayoutConstants
.FILL_HORIZONTALLY(2, 1));
64 annotationSection
.setEntity(entity
);
68 public void handleEvent(Object eventSource
) {
69 if(eventSource
==textPrimerName
){
70 getEntity().setLabel(textPrimerName
.getText());
72 else if(eventSource
==comboMarker
){
73 getEntity().setDnaMarker(comboMarker
.getSelection());
75 else if(eventSource
==textPrimerSequence
){
76 SequenceString sequenceString
= getEntity().getSequence();
77 if(sequenceString
==null){
78 sequenceString
= SequenceString
.NewInstance("");
79 getEntity().setSequence(sequenceString
);
81 sequenceString
.setString(textPrimerSequence
.getText());
83 else if(eventSource
==selectionReference
){
84 getEntity().setPublishedIn(selectionReference
.getSelection());
89 public void fillFields() {
90 // TODO Auto-generated method stub