Project

General

Profile

Download (4.31 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
 * Copyright (C) 2007 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

    
10
package eu.etaxonomy.taxeditor.ui.section.occurrence.association;
11

    
12
import java.util.Set;
13

    
14
import org.eclipse.swt.events.SelectionListener;
15

    
16
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
17
import eu.etaxonomy.cdm.model.common.TermType;
18
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation;
19
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignationStatus;
20
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
21
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
22
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
23
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
24
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
25
import eu.etaxonomy.taxeditor.ui.section.name.AbstractTypeDesignationElement;
26
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
27

    
28
/**
29
 * @author n.hoffmann
30
 * @created May 17, 2010
31
 */
32
public class DerivedUnitTypeDesignationElement extends AbstractTypeDesignationElement<SpecimenTypeDesignation> {
33

    
34
    private TermComboElement<SpecimenTypeDesignationStatus> combo_typeStatus;
35

    
36
//    private List<EntitySelectionElement<TaxonNameBase>> selectionTaxonNames;
37
    private ICdmFormElement parentFormElement;
38
    private int style;
39

    
40
    private EntitySelectionElement<TaxonNameBase> selectionTaxonName;
41

    
42
    public DerivedUnitTypeDesignationElement(CdmFormFactory formFactory,
43
            AbstractFormSection section, SpecimenTypeDesignation entity,
44
            SelectionListener removeListener, int style) {
45
        super(formFactory, section, entity, removeListener, style);
46
    }
47

    
48
    @Override
49
    public void setEntity(SpecimenTypeDesignation entity) {
50
        super.setEntity(entity);
51
        Set<TaxonNameBase> typifiedNames = entity.getTypifiedNames();
52
        if(typifiedNames.size()==1){
53
            selectionTaxonName.setEntity(typifiedNames.iterator().next());
54
        }
55
        else if(typifiedNames.size()>1){
56
            formFactory.createLabel(getLayoutComposite(), "!!!!!!!!");
57
        }
58

    
59
        SpecimenTypeDesignationStatus typeStatus = HibernateProxyHelper
60
        		.deproxy(entity.getTypeStatus());
61
        combo_typeStatus.setSelection(typeStatus);
62
        checkbox_notDesignated.setSelection(entity.isNotDesignated());
63

    
64
//        for (TaxonNameBase taxonNameBase : typifiedNames) {
65
//            EntitySelectionElement<TaxonNameBase> selectionElement = formFactory.createSelectionElement(
66
//                    TaxonNameBase.class, getConversationHolder(), parentFormElement, "Scientific Name", null,
67
//                    EntitySelectionElement.EDITABLE | EntitySelectionElement.SELECTABLE, style);
68
//            selectionElement.setEntity(taxonNameBase);
69
//        }
70

    
71

    
72
    }
73

    
74
    /** {@inheritDoc} */
75
    @Override
76
    public void createControls(ICdmFormElement element, int style) {
77
        this.parentFormElement = element;
78
        this.style = style;
79

    
80
        selectionTaxonName = formFactory.createSelectionElement(
81
                TaxonNameBase.class, getConversationHolder(), parentFormElement, "Scientific Name", null,
82
                EntitySelectionElement.EDITABLE | EntitySelectionElement.SELECTABLE, style);
83

    
84
        combo_typeStatus = formFactory.createDefinedTermComboElement(TermType.SpecimenTypeDesignationStatus,
85
                parentFormElement, "Designation Status", null, style);
86

    
87
        super.createControls(element, style);
88
    }
89

    
90
    /** {@inheritDoc} */
91
    @Override
92
    public void handleEvent(Object eventSource) {
93
        if (eventSource == selectionTaxonName) {
94
            selectionTaxonName.getSelection().addTypeDesignation(getEntity(), false);
95
        } else if (eventSource == combo_typeStatus) {
96
            getEntity().setTypeStatus(combo_typeStatus.getSelection());
97
        } else if (eventSource == checkbox_notDesignated) {
98
            getEntity().setNotDesignated(checkbox_notDesignated.getSelection());
99
        } else if (eventSource == selection_reference) {
100
            getEntity().setCitation(selection_reference.getSelection());
101
        } else if (eventSource == text_referenceDetail) {
102
            getEntity().setCitationMicroReference(
103
                    text_referenceDetail.getText());
104
        }
105
    }
106

    
107
}
(1-1/4)