Merge branch 'release/5.18.0'
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / classification / TaxonNodeAgentRelationCollectionSection.java
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 java.util.Collection;
12 import java.util.Comparator;
13
14 import org.eclipse.ui.forms.widgets.TableWrapData;
15
16 import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
17 import eu.etaxonomy.cdm.model.taxon.TaxonNode;
18 import eu.etaxonomy.cdm.model.taxon.TaxonNodeAgentRelation;
19 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
20 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
21 import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
22 import eu.etaxonomy.taxeditor.ui.section.DefaultCdmBaseComparator;
23
24 /**
25 * @author k.luther
26 * @date 22.03.2016
27 *
28 */
29 public class TaxonNodeAgentRelationCollectionSection extends AbstractEntityCollectionSection<TaxonNode, TaxonNodeAgentRelation> {
30
31
32
33 public TaxonNodeAgentRelationCollectionSection (CdmFormFactory formFactory, ConversationHolder conversation,
34 ICdmFormElement parentElement, int style) {
35 super(formFactory, conversation, parentElement, "Related persons or teams", style);
36
37 }
38
39 @Override
40 public String getEmptyString() {
41 return "No related persons or teams yet.";
42 }
43
44 @Override
45 protected String getTooltipString() {
46 return "Add a new person/team to this taxon node.";
47 }
48
49 @Override
50 public Collection<TaxonNodeAgentRelation> getCollection(TaxonNode entity) {
51 //why Do I have to give the method an entity???
52 Collection<TaxonNodeAgentRelation> allAgentRelationships = getEntity().getAgentRelations();
53 return allAgentRelationships;
54 }
55
56 @Override
57 public Comparator<TaxonNodeAgentRelation> getComparator() {
58 return new DefaultCdmBaseComparator<>();
59 }
60
61 @Override
62 public void addElement(TaxonNodeAgentRelation element) {
63
64
65 }
66
67 @Override
68 public void removeElement(TaxonNodeAgentRelation element) {
69 getEntity().removeAgentRelation(element);
70 // CdmStore.getService(ITaxonNodeService.class).deleteAgentrelation(element);
71 }
72
73
74 @Override
75 public TaxonNodeAgentRelation createNewElement() {
76 TaxonNodeAgentRelation rel = getEntity().addAgentRelation(null, null);
77 return rel;
78 }
79
80 public boolean isComplete(){
81
82 return false;
83 }
84
85 /**
86 * {@inheritDoc}
87 */
88 @Override
89 public TaxonNodeAgentRelation addExisting() {
90 return null;
91 }
92
93 /**
94 * {@inheritDoc}
95 */
96 @Override
97 public boolean allowAddExisting() {
98 return false;
99 }
100
101 /**
102 * @param i
103 */
104 public void setIndent(int i) {
105 TableWrapData tableWrapData = (TableWrapData)getLayoutData();
106 if (tableWrapData == null){
107 tableWrapData = new TableWrapData();
108 }
109 tableWrapData.indent = i;
110 setLayoutData(tableWrapData);
111
112 }
113
114 }