1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2016 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.classification;
|
11
|
|
12
|
import org.eclipse.swt.events.SelectionListener;
|
13
|
import org.eclipse.swt.graphics.Color;
|
14
|
|
15
|
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
|
16
|
import eu.etaxonomy.cdm.model.common.DefinedTerm;
|
17
|
import eu.etaxonomy.cdm.model.common.TermType;
|
18
|
import eu.etaxonomy.cdm.model.taxon.TaxonNodeAgentRelation;
|
19
|
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
|
20
|
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
|
21
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
22
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
23
|
import eu.etaxonomy.taxeditor.ui.element.LabelElement;
|
24
|
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement;
|
25
|
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
|
26
|
|
27
|
/**
|
28
|
* @author k.luther
|
29
|
* @date 22.03.2016
|
30
|
*
|
31
|
*/
|
32
|
public class TaxonNodeAgentRelationCollectionElement extends AbstractEntityCollectionElement<TaxonNodeAgentRelation> {
|
33
|
|
34
|
|
35
|
|
36
|
|
37
|
/**
|
38
|
* @param formFactory
|
39
|
* @param section
|
40
|
* @param entity
|
41
|
* @param removeListener
|
42
|
* @param backgroundColor
|
43
|
* @param style
|
44
|
*/
|
45
|
public TaxonNodeAgentRelationCollectionElement(CdmFormFactory formFactory, AbstractFormSection section,
|
46
|
TaxonNodeAgentRelation entity, SelectionListener removeListener, Color backgroundColor, int style) {
|
47
|
super(formFactory, section, entity, removeListener, backgroundColor, style);
|
48
|
|
49
|
// TODO Auto-generated constructor stub
|
50
|
}
|
51
|
|
52
|
|
53
|
|
54
|
|
55
|
private EntitySelectionElement<TeamOrPersonBase> selection_toPerson;
|
56
|
private TermComboElement<DefinedTerm> combo_relationshipType;
|
57
|
private LabelElement label;
|
58
|
|
59
|
|
60
|
|
61
|
|
62
|
|
63
|
|
64
|
|
65
|
@Override
|
66
|
public void setEntity(TaxonNodeAgentRelation entity) {
|
67
|
|
68
|
if(entity.getId()!=0){
|
69
|
combo_relationshipType.setSelection(entity.getType());
|
70
|
selection_toPerson.setEntity(entity.getAgent());
|
71
|
}
|
72
|
this.entity = entity;
|
73
|
}
|
74
|
|
75
|
@Override
|
76
|
public void handleEvent(Object eventSource) {
|
77
|
if(eventSource==combo_relationshipType){
|
78
|
|
79
|
entity.setType(combo_relationshipType.getSelection());
|
80
|
|
81
|
}else if (eventSource == selection_toPerson){
|
82
|
entity.setAgent(selection_toPerson.getEntity());
|
83
|
}
|
84
|
}
|
85
|
|
86
|
/* (non-Javadoc)
|
87
|
* @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement#createControls(eu.etaxonomy.taxeditor.ui.element.ICdmFormElement, int)
|
88
|
*/
|
89
|
@Override
|
90
|
public void createControls(ICdmFormElement element, int style) {
|
91
|
combo_relationshipType = formFactory.createDefinedTermComboElement(TermType.TaxonNodeAgentRelationType, element, "Taxon node agent relationtype", null, style);
|
92
|
if (entity != null){
|
93
|
selection_toPerson = formFactory
|
94
|
.createSelectionElement(TeamOrPersonBase.class,
|
95
|
getConversationHolder(), element, "Agent", entity.getAgent(),
|
96
|
EntitySelectionElement.ALL, style);
|
97
|
} else{
|
98
|
selection_toPerson = formFactory
|
99
|
.createSelectionElement(TeamOrPersonBase.class,
|
100
|
getConversationHolder(), element, "Agent", null,
|
101
|
EntitySelectionElement.ALL, style);
|
102
|
}
|
103
|
label = formFactory.createLabel(element, null);
|
104
|
|
105
|
}
|
106
|
|
107
|
public boolean isComplete(){
|
108
|
if (selection_toPerson.getSelection()!= null && combo_relationshipType.getSelection() != null){
|
109
|
return true;
|
110
|
}
|
111
|
return false;
|
112
|
|
113
|
}
|
114
|
|
115
|
|
116
|
}
|