1
|
/**
|
2
|
* Copyright (C) 2013 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 java.net.URI;
|
12
|
import java.net.URISyntaxException;
|
13
|
|
14
|
import org.eclipse.swt.widgets.Text;
|
15
|
|
16
|
import eu.etaxonomy.cdm.model.term.DefinedTerm;
|
17
|
import eu.etaxonomy.cdm.model.term.TermType;
|
18
|
import eu.etaxonomy.cdm.model.molecular.Sequence;
|
19
|
import eu.etaxonomy.cdm.model.molecular.SequenceString;
|
20
|
import eu.etaxonomy.taxeditor.preference.Resources;
|
21
|
import eu.etaxonomy.taxeditor.ui.combo.term.TermComboElement;
|
22
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
23
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
24
|
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
|
25
|
import eu.etaxonomy.taxeditor.ui.element.UriWithLabelElement;
|
26
|
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
|
27
|
|
28
|
/**
|
29
|
* @author pplitzner
|
30
|
* @date 19.12.2013
|
31
|
*/
|
32
|
public class SequenceGeneralDetailElement extends AbstractCdmDetailElement<Sequence> {
|
33
|
|
34
|
private TermComboElement<DefinedTerm> comboMarker;
|
35
|
private TextWithLabelElement textConsensusSequence;
|
36
|
private TextWithLabelElement textGeneticAccessNo;
|
37
|
private UriWithLabelElement textNCBIUri;
|
38
|
private UriWithLabelElement textENAUri;
|
39
|
private UriWithLabelElement textDDBJUri;
|
40
|
private TextWithLabelElement textBoldProcessID;
|
41
|
private UriWithLabelElement textBoldUri;
|
42
|
|
43
|
/**
|
44
|
* @param formFactory
|
45
|
* @param formElement
|
46
|
*/
|
47
|
public SequenceGeneralDetailElement(CdmFormFactory formFactory, ICdmFormElement formElement) {
|
48
|
super(formFactory, formElement);
|
49
|
}
|
50
|
|
51
|
/*
|
52
|
* (non-Javadoc)
|
53
|
*
|
54
|
* @see
|
55
|
* eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#createControls
|
56
|
* (eu.etaxonomy.taxeditor.forms.ICdmFormElement, java.lang.Object, int)
|
57
|
*/
|
58
|
@Override
|
59
|
protected void createControls(ICdmFormElement formElement, Sequence entity, int style) {
|
60
|
comboMarker = formFactory.createDefinedTermComboElement(TermType.DnaMarker, formElement, "DNA Marker", entity.getDnaMarker(), style);
|
61
|
textConsensusSequence = formFactory.createTextWithLabelElement(formElement, "Consensus Sequence 5'->3'", entity.getConsensusSequence().getString(), style);
|
62
|
|
63
|
URI genBankUri = null;
|
64
|
URI emblUri = null;
|
65
|
URI ddbjUri = null;
|
66
|
URI boldUri = null;
|
67
|
try{
|
68
|
genBankUri = entity.getGenBankUri();
|
69
|
emblUri = entity.getEmblUri();
|
70
|
ddbjUri = entity.getDdbjUri();
|
71
|
boldUri = entity.getBoldUri();
|
72
|
}
|
73
|
catch(URISyntaxException e){
|
74
|
|
75
|
}
|
76
|
textGeneticAccessNo = formFactory.createTextWithLabelElement(formElement, "Genetic Acc. No.", entity.getGeneticAccessionNumber(), style);
|
77
|
textNCBIUri = formFactory.createUriWithLabelElement(formElement, "NCBI URI", genBankUri, style);
|
78
|
((Text) textNCBIUri.getMainControl()).setEditable(false);
|
79
|
textENAUri = formFactory.createUriWithLabelElement(formElement, "ENA URI", emblUri, style);
|
80
|
((Text) textENAUri.getMainControl()).setEditable(false);
|
81
|
textDDBJUri = formFactory.createUriWithLabelElement(formElement, "DDBJ URI", ddbjUri, style);
|
82
|
((Text) textDDBJUri.getMainControl()).setEditable(false);
|
83
|
textBoldProcessID = formFactory.createTextWithLabelElement(formElement, "BOLD Process ID", entity.getBoldProcessId(), style);
|
84
|
textBoldUri = formFactory.createUriWithLabelElement(formElement, "BOLD URI", boldUri, style);
|
85
|
((Text) textBoldUri.getMainControl()).setEditable(false);
|
86
|
((Text) textBoldUri.getMainControl()).setToolTipText("Query BOLD");
|
87
|
}
|
88
|
|
89
|
/*
|
90
|
* (non-Javadoc)
|
91
|
*
|
92
|
* @see
|
93
|
* eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#handleEvent(java
|
94
|
* .lang.Object)
|
95
|
*/
|
96
|
@Override
|
97
|
public void handleEvent(Object eventSource) {
|
98
|
if(eventSource==comboMarker){
|
99
|
getEntity().setDnaMarker(comboMarker.getSelection());
|
100
|
}
|
101
|
else if(eventSource==textConsensusSequence){
|
102
|
SequenceString consensusSequence = getEntity().getConsensusSequence();
|
103
|
if(consensusSequence==null){
|
104
|
consensusSequence = SequenceString.NewInstance();
|
105
|
}
|
106
|
consensusSequence.setString(textConsensusSequence.getText());
|
107
|
getEntity().setConsensusSequence(consensusSequence);
|
108
|
}
|
109
|
else if(eventSource==textGeneticAccessNo){
|
110
|
textGeneticAccessNo.setBackground(getPersistentBackground());
|
111
|
getEntity().setGeneticAccessionNumber(textGeneticAccessNo.getText());
|
112
|
if(textGeneticAccessNo.getText()!=null && !textGeneticAccessNo.getText().isEmpty()){
|
113
|
try {
|
114
|
textNCBIUri.setParsedText(getEntity().getGenBankUri());
|
115
|
textENAUri.setParsedText(getEntity().getEmblUri());
|
116
|
textDDBJUri.setParsedText(getEntity().getDdbjUri());
|
117
|
} catch (URISyntaxException e) {
|
118
|
textGeneticAccessNo.setBackground(getColor(Resources.COLOR_PARSE_ERROR));
|
119
|
}
|
120
|
}
|
121
|
else{
|
122
|
textNCBIUri.setText("");
|
123
|
textENAUri.setText("");
|
124
|
textDDBJUri.setText("");
|
125
|
}
|
126
|
}
|
127
|
else if(eventSource==textBoldProcessID){
|
128
|
textBoldProcessID.setBackground(getPersistentBackground());
|
129
|
getEntity().setBoldProcessId(textBoldProcessID.getText());
|
130
|
if(textBoldProcessID.getText()!=null && !textBoldProcessID.getText().isEmpty()){
|
131
|
try {
|
132
|
textBoldUri.setParsedText(getEntity().getBoldUri());
|
133
|
} catch (URISyntaxException e) {
|
134
|
textBoldProcessID.setBackground(getColor(Resources.COLOR_PARSE_ERROR));
|
135
|
}
|
136
|
}
|
137
|
else{
|
138
|
textBoldUri.setText("");
|
139
|
}
|
140
|
}
|
141
|
}
|
142
|
|
143
|
}
|