org.eclipse.emf.workspace
Class EMFCommandOperation

java.lang.Object
  extended byorg.eclipse.core.commands.operations.AbstractOperation
      extended byorg.eclipse.emf.workspace.AbstractEMFOperation
          extended byorg.eclipse.emf.workspace.EMFCommandOperation
All Implemented Interfaces:
org.eclipse.core.commands.operations.IUndoableOperation

public class EMFCommandOperation
extends AbstractEMFOperation

An operation that wraps an EMF Command to execute it in a read/write transaction on an IOperationHistory. This class may be created explicitly by a client of the operation history, or it may be used implicitly by executing a command on the TransactionalCommandStack.


Constructor Summary
EMFCommandOperation(TransactionalEditingDomain domain, org.eclipse.emf.common.command.Command command)
          Initializes me with my editing domain and a command to execute.
EMFCommandOperation(TransactionalEditingDomain domain, org.eclipse.emf.common.command.Command command, Map options)
          Initializes me with my editing domain, a command to execute, and transaction options.
 
Method Summary
 boolean canExecute()
          I can execute if my command can execute.
 boolean canRedo()
          I can redo if either my wrapped command is a ConditionalRedoCommand that can undo, or it is not a conditionally redoable command.
 boolean canUndo()
          I can undo if my command or (if any) trigger command can undo.
protected  void didCommit(Transaction transaction)
           Hook for subclasses to learn that the specified transaction has been successfully committed and, if necessary, to extract information from it.
protected  org.eclipse.core.runtime.IStatus doExecute(org.eclipse.core.runtime.IProgressMonitor monitor, org.eclipse.core.runtime.IAdaptable info)
          Executes me by executing my command.
protected  org.eclipse.core.runtime.IStatus doRedo(org.eclipse.core.runtime.IProgressMonitor monitor, org.eclipse.core.runtime.IAdaptable info)
          Redoes me by redoing my command and my trigger command (if any).
protected  org.eclipse.core.runtime.IStatus doUndo(org.eclipse.core.runtime.IProgressMonitor monitor, org.eclipse.core.runtime.IAdaptable info)
          Undoes me by undoing my trigger command (if any) and my command.
 org.eclipse.emf.common.command.Command getCommand()
          Obtains the command that I wrap.
protected  void improveLabel(org.eclipse.emf.common.command.Command cmd)
          Computes a more user-friendly label for the operation than the label created by default for EMF's feature-changing commands.
 
Methods inherited from class org.eclipse.emf.workspace.AbstractEMFOperation
aggregateStatuses, didRedo, didUndo, dispose, execute, getChange, getEditingDomain, getOptions, redo, undo
 
Methods inherited from class org.eclipse.core.commands.operations.AbstractOperation
addContext, getContexts, getLabel, hasContext, removeContext, setLabel, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

EMFCommandOperation

public EMFCommandOperation(TransactionalEditingDomain domain,
                           org.eclipse.emf.common.command.Command command)
Initializes me with my editing domain and a command to execute.

Parameters:
domain - my domain
command - my command

EMFCommandOperation

public EMFCommandOperation(TransactionalEditingDomain domain,
                           org.eclipse.emf.common.command.Command command,
                           Map options)
Initializes me with my editing domain, a command to execute, and transaction options.

Parameters:
domain - my domain
command - my command
Method Detail

getCommand

public final org.eclipse.emf.common.command.Command getCommand()
Obtains the command that I wrap.

Returns:
my command

canExecute

public boolean canExecute()
I can execute if my command can execute.


doExecute

protected org.eclipse.core.runtime.IStatus doExecute(org.eclipse.core.runtime.IProgressMonitor monitor,
                                                     org.eclipse.core.runtime.IAdaptable info)
                                              throws org.eclipse.core.commands.ExecutionException
Executes me by executing my command.

Specified by:
doExecute in class AbstractEMFOperation
Parameters:
monitor - the progress monitor provided by the operation history
info - the adaptable provided by the operation history
Returns:
the status of the execution
Throws:
org.eclipse.core.commands.ExecutionException - if, for some reason, I fail to complete the operation

didCommit

protected void didCommit(Transaction transaction)
Description copied from class: AbstractEMFOperation

Hook for subclasses to learn that the specified transaction has been successfully committed and, if necessary, to extract information from it.

Note: subclasses should call this super implementation to get some default behaviours.

Overrides:
didCommit in class AbstractEMFOperation
Parameters:
transaction - a transaction that has committed, which has recorded our changes

canUndo

public boolean canUndo()
I can undo if my command or (if any) trigger command can undo.

Specified by:
canUndo in interface org.eclipse.core.commands.operations.IUndoableOperation
Overrides:
canUndo in class AbstractEMFOperation

doUndo

protected org.eclipse.core.runtime.IStatus doUndo(org.eclipse.core.runtime.IProgressMonitor monitor,
                                                  org.eclipse.core.runtime.IAdaptable info)
                                           throws org.eclipse.core.commands.ExecutionException
Undoes me by undoing my trigger command (if any) and my command.

Overrides:
doUndo in class AbstractEMFOperation
Parameters:
monitor - the progress monitor provided by the operation history
info - the adaptable provided by the operation history
Returns:
the status of the undo operation
Throws:
org.eclipse.core.commands.ExecutionException - on failure to undo

canRedo

public boolean canRedo()
I can redo if either my wrapped command is a ConditionalRedoCommand that can undo, or it is not a conditionally redoable command.

Specified by:
canRedo in interface org.eclipse.core.commands.operations.IUndoableOperation
Overrides:
canRedo in class AbstractEMFOperation

doRedo

protected org.eclipse.core.runtime.IStatus doRedo(org.eclipse.core.runtime.IProgressMonitor monitor,
                                                  org.eclipse.core.runtime.IAdaptable info)
                                           throws org.eclipse.core.commands.ExecutionException
Redoes me by redoing my command and my trigger command (if any).

Overrides:
doRedo in class AbstractEMFOperation
Parameters:
monitor - the progress monitor provided by the operation history
info - the adaptable provided by the operation history
Returns:
the status of the redo operation
Throws:
org.eclipse.core.commands.ExecutionException - on failure to redo

improveLabel

protected void improveLabel(org.eclipse.emf.common.command.Command cmd)
Computes a more user-friendly label for the operation than the label created by default for EMF's feature-changing commands.

Parameters:
cmd - a command

Copyright 2002, 2006 IBM Corporation and others.
All Rights Reserved.