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