X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.cms.e4%2Fsrc%2Forg%2Fargeo%2Fcms%2Fe4%2Fusers%2FUserEditor.java;h=3d67b8c3b599786e50fa02233114bf5c9e9e86d1;hb=2b6597a096ac21375aa83f86d1f750061b20387c;hp=c7e5fe40e6046dceb39b8a651c4cbff08a52dd5a;hpb=d6390257a328199a2a4a677b33e79b6535175169;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.cms.e4/src/org/argeo/cms/e4/users/UserEditor.java b/org.argeo.cms.e4/src/org/argeo/cms/e4/users/UserEditor.java index c7e5fe40e..3d67b8c3b 100644 --- a/org.argeo.cms.e4/src/org/argeo/cms/e4/users/UserEditor.java +++ b/org.argeo.cms.e4/src/org/argeo/cms/e4/users/UserEditor.java @@ -15,7 +15,7 @@ */ package org.argeo.cms.e4.users; -import static org.argeo.cms.util.UserAdminUtils.getProperty; +import static org.argeo.cms.auth.UserAdminUtils.getProperty; import static org.argeo.naming.LdapAttrs.cn; import static org.argeo.naming.LdapAttrs.givenName; import static org.argeo.naming.LdapAttrs.mail; @@ -28,8 +28,9 @@ import java.util.List; import javax.inject.Inject; -import org.argeo.cms.ArgeoNames; +import org.argeo.api.NodeConstants; import org.argeo.cms.auth.CurrentUser; +import org.argeo.cms.auth.UserAdminUtils; import org.argeo.cms.e4.users.providers.CommonNameLP; import org.argeo.cms.e4.users.providers.DomainNameLP; import org.argeo.cms.e4.users.providers.RoleIconLP; @@ -37,13 +38,11 @@ import org.argeo.cms.e4.users.providers.UserFilter; import org.argeo.cms.ui.eclipse.forms.AbstractFormPart; //import org.argeo.cms.ui.eclipse.forms.FormToolkit; import org.argeo.cms.ui.eclipse.forms.IManagedForm; -import org.argeo.cms.util.CmsUtils; -import org.argeo.cms.util.UserAdminUtils; +import org.argeo.cms.ui.util.CmsUiUtils; import org.argeo.eclipse.ui.ColumnDefinition; import org.argeo.eclipse.ui.EclipseUiUtils; import org.argeo.eclipse.ui.parts.LdifUsersTable; import org.argeo.naming.LdapAttrs; -import org.argeo.node.NodeConstants; import org.eclipse.e4.ui.workbench.modeling.EPartService; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.ToolBarManager; @@ -61,13 +60,10 @@ import org.eclipse.swt.dnd.DropTargetEvent; import org.eclipse.swt.dnd.TextTransfer; import org.eclipse.swt.dnd.Transfer; import org.eclipse.swt.dnd.TransferData; -import org.eclipse.swt.events.DisposeEvent; -import org.eclipse.swt.events.DisposeListener; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.Cursor; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; @@ -85,7 +81,7 @@ import org.osgi.service.useradmin.UserAdmin; import org.osgi.service.useradmin.UserAdminEvent; /** Display/edit the properties of a given user */ -public class UserEditor extends AbstractRoleEditor implements ArgeoNames { +public class UserEditor extends AbstractRoleEditor { // final static String ID = "UserEditor.mainPage"; @Inject @@ -118,12 +114,12 @@ public class UserEditor extends AbstractRoleEditor implements ArgeoNames { @Override protected void createUi(Composite body) { -// Composite body = new Composite(parent, SWT.BORDER); + // Composite body = new Composite(parent, SWT.BORDER); GridLayout mainLayout = new GridLayout(); // mainLayout.marginRight = 10; body.setLayout(mainLayout); -// body.getParent().setLayout(new GridLayout()); -// body.setLayoutData(CmsUtils.fillAll()); + // body.getParent().setLayout(new GridLayout()); + // body.setLayoutData(CmsUiUtils.fillAll()); User user = getDisplayedUser(); appendOverviewPart(body, user); // Remove to ability to force the password for his own user. The user @@ -139,7 +135,7 @@ public class UserEditor extends AbstractRoleEditor implements ArgeoNames { // GridData gd = EclipseUiUtils.fillWidth(); // // gd.verticalAlignment = PRE_TITLE_INDENT; // section.setLayoutData(gd); - Composite body = new Composite(parent, SWT.BORDER); + Composite body = new Composite(parent, SWT.NONE); body.setLayoutData(EclipseUiUtils.fillWidth()); // section.setClient(body); // body.setLayout(new GridLayout(6, false)); @@ -295,9 +291,9 @@ public class UserEditor extends AbstractRoleEditor implements ArgeoNames { // Section section = addSection(tk, parent, "Roles"); // Composite body = (Composite) section.getClient(); // Composite body= parent; - Composite body = new Composite(parent, SWT.NONE); - body.setLayout(EclipseUiUtils.noSpaceGridLayout()); - body.setLayoutData(CmsUtils.fillAll()); + Composite body = new Composite(parent, SWT.BORDER); + body.setLayout(new GridLayout()); + body.setLayoutData(CmsUiUtils.fillAll()); // boolean isAdmin = CurrentUser.isInRole(NodeConstants.ROLE_ADMIN); @@ -360,6 +356,14 @@ public class UserEditor extends AbstractRoleEditor implements ArgeoNames { }; getManagedForm().addPart(part); // addRemoveAbitily(body, userViewer, user); + // userViewerCmp.refresh(); + String tooltip = "Remove " + UserAdminUtils.getUserLocalId(user.getName()) + " from the below selected groups"; + Action action = new RemoveMembershipAction(userViewer, user, tooltip, SecurityAdminImages.ICON_REMOVE_DESC); + ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT); + ToolBar toolBar = toolBarManager.createControl(body); + toolBar.setLayoutData(CmsUiUtils.fillWidth()); + toolBarManager.add(action); + toolBarManager.update(true); return userViewerCmp; } @@ -409,28 +413,31 @@ public class UserEditor extends AbstractRoleEditor implements ArgeoNames { } } - private void addRemoveAbitily(Composite parent, TableViewer userViewer, User user) { - // Section section = sectionPart.getSection(); - ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT); - ToolBar toolbar = toolBarManager.createControl(parent); - final Cursor handCursor = new Cursor(Display.getCurrent(), SWT.CURSOR_HAND); - toolbar.setCursor(handCursor); - toolbar.addDisposeListener(new DisposeListener() { - private static final long serialVersionUID = 3882131405820522925L; - - public void widgetDisposed(DisposeEvent e) { - if ((handCursor != null) && (handCursor.isDisposed() == false)) { - handCursor.dispose(); - } - } - }); - - String tooltip = "Remove " + UserAdminUtils.getUserLocalId(user.getName()) + " from the below selected groups"; - Action action = new RemoveMembershipAction(userViewer, user, tooltip, SecurityAdminImages.ICON_REMOVE_DESC); - toolBarManager.add(action); - toolBarManager.update(true); - // section.setTextClient(toolbar); - } + // private void addRemoveAbility(Composite parent, TableViewer userViewer, User + // user) { + // // Section section = sectionPart.getSection(); + // ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT); + // ToolBar toolbar = toolBarManager.createControl(parent); + // final Cursor handCursor = new Cursor(Display.getCurrent(), SWT.CURSOR_HAND); + // toolbar.setCursor(handCursor); + // toolbar.addDisposeListener(new DisposeListener() { + // private static final long serialVersionUID = 3882131405820522925L; + // + // public void widgetDisposed(DisposeEvent e) { + // if ((handCursor != null) && (handCursor.isDisposed() == false)) { + // handCursor.dispose(); + // } + // } + // }); + // + // String tooltip = "Remove " + UserAdminUtils.getUserLocalId(user.getName()) + + // " from the below selected groups"; + // Action action = new RemoveMembershipAction(userViewer, user, tooltip, + // SecurityAdminImages.ICON_REMOVE_DESC); + // toolBarManager.add(action); + // toolBarManager.update(true); + // // section.setTextClient(toolbar); + // } private class RemoveMembershipAction extends Action { private static final long serialVersionUID = -1337713097184522588L;