org.eclipse.emf.workspace.impl
Class WorkspaceCommandStackImpl

java.lang.Object
  extended byorg.eclipse.emf.common.command.BasicCommandStack
      extended byorg.eclipse.emf.workspace.impl.WorkspaceCommandStackImpl
All Implemented Interfaces:
org.eclipse.emf.common.command.CommandStack, IWorkspaceCommandStack

public class WorkspaceCommandStackImpl
extends org.eclipse.emf.common.command.BasicCommandStack
implements IWorkspaceCommandStack

Implementation of a transactional command stack that delegates execution of commands to an IOperationHistory.

This is the command stack implementation used by editing domains created by the WorkspaceEditingDomainFactory.


Field Summary
 
Fields inherited from class org.eclipse.emf.common.command.BasicCommandStack
commandList, listeners, mostRecentCommand, saveIndex, top
 
Constructor Summary
WorkspaceCommandStackImpl(org.eclipse.core.commands.operations.IOperationHistory history)
          Initializes me with the operation history to which I delegate command execution.
 
Method Summary
 boolean canRedo()
          Queries whether we can redo my default undo context in my operation history.
 boolean canUndo()
          Queries whether we can undo my default undo context in my operation history.
 EMFCommandTransaction createTransaction(org.eclipse.emf.common.command.Command command, java.util.Map options)
           
 void dispose()
           
 void execute(org.eclipse.emf.common.command.Command command)
           
 void execute(org.eclipse.emf.common.command.Command command, java.util.Map options)
           
 void executeTriggers(org.eclipse.emf.common.command.Command command, java.util.List triggers, java.util.Map options)
           
 void flush()
          Disposes my default undo context in my operation history.
 org.eclipse.core.commands.operations.IUndoContext getDefaultUndoContext()
          Obtains the default undo context to add to the undoable operations that I execute on my operation history to wrap Commands.
 InternalTransactionalEditingDomain getDomain()
           
 ExceptionHandler getExceptionHandler()
           
 org.eclipse.emf.common.command.Command getMostRecentCommand()
          Gets the command from the most recently executed, done, or redone operation.
 org.eclipse.core.commands.operations.IOperationHistory getOperationHistory()
          Obtains the operation history to which I delegate command execution.
 org.eclipse.emf.common.command.Command getRedoCommand()
          Gets the command from the top of the redo history, if any.
 org.eclipse.emf.common.command.Command getUndoCommand()
          Gets the command from the top of the undo history, if any.
protected  void handleError(java.lang.Exception exception)
          Extends the inherited method by first passing the exception along to the registered exception handler (if any).
 boolean isSaveNeeded()
           
 void redo()
          Redoes my default undo context in my operation history.
 void saveIsDone()
           
 void setEditingDomain(InternalTransactionalEditingDomain domain)
           
 void setExceptionHandler(ExceptionHandler handler)
           
 void undo()
          Undoes my default undo context in my operation history.
 
Methods inherited from class org.eclipse.emf.common.command.BasicCommandStack
addCommandStackListener, notifyListeners, removeCommandStackListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WorkspaceCommandStackImpl

public WorkspaceCommandStackImpl(org.eclipse.core.commands.operations.IOperationHistory history)
Initializes me with the operation history to which I delegate command execution.

Parameters:
history - my operation history
Method Detail

getDomain

public InternalTransactionalEditingDomain getDomain()

setEditingDomain

public void setEditingDomain(InternalTransactionalEditingDomain domain)

getOperationHistory

public final org.eclipse.core.commands.operations.IOperationHistory getOperationHistory()
Description copied from interface: IWorkspaceCommandStack
Obtains the operation history to which I delegate command execution.

Specified by:
getOperationHistory in interface IWorkspaceCommandStack
Returns:
my operation history

getDefaultUndoContext

public final org.eclipse.core.commands.operations.IUndoContext getDefaultUndoContext()
Description copied from interface: IWorkspaceCommandStack
Obtains the default undo context to add to the undoable operations that I execute on my operation history to wrap Commands. Moreover, undo, redo, and flush are context-specific operations in the operation history, so my undo/redo/flush commands use this context in delegating to the history. Likewise, the determination of the most recent command and undo/redo commands depends on this context.

Specified by:
getDefaultUndoContext in interface IWorkspaceCommandStack
Returns:
the default undo context for undo/redo/flush invocations
See Also:
TransactionalCommandStack#execute(Command, java.util.Map), CommandStack.undo(), CommandStack.redo(), CommandStack.flush(), CommandStack.getMostRecentCommand(), CommandStack.getUndoCommand(), CommandStack.getRedoCommand()

execute

public void execute(org.eclipse.emf.common.command.Command command,
                    java.util.Map options)
             throws java.lang.InterruptedException,
                    RollbackException
Throws:
java.lang.InterruptedException
RollbackException

execute

public void execute(org.eclipse.emf.common.command.Command command)
Specified by:
execute in interface org.eclipse.emf.common.command.CommandStack

setExceptionHandler

public void setExceptionHandler(ExceptionHandler handler)

getExceptionHandler

public ExceptionHandler getExceptionHandler()

handleError

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


canUndo

public boolean canUndo()
Queries whether we can undo my default undo context in my operation history.

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

undo

public void undo()
Undoes my default undo context in my operation history.

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

canRedo

public boolean canRedo()
Queries whether we can redo my default undo context in my operation history.

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

redo

public void redo()
Redoes my default undo context in my operation history.

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

flush

public void flush()
Disposes my default undo context in my operation history.

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

getMostRecentCommand

public org.eclipse.emf.common.command.Command getMostRecentCommand()
Gets the command from the most recently executed, done, or redone operation.

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

getUndoCommand

public org.eclipse.emf.common.command.Command getUndoCommand()
Gets the command from the top of the undo history, if any.

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

getRedoCommand

public org.eclipse.emf.common.command.Command getRedoCommand()
Gets the command from the top of the redo history, if any.

Specified by:
getRedoCommand 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
Throws:
java.lang.InterruptedException

executeTriggers

public void executeTriggers(org.eclipse.emf.common.command.Command command,
                            java.util.List triggers,
                            java.util.Map options)
                     throws java.lang.InterruptedException,
                            RollbackException
Throws:
java.lang.InterruptedException
RollbackException

dispose

public void dispose()

isSaveNeeded

public boolean isSaveNeeded()

saveIsDone

public void saveIsDone()

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