X-Git-Url: https://git.argeo.org/?p=gpl%2Fargeo-suite.git;a=blobdiff_plain;f=swt%2Forg.argeo.app.ui%2Fsrc%2Forg%2Fargeo%2Fapp%2Fui%2Fpeople%2FPeopleEntryArea.java;h=41310aa8c6e8f36a0c46f918526169653e81334e;hp=156a092afa96f727fc76cd3b633e6c71fe5e28de;hb=0b492f2cfb8a24ec84e1dd52825624f5e9ab7e81;hpb=3197ec58385951957c237fd6c147670cca89123c diff --git a/swt/org.argeo.app.ui/src/org/argeo/app/ui/people/PeopleEntryArea.java b/swt/org.argeo.app.ui/src/org/argeo/app/ui/people/PeopleEntryArea.java index 156a092..41310aa 100644 --- a/swt/org.argeo.app.ui/src/org/argeo/app/ui/people/PeopleEntryArea.java +++ b/swt/org.argeo.app.ui/src/org/argeo/app/ui/people/PeopleEntryArea.java @@ -1,8 +1,5 @@ package org.argeo.app.ui.people; -import java.util.ArrayList; -import java.util.List; - import javax.jcr.Node; import javax.jcr.RepositoryException; @@ -10,20 +7,13 @@ import org.argeo.api.acr.Content; import org.argeo.api.acr.ContentRepository; import org.argeo.api.acr.ContentSession; import org.argeo.api.acr.ldap.LdapAttrs; -import org.argeo.api.acr.ldap.LdapObjs; -import org.argeo.api.cms.directory.CmsDirectory; import org.argeo.api.cms.directory.CmsUserManager; import org.argeo.api.cms.directory.HierarchyUnit; -import org.argeo.api.cms.directory.UserDirectory; -import org.argeo.api.cms.ux.CmsIcon; import org.argeo.api.cms.ux.CmsView; import org.argeo.app.ui.SuiteIcon; import org.argeo.app.ui.SuiteMsg; import org.argeo.app.ui.SuiteUxEvent; -import org.argeo.cms.CurrentUser; import org.argeo.cms.acr.ContentUtils; -import org.argeo.cms.auth.CmsRole; -import org.argeo.cms.auth.UserAdminUtils; import org.argeo.cms.jcr.acr.JcrContent; import org.argeo.cms.swt.CmsSwtTheme; import org.argeo.cms.swt.CmsSwtUtils; @@ -33,11 +23,8 @@ import org.argeo.cms.swt.widgets.SwtGuidedFormDialog; import org.argeo.cms.swt.widgets.SwtTableView; import org.argeo.cms.swt.widgets.SwtTreeView; import org.argeo.cms.ui.CmsUiProvider; -import org.argeo.cms.ux.widgets.AbstractHierarchicalPart; import org.argeo.cms.ux.widgets.Column; -import org.argeo.cms.ux.widgets.DefaultTabularPart; import org.argeo.cms.ux.widgets.GuidedForm; -import org.argeo.cms.ux.widgets.HierarchicalPart; import org.eclipse.jface.window.Window; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.SashForm; @@ -52,8 +39,6 @@ import org.eclipse.swt.widgets.Menu; import org.eclipse.swt.widgets.MenuItem; import org.eclipse.swt.widgets.ToolBar; import org.eclipse.swt.widgets.ToolItem; -import org.osgi.service.useradmin.Role; -import org.osgi.service.useradmin.User; /** Entry to the admin area. */ public class PeopleEntryArea implements SwtUiProvider, CmsUiProvider { @@ -73,116 +58,10 @@ public class PeopleEntryArea implements SwtUiProvider, CmsUiProvider { CmsSwtUtils.fill(sashForm); // VIEW - HierarchicalPart hierarchyPart = new AbstractHierarchicalPart<>() { - - @Override - public List getChildren(HierarchyUnit parent) { - List visible = new ArrayList<>(); - if (parent != null) { - if (parent instanceof CmsDirectory) // do no show children of the directories - return visible; - for (HierarchyUnit hu : parent.getDirectHierarchyUnits(true)) { - visible.add(hu); - } - } else { - for (UserDirectory directory : cmsUserManager.getUserDirectories()) { - if (CurrentUser.implies(CmsRole.userAdmin, directory.getBase())) { - visible.add(directory); - } - for (HierarchyUnit hu : directory.getDirectHierarchyUnits(true)) { - if (CurrentUser.implies(CmsRole.userAdmin, hu.getBase())) { - visible.add(hu); - } - } - - } - } - return visible; - } - - @Override - public String getText(HierarchyUnit model) { - return model.getHierarchyUnitLabel(CurrentUser.locale()); - } - - @Override - public CmsIcon getIcon(HierarchyUnit model) { - Content content = ContentUtils.hierarchyUnitToContent(contentSession, model); - if (content.hasContentClass(LdapObjs.organization)) - return SuiteIcon.organisation; - else if (content.hasContentClass(LdapObjs.posixGroup)) - return SuiteIcon.users; - else - return SuiteIcon.addressBook; - } - - }; + HierarchyUnitPart hierarchyPart = new HierarchyUnitPart(contentSession, cmsUserManager); SwtTreeView directoriesView = new SwtTreeView<>(sashForm, SWT.BORDER, hierarchyPart); - DefaultTabularPart usersPart = new DefaultTabularPart<>() { - - @Override - protected List asList(HierarchyUnit hu) { - List roles = new ArrayList<>(); - UserDirectory ud = (UserDirectory) hu.getDirectory(); - if (ud.getRealm().isPresent()) { - for (Role r : ud.getHierarchyUnitRoles(ud, null, true)) { - Content content = ContentUtils.roleToContent(cmsUserManager, contentSession, r); - if (content.hasContentClass(LdapObjs.inetOrgPerson, LdapObjs.organization)) - roles.add(content); - } - - } else { - for (HierarchyUnit directChild : hu.getDirectHierarchyUnits(false)) { - if (!(directChild.isType(HierarchyUnit.Type.FUNCTIONAL) - || directChild.isType(HierarchyUnit.Type.ROLES))) { - for (Role r : ud.getHierarchyUnitRoles(directChild, null, false)) { - Content content = ContentUtils.roleToContent(cmsUserManager, contentSession, r); - if (content.hasContentClass(LdapObjs.inetOrgPerson, LdapObjs.organization, - LdapObjs.groupOfNames)) - roles.add(content); - } - } - } - } - return roles; - } - }; - usersPart.addColumn(new Column() { - - @Override - public String getText(Content role) { - if (role.hasContentClass(LdapObjs.inetOrgPerson)) - return UserAdminUtils.getUserDisplayName(role.adapt(User.class)); - else if (role.hasContentClass(LdapObjs.organization)) - return role.attr(LdapAttrs.o); - else if (role.hasContentClass(LdapObjs.groupOfNames)) - return role.attr(LdapAttrs.cn); - else - return null; - } - - @Override - public CmsIcon getIcon(Content role) { - if (role.hasContentClass(LdapObjs.posixAccount)) - return SuiteIcon.user; - else if (role.hasContentClass(LdapObjs.inetOrgPerson)) - return SuiteIcon.person; - else if (role.hasContentClass(LdapObjs.organization)) - return SuiteIcon.organisationContact; - else if (role.hasContentClass(LdapObjs.groupOfNames)) - return SuiteIcon.group; - else - return null; - } - - @Override - public int getWidth() { - return 300; - } - - }); -// usersPart.addColumn((Column) (role) -> role.attr(LdapAttrs.mail)); + UsersPart usersPart = new UsersPart(contentSession, cmsUserManager); usersPart.addColumn(new Column() { @Override @@ -242,8 +121,8 @@ public class PeopleEntryArea implements SwtUiProvider, CmsUiProvider { sashForm.setWeights(new int[] { 30, 70 }); - SwtTableView usersTable = new SwtTableView<>(bottom, SWT.BORDER, usersPart); - usersTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + SwtTableView usersView = new SwtTableView<>(bottom, SWT.BORDER, usersPart); + usersView.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); // CONTROLLER hierarchyPart.onSelected((o) -> {