X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.cms.e4%2Fsrc%2Forg%2Fargeo%2Fcms%2Fe4%2Fusers%2FUserEditor.java;h=66f442082191a10f1161ea9cce546810d87700e5;hb=b71546ddc74d6ca49d252806aafd491c75dfe1fb;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..66f442082 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 @@ -1,26 +1,11 @@ -/* - * Copyright (C) 2007-2012 Argeo GmbH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ package org.argeo.cms.e4.users; -import static org.argeo.cms.util.UserAdminUtils.getProperty; -import static org.argeo.naming.LdapAttrs.cn; -import static org.argeo.naming.LdapAttrs.givenName; -import static org.argeo.naming.LdapAttrs.mail; -import static org.argeo.naming.LdapAttrs.sn; -import static org.argeo.naming.LdapAttrs.uid; +import static org.argeo.cms.auth.UserAdminUtils.getProperty; +import static org.argeo.util.naming.LdapAttrs.cn; +import static org.argeo.util.naming.LdapAttrs.givenName; +import static org.argeo.util.naming.LdapAttrs.mail; +import static org.argeo.util.naming.LdapAttrs.sn; +import static org.argeo.util.naming.LdapAttrs.uid; import java.util.ArrayList; import java.util.Iterator; @@ -28,22 +13,21 @@ import java.util.List; import javax.inject.Inject; -import org.argeo.cms.ArgeoNames; +import org.argeo.api.cms.CmsConstants; 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; import org.argeo.cms.e4.users.providers.UserFilter; +import org.argeo.cms.swt.CmsSwtUtils; 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.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.argeo.util.naming.LdapAttrs; import org.eclipse.e4.ui.workbench.modeling.EPartService; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.ToolBarManager; @@ -61,13 +45,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 +66,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 +99,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 +120,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 +276,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(CmsSwtUtils.fillAll()); // boolean isAdmin = CurrentUser.isInRole(NodeConstants.ROLE_ADMIN); @@ -360,6 +341,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(CmsSwtUtils.fillWidth()); + toolBarManager.add(action); + toolBarManager.update(true); return userViewerCmp; } @@ -381,7 +370,7 @@ public class UserEditor extends AbstractRoleEditor implements ArgeoNames { staticFilterCmp.setLayout(new GridLayout()); showSystemRoleBtn = new Button(staticFilterCmp, SWT.CHECK); showSystemRoleBtn.setText("Show system roles"); - boolean showSysRole = CurrentUser.isInRole(NodeConstants.ROLE_ADMIN); + boolean showSysRole = CurrentUser.isInRole(CmsConstants.ROLE_ADMIN); showSystemRoleBtn.setSelection(showSysRole); userFilter.setShowSystemRole(showSysRole); showSystemRoleBtn.addSelectionListener(new SelectionAdapter() { @@ -409,28 +398,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;