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