1 |
a60842d7
|
n.hoffmann
|
/**
|
2 |
3878a377
|
n.hoffmann
|
* Copyright (C) 2007 EDIT
|
3 |
f5b66699
|
Patrick Plitzner
|
* European Distributed Institute of Taxonomy
|
4 |
3878a377
|
n.hoffmann
|
* http://www.e-taxonomy.eu
|
5 |
f5b66699
|
Patrick Plitzner
|
*
|
6 |
3878a377
|
n.hoffmann
|
* 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.
|
8 |
|
|
*/
|
9 |
a60842d7
|
n.hoffmann
|
|
10 |
30a27c33
|
Andreas Kohlbecker
|
package eu.etaxonomy.taxeditor.ui.section.grantedAuthority;
|
11 |
a60842d7
|
n.hoffmann
|
|
12 |
|
|
import java.util.Collection;
|
13 |
1c3cb06b
|
Patrick Plitzner
|
import java.util.Comparator;
|
14 |
a60842d7
|
n.hoffmann
|
|
15 |
|
|
import org.springframework.security.core.GrantedAuthority;
|
16 |
|
|
|
17 |
|
|
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
|
18 |
d9054fe5
|
Andreas Müller
|
import eu.etaxonomy.cdm.model.permission.Group;
|
19 |
28b3f4aa
|
Andreas Kohlbecker
|
import eu.etaxonomy.taxeditor.ui.dialog.selection.GrantedAuthoritySelectionDialog;
|
20 |
78222507
|
n.hoffmann
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
21 |
dacb59c9
|
Patric Plitzner
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
22 |
a60842d7
|
n.hoffmann
|
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
|
23 |
|
|
|
24 |
|
|
/**
|
25 |
|
|
* @author n.hoffmann
|
26 |
|
|
* @created Mar 9, 2011
|
27 |
|
|
* @version 1.0
|
28 |
|
|
*/
|
29 |
3878a377
|
n.hoffmann
|
public class GrantedAuthorityDetailSection extends
|
30 |
|
|
AbstractEntityCollectionSection<Group, GrantedAuthority> {
|
31 |
a60842d7
|
n.hoffmann
|
|
32 |
|
|
/**
|
33 |
|
|
* @param formFactory
|
34 |
|
|
* @param conversation
|
35 |
|
|
* @param parentElement
|
36 |
|
|
* @param title
|
37 |
|
|
* @param style
|
38 |
|
|
*/
|
39 |
|
|
public GrantedAuthorityDetailSection(CdmFormFactory formFactory,
|
40 |
|
|
ConversationHolder conversation, ICdmFormElement parentElement,
|
41 |
|
|
int style) {
|
42 |
3878a377
|
n.hoffmann
|
super(formFactory, conversation, parentElement, "Granted Authorities",
|
43 |
|
|
style);
|
44 |
a60842d7
|
n.hoffmann
|
}
|
45 |
|
|
|
46 |
3878a377
|
n.hoffmann
|
/*
|
47 |
|
|
* (non-Javadoc)
|
48 |
f5b66699
|
Patrick Plitzner
|
*
|
49 |
3878a377
|
n.hoffmann
|
* @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection#
|
50 |
|
|
* getCollection(java.lang.Object)
|
51 |
a60842d7
|
n.hoffmann
|
*/
|
52 |
|
|
@Override
|
53 |
|
|
public Collection<GrantedAuthority> getCollection(Group entity) {
|
54 |
|
|
return entity.getGrantedAuthorities();
|
55 |
|
|
}
|
56 |
|
|
|
57 |
1c3cb06b
|
Patrick Plitzner
|
@Override
|
58 |
|
|
public Comparator<GrantedAuthority> getComparator() {
|
59 |
|
|
return new Comparator<GrantedAuthority>() {
|
60 |
|
|
|
61 |
|
|
@Override
|
62 |
|
|
public int compare(GrantedAuthority o1, GrantedAuthority o2) {
|
63 |
|
|
if(o1==null){
|
64 |
|
|
return -1;
|
65 |
|
|
}
|
66 |
|
|
if(o2==null){
|
67 |
|
|
return 1;
|
68 |
|
|
}
|
69 |
|
|
return o1.getAuthority().compareTo(o2.getAuthority());
|
70 |
|
|
}
|
71 |
|
|
};
|
72 |
|
|
}
|
73 |
|
|
|
74 |
3878a377
|
n.hoffmann
|
/*
|
75 |
|
|
* (non-Javadoc)
|
76 |
f5b66699
|
Patrick Plitzner
|
*
|
77 |
3878a377
|
n.hoffmann
|
* @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection#
|
78 |
|
|
* createNewElement()
|
79 |
a60842d7
|
n.hoffmann
|
*/
|
80 |
|
|
@Override
|
81 |
|
|
public GrantedAuthority createNewElement() {
|
82 |
28b3f4aa
|
Andreas Kohlbecker
|
// StoreUtil
|
83 |
|
|
// .warningDialog("Not implemented yet", getClass(),
|
84 |
|
|
// "This functionality needs to be implemented in CDM Library first.");
|
85 |
f5b66699
|
Patrick Plitzner
|
|
86 |
f5979052
|
Katja Luther
|
GrantedAuthority selection = GrantedAuthoritySelectionDialog.select(getLayoutComposite().getShell(), //getConversationHolder(),
|
87 |
|
|
null);
|
88 |
a60842d7
|
n.hoffmann
|
return selection;
|
89 |
|
|
}
|
90 |
|
|
|
91 |
3878a377
|
n.hoffmann
|
/*
|
92 |
|
|
* (non-Javadoc)
|
93 |
f5b66699
|
Patrick Plitzner
|
*
|
94 |
3878a377
|
n.hoffmann
|
* @see
|
95 |
|
|
* eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection#addElement
|
96 |
|
|
* (java.lang.Object)
|
97 |
a60842d7
|
n.hoffmann
|
*/
|
98 |
|
|
@Override
|
99 |
|
|
public void addElement(GrantedAuthority element) {
|
100 |
|
|
getEntity().addGrantedAuthority(element);
|
101 |
|
|
}
|
102 |
|
|
|
103 |
3878a377
|
n.hoffmann
|
/*
|
104 |
|
|
* (non-Javadoc)
|
105 |
f5b66699
|
Patrick Plitzner
|
*
|
106 |
3878a377
|
n.hoffmann
|
* @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection#
|
107 |
|
|
* removeElement(java.lang.Object)
|
108 |
a60842d7
|
n.hoffmann
|
*/
|
109 |
|
|
@Override
|
110 |
|
|
public void removeElement(GrantedAuthority element) {
|
111 |
|
|
getEntity().removeGrantedAuthority(element);
|
112 |
|
|
}
|
113 |
|
|
|
114 |
3878a377
|
n.hoffmann
|
/*
|
115 |
|
|
* (non-Javadoc)
|
116 |
f5b66699
|
Patrick Plitzner
|
*
|
117 |
3878a377
|
n.hoffmann
|
* @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection#
|
118 |
|
|
* getEmptyString()
|
119 |
a60842d7
|
n.hoffmann
|
*/
|
120 |
|
|
@Override
|
121 |
|
|
public String getEmptyString() {
|
122 |
28b3f4aa
|
Andreas Kohlbecker
|
return "No Granted Authorities yet.";
|
123 |
a60842d7
|
n.hoffmann
|
}
|
124 |
|
|
|
125 |
3878a377
|
n.hoffmann
|
/*
|
126 |
|
|
* (non-Javadoc)
|
127 |
f5b66699
|
Patrick Plitzner
|
*
|
128 |
3878a377
|
n.hoffmann
|
* @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection#
|
129 |
|
|
* getTooltipString()
|
130 |
a60842d7
|
n.hoffmann
|
*/
|
131 |
|
|
@Override
|
132 |
|
|
protected String getTooltipString() {
|
133 |
|
|
return "Add a Granted Authority";
|
134 |
|
|
}
|
135 |
|
|
|
136 |
f5b66699
|
Patrick Plitzner
|
/**
|
137 |
|
|
* {@inheritDoc}
|
138 |
|
|
*/
|
139 |
|
|
@Override
|
140 |
|
|
public GrantedAuthority addExisting() {
|
141 |
f5979052
|
Katja Luther
|
|
142 |
f5b66699
|
Patrick Plitzner
|
return null;
|
143 |
|
|
}
|
144 |
|
|
|
145 |
|
|
/**
|
146 |
|
|
* {@inheritDoc}
|
147 |
|
|
*/
|
148 |
|
|
@Override
|
149 |
|
|
public boolean allowAddExisting() {
|
150 |
|
|
return false;
|
151 |
|
|
}
|
152 |
|
|
|
153 |
a60842d7
|
n.hoffmann
|
}
|