2 * Copyright (C) 2016 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.taxeditor
.ui
.section
.classification
;
11 import org
.eclipse
.swt
.events
.SelectionListener
;
12 import org
.eclipse
.swt
.graphics
.Color
;
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
;
31 public class TaxonNodeAgentRelationCollectionElement
extends AbstractEntityCollectionElement
<TaxonNodeAgentRelation
> {
38 * @param removeListener
39 * @param backgroundColor
42 public TaxonNodeAgentRelationCollectionElement(CdmFormFactory formFactory
, AbstractFormSection section
,
43 TaxonNodeAgentRelation entity
, SelectionListener removeListener
, Color backgroundColor
, int style
) {
44 super(formFactory
, section
, entity
, removeListener
, backgroundColor
, style
);
50 private EntitySelectionElement
<TeamOrPersonBase
> selection_toPerson
;
51 private TermComboElement
<DefinedTerm
> combo_relationshipType
;
52 private LabelElement label
;
57 public void setEntity(TaxonNodeAgentRelation entity
) {
59 if(entity
.getId()!=0){
60 combo_relationshipType
.setSelection(entity
.getType());
61 selection_toPerson
.setEntity(entity
.getAgent());
67 public void handleEvent(Object eventSource
) {
68 if(eventSource
==combo_relationshipType
){
70 entity
.setType(combo_relationshipType
.getSelection());
72 }else if (eventSource
== selection_toPerson
){
73 entity
.setAgent(selection_toPerson
.getEntity());
78 public void createControls(ICdmFormElement element
, int style
) {
79 combo_relationshipType
= formFactory
.createDefinedTermComboElement(TermType
.TaxonNodeAgentRelationType
, element
, "Relation type", null, style
);
81 selection_toPerson
= formFactory
82 .createSelectionElement(TeamOrPersonBase
.class,
83 getConversationHolder(), element
, "Agent", entity
.getAgent(),
84 EntitySelectionElement
.ALL
, style
);
86 selection_toPerson
= formFactory
87 .createSelectionElement(TeamOrPersonBase
.class,
88 getConversationHolder(), element
, "Agent", null,
89 EntitySelectionElement
.ALL
, style
);
91 label
= formFactory
.createLabel(element
, null);
95 public boolean isComplete(){
96 if (selection_toPerson
.getSelection()!= null && combo_relationshipType
.getSelection() != null){