Project

General

Profile

Download (3.53 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2016 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
package eu.etaxonomy.taxeditor.ui.section.classification;
10

    
11
import org.eclipse.swt.events.SelectionListener;
12
import org.eclipse.swt.graphics.Color;
13

    
14
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
15
import eu.etaxonomy.cdm.model.common.DefinedTerm;
16
import eu.etaxonomy.cdm.model.common.TermType;
17
import eu.etaxonomy.cdm.model.taxon.TaxonNodeAgentRelation;
18
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
19
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
20
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
21
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
22
import eu.etaxonomy.taxeditor.ui.element.LabelElement;
23
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement;
24
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
25

    
26
/**
27
 * @author k.luther
28
 * @date 22.03.2016
29
 *
30
 */
31
public class TaxonNodeAgentRelationCollectionElement extends AbstractEntityCollectionElement<TaxonNodeAgentRelation> {
32

    
33

    
34
    /**
35
     * @param formFactory
36
     * @param section
37
     * @param entity
38
     * @param removeListener
39
     * @param backgroundColor
40
     * @param style
41
     */
42
    public TaxonNodeAgentRelationCollectionElement(CdmFormFactory formFactory, AbstractFormSection section,
43
            TaxonNodeAgentRelation entity, SelectionListener removeListener, Color backgroundColor, int style) {
44
        super(formFactory, section, entity, removeListener, backgroundColor, style);
45
    }
46

    
47

    
48

    
49

    
50
    private EntitySelectionElement<TeamOrPersonBase> selection_toPerson;
51
    private TermComboElement<DefinedTerm> combo_relationshipType;
52
    private LabelElement label;
53

    
54

    
55

    
56
    @Override
57
    public void setEntity(TaxonNodeAgentRelation entity) {
58

    
59
        if(entity.getId()!=0){
60
            combo_relationshipType.setSelection(entity.getType());
61
            selection_toPerson.setEntity(entity.getAgent());
62
        }
63
        this.entity = entity;
64
    }
65

    
66
    @Override
67
    public void handleEvent(Object eventSource) {
68
        if(eventSource==combo_relationshipType){
69

    
70
            entity.setType(combo_relationshipType.getSelection());
71

    
72
        }else if (eventSource == selection_toPerson){
73
            entity.setAgent(selection_toPerson.getEntity());
74
        }
75
    }
76

    
77
    @Override
78
    public void createControls(ICdmFormElement element, int style) {
79
        combo_relationshipType = formFactory.createDefinedTermComboElement(TermType.TaxonNodeAgentRelationType, element, "Relation type", null, style);
80
        if (entity != null){
81
            selection_toPerson = formFactory
82
                    .createSelectionElement(TeamOrPersonBase.class,
83
                            //getConversationHolder(),
84
                            element, "Agent", entity.getAgent(),
85
                            EntitySelectionElement.ALL, style);
86
        } else{
87
            selection_toPerson = formFactory
88
                    .createSelectionElement(TeamOrPersonBase.class,
89
                            //getConversationHolder(),
90
                            element, "Agent", null,
91
                            EntitySelectionElement.ALL, style);
92
        }
93
        label = formFactory.createLabel(element, null);
94

    
95
    }
96

    
97
    public boolean isComplete(){
98
        if (selection_toPerson.getSelection()!= null && combo_relationshipType.getSelection() != null){
99
            return true;
100
        }
101
        return false;
102

    
103
    }
104

    
105
}
(8-8/12)