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
.operation
;
13 import org
.eclipse
.core
.commands
.ExecutionException
;
14 import org
.eclipse
.core
.commands
.operations
.IUndoContext
;
15 import org
.eclipse
.core
.runtime
.IAdaptable
;
16 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
17 import org
.eclipse
.core
.runtime
.IStatus
;
19 import eu
.etaxonomy
.cdm
.api
.conversation
.IConversationEnabled
;
20 import eu
.etaxonomy
.cdm
.api
.service
.IUserService
;
21 import eu
.etaxonomy
.cdm
.model
.common
.User
;
22 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPersistentPostOperation
;
23 import eu
.etaxonomy
.taxeditor
.operation
.IPostOperationEnabled
;
24 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
27 * <p>ToggleUserEnablementOperation class.</p>
33 public class ToggleUserEnablementOperation
extends AbstractPersistentPostOperation
{
38 * <p>Constructor for ToggleUserEnablementOperation.</p>
40 * @param label a {@link java.lang.String} object.
41 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
42 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
43 * @param user a {@link eu.etaxonomy.cdm.model.common.User} object.
44 * @param conversationEnabled a {@link eu.etaxonomy.cdm.api.conversation.IConversationEnabled} object.
46 public ToggleUserEnablementOperation(String label
, IUndoContext undoContext
,
47 User user
, IPostOperationEnabled postOperationEnabled
, IConversationEnabled conversationEnabled
) {
48 super(label
, undoContext
, postOperationEnabled
, conversationEnabled
);
53 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
57 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
58 throws ExecutionException
{
63 user
.setEnabled(! user
.isEnabled());
65 CdmStore
.getService(IUserService
.class).saveOrUpdate(user
);
68 return postExecute(null);
72 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
76 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
77 throws ExecutionException
{
78 return execute(monitor
, info
);
82 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
86 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
87 throws ExecutionException
{
89 CdmStore
.getService(IUserService
.class).createUser(user
);
90 return postExecute(null);