org.eclipse.emf.transaction.impl
Class TransactionalCommandStackImpl

java.lang.Object
  extended byorg.eclipse.emf.common.command.BasicCommandStack
      extended byorg.eclipse.emf.transaction.impl.TransactionalCommandStackImpl
All Implemented Interfaces:
org.eclipse.emf.common.command.CommandStack, InternalTransactionalCommandStack, TransactionalCommandStack

public class TransactionalCommandStackImpl
extends org.eclipse.emf.common.command.BasicCommandStack
implements InternalTransactionalCommandStack

The default implementation of the transactional editing domain command stack.


Field Summary
 
Fields inherited from class org.eclipse.emf.common.command.BasicCommandStack
commandList, listeners, mostRecentCommand, saveIndex, top
 
Constructor Summary
TransactionalCommandStackImpl()
          Initializes me.
 
Method Summary
 boolean canRedo()
          Extends the inherited implementation to consider the redoability of ConditionalRedoCommands.
 EMFCommandTransaction createTransaction(org.eclipse.emf.common.command.Command command, java.util.Map options)
          Creates a read/write transaction in my editing domain for the purpose of executing the specified command.
 void dispose()
          Disposes of my state and any additional resources that I may be retaining.
 void execute(org.eclipse.emf.common.command.Command command)
          Redefines the inherited method by forwarding to the TransactionalEditingDomain#execute(Command, Map) method.
 void execute(org.eclipse.emf.common.command.Command command, java.util.Map options)
          Executes the specified command in a read/write transaction.
 void executeTriggers(org.eclipse.emf.common.command.Command command, java.util.List triggers, java.util.Map options)
          Executes the specified list of trigger commands.
 InternalTransactionalEditingDomain getDomain()
          Obtains the editing domain in which I create transactions.
 ExceptionHandler getExceptionHandler()
          Obtains my exception handler.
protected  void handleError(java.lang.Exception exception)
          Extends the inherited method by first rolling back the active transaction (if any) and passing the exception along to the registered exception handler (if any).
 void redo()
          Extends the inherited implementation by invoking it within the context of a redo transaction (a read/write transaction with the undo/redo options).
 void setEditingDomain(InternalTransactionalEditingDomain domain)
          Assigns the editing domain in which I create transactions.
 void setExceptionHandler(ExceptionHandler handler)
          Sets an exception handler.
 void undo()
          Extends the inherited implementation by invoking it within the context of an undo transaction (a read/write transaction with the undo/redo options).
 
Methods inherited from class org.eclipse.emf.common.command.BasicCommandStack
addCommandStackListener, canUndo, flush, getMostRecentCommand, getRedoCommand, getUndoCommand, isSaveNeeded, notifyListeners, removeCommandStackListener, saveIsDone
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.emf.common.command.CommandStack
addCommandStackListener, canUndo, flush, getMostRecentCommand, getRedoCommand, getUndoCommand, removeCommandStackListener
 

Constructor Detail

TransactionalCommandStackImpl

public TransactionalCommandStackImpl()
Initializes me.

Method Detail

getDomain

public InternalTransactionalEditingDomain getDomain()
Description copied from interface: InternalTransactionalCommandStack
Obtains the editing domain in which I create transactions.

Specified by:
getDomain in interface InternalTransactionalCommandStack
Returns:
my editing domain
See Also:
InternalTransactionalCommandStack.createTransaction(Command, Map)

setEditingDomain

public void setEditingDomain(InternalTransactionalEditingDomain domain)
Description copied from interface: InternalTransactionalCommandStack
Assigns the editing domain in which I create transactions.

Specified by:
setEditingDomain in interface InternalTransactionalCommandStack
Parameters:
domain - my editing domain
See Also:
InternalTransactionalCommandStack.createTransaction(Command, Map)

execute

public void execute(org.eclipse.emf.common.command.Command command,
                    java.util.Map options)
             throws java.lang.InterruptedException,
                    RollbackException
Description copied from interface: TransactionalCommandStack
Executes the specified command in a read/write transaction. This method is preferred over the inherited CommandStack.execute(Command) method because it provides feed-back when a command fails to complete. The implementation of this latter method simply suppresses (but logs) any checked exception that occurs.

Note that this method will block the caller until a read/write transaction can be started (if other transactions are currently active).

Specified by:
execute in interface TransactionalCommandStack
Parameters:
command - the command to execute
options - the options to apply to the command's transaction, or null to select the defaults
Throws:
RollbackException - if the changes performed by the command are rolled back by validation of the transaction
java.lang.InterruptedException - if the current thread is interrupted while waiting to start a read/write transaction for the command execution

setExceptionHandler

public void setExceptionHandler(ExceptionHandler handler)
Description copied from interface: TransactionalCommandStack
Sets an exception handler. This object will be notified when exceptions occur, but is not really expected to be able to do anything about them. Its intended purpose is to support an user feed-back mechanism appropriate to the environment.

Specified by:
setExceptionHandler in interface TransactionalCommandStack
Parameters:
handler - the exception handler to set

getExceptionHandler

public ExceptionHandler getExceptionHandler()
Description copied from interface: TransactionalCommandStack
Obtains my exception handler.

Specified by:
getExceptionHandler in interface TransactionalCommandStack
Returns:
my exception handler, or null if none
See Also:
TransactionalCommandStack.setExceptionHandler(ExceptionHandler)

handleError

protected void handleError(java.lang.Exception exception)
Extends the inherited method by first rolling back the active transaction (if any) and passing the exception along to the registered exception handler (if any).


execute

public void execute(org.eclipse.emf.common.command.Command command)
Redefines the inherited method by forwarding to the TransactionalEditingDomain#execute(Command, Map) method. Any checked exception thrown by that method is handled by TransactionalCommandStackImpl.handleError(Exception) but is not propagated.

Specified by:
execute in interface org.eclipse.emf.common.command.CommandStack

undo

public void undo()
Extends the inherited implementation by invoking it within the context of an undo transaction (a read/write transaction with the undo/redo options).

Specified by:
undo in interface org.eclipse.emf.common.command.CommandStack

canRedo

public boolean canRedo()
Extends the inherited implementation to consider the redoability of ConditionalRedoCommands.

Specified by:
canRedo in interface org.eclipse.emf.common.command.CommandStack

redo

public void redo()
Extends the inherited implementation by invoking it within the context of a redo transaction (a read/write transaction with the undo/redo options).

Specified by:
redo in interface org.eclipse.emf.common.command.CommandStack

createTransaction

public EMFCommandTransaction createTransaction(org.eclipse.emf.common.command.Command command,
                                               java.util.Map options)
                                        throws java.lang.InterruptedException
Description copied from interface: InternalTransactionalCommandStack
Creates a read/write transaction in my editing domain for the purpose of executing the specified command. The resulting transaction is expected to be started when it is returned (hence the possibility of interruption).

Specified by:
createTransaction in interface InternalTransactionalCommandStack
Parameters:
command - a command that I need to execute
options - the options to apply to the resulting transaction
Returns:
the command transaction
Throws:
java.lang.InterruptedException - if the current thread is interrupted while waiting for the transaction to start
See Also:
InternalTransactionalCommandStack.getDomain()

executeTriggers

public void executeTriggers(org.eclipse.emf.common.command.Command command,
                            java.util.List triggers,
                            java.util.Map options)
                     throws java.lang.InterruptedException,
                            RollbackException
Description copied from interface: InternalTransactionalCommandStack
Executes the specified list of trigger commands. All of the commands are executed within a single child transaction of the transaction that executed the triggering command; they must not be "piggy-backed" on the currently active transaction.

Specified by:
executeTriggers in interface InternalTransactionalCommandStack
Parameters:
command - the command whose execution triggered additional commands (from pre-commit listeners)
triggers - a list of zero or more Commands to execute. If there are none, then no transaction needs to be started
options - the options to apply to the child transaction
Throws:
RollbackException - if the trigger transaction rolls back on commit
java.lang.InterruptedException - if the current thread is interrupted while waiting for the trigger transaction to start
See Also:
ResourceSetListener.transactionAboutToCommit(org.eclipse.emf.transaction.ResourceSetChangeEvent), InternalTransactionalCommandStack.createTransaction(Command, Map)

dispose

public void dispose()
Description copied from interface: InternalTransactionalCommandStack
Disposes of my state and any additional resources that I may be retaining. I am only disposed when my editing domain is disposed.

Specified by:
dispose in interface InternalTransactionalCommandStack

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