Project

General

Profile

Download (6.32 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.agent.AgentBase;
13
import eu.etaxonomy.cdm.model.agent.Institution;
14
import eu.etaxonomy.cdm.model.common.DefinedTerm;
15
import eu.etaxonomy.cdm.model.common.TermType;
16
import eu.etaxonomy.cdm.model.common.TimePeriod;
17
import eu.etaxonomy.cdm.model.molecular.Amplification;
18
import eu.etaxonomy.cdm.model.molecular.Primer;
19
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
20
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
21
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
22
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
23
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
24
import eu.etaxonomy.taxeditor.ui.element.TimePeriodElement;
25
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
26
import eu.etaxonomy.taxeditor.ui.section.supplemental.AnnotationSection;
27
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
28

    
29
/**
30
 * @author pplitzner
31
 * @date 19.12.2013
32
 *
33
 */
34
public class AmplificationGeneralDetailElement extends AbstractCdmDetailElement<Amplification> {
35

    
36
    private TextWithLabelElement textDesignation;
37
    private TextWithLabelElement textNotes;
38
    private TermComboElement<DefinedTerm> comboMarker;
39
    private TimePeriodElement dateAmplification;
40
    private EntitySelectionElement<Institution> selectionInstitution;
41
    private EntitySelectionElement<AgentBase> selectionAmplificationStaff;
42
    private EntitySelectionElement<Primer> selectionPrimerFW;
43
    private EntitySelectionElement<Primer> selectionPrimerRW;
44

    
45
    /**
46
     * @param formFactory
47
     * @param formElement
48
     */
49
    public AmplificationGeneralDetailElement(CdmFormFactory formFactory, ICdmFormElement formElement) {
50
        super(formFactory, formElement);
51
    }
52

    
53
    /*
54
     * (non-Javadoc)
55
     *
56
     * @see
57
     * eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#createControls
58
     * (eu.etaxonomy.taxeditor.forms.ICdmFormElement, java.lang.Object, int)
59
     */
60
    @Override
61
    protected void createControls(ICdmFormElement formElement, Amplification entity, int style) {
62
        textDesignation = formFactory.createTextWithLabelElement(formElement, "Designation", entity.getDescription(), style);
63
        textDesignation.setEnabled(false);
64
        //TODO institution
65
//        selectionInstitution = formFactory.createSelectionElement(Institution.class, getConversationHolder(), formElement, "Institution", entity.getInstitution(), EntitySelectionElement.ALL, style);
66
        selectionAmplificationStaff = formFactory.createSelectionElement(AgentBase.class, getConversationHolder(), formElement, "Amplification staff", entity.getActor(), EntitySelectionElement.ALL, style);
67
        dateAmplification = formFactory.createTimePeriodElement(formElement, "Date", entity.getTimeperiod(), style);
68
        comboMarker = formFactory.createDefinedTermComboElement(TermType.DnaMarker, formElement, "DNA Marker", entity.getDnaMarker(), style);
69
        selectionPrimerFW = formFactory.createSelectionElement(Primer.class, getConversationHolder(), formElement, "Primer FW", entity.getForwardPrimer(), EntitySelectionElement.ALL, style);
70
        selectionPrimerRW = formFactory.createSelectionElement(Primer.class, getConversationHolder(), formElement, "Primer RW", entity.getReversePrimer(), EntitySelectionElement.ALL, style);
71

    
72
        AnnotationSection annotationSection = formFactory.createAnnotationSection(getConversationHolder(), formElement, style);
73
        annotationSection.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
74
        annotationSection.setEntity(entity);
75

    
76
        updateDesignationText();
77
    }
78

    
79
    private void updateDesignationText(){
80
        String institutionName = "";
81
        String staffName = "";
82
        String dateString = "";
83
        //TODO institution
84
//        Institution selection = selectionInstitution.getSelection();
85
//        if(selection!=null){
86
//            institutionName = selection.getName();
87
//        }
88
        AgentBase staff = selectionAmplificationStaff.getSelection();
89
        if(staff!=null){
90
            staffName = staff.getTitleCache();
91
        }
92
        TimePeriod timePeriod = dateAmplification.getTimePeriod();
93
        if(timePeriod!=null){
94
            dateString = timePeriod.toString()!=null?timePeriod.toString():"";
95
        }
96
        String designation = "";
97
        if(!institutionName.equals("")){
98
            designation += institutionName;
99
        }
100
        if(!staffName.equals("")){
101
            if(!designation.equals("")){
102
                designation += "_";
103
            }
104
            designation += staffName;
105
        }
106
        if(!dateString.equals("")){
107
            if(!designation.equals("")){
108
                designation += "_";
109
            }
110
            designation += dateString;
111
        }
112
        textDesignation.setText(designation);
113
        getEntity().setDescription(designation);
114
    }
115

    
116
    /*
117
     * (non-Javadoc)
118
     *
119
     * @see
120
     * eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#handleEvent(java
121
     * .lang.Object)
122
     */
123
    @Override
124
    public void handleEvent(Object eventSource) {
125
        if(eventSource==textNotes){
126
            getEntity().setDescription(textNotes.getText());
127
        }
128
        else if(eventSource==comboMarker){
129
            getEntity().setDnaMarker(comboMarker.getSelection());
130
        }
131
        else if(eventSource==dateAmplification){
132
            getEntity().setTimeperiod(dateAmplification.getTimePeriod());
133
            updateDesignationText();
134
        }
135
        else if(eventSource==selectionAmplificationStaff){
136
            getEntity().setActor(selectionAmplificationStaff.getEntity());
137
            updateDesignationText();
138
        }
139
        else if(eventSource==selectionInstitution){
140
            //TODO institution
141
//            getEntity().setInstitution(selectionInstitution.getSelection());
142
            updateDesignationText();
143
        }
144
        else if(eventSource==selectionPrimerFW){
145
            getEntity().setForwardPrimer(selectionPrimerFW.getSelection());
146
        }
147
        else if(eventSource==selectionPrimerRW){
148
            getEntity().setReversePrimer(selectionPrimerRW.getSelection());
149
        }
150
    }
151
}
(7-7/30)