1
|
/**
|
2
|
*
|
3
|
*/
|
4
|
package eu.etaxonomy.taxeditor.ui.section.user;
|
5
|
|
6
|
import java.util.Collection;
|
7
|
import java.util.Comparator;
|
8
|
|
9
|
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
|
10
|
import eu.etaxonomy.cdm.model.common.Group;
|
11
|
import eu.etaxonomy.cdm.model.common.User;
|
12
|
import eu.etaxonomy.taxeditor.ui.dialog.selection.GroupSelectionDialog;
|
13
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
14
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
15
|
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
|
16
|
import eu.etaxonomy.taxeditor.ui.section.DefaultCdmBaseComparator;
|
17
|
|
18
|
/**
|
19
|
* @author n.hoffmann
|
20
|
*
|
21
|
*/
|
22
|
public class GroupsByUserDetailSection extends AbstractEntityCollectionSection<User, Group> {
|
23
|
|
24
|
/**
|
25
|
* @param formFactory
|
26
|
* @param conversation
|
27
|
* @param parentElement
|
28
|
* @param title
|
29
|
* @param style
|
30
|
*/
|
31
|
public GroupsByUserDetailSection(CdmFormFactory formFactory,
|
32
|
ConversationHolder conversation, ICdmFormElement parentElement,
|
33
|
int style) {
|
34
|
super(formFactory, conversation, parentElement, "Groups", style);
|
35
|
}
|
36
|
|
37
|
/* (non-Javadoc)
|
38
|
* @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection#getCollection(java.lang.Object)
|
39
|
*/
|
40
|
@Override
|
41
|
public Collection<Group> getCollection(User entity) {
|
42
|
return entity.getGroups();
|
43
|
}
|
44
|
|
45
|
@Override
|
46
|
public Comparator<Group> getComparator() {
|
47
|
return new DefaultCdmBaseComparator<>();
|
48
|
}
|
49
|
|
50
|
/* (non-Javadoc)
|
51
|
* @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection#createNewElement()
|
52
|
*/
|
53
|
@Override
|
54
|
public Group createNewElement() {
|
55
|
Group selectedGroup = GroupSelectionDialog.select(getShell(), //getConversationHolder(),
|
56
|
null);
|
57
|
return selectedGroup;
|
58
|
}
|
59
|
|
60
|
/* (non-Javadoc)
|
61
|
* @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection#addElement(java.lang.Object)
|
62
|
*/
|
63
|
@Override
|
64
|
public void addElement(Group element) {
|
65
|
element.addMember(getEntity());
|
66
|
}
|
67
|
|
68
|
/* (non-Javadoc)
|
69
|
* @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection#removeElement(java.lang.Object)
|
70
|
*/
|
71
|
@Override
|
72
|
public void removeElement(Group element) {
|
73
|
element.removeMember(getEntity());
|
74
|
}
|
75
|
|
76
|
/* (non-Javadoc)
|
77
|
* @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection#getEmptyString()
|
78
|
*/
|
79
|
@Override
|
80
|
public String getEmptyString() {
|
81
|
return "No groups yet.";
|
82
|
}
|
83
|
|
84
|
/* (non-Javadoc)
|
85
|
* @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection#getTooltipString()
|
86
|
*/
|
87
|
@Override
|
88
|
protected String getTooltipString() {
|
89
|
return "Add this user to a group";
|
90
|
}
|
91
|
|
92
|
/**
|
93
|
* {@inheritDoc}
|
94
|
*/
|
95
|
@Override
|
96
|
public Group addExisting() {
|
97
|
// TODO Auto-generated method stub
|
98
|
return null;
|
99
|
}
|
100
|
|
101
|
/**
|
102
|
* {@inheritDoc}
|
103
|
*/
|
104
|
@Override
|
105
|
public boolean allowAddExisting() {
|
106
|
// TODO Auto-generated method stub
|
107
|
return false;
|
108
|
}
|
109
|
|
110
|
}
|