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
.dna
;
12 import eu
.etaxonomy
.cdm
.model
.common
.DefinedTerm
;
13 import eu
.etaxonomy
.cdm
.model
.molecular
.Sequence
;
14 import eu
.etaxonomy
.cdm
.model
.molecular
.SequenceString
;
15 import eu
.etaxonomy
.taxeditor
.ui
.combo
.TermComboElement
;
16 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
17 import eu
.etaxonomy
.taxeditor
.ui
.element
.ICdmFormElement
;
18 import eu
.etaxonomy
.taxeditor
.ui
.element
.NumberWithLabelElement
;
19 import eu
.etaxonomy
.taxeditor
.ui
.element
.TextWithLabelElement
;
20 import eu
.etaxonomy
.taxeditor
.ui
.element
.UriWithLabelElement
;
21 import eu
.etaxonomy
.taxeditor
.ui
.section
.AbstractCdmDetailElement
;
28 public class SequenceGeneralDetailElement
extends AbstractCdmDetailElement
<Sequence
> {
30 private TermComboElement
<DefinedTerm
> comboMarker
;
31 private TextWithLabelElement textConsensusSequence
;
32 private NumberWithLabelElement textConsensusSequenceLength
;
33 private TextWithLabelElement textBarcodeSequence
;
34 private TextWithLabelElement textGeneticAccessNo
;
35 private TextWithLabelElement textBoldProcessID
;
36 private UriWithLabelElement textBoldUri
;
42 public SequenceGeneralDetailElement(CdmFormFactory formFactory
, ICdmFormElement formElement
) {
43 super(formFactory
, formElement
);
50 * eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#createControls
51 * (eu.etaxonomy.taxeditor.forms.ICdmFormElement, java.lang.Object, int)
54 protected void createControls(ICdmFormElement formElement
, Sequence entity
, int style
) {
55 comboMarker
= formFactory
.createTermComboElement(DefinedTerm
.class, formElement
, "DNA Marker",
56 entity
.getDnaMarker(),
58 textConsensusSequence
= formFactory
.createTextWithLabelElement(formElement
, "Consensus Sequence 5'->3'", entity
.getConsensusSequence().getString(), style
);
59 textConsensusSequenceLength
= formFactory
.createNumberTextWithLabelElement(formElement
, "Consensus Seq. Length", entity
.getConsensusSequence().getLength(), style
);
60 textConsensusSequenceLength
.setEnabled(false);
61 textBarcodeSequence
= formFactory
.createTextWithLabelElement(formElement
, "Barcode Sequence 5'->3'", entity
.getBarcodeSequencePart()==null?
"":entity
.getBarcodeSequencePart().getString(), style
);
63 textGeneticAccessNo
= formFactory
.createTextWithLabelElement(formElement
, "Genetic Acc. No.", entity
.getGeneticAccessionNumber(), style
);
64 textBoldProcessID
= formFactory
.createTextWithLabelElement(formElement
, "BOLD Process ID", entity
.getBoldProcessId(), style
);
65 textBoldUri
= formFactory
.createUriWithLabelElement(formElement
, "BOLD URI", entity
.getBoldUri(), style
);
66 textBoldUri
.setEnabled(false);
74 * eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#handleEvent(java
78 public void handleEvent(Object eventSource
) {
79 if(eventSource
==comboMarker
){
80 getEntity().setDnaMarker(comboMarker
.getSelection());
82 else if(eventSource
==textConsensusSequence
){
83 SequenceString consensusSequence
= getEntity().getConsensusSequence();
84 if(consensusSequence
==null){
85 consensusSequence
= SequenceString
.NewInstance();
87 consensusSequence
.setString(textConsensusSequence
.getText());
88 getEntity().setConsensusSequence(consensusSequence
);
89 textConsensusSequenceLength
.setNumber(consensusSequence
.getLength());
91 else if(eventSource
==textConsensusSequenceLength
){
92 // this is a derived value and should not be edited
94 else if(eventSource
==textBarcodeSequence
){
95 SequenceString barcodeSequencePart
= getEntity().getBarcodeSequencePart();
96 if(barcodeSequencePart
==null){
97 barcodeSequencePart
= SequenceString
.NewInstance();
99 barcodeSequencePart
.setString(textBarcodeSequence
.getText());
100 getEntity().setBarcodeSequencePart(barcodeSequencePart
);
102 else if(eventSource
==textGeneticAccessNo
){
103 getEntity().setGeneticAccessionNumber(textGeneticAccessNo
.getText());
105 else if(eventSource
==textBoldProcessID
){
106 getEntity().setBoldProcessId(textBoldProcessID
.getText());
107 if(textBoldProcessID
.getText()!=null && !textBoldProcessID
.getText().isEmpty()){
108 textBoldUri
.setUri(getEntity().getBoldUri());
111 textBoldUri
.setText("");
114 else if(eventSource
==textBoldUri
){
115 //cannot be set because it is generated from the genetic access number and a base URI