Project

General

Profile

Download (5.25 KB) Statistics
| Branch: | Tag: | Revision:
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 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;
22

    
23
/**
24
 * @author pplitzner
25
 * @date 19.12.2013
26
 *
27
 */
28
public class SequenceGeneralDetailElement extends AbstractCdmDetailElement<Sequence> {
29

    
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;
37

    
38
    /**
39
     * @param formFactory
40
     * @param formElement
41
     */
42
    public SequenceGeneralDetailElement(CdmFormFactory formFactory, ICdmFormElement formElement) {
43
        super(formFactory, formElement);
44
    }
45

    
46
    /*
47
     * (non-Javadoc)
48
     *
49
     * @see
50
     * eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#createControls
51
     * (eu.etaxonomy.taxeditor.forms.ICdmFormElement, java.lang.Object, int)
52
     */
53
    @Override
54
    protected void createControls(ICdmFormElement formElement, Sequence entity, int style) {
55
        comboMarker = formFactory.createTermComboElement(DefinedTerm.class, formElement, "DNA Marker",
56
                entity.getDnaMarker(),
57
                        style);
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
        textBarcodeSequence = formFactory.createTextWithLabelElement(formElement, "Barcode Sequence 5'->3'", entity.getBarcodeSequencePart()==null?"":entity.getBarcodeSequencePart().getString(), style);
61

    
62
        textGeneticAccessNo = formFactory.createTextWithLabelElement(formElement, "Genetic Acc. No.", entity.getGeneticAccessionNumber(), style);
63
        textBoldProcessID = formFactory.createTextWithLabelElement(formElement, "BOLD Process ID", entity.getBoldProcessId(), style);
64
        textBoldUri = formFactory.createUriWithLabelElement(formElement, "BOLD URI", entity.getBoldUri(), style);
65
        textBoldUri.setEnabled(false);
66

    
67
    }
68

    
69
    /*
70
     * (non-Javadoc)
71
     *
72
     * @see
73
     * eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#handleEvent(java
74
     * .lang.Object)
75
     */
76
    @Override
77
    public void handleEvent(Object eventSource) {
78
        if(eventSource==comboMarker){
79
            getEntity().setDnaMarker(comboMarker.getSelection());
80
        }
81
        else if(eventSource==textConsensusSequence){
82
            SequenceString consensusSequence = getEntity().getConsensusSequence();
83
            if(consensusSequence==null){
84
                consensusSequence = SequenceString.NewInstance();
85
            }
86
            consensusSequence.setString(textConsensusSequence.getText());
87
            getEntity().setConsensusSequence(consensusSequence);
88
        }
89
        else if(eventSource==textConsensusSequenceLength){
90
            SequenceString consensusSequence = getEntity().getConsensusSequence();
91
            if(consensusSequence==null){
92
                consensusSequence = SequenceString.NewInstance();
93
            }
94
            consensusSequence.setLength(textConsensusSequenceLength.getInteger());
95
            getEntity().setConsensusSequence(consensusSequence);
96
        }
97
        else if(eventSource==textBarcodeSequence){
98
            SequenceString barcodeSequencePart = getEntity().getBarcodeSequencePart();
99
            if(barcodeSequencePart==null){
100
                barcodeSequencePart = SequenceString.NewInstance();
101
            }
102
            barcodeSequencePart.setString(textBarcodeSequence.getText());
103
            getEntity().setBarcodeSequencePart(barcodeSequencePart);
104
        }
105
        else if(eventSource==textGeneticAccessNo){
106
            getEntity().setGeneticAccessionNumber(textGeneticAccessNo.getText());
107
        }
108
        else if(eventSource==textBoldProcessID){
109
            getEntity().setBoldProcessId(textBoldProcessID.getText());
110
            if(textBoldProcessID.getText()!=null && !textBoldProcessID.getText().isEmpty()){
111
                textBoldUri.setUri(getEntity().getBoldUri());
112
            }
113
            else{
114
                textBoldUri.setText("");
115
            }
116
        }
117
        else if(eventSource==textBoldUri){
118
            //cannot be set because it is generated from the genetic access number and a base URI
119
        }
120
    }
121

    
122
}
(12-12/20)