import eu.etaxonomy.cdm.model.molecular.Amplification;
import eu.etaxonomy.cdm.model.molecular.Primer;
-import eu.etaxonomy.cdm.model.molecular.Sequence;
-import eu.etaxonomy.cdm.model.reference.Reference;
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
-import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
public class AmplificationPrimerDetailElement extends AbstractCdmDetailElement<Amplification> {
//forward primer
- private TextWithLabelElement textPrimerForwardName;
- private TextWithLabelElement textPrimerForwardSequence;
- private EntitySelectionElement<Reference> selectionPrimerForwardReference;
+ private EntitySelectionElement<Primer> selectionPrimerForward;
//reverse primer
- private TextWithLabelElement textPrimerReverseName;
- private TextWithLabelElement textPrimerReverseSequence;
- private EntitySelectionElement<Reference> selectionPrimerReverseReference;
+ private EntitySelectionElement<Primer> selectionPrimerReverse;
/**
*/
@Override
protected void createControls(ICdmFormElement formElement, Amplification entity, int style) {
- //first primer
- Primer forwardPrimer = entity.getForwardPrimer();
- String initialName;
- String initalSequenceString;
- Reference initialReference;
- if(forwardPrimer==null){
- initialName = "";
- initalSequenceString = null;
- initialReference = null;
- }
- else{
- initialName = forwardPrimer.getLabel();
- initialReference = forwardPrimer.getPublishedIn();
- if(forwardPrimer.getSequence()==null){
- initalSequenceString = "";
- }
- else{
- initalSequenceString = forwardPrimer.getSequence().getSequenceString();
- }
- }
- textPrimerForwardName = formFactory.createTextWithLabelElement(formElement, "Forward Primer", initialName, style);
- textPrimerForwardSequence = formFactory.createTextWithLabelElement(formElement, "Fw. Primer Sequence", initalSequenceString, style);
- selectionPrimerForwardReference = formFactory.createSelectionElement(Reference.class, getConversationHolder(), formElement, "Fw. Primer Reference", initialReference, EntitySelectionElement.ALL, style);
-
- //second primer
- Primer reversePrimer = entity.getForwardPrimer();
- String initialNameReverse;
- String initalSequenceStringReverse;
- Reference initialReferenceReverse;
- if(reversePrimer==null){
- initialNameReverse = "";
- initalSequenceStringReverse = null;
- initialReferenceReverse = null;
- }
- else{
- initialNameReverse = reversePrimer.getLabel();
- initialReferenceReverse = reversePrimer.getPublishedIn();
- if(reversePrimer.getSequence()==null){
- initalSequenceStringReverse = "";
- }
- else{
- initalSequenceStringReverse = reversePrimer.getSequence().getSequenceString();
- }
- }
- textPrimerReverseName = formFactory.createTextWithLabelElement(formElement, "Reverse Primer", initialNameReverse, style);
- textPrimerReverseSequence = formFactory.createTextWithLabelElement(formElement, "Rv. Primer Sequence", initalSequenceStringReverse, style);
- selectionPrimerReverseReference = formFactory.createSelectionElement(Reference.class, getConversationHolder(), formElement, "Rv. Primer Reference", initialReferenceReverse, EntitySelectionElement.ALL, style);
+ selectionPrimerForward = formFactory.createSelectionElement(Primer.class, getConversationHolder(), formElement, "Forward Primer", entity.getForwardPrimer(), EntitySelectionElement.ALL, style);
+ selectionPrimerReverse = formFactory.createSelectionElement(Primer.class, getConversationHolder(), formElement, "Reverse Primer", entity.getReversePrimer(), EntitySelectionElement.ALL, style);
}
/*
*/
@Override
public void handleEvent(Object eventSource) {
- if(eventSource==textPrimerForwardName || eventSource==textPrimerForwardSequence || eventSource==selectionPrimerForwardReference){
- Primer forwardPrimer = getEntity().getForwardPrimer();
- if(forwardPrimer==null){
- forwardPrimer = Primer.NewInstance("");
- getEntity().setForwardPrimer(forwardPrimer);
- }
- if(eventSource==textPrimerForwardName){
- forwardPrimer.setLabel(textPrimerForwardName.getText());
- }
- else if(eventSource==textPrimerForwardSequence){
- Sequence sequence = forwardPrimer.getSequence();
- if(sequence==null){
- sequence = Sequence.NewInstance(textPrimerForwardSequence.getText());
- forwardPrimer.setSequence(sequence);
- }
- else{
- sequence.setSequenceString(textPrimerForwardSequence.getText());
- }
- }
- else if(eventSource==selectionPrimerForwardReference){
- forwardPrimer.setPublishedIn(selectionPrimerForwardReference.getSelection());
- }
+ if(eventSource==selectionPrimerForward){
+ getEntity().setForwardPrimer(selectionPrimerForward.getSelection());
}
- else if(eventSource==textPrimerReverseName || eventSource==textPrimerReverseSequence || eventSource==selectionPrimerReverseReference){
- Primer reversePrimer = getEntity().getReversePrimer();
- if(reversePrimer==null){
- reversePrimer = Primer.NewInstance("");
- getEntity().setReversePrimer(reversePrimer);
- }
- if(eventSource==textPrimerReverseName){
- reversePrimer.setLabel(textPrimerReverseName.getText());
- }
- else if(eventSource==textPrimerReverseSequence){
- Sequence sequence = reversePrimer.getSequence();
- if(sequence==null){
- sequence = Sequence.NewInstance(textPrimerReverseSequence.getText());
- reversePrimer.setSequence(sequence);
- }
- else{
- sequence.setSequenceString(textPrimerReverseSequence.getText());
- }
- }
- else if(eventSource==selectionPrimerReverseReference){
- reversePrimer.setPublishedIn(selectionPrimerReverseReference.getSelection());
- }
+ else if(eventSource==selectionPrimerReverse){
+ getEntity().setReversePrimer(selectionPrimerReverse.getSelection());
}
}
}