2 * Copyright (C) 2007 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
.agent
;
11 import java
.util
.Collection
;
12 import java
.util
.Comparator
;
13 import java
.util
.List
;
15 import org
.eclipse
.swt
.graphics
.Color
;
17 import eu
.etaxonomy
.cdm
.model
.agent
.Person
;
18 import eu
.etaxonomy
.cdm
.model
.agent
.Team
;
19 import eu
.etaxonomy
.taxeditor
.ui
.dialog
.selection
.CollectorSelectionDialog
;
20 import eu
.etaxonomy
.taxeditor
.ui
.dialog
.selection
.NomenclaturalPersonAuthorSelectionDialog
;
21 import eu
.etaxonomy
.taxeditor
.ui
.dialog
.selection
.PersonSelectionDialog
;
22 import eu
.etaxonomy
.taxeditor
.ui
.element
.CacheRelevance
;
23 import eu
.etaxonomy
.taxeditor
.ui
.element
.CacheRelevanceHelper
;
24 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
25 import eu
.etaxonomy
.taxeditor
.ui
.element
.ICacheRelevantFormElement
;
26 import eu
.etaxonomy
.taxeditor
.ui
.element
.ICdmFormElement
;
27 import eu
.etaxonomy
.taxeditor
.ui
.element
.ToggleableTextElement
;
28 import eu
.etaxonomy
.taxeditor
.ui
.section
.AbstractEntityCollectionSection
;
32 * @created Apr 30, 2010
34 public class TeamMemberSection
35 extends AbstractEntityCollectionSection
<Team
, Person
>
36 implements ICacheRelevantFormElement
{
38 private boolean isNomenclaturalTeam
= false;
39 private boolean isCollectorTeam
= false;
41 private CacheRelevanceHelper cacheRelevanceHelper
= new CacheRelevanceHelper();
43 public TeamMemberSection(CdmFormFactory cdmFormFactory
, ICdmFormElement parentElement
, int style
, boolean isNomenclatural
, boolean isCollectorTeam
) {
44 super(cdmFormFactory
, parentElement
, null, style
);
45 isNomenclaturalTeam
= isNomenclatural
;
46 this.isCollectorTeam
= isCollectorTeam
;
50 public String
getTitleString() {
51 return "Team Members";
55 public void addElement(Person element
) {
56 getEntity().addTeamMember(element
);
60 public Person
createNewElement() {
61 Person selection
= null;
62 if (isNomenclaturalTeam
){
63 selection
= NomenclaturalPersonAuthorSelectionDialog
.select(getShell(), null, true);
64 }else if(isCollectorTeam
){
65 selection
= CollectorSelectionDialog
.select(getShell(), null, true);
67 selection
= PersonSelectionDialog
.select(getShell(), null);
74 public String
getEmptyString() {
75 return "No persons yet.";
79 protected String
getTooltipString() {
80 return "Add a member to this team";
84 public void removeElement(Person element
) {
85 getEntity().removeTeamMember(element
);
91 public Comparator
<Person
> getComparator() {
101 List
<Person
> teamMembers
= getEntity().getTeamMembers();
102 int indexOfP1
= teamMembers
.indexOf(p1
);
103 int indexOfP2
= teamMembers
.indexOf(p2
);
110 return indexOfP1
- indexOfP2
;
114 public boolean isNomenclaturalTeam() {
115 return isNomenclaturalTeam
;
119 public Person
addExisting() {
124 public boolean allowAddExisting() {
129 public void updateCacheRelevance() {
130 Color color
= cacheRelevance().getColor();
131 setBackground(color
);
135 public void addDependsOnCache(ToggleableTextElement toggleElement
) {
136 cacheRelevanceHelper
.addDependsOnCache(toggleElement
);
140 public CacheRelevance
cacheRelevance() {
141 return cacheRelevanceHelper
.cacheRelevance();
145 public Collection
<Person
> getCollection(Team entity
) {
146 return entity
.getTeamMembers();