Project

General

Profile

« Previous | Next » 

Revision d21a66e3

Added by Patrick Plitzner over 7 years ago

Inherit from abstract type designation element

  • label fix

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/association/DerivedUnitTypeDesignationElement.java
15 15

  
16 16
import org.eclipse.swt.events.SelectionListener;
17 17

  
18
import eu.etaxonomy.cdm.model.common.TermType;
18 19
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation;
20
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignationStatus;
19 21
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
22
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
23
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
20 24
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
21 25
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
22 26
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
23
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement;
27
import eu.etaxonomy.taxeditor.ui.section.name.AbstractTypeDesignationElement;
24 28
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
25 29

  
26 30
/**
......
28 32
 * @created May 17, 2010
29 33
 * @version 1.0
30 34
 */
31
public class DerivedUnitTypeDesignationElement extends
32
		AbstractEntityCollectionElement<SpecimenTypeDesignation> {
35
public class DerivedUnitTypeDesignationElement extends AbstractTypeDesignationElement<SpecimenTypeDesignation> {
36

  
37
    private TermComboElement<SpecimenTypeDesignationStatus> combo_typeStatus;
38
    private EntitySelectionElement<DerivedUnit> selection_typeSpecimen;
33 39

  
34 40
    private List<EntitySelectionElement<TaxonNameBase>> selectionTaxonNames;
35 41
    private ICdmFormElement parentFormElement;
......
38 44
    public DerivedUnitTypeDesignationElement(CdmFormFactory formFactory,
39 45
            AbstractFormSection section, SpecimenTypeDesignation entity,
40 46
            SelectionListener removeListener, int style) {
41
        super(formFactory, section, entity, removeListener, null, style);
47
        super(formFactory, section, entity, removeListener, style);
42 48
    }
43 49

  
44 50
    @Override
......
47 53
        Set<TaxonNameBase> typifiedNames = entity.getTypifiedNames();
48 54
        if(typifiedNames.isEmpty()){
49 55
            formFactory.createSelectionElement(
50
                    TaxonNameBase.class, getConversationHolder(), parentFormElement, "Taxon Name", null,
56
                    TaxonNameBase.class, getConversationHolder(), parentFormElement, "Scientific Name", null,
51 57
                    EntitySelectionElement.EDITABLE | EntitySelectionElement.SELECTABLE, style);
52 58
        }
53 59
        else{
54 60
            for (TaxonNameBase taxonNameBase : typifiedNames) {
55 61
                EntitySelectionElement<TaxonNameBase> selectionElement = formFactory.createSelectionElement(
56
                        TaxonNameBase.class, getConversationHolder(), parentFormElement, "Taxon Name", null,
62
                        TaxonNameBase.class, getConversationHolder(), parentFormElement, "Scientific Name", null,
57 63
                        EntitySelectionElement.EDITABLE | EntitySelectionElement.SELECTABLE, style);
58 64
                selectionElement.setEntity(taxonNameBase);
59 65
            }
60 66
        }
67

  
68
        checkbox_notDesignated = formFactory.createCheckbox(parentFormElement, "Not Designated", false, style);
69

  
70
        selection_typeSpecimen = formFactory
71
                .createSelectionElement(DerivedUnit.class,
72
                        getConversationHolder(), parentFormElement, "Specimen", null,
73
                        EntitySelectionElement.ALL, style);
74
        combo_typeStatus = formFactory.createDefinedTermComboElement(TermType.SpecimenTypeDesignationStatus,
75
                        parentFormElement, "Designation Status", null, style);
76

  
61 77
    }
62 78

  
63 79
    /** {@inheritDoc} */
......
65 81
    public void createControls(ICdmFormElement element, int style) {
66 82
        this.parentFormElement = element;
67 83
        this.style = style;
84
        super.createControls(element, style);
68 85
    }
69 86

  
70 87
    /** {@inheritDoc} */
71 88
    @Override
72 89
    public void handleEvent(Object eventSource) {
73
        if (eventSource instanceof EntitySelectionElement) {
90
        if (selectionTaxonNames.contains(eventSource)) {
74 91
            ((EntitySelectionElement<TaxonNameBase>) eventSource).getSelection().addTypeDesignation(getEntity(), false);
75 92
        }
93
        else if (eventSource == combo_typeStatus) {
94
            getEntity().setTypeStatus(combo_typeStatus.getSelection());
95
        } else if (eventSource == selection_typeSpecimen) {
96
            getEntity().setTypeSpecimen(selection_typeSpecimen.getSelection());
97
        }  else if (eventSource == checkbox_notDesignated) {
98
            getEntity().setNotDesignated(checkbox_notDesignated.getSelection());
99
        }
76 100
    }
77 101

  
78 102
}

Also available in: Unified diff