1 |
f211dd28
|
n.hoffmann
|
/**
|
2 |
f5b66699
|
Patrick Plitzner
|
*
|
3 |
f211dd28
|
n.hoffmann
|
*/
|
4 |
|
|
package eu.etaxonomy.taxeditor.ui.section.user;
|
5 |
|
|
|
6 |
a60842d7
|
n.hoffmann
|
import java.util.Collection;
|
7 |
1c3cb06b
|
Patrick Plitzner
|
import java.util.Comparator;
|
8 |
f211dd28
|
n.hoffmann
|
|
9 |
|
|
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
|
10 |
a60842d7
|
n.hoffmann
|
import eu.etaxonomy.cdm.model.common.Group;
|
11 |
f211dd28
|
n.hoffmann
|
import eu.etaxonomy.cdm.model.common.User;
|
12 |
78222507
|
n.hoffmann
|
import eu.etaxonomy.taxeditor.ui.dialog.selection.GroupSelectionDialog;
|
13 |
|
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
14 |
dacb59c9
|
Patric Plitzner
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
15 |
a60842d7
|
n.hoffmann
|
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
|
16 |
1c3cb06b
|
Patrick Plitzner
|
import eu.etaxonomy.taxeditor.ui.section.DefaultCdmBaseComparator;
|
17 |
f211dd28
|
n.hoffmann
|
|
18 |
|
|
/**
|
19 |
|
|
* @author n.hoffmann
|
20 |
|
|
*
|
21 |
|
|
*/
|
22 |
a60842d7
|
n.hoffmann
|
public class GroupsByUserDetailSection extends AbstractEntityCollectionSection<User, Group> {
|
23 |
f211dd28
|
n.hoffmann
|
|
24 |
a60842d7
|
n.hoffmann
|
/**
|
25 |
|
|
* @param formFactory
|
26 |
|
|
* @param conversation
|
27 |
|
|
* @param parentElement
|
28 |
|
|
* @param title
|
29 |
|
|
* @param style
|
30 |
|
|
*/
|
31 |
f211dd28
|
n.hoffmann
|
public GroupsByUserDetailSection(CdmFormFactory formFactory,
|
32 |
|
|
ConversationHolder conversation, ICdmFormElement parentElement,
|
33 |
a60842d7
|
n.hoffmann
|
int style) {
|
34 |
|
|
super(formFactory, conversation, parentElement, "Groups", style);
|
35 |
f211dd28
|
n.hoffmann
|
}
|
36 |
|
|
|
37 |
a60842d7
|
n.hoffmann
|
/* (non-Javadoc)
|
38 |
|
|
* @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection#getCollection(java.lang.Object)
|
39 |
|
|
*/
|
40 |
f211dd28
|
n.hoffmann
|
@Override
|
41 |
a60842d7
|
n.hoffmann
|
public Collection<Group> getCollection(User entity) {
|
42 |
|
|
return entity.getGroups();
|
43 |
f211dd28
|
n.hoffmann
|
}
|
44 |
|
|
|
45 |
1c3cb06b
|
Patrick Plitzner
|
@Override
|
46 |
|
|
public Comparator<Group> getComparator() {
|
47 |
|
|
return new DefaultCdmBaseComparator<>();
|
48 |
|
|
}
|
49 |
|
|
|
50 |
a60842d7
|
n.hoffmann
|
/* (non-Javadoc)
|
51 |
|
|
* @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection#createNewElement()
|
52 |
|
|
*/
|
53 |
f211dd28
|
n.hoffmann
|
@Override
|
54 |
a60842d7
|
n.hoffmann
|
public Group createNewElement() {
|
55 |
f5979052
|
Katja Luther
|
Group selectedGroup = GroupSelectionDialog.select(getShell(), //getConversationHolder(),
|
56 |
|
|
null);
|
57 |
a60842d7
|
n.hoffmann
|
return selectedGroup;
|
58 |
f211dd28
|
n.hoffmann
|
}
|
59 |
|
|
|
60 |
a60842d7
|
n.hoffmann
|
/* (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 |
f5b66699
|
Patrick Plitzner
|
|
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 |
f211dd28
|
n.hoffmann
|
}
|