Project

General

Profile

Download (4.47 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.term.TermType;
18
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation;
19
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignationStatus;
20
import eu.etaxonomy.cdm.model.name.TaxonName;
21
import eu.etaxonomy.taxeditor.ui.combo.term.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
33
		extends AbstractTypeDesignationElement<SpecimenTypeDesignation> {
34

    
35
    private TermComboElement<SpecimenTypeDesignationStatus> combo_typeStatus;
36

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

    
41
    private EntitySelectionElement<TaxonName> selectionTaxonName;
42

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

    
49
    @Override
50
    public void setEntity(SpecimenTypeDesignation entity) {
51
        super.setEntity(entity);
52
        if (combo_typeStatus != null){
53
	        Set<TaxonName> typifiedNames = entity.getTypifiedNames();
54
	        if(typifiedNames.size()==1){
55
	            selectionTaxonName.setEntity(typifiedNames.iterator().next());
56
	        }
57
	        else if(typifiedNames.size()>1){
58
	            formFactory.createLabel(getLayoutComposite(), "!!!!!!!!");
59
	        }
60
	
61
	        SpecimenTypeDesignationStatus typeStatus = HibernateProxyHelper
62
	        		.deproxy(entity.getTypeStatus());
63
	        combo_typeStatus.setSelection(typeStatus);
64
	        checkbox_notDesignated.setSelection(entity.isNotDesignated());
65
        }
66

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

    
74

    
75
    }
76

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

    
83
        selectionTaxonName = formFactory.createSelectionElement(
84
                TaxonName.class, //getConversationHolder(),
85
                parentFormElement, "Scientific Name", null,
86
                EntitySelectionElement.EDITABLE | EntitySelectionElement.SELECTABLE, style);
87

    
88
        combo_typeStatus = formFactory.createDefinedTermComboElement(TermType.SpecimenTypeDesignationStatus,
89
                parentFormElement, "Designation Status", null, style);
90

    
91
        super.createControls(element, style);
92
        if (entity != null){
93
        	setEntity(entity);
94
        }
95
    }
96

    
97
    /** {@inheritDoc} */
98
    @Override
99
    public void handleEvent(Object eventSource) {
100
        if (eventSource == selectionTaxonName) {
101
            selectionTaxonName.getSelection().addTypeDesignation(getEntity(), false);
102
        } else if (eventSource == combo_typeStatus) {
103
            getEntity().setTypeStatus(combo_typeStatus.getSelection());
104
        } else if (eventSource == checkbox_notDesignated) {
105
            getEntity().setNotDesignated(checkbox_notDesignated.getSelection());
106
        }
107
//        else if (eventSource == selection_reference) {
108
//            getEntity().setCitation(selection_reference.getSelection());
109
//        } else if (eventSource == text_referenceDetail) {
110
//            getEntity().setCitationMicroReference(
111
//                    text_referenceDetail.getText());
112
//        }
113
    }
114

    
115
}
(1-1/4)