]>
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
.ArgeoException
;
7 import org
.argeo
.eclipse
.ui
.workbench
.internal
.users
.UsersImages
;
8 import org
.argeo
.eclipse
.ui
.workbench
.internal
.users
.UsersUtils
;
9 import org
.argeo
.osgi
.useradmin
.LdifName
;
10 import org
.eclipse
.jface
.resource
.JFaceResources
;
11 import org
.eclipse
.jface
.viewers
.ColumnLabelProvider
;
12 import org
.eclipse
.swt
.SWT
;
13 import org
.eclipse
.swt
.graphics
.Font
;
14 import org
.eclipse
.swt
.graphics
.Image
;
15 import org
.eclipse
.swt
.widgets
.Display
;
16 import org
.osgi
.service
.useradmin
.Role
;
17 import org
.osgi
.service
.useradmin
.User
;
19 /** Centralize label providers for the group table */
20 class UserLP
extends ColumnLabelProvider
{
21 private static final long serialVersionUID
= -4645930210988368571L;
23 final static String COL_ICON
= "colID.icon";
24 final static String COL_DN
= "colID.dn";
25 final static String COL_DISPLAY_NAME
= "colID.displayName";
26 final static String COL_DOMAIN
= "colID.domain";
28 final String currType
;
30 // private Font italic;
33 UserLP(String colId
) {
34 this.currType
= colId
;
38 public Font
getFont(Object element
) {
41 LdapName selfUserName
= UsersUtils
.getLdapName();
42 String userName
= UsersUtils
.getProperty((User
) element
,
44 LdapName userLdapName
= new LdapName(userName
);
45 if (userLdapName
.equals(selfUserName
)) {
47 bold
= JFaceResources
.getFontRegistry()
48 .defaultFontDescriptor().setStyle(SWT
.BOLD
)
49 .createFont(Display
.getCurrent());
52 } catch (InvalidNameException e
) {
53 throw new ArgeoException("cannot parse dn for " + element
, e
);
57 // Node userProfile = (Node) elem;
58 // if (!userProfile.getProperty(ARGEO_ENABLED).getBoolean())
62 // return super.getFont(element);
66 public Image
getImage(Object element
) {
67 if (COL_ICON
.equals(currType
)) {
68 User user
= (User
) element
;
69 String dn
= (String
) user
.getProperties().get(LdifName
.dn
.name());
70 if (dn
.endsWith(UsersUtils
.ROLES_BASEDN
))
71 return UsersImages
.ICON_ROLE
;
72 else if (user
.getType() == Role
.GROUP
)
73 return UsersImages
.ICON_GROUP
;
75 return UsersImages
.ICON_USER
;
81 public String
getText(Object element
) {
82 User user
= (User
) element
;
87 public String
getText(User user
) {
88 if (COL_DN
.equals(currType
))
89 return user
.getName();
90 else if (COL_DISPLAY_NAME
.equals(currType
))
91 return UsersUtils
.getCommonName(user
);
92 else if (COL_DOMAIN
.equals(currType
))
93 return UsersUtils
.getDomainName(user
);