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
.account
.user
.handler
;
13 import org
.eclipse
.core
.commands
.AbstractHandler
;
14 import org
.eclipse
.core
.commands
.ExecutionEvent
;
15 import org
.eclipse
.core
.commands
.ExecutionException
;
16 import org
.eclipse
.core
.commands
.common
.NotDefinedException
;
17 import org
.eclipse
.jface
.viewers
.StructuredSelection
;
18 import org
.eclipse
.ui
.handlers
.HandlerUtil
;
20 import eu
.etaxonomy
.cdm
.model
.common
.User
;
21 import eu
.etaxonomy
.taxeditor
.account
.user
.operation
.ToggleUserEnablementOperation
;
22 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPostOperation
;
23 import eu
.etaxonomy
.taxeditor
.store
.StoreUtil
;
24 import eu
.etaxonomy
.taxeditor
.view
.user
.UserView
;
27 * <p>ToggleUserEnablementHandler class.</p>
33 public class ToggleUserEnablementHandler
extends AbstractHandler
{
36 * @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 UserView userManagerView
= (UserView
) 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 StoreUtil
.warn(this.getClass(), "Command name not set");