1
|
/**
|
2
|
* Copyright (C) 2014 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
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.
|
8
|
*/
|
9
|
package eu.etaxonomy.taxeditor.ui.section.occurrence.dna;
|
10
|
|
11
|
import eu.etaxonomy.cdm.model.common.DefinedTerm;
|
12
|
import eu.etaxonomy.cdm.model.common.TermType;
|
13
|
import eu.etaxonomy.cdm.model.molecular.Primer;
|
14
|
import eu.etaxonomy.cdm.model.molecular.SequenceString;
|
15
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
16
|
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
|
17
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
18
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
19
|
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
|
20
|
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
|
21
|
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
|
22
|
import eu.etaxonomy.taxeditor.ui.section.supplemental.AnnotationSection;
|
23
|
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
|
24
|
|
25
|
/**
|
26
|
* @author pplitzner
|
27
|
* @date 06.01.2014
|
28
|
*
|
29
|
*/
|
30
|
public class PrimerGeneralDetailElement extends AbstractCdmDetailElement<Primer> {
|
31
|
|
32
|
|
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;
|
40
|
|
41
|
/**
|
42
|
* @param formFactory
|
43
|
* @param formElement
|
44
|
*/
|
45
|
public PrimerGeneralDetailElement(CdmFormFactory formFactory, ICdmFormElement formElement) {
|
46
|
super(formFactory, formElement);
|
47
|
}
|
48
|
|
49
|
/*
|
50
|
* (non-Javadoc)
|
51
|
*
|
52
|
* @see
|
53
|
* eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#createControls
|
54
|
* (eu.etaxonomy.taxeditor.forms.ICdmFormElement, java.lang.Object, int)
|
55
|
*/
|
56
|
@Override
|
57
|
protected void createControls(ICdmFormElement formElement, Primer entity, int style) {
|
58
|
textPrimerName = formFactory.createTextWithLabelElement(formElement, "Primer Name", entity.getLabel(), style);
|
59
|
String sequenceString = null;
|
60
|
if(entity.getSequence()!=null){
|
61
|
sequenceString = entity.getSequence().getString();
|
62
|
}
|
63
|
textPrimerSequence = formFactory.createTextWithLabelElement(formElement, "Primer seq. 5'->3'", sequenceString, style);
|
64
|
|
65
|
comboMarker = formFactory.createDefinedTermComboElement(TermType.DnaMarker, formElement, "DNA Marker", entity.getDnaMarker(), style);
|
66
|
|
67
|
selectionReference = formFactory
|
68
|
.createSelectionElement(Reference.class,//getConversationHolder(),
|
69
|
formElement, "Reference",
|
70
|
entity.getPublishedIn(),
|
71
|
EntitySelectionElement.ALL, style);
|
72
|
|
73
|
AnnotationSection annotationSection = formFactory.createAnnotationSection(getConversationHolder(), formElement, style);
|
74
|
annotationSection.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
75
|
annotationSection.setEntity(entity);
|
76
|
}
|
77
|
|
78
|
/*
|
79
|
* (non-Javadoc)
|
80
|
*
|
81
|
* @see
|
82
|
* eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#handleEvent(java
|
83
|
* .lang.Object)
|
84
|
*/
|
85
|
@Override
|
86
|
public void handleEvent(Object eventSource) {
|
87
|
if(eventSource==textPrimerName){
|
88
|
getEntity().setLabel(textPrimerName.getText());
|
89
|
}
|
90
|
else if(eventSource==comboMarker){
|
91
|
getEntity().setDnaMarker(comboMarker.getSelection());
|
92
|
}
|
93
|
else if(eventSource==textPrimerSequence){
|
94
|
SequenceString sequenceString = getEntity().getSequence();
|
95
|
if(sequenceString==null){
|
96
|
sequenceString = SequenceString.NewInstance("");
|
97
|
getEntity().setSequence(sequenceString);
|
98
|
}
|
99
|
sequenceString.setString(textPrimerSequence.getText());
|
100
|
}
|
101
|
else if(eventSource==selectionReference){
|
102
|
getEntity().setPublishedIn(selectionReference.getSelection());
|
103
|
}
|
104
|
}
|
105
|
}
|