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(),
|
49
|
null);
|
50
|
return selectedGroup;
|
51
|
}
|
52
|
|
53
|
/* (non-Javadoc)
|
54
|
* @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection#addElement(java.lang.Object)
|
55
|
*/
|
56
|
@Override
|
57
|
public void addElement(Group element) {
|
58
|
element.addMember(getEntity());
|
59
|
}
|
60
|
|
61
|
/* (non-Javadoc)
|
62
|
* @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection#removeElement(java.lang.Object)
|
63
|
*/
|
64
|
@Override
|
65
|
public void removeElement(Group element) {
|
66
|
element.removeMember(getEntity());
|
67
|
}
|
68
|
|
69
|
/* (non-Javadoc)
|
70
|
* @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection#getEmptyString()
|
71
|
*/
|
72
|
@Override
|
73
|
public String getEmptyString() {
|
74
|
return "No groups yet.";
|
75
|
}
|
76
|
|
77
|
/* (non-Javadoc)
|
78
|
* @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection#getTooltipString()
|
79
|
*/
|
80
|
@Override
|
81
|
protected String getTooltipString() {
|
82
|
return "Add this user to a group";
|
83
|
}
|
84
|
|
85
|
/**
|
86
|
* {@inheritDoc}
|
87
|
*/
|
88
|
@Override
|
89
|
public Group addExisting() {
|
90
|
// TODO Auto-generated method stub
|
91
|
return null;
|
92
|
}
|
93
|
|
94
|
/**
|
95
|
* {@inheritDoc}
|
96
|
*/
|
97
|
@Override
|
98
|
public boolean allowAddExisting() {
|
99
|
// TODO Auto-generated method stub
|
100
|
return false;
|
101
|
}
|
102
|
|
103
|
}
|