]>
git.argeo.org Git - lgpl/argeo-commons.git/blob - org.argeo.eclipse.ui.workbench/src/org/argeo/eclipse/ui/workbench/users/UserLP.java
1 package org
.argeo
.eclipse
.ui
.workbench
.users
;
3 import javax
.naming
.InvalidNameException
;
4 import javax
.naming
.ldap
.LdapName
;
6 import org
.argeo
.eclipse
.ui
.EclipseUiException
;
7 import org
.argeo
.eclipse
.ui
.workbench
.internal
.users
.UsersImages
;
8 import org
.argeo
.eclipse
.ui
.workbench
.internal
.users
.UsersUtils
;
9 import org
.eclipse
.jface
.resource
.JFaceResources
;
10 import org
.eclipse
.jface
.viewers
.ColumnLabelProvider
;
11 import org
.eclipse
.swt
.SWT
;
12 import org
.eclipse
.swt
.graphics
.Font
;
13 import org
.eclipse
.swt
.graphics
.Image
;
14 import org
.eclipse
.swt
.widgets
.Display
;
15 import org
.osgi
.service
.useradmin
.Role
;
16 import org
.osgi
.service
.useradmin
.User
;
18 /** Centralize label providers for the group table */
19 class UserLP
extends ColumnLabelProvider
{
20 private static final long serialVersionUID
= -4645930210988368571L;
22 final static String COL_ICON
= "colID.icon";
23 final static String COL_DN
= "colID.dn";
24 final static String COL_DISPLAY_NAME
= "colID.displayName";
25 final static String COL_DOMAIN
= "colID.domain";
27 final String currType
;
29 // private Font italic;
32 UserLP(String colId
) {
33 this.currType
= colId
;
37 public Font
getFont(Object element
) {
40 LdapName selfUserName
= UsersUtils
.getLdapName();
41 String userName
= ((User
) element
).getName();
42 LdapName userLdapName
= new LdapName(userName
);
43 if (userLdapName
.equals(selfUserName
)) {
45 bold
= JFaceResources
.getFontRegistry()
46 .defaultFontDescriptor().setStyle(SWT
.BOLD
)
47 .createFont(Display
.getCurrent());
50 } catch (InvalidNameException e
) {
51 throw new EclipseUiException("cannot parse dn for " + element
, e
);
55 // Node userProfile = (Node) elem;
56 // if (!userProfile.getProperty(ARGEO_ENABLED).getBoolean())
60 // return super.getFont(element);
64 public Image
getImage(Object element
) {
65 if (COL_ICON
.equals(currType
)) {
66 User user
= (User
) element
;
67 String dn
= user
.getName();
68 if (dn
.endsWith(UsersUtils
.ROLES_BASEDN
))
69 return UsersImages
.ICON_ROLE
;
70 else if (user
.getType() == Role
.GROUP
)
71 return UsersImages
.ICON_GROUP
;
73 return UsersImages
.ICON_USER
;
79 public String
getText(Object element
) {
80 User user
= (User
) element
;
85 public String
getText(User user
) {
86 if (COL_DN
.equals(currType
))
87 return user
.getName();
88 else if (COL_DISPLAY_NAME
.equals(currType
))
89 return UsersUtils
.getCommonName(user
);
90 else if (COL_DOMAIN
.equals(currType
))
91 return UsersUtils
.getDomainName(user
);