3 * Copyright (C) 2013 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
;
12 import org
.eclipse
.ui
.forms
.widgets
.ExpandableComposite
;
14 import eu
.etaxonomy
.cdm
.model
.common
.DefinedTerm
;
15 import eu
.etaxonomy
.cdm
.model
.molecular
.Sequence
;
16 import eu
.etaxonomy
.cdm
.model
.molecular
.SequenceString
;
17 import eu
.etaxonomy
.taxeditor
.ui
.campanula
.compatibility
.ICdmFormElement
;
18 import eu
.etaxonomy
.taxeditor
.ui
.combo
.TermComboElement
;
19 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
20 import eu
.etaxonomy
.taxeditor
.ui
.element
.LayoutConstants
;
21 import eu
.etaxonomy
.taxeditor
.ui
.element
.NumberWithLabelElement
;
22 import eu
.etaxonomy
.taxeditor
.ui
.element
.TextWithLabelElement
;
23 import eu
.etaxonomy
.taxeditor
.ui
.section
.AbstractCdmDetailElement
;
30 public class SequenceGeneralDetailElement
extends AbstractCdmDetailElement
<Sequence
> {
32 private TermComboElement
<DefinedTerm
> comboMarker
;
33 private TextWithLabelElement textContigFile
;
34 private TextWithLabelElement textConsensusSequence
;
35 private NumberWithLabelElement textConsensusSequenceLength
;
36 private TextWithLabelElement textBarcodeSequence
;
37 private TextWithLabelElement textGeneticAccessNo
;
38 private TextWithLabelElement textBoldProcessID
;
39 private TextWithLabelElement textBoldLink
;
41 private SequenceReferenceCollectionDetailSection sectionReferenceCollection
;
47 public SequenceGeneralDetailElement(CdmFormFactory formFactory
, ICdmFormElement formElement
) {
48 super(formFactory
, formElement
);
55 * eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#createControls
56 * (eu.etaxonomy.taxeditor.forms.ICdmFormElement, java.lang.Object, int)
59 protected void createControls(ICdmFormElement formElement
, Sequence entity
, int style
) {
60 comboMarker
= formFactory
.createTermComboElement(DefinedTerm
.class, formElement
, "DNA Marker",
61 entity
.getDnaMarker(),
63 textContigFile
= formFactory
.createTextWithLabelElement(formElement
, "Contig File", "XXX", style
);
64 textConsensusSequence
= formFactory
.createTextWithLabelElement(formElement
, "Consensus Sequence 5'->3'", entity
.getConsensusSequence().getString(), style
);
65 textConsensusSequenceLength
= formFactory
.createNumberTextWithLabelElement(formElement
, "Consensus Seq. Length", entity
.getConsensusSequence().getLength(), style
);
66 textBarcodeSequence
= formFactory
.createTextWithLabelElement(formElement
, "Barcode Sequence 5'->3'", entity
.getBarcodeSequencePart()==null?
"":entity
.getBarcodeSequencePart().getString(), style
);
68 textGeneticAccessNo
= formFactory
.createTextWithLabelElement(formElement
, "Genetic Acc. No.", entity
.getGeneticAccessionNumber(), style
);
69 textBoldProcessID
= formFactory
.createTextWithLabelElement(formElement
, "BOLD Process ID", entity
.getBoldProcessId(), style
);
70 textBoldLink
= formFactory
.createTextWithLabelElement(formElement
, "BOLD URI", entity
.getBoldUri(), style
);
71 textBoldLink
.setEnabled(false);
73 sectionReferenceCollection
= formFactory
.createSequenceReferenceCollectionDetailSection(getConversationHolder(), formElement
, ExpandableComposite
.TWISTIE
);
74 sectionReferenceCollection
.setLayoutData(LayoutConstants
.FILL_HORIZONTALLY(2, 1));
75 sectionReferenceCollection
.setEntity(entity
);
82 * eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#handleEvent(java
86 public void handleEvent(Object eventSource
) {
87 if(eventSource
==comboMarker
){
88 getEntity().setDnaMarker(comboMarker
.getSelection());
90 else if(eventSource
==textContigFile
){
93 else if(eventSource
==textConsensusSequence
){
94 SequenceString consensusSequence
= getEntity().getConsensusSequence();
95 if(consensusSequence
==null){
96 consensusSequence
= SequenceString
.NewInstance();
98 consensusSequence
.setString(textConsensusSequence
.getText());
99 getEntity().setConsensusSequence(consensusSequence
);
101 else if(eventSource
==textConsensusSequenceLength
){
102 SequenceString consensusSequence
= getEntity().getConsensusSequence();
103 if(consensusSequence
==null){
104 consensusSequence
= SequenceString
.NewInstance();
106 consensusSequence
.setLength(textConsensusSequenceLength
.getInteger());
107 getEntity().setConsensusSequence(consensusSequence
);
109 else if(eventSource
==textBarcodeSequence
){
110 SequenceString barcodeSequencePart
= getEntity().getBarcodeSequencePart();
111 if(barcodeSequencePart
==null){
112 barcodeSequencePart
= SequenceString
.NewInstance();
114 barcodeSequencePart
.setString(textBarcodeSequence
.getText());
115 getEntity().setBarcodeSequencePart(barcodeSequencePart
);
117 else if(eventSource
==textGeneticAccessNo
){
118 getEntity().setGeneticAccessionNumber(textGeneticAccessNo
.getText());
120 else if(eventSource
==textBoldProcessID
){
121 getEntity().setBoldProcessId(textBoldProcessID
.getText());
122 if(textBoldProcessID
.getText()!=null && !textBoldProcessID
.getText().isEmpty()){
123 textBoldLink
.setText(getEntity().getBoldUri().toString());
126 textBoldLink
.setText("");
129 else if(eventSource
==textBoldLink
){
130 //cannot be set because it is generated from the genetic access number and a base URI