Few enhancements
authorbsinou <bsinou@argeo.org>
Sun, 12 Mar 2017 10:24:42 +0000 (11:24 +0100)
committerbsinou <bsinou@argeo.org>
Sun, 12 Mar 2017 10:24:42 +0000 (11:24 +0100)
org.argeo.cms.ui.workbench/src/org/argeo/cms/ui/workbench/UserHomePerspective.java
org.argeo.cms.ui.workbench/src/org/argeo/cms/ui/workbench/internal/useradmin/parts/GroupsView.java
org.argeo.cms.ui.workbench/src/org/argeo/cms/ui/workbench/internal/useradmin/providers/UserFilter.java

index 86caad9c45134cf482a83a36a2a0da012c5143ea..ee91b4ea1ffac57396596c6cc8f84f9b3fd4e923 100644 (file)
@@ -23,18 +23,15 @@ import org.eclipse.ui.IPerspectiveFactory;
 
 /** Home perspective for the current user */
 public class UserHomePerspective implements IPerspectiveFactory {
-       public final static String ID = WorkbenchUiPlugin.PLUGIN_ID
-                       + ".userHomePerspective";
+       public final static String ID = WorkbenchUiPlugin.PLUGIN_ID + ".userHomePerspective";
 
        public void createInitialLayout(IPageLayout layout) {
                String editorArea = layout.getEditorArea();
                layout.setEditorAreaVisible(true);
                layout.setFixed(false);
 
-               IFolderLayout left = layout.createFolder("left", IPageLayout.LEFT,
-                               0.30f, editorArea);
+               IFolderLayout left = layout.createFolder("left", IPageLayout.LEFT, 0.30f, editorArea);
                left.addView(UserProfile.ID);
                left.addView(LogView.ID);
        }
-
 }
index 580e05150ef5514c660ad131ca298ec5bcfadacf..0d33677ac572da6e018da14fc9556f10af99071e 100644 (file)
@@ -144,7 +144,7 @@ public class GroupsView extends ViewPart implements ArgeoNames {
        private class MyUserTableViewer extends LdifUsersTable {
                private static final long serialVersionUID = 8467999509931900367L;
 
-               private boolean showSystemRoles = false;
+               private boolean showSystemRoles;
 
                private final String[] knownProps = { LdapAttrs.uid.name(),
                                LdapAttrs.cn.name(), LdapAttrs.DN };
@@ -158,6 +158,9 @@ public class GroupsView extends ViewPart implements ArgeoNames {
                        final Button showSystemRoleBtn = new Button(staticFilterCmp,
                                        SWT.CHECK);
                        showSystemRoleBtn.setText("Show system roles");
+                       showSystemRoles = CurrentUser.isInRole(NodeConstants.ROLE_ADMIN);
+                       showSystemRoleBtn.setSelection(showSystemRoles);
+                       
                        showSystemRoleBtn.addSelectionListener(new SelectionAdapter() {
                                private static final long serialVersionUID = -7033424592697691676L;
 
index b89c58d592ced0bca2cb371edd3615c4c9172142..46bce8d76c6bae230e00fb87f6b166136de93e88 100644 (file)
@@ -9,16 +9,18 @@ import org.eclipse.jface.viewers.Viewer;
 import org.eclipse.jface.viewers.ViewerFilter;
 import org.osgi.service.useradmin.User;
 
+/**
+ * Filter user list using JFace mechanism on the client (yet on the server) side
+ * rather than having the UserAdmin to process the search
+ */
 public class UserFilter extends ViewerFilter {
        private static final long serialVersionUID = 5082509381672880568L;
 
        private String searchString;
        private boolean showSystemRole = true;
 
-       private final String[] knownProps = { LdapAttrs.DN, LdapAttrs.cn.name(),
-                       LdapAttrs.givenName.name(), LdapAttrs.sn.name(),
-                       LdapAttrs.uid.name(), LdapAttrs.description.name(),
-                       LdapAttrs.mail.name() };
+       private final String[] knownProps = { LdapAttrs.DN, LdapAttrs.cn.name(), LdapAttrs.givenName.name(),
+                       LdapAttrs.sn.name(), LdapAttrs.uid.name(), LdapAttrs.description.name(), LdapAttrs.mail.name() };
 
        public void setSearchText(String s) {
                // ensure that the value can be used for matching
@@ -35,9 +37,7 @@ public class UserFilter extends ViewerFilter {
        @Override
        public boolean select(Viewer viewer, Object parentElement, Object element) {
                User user = (User) element;
-               if (!showSystemRole
-                               && user.getName().matches(
-                                               ".*(" + NodeConstants.ROLES_BASEDN + ")"))
+               if (!showSystemRole && user.getName().matches(".*(" + NodeConstants.ROLES_BASEDN + ")"))
                        // UserAdminUtils.getProperty(user, LdifName.dn.name())
                        // .toLowerCase().endsWith(AuthConstants.ROLES_BASEDN))
                        return false;
@@ -50,8 +50,7 @@ public class UserFilter extends ViewerFilter {
 
                for (String key : knownProps) {
                        String currVal = UserAdminUtils.getProperty(user, key);
-                       if (notEmpty(currVal)
-                                       && currVal.toLowerCase().matches(searchString))
+                       if (notEmpty(currVal) && currVal.toLowerCase().matches(searchString))
                                return true;
                }
                return false;