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 eu
.etaxonomy
.cdm
.model
.molecular
.Amplification
;
13 import eu
.etaxonomy
.cdm
.model
.molecular
.Primer
;
14 import eu
.etaxonomy
.cdm
.model
.molecular
.Sequence
;
15 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
16 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
17 import eu
.etaxonomy
.taxeditor
.ui
.element
.ICdmFormElement
;
18 import eu
.etaxonomy
.taxeditor
.ui
.element
.TextWithLabelElement
;
19 import eu
.etaxonomy
.taxeditor
.ui
.section
.AbstractCdmDetailElement
;
20 import eu
.etaxonomy
.taxeditor
.ui
.selection
.EntitySelectionElement
;
27 public class AmplificationPrimerDetailElement
extends AbstractCdmDetailElement
<Amplification
> {
30 private TextWithLabelElement textPrimerForwardName
;
31 private TextWithLabelElement textPrimerForwardSequence
;
32 private EntitySelectionElement
<Reference
> selectionPrimerForwardReference
;
34 private TextWithLabelElement textPrimerReverseName
;
35 private TextWithLabelElement textPrimerReverseSequence
;
36 private EntitySelectionElement
<Reference
> selectionPrimerReverseReference
;
43 public AmplificationPrimerDetailElement(CdmFormFactory formFactory
, ICdmFormElement formElement
) {
44 super(formFactory
, formElement
);
51 * eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#createControls
52 * (eu.etaxonomy.taxeditor.forms.ICdmFormElement, java.lang.Object, int)
55 protected void createControls(ICdmFormElement formElement
, Amplification entity
, int style
) {
57 Primer forwardPrimer
= entity
.getForwardPrimer();
59 String initalSequenceString
;
60 Reference initialReference
;
61 if(forwardPrimer
==null){
63 initalSequenceString
= null;
64 initialReference
= null;
67 initialName
= forwardPrimer
.getLabel();
68 initialReference
= forwardPrimer
.getPublishedIn();
69 if(forwardPrimer
.getSequence()==null){
70 initalSequenceString
= "";
73 initalSequenceString
= forwardPrimer
.getSequence().getSequenceString();
76 textPrimerForwardName
= formFactory
.createTextWithLabelElement(formElement
, "Forward Primer", initialName
, style
);
77 textPrimerForwardSequence
= formFactory
.createTextWithLabelElement(formElement
, "Fw. Primer Sequence", initalSequenceString
, style
);
78 selectionPrimerForwardReference
= formFactory
.createSelectionElement(Reference
.class, getConversationHolder(), formElement
, "Fw. Primer Reference", initialReference
, EntitySelectionElement
.ALL
, style
);
81 Primer reversePrimer
= entity
.getForwardPrimer();
82 String initialNameReverse
;
83 String initalSequenceStringReverse
;
84 Reference initialReferenceReverse
;
85 if(reversePrimer
==null){
86 initialNameReverse
= "";
87 initalSequenceStringReverse
= null;
88 initialReferenceReverse
= null;
91 initialNameReverse
= reversePrimer
.getLabel();
92 initialReferenceReverse
= reversePrimer
.getPublishedIn();
93 if(reversePrimer
.getSequence()==null){
94 initalSequenceStringReverse
= "";
97 initalSequenceStringReverse
= reversePrimer
.getSequence().getSequenceString();
100 textPrimerReverseName
= formFactory
.createTextWithLabelElement(formElement
, "Reverse Primer", initialNameReverse
, style
);
101 textPrimerReverseSequence
= formFactory
.createTextWithLabelElement(formElement
, "Rv. Primer Sequence", initalSequenceStringReverse
, style
);
102 selectionPrimerReverseReference
= formFactory
.createSelectionElement(Reference
.class, getConversationHolder(), formElement
, "Rv. Primer Reference", initialReferenceReverse
, EntitySelectionElement
.ALL
, style
);
109 * eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#handleEvent(java
113 public void handleEvent(Object eventSource
) {
114 if(eventSource
==textPrimerForwardName
|| eventSource
==textPrimerForwardSequence
|| eventSource
==selectionPrimerForwardReference
){
115 Primer forwardPrimer
= getEntity().getForwardPrimer();
116 if(forwardPrimer
==null){
117 forwardPrimer
= Primer
.NewInstance("");
118 getEntity().setForwardPrimer(forwardPrimer
);
120 if(eventSource
==textPrimerForwardName
){
121 forwardPrimer
.setLabel(textPrimerForwardName
.getText());
123 else if(eventSource
==textPrimerForwardSequence
){
124 Sequence sequence
= forwardPrimer
.getSequence();
126 sequence
= Sequence
.NewInstance(textPrimerForwardSequence
.getText());
127 forwardPrimer
.setSequence(sequence
);
130 sequence
.setSequenceString(textPrimerForwardSequence
.getText());
133 else if(eventSource
==selectionPrimerForwardReference
){
134 forwardPrimer
.setPublishedIn(selectionPrimerForwardReference
.getSelection());
137 else if(eventSource
==textPrimerReverseName
|| eventSource
==textPrimerReverseSequence
|| eventSource
==selectionPrimerReverseReference
){
138 Primer reversePrimer
= getEntity().getReversePrimer();
139 if(reversePrimer
==null){
140 reversePrimer
= Primer
.NewInstance("");
141 getEntity().setReversePrimer(reversePrimer
);
143 if(eventSource
==textPrimerReverseName
){
144 reversePrimer
.setLabel(textPrimerReverseName
.getText());
146 else if(eventSource
==textPrimerReverseSequence
){
147 Sequence sequence
= reversePrimer
.getSequence();
149 sequence
= Sequence
.NewInstance(textPrimerReverseSequence
.getText());
150 reversePrimer
.setSequence(sequence
);
153 sequence
.setSequenceString(textPrimerReverseSequence
.getText());
156 else if(eventSource
==selectionPrimerReverseReference
){
157 reversePrimer
.setPublishedIn(selectionPrimerReverseReference
.getSelection());