3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
11 package eu
.etaxonomy
.taxeditor
.user
.handler
;
13 import org
.apache
.log4j
.Logger
;
14 import org
.eclipse
.core
.commands
.AbstractHandler
;
15 import org
.eclipse
.core
.commands
.ExecutionEvent
;
16 import org
.eclipse
.core
.commands
.ExecutionException
;
17 import org
.eclipse
.core
.commands
.common
.NotDefinedException
;
18 import org
.eclipse
.jface
.viewers
.StructuredSelection
;
19 import org
.eclipse
.ui
.handlers
.HandlerUtil
;
21 import eu
.etaxonomy
.cdm
.model
.common
.User
;
22 import eu
.etaxonomy
.taxeditor
.operations
.AbstractPostOperation
;
23 import eu
.etaxonomy
.taxeditor
.operations
.ToggleUserEnablementOperation
;
24 import eu
.etaxonomy
.taxeditor
.store
.StoreUtil
;
25 import eu
.etaxonomy
.taxeditor
.user
.view
.UserManagerView
;
32 public class ToggleUserEnablementHandler
extends AbstractHandler
{
33 private static final Logger logger
= Logger
34 .getLogger(ToggleUserEnablementHandler
.class);
37 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
39 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
41 StructuredSelection menuSelection
= (StructuredSelection
) HandlerUtil
.getActiveMenuSelection(event
);
43 for (Object object
: menuSelection
.toArray()){
45 User user
= (User
) object
;
47 // TODO refresh the list -> set postOperationEnabled to the real deal
48 UserManagerView userManagerView
= (UserManagerView
) HandlerUtil
.getActivePart(event
);
50 AbstractPostOperation operation
= null;
52 operation
= new ToggleUserEnablementOperation(event
.getCommand().getName(),
53 StoreUtil
.getUndoContext(), user
, userManagerView
, userManagerView
);
55 StoreUtil
.executeOperation(operation
);
56 } catch (NotDefinedException e
) {
57 logger
.warn("Command name not set");