fix #6330 Add default sorting for all entity collections
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / agent / TeamMemberSection.java
1 /**
2 * Copyright (C) 2007 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
10 package eu.etaxonomy.taxeditor.ui.section.agent;
11
12 import java.util.Collection;
13 import java.util.Comparator;
14
15 import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
16 import eu.etaxonomy.cdm.model.agent.Person;
17 import eu.etaxonomy.cdm.model.agent.Team;
18 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
19 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
20 import eu.etaxonomy.taxeditor.ui.section.DefaultCdmBaseComparator;
21 import eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AbstractUnboundEntityCollectionSection;
22
23 /**
24 * <p>TeamMemberSection class.</p>
25 *
26 * @author n.hoffmann
27 * @created Apr 30, 2010
28 * @version 1.0
29 */
30 public class TeamMemberSection extends AbstractUnboundEntityCollectionSection<Team, Person> {
31
32 private boolean isNomenclaturalTeam = false;
33
34 /**
35 * <p>Constructor for TeamMemberSection.</p>
36 *
37 * @param cdmFormFactory a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object.
38 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
39 * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} object.
40 * @param style a int.
41 */
42 public TeamMemberSection(CdmFormFactory cdmFormFactory, ConversationHolder conversation, ICdmFormElement parentElement, int style, boolean isNomenclatural) {
43 super(cdmFormFactory, conversation, parentElement, null, style);
44 isNomenclaturalTeam = isNomenclatural;
45 }
46
47 /** {@inheritDoc} */
48 @Override
49 public String getTitleString() {
50 return "Team Members";
51 }
52
53 /** {@inheritDoc} */
54 @Override
55 public void addElement(Person element) {
56 getEntity().addTeamMember(element);
57 }
58
59 /** {@inheritDoc} */
60 @Override
61 public Person createNewElement() {
62 return Person.NewTitledInstance("");
63 }
64
65 /** {@inheritDoc} */
66 @Override
67 public String getEmptyString() {
68 return "No persons yet.";
69 }
70
71 /** {@inheritDoc} */
72 @Override
73 protected String getTooltipString() {
74 return "Add a member to this team";
75 }
76
77 /** {@inheritDoc} */
78 @Override
79 public void removeElement(Person element) {
80 getEntity().removeTeamMember(element);
81 }
82
83 @Override
84 protected Collection<Person> getEntityCollection(Team entity) {
85 return getEntity().getTeamMembers();
86 }
87
88 @Override
89 public Comparator<Person> getComparator() {
90 return new DefaultCdmBaseComparator<>();
91 }
92
93 /**
94 * @return
95 */
96 public boolean isNomenclaturalTeam() {
97 return isNomenclaturalTeam;
98 }
99
100 /**
101 * {@inheritDoc}
102 */
103 @Override
104 public Person addExisting() {
105 return null;
106 }
107
108 /**
109 * {@inheritDoc}
110 */
111 @Override
112 public boolean allowAddExisting() {
113 return false;
114 }
115
116 }