]>
git.argeo.org Git - lgpl/argeo-commons.git/blob - org.argeo.security.ui.admin/src/org/argeo/security/ui/admin/commands/DeleteGroups.java
2 * Copyright (C) 2007-2012 Argeo GmbH
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org
.argeo
.security
.ui
.admin
.commands
;
18 import java
.util
.Iterator
;
20 import java
.util
.TreeMap
;
22 import org
.argeo
.security
.ui
.admin
.SecurityAdminPlugin
;
23 import org
.argeo
.security
.ui
.admin
.internal
.UiAdminUtils
;
24 import org
.argeo
.security
.ui
.admin
.internal
.UserAdminConstants
;
25 import org
.eclipse
.core
.commands
.AbstractHandler
;
26 import org
.eclipse
.core
.commands
.ExecutionEvent
;
27 import org
.eclipse
.core
.commands
.ExecutionException
;
28 import org
.eclipse
.jface
.dialogs
.MessageDialog
;
29 import org
.eclipse
.jface
.viewers
.ISelection
;
30 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
31 import org
.eclipse
.ui
.handlers
.HandlerUtil
;
32 import org
.osgi
.service
.useradmin
.Group
;
34 /** Deletes the selected groups */
35 public class DeleteGroups
extends AbstractHandler
{
36 public final static String ID
= SecurityAdminPlugin
.PLUGIN_ID
+ ".deleteGroups";
39 @SuppressWarnings("unchecked")
40 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
41 ISelection selection
= HandlerUtil
.getCurrentSelection(event
);
42 if (selection
.isEmpty())
45 Map
<String
, Group
> toDelete
= new TreeMap
<String
, Group
>();
46 Iterator
<Group
> it
= ((IStructuredSelection
) selection
).iterator();
47 groups
: while (it
.hasNext()) {
48 Group currGroup
= it
.next();
49 String groupName
= UiAdminUtils
.getProperty(currGroup
,
50 UserAdminConstants
.KEY_CN
);
53 // if (userName.equals(profileNode.getSession().getUserID())) {
54 // log.warn("Cannot delete its own user: " + userName);
57 toDelete
.put(groupName
, currGroup
);
62 HandlerUtil
.getActiveShell(event
),
64 "Are you sure that you want to delete groups "
67 + "This might lead to inconsistencies in the application."))
70 for (String groupName
: toDelete
.keySet()) {
72 MessageDialog
.openInformation(HandlerUtil
.getActiveShell(event
),
73 "Unimplemented method",
74 "The effective deletion is not yet implemented");
76 // JcrUsersView view = (JcrUsersView) HandlerUtil
77 // .getActiveWorkbenchWindow(event).getActivePage()
78 // .findView(JcrUsersView.ID);
83 // public void setUserAdmin(UserAdmin userAdmin) {
84 // this.userAdmin = userAdmin;