1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2013 EDIT
|
4
|
* European Distributed Institute of Taxonomy
|
5
|
* http://www.e-taxonomy.eu
|
6
|
*
|
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.
|
9
|
*/
|
10
|
package eu.etaxonomy.taxeditor.ui.section.occurrence.dna;
|
11
|
|
12
|
import org.eclipse.swt.widgets.Text;
|
13
|
|
14
|
import eu.etaxonomy.cdm.model.common.DefinedTerm;
|
15
|
import eu.etaxonomy.cdm.model.common.TermType;
|
16
|
import eu.etaxonomy.cdm.model.molecular.Sequence;
|
17
|
import eu.etaxonomy.cdm.model.molecular.SequenceString;
|
18
|
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
|
19
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
20
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
21
|
import eu.etaxonomy.taxeditor.ui.element.NumberWithLabelElement;
|
22
|
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
|
23
|
import eu.etaxonomy.taxeditor.ui.element.UriWithLabelElement;
|
24
|
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
|
25
|
|
26
|
/**
|
27
|
* @author pplitzner
|
28
|
* @date 19.12.2013
|
29
|
*
|
30
|
*/
|
31
|
public class SequenceGeneralDetailElement extends AbstractCdmDetailElement<Sequence> {
|
32
|
|
33
|
private TermComboElement<DefinedTerm> comboMarker;
|
34
|
private TextWithLabelElement textConsensusSequence;
|
35
|
private NumberWithLabelElement textConsensusSequenceLength;
|
36
|
private TextWithLabelElement textBarcodeSequence;
|
37
|
private TextWithLabelElement textGeneticAccessNo;
|
38
|
private TextWithLabelElement textBoldProcessID;
|
39
|
private UriWithLabelElement textBoldUri;
|
40
|
|
41
|
/**
|
42
|
* @param formFactory
|
43
|
* @param formElement
|
44
|
*/
|
45
|
public SequenceGeneralDetailElement(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, Sequence entity, int style) {
|
58
|
comboMarker = formFactory.createDefinedTermComboElement(TermType.DnaMarker, formElement, "DNA Marker", entity.getDnaMarker(), style);
|
59
|
textConsensusSequence = formFactory.createTextWithLabelElement(formElement, "Consensus Sequence 5'->3'", entity.getConsensusSequence().getString(), style);
|
60
|
textConsensusSequenceLength = formFactory.createNumberTextWithLabelElement(formElement, "Consensus Seq. Length", entity.getConsensusSequence().getLength(), style);
|
61
|
((Text) textConsensusSequenceLength.getMainControl()).setEditable(false);
|
62
|
textBarcodeSequence = formFactory.createTextWithLabelElement(formElement, "Barcode Sequence 5'->3'", entity.getBarcodeSequencePart()==null?"":entity.getBarcodeSequencePart().getString(), style);
|
63
|
|
64
|
textGeneticAccessNo = formFactory.createTextWithLabelElement(formElement, "Genetic Acc. No.", entity.getGeneticAccessionNumber(), style);
|
65
|
textBoldProcessID = formFactory.createTextWithLabelElement(formElement, "BOLD Process ID", entity.getBoldProcessId(), style);
|
66
|
textBoldUri = formFactory.createUriWithLabelElement(formElement, "BOLD URI", entity.getBoldUri(), style);
|
67
|
((Text) textBoldUri.getMainControl()).setEditable(false);
|
68
|
|
69
|
}
|
70
|
|
71
|
/*
|
72
|
* (non-Javadoc)
|
73
|
*
|
74
|
* @see
|
75
|
* eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#handleEvent(java
|
76
|
* .lang.Object)
|
77
|
*/
|
78
|
@Override
|
79
|
public void handleEvent(Object eventSource) {
|
80
|
if(eventSource==comboMarker){
|
81
|
getEntity().setDnaMarker(comboMarker.getSelection());
|
82
|
}
|
83
|
else if(eventSource==textConsensusSequence){
|
84
|
SequenceString consensusSequence = getEntity().getConsensusSequence();
|
85
|
if(consensusSequence==null){
|
86
|
consensusSequence = SequenceString.NewInstance();
|
87
|
}
|
88
|
consensusSequence.setString(textConsensusSequence.getText());
|
89
|
getEntity().setConsensusSequence(consensusSequence);
|
90
|
textConsensusSequenceLength.setNumber(consensusSequence.getLength());
|
91
|
}
|
92
|
else if(eventSource==textConsensusSequenceLength){
|
93
|
// this is a derived value and should not be edited
|
94
|
}
|
95
|
else if(eventSource==textBarcodeSequence){
|
96
|
SequenceString barcodeSequencePart = getEntity().getBarcodeSequencePart();
|
97
|
if(barcodeSequencePart==null){
|
98
|
barcodeSequencePart = SequenceString.NewInstance();
|
99
|
}
|
100
|
barcodeSequencePart.setString(textBarcodeSequence.getText());
|
101
|
getEntity().setBarcodeSequencePart(barcodeSequencePart);
|
102
|
}
|
103
|
else if(eventSource==textGeneticAccessNo){
|
104
|
getEntity().setGeneticAccessionNumber(textGeneticAccessNo.getText());
|
105
|
}
|
106
|
else if(eventSource==textBoldProcessID){
|
107
|
getEntity().setBoldProcessId(textBoldProcessID.getText());
|
108
|
if(textBoldProcessID.getText()!=null && !textBoldProcessID.getText().isEmpty()){
|
109
|
textBoldUri.setUri(getEntity().getBoldUri());
|
110
|
}
|
111
|
else{
|
112
|
textBoldUri.setText("");
|
113
|
}
|
114
|
}
|
115
|
else if(eventSource==textBoldUri){
|
116
|
//cannot be set because it is generated from the genetic access number and a base URI
|
117
|
}
|
118
|
}
|
119
|
|
120
|
}
|