|
|
|
|
org.eclipse.emf.workspace.impl
Class WorkspaceCommandStackImpl
java.lang.Object
org.eclipse.emf.common.command.BasicCommandStack
org.eclipse.emf.transaction.impl.AbstractTransactionalCommandStack
org.eclipse.emf.workspace.impl.WorkspaceCommandStackImpl
-
All Implemented Interfaces:
-
CommandStack,
InternalTransactionalCommandStack,
TransactionalCommandStack,
IWorkspaceCommandStack
-
public class WorkspaceCommandStackImpl
- extends
AbstractTransactionalCommandStack
- 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 .
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
(
Command command,
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. |
protected void
|
doExecute
(
Command command,
Map<?,?> options)
Implemented by subclasses to perform the execution of the specified
command . |
void
|
executeTriggers
(
Command command,
List<
Command> triggers,
Map<?,?> options)
Executes the specified list of trigger commands. |
void
|
flush
()
Disposes my default undo context in my operation history. |
IUndoContext
|
getDefaultUndoContext
()
Obtains the default undo context to add to the undoable operations that
I execute on my operation history to wrap
Command s. |
protected
String
|
getDefaultUndoContextLabel
()
Obtains the label to display for the default undo context that I apply
to operations executed through me as
Command s. |
Command
|
getMostRecentCommand
()
Gets the command from the most recently executed, done, or redone
operation. |
IOperationHistory
|
getOperationHistory
()
Obtains the operation history to which I delegate command execution. |
Command
|
getRedoCommand
()
Gets the command from the top of the redo history, if any. |
IResourceUndoContextPolicy
|
getResourceUndoContextPolicy
()
Obtains my resource undo-context policy. |
protected
String
|
getSavepointUndoContextLabel
()
Obtains the label to display for the save-point undo context that I apply
to the last operation in my
default undo context
that was executed at the time save was performed (as indicated by invocation
of the
saveIsDone() method). |
Command
|
getUndoCommand
()
Gets the command from the top of the undo history, if any. |
boolean
|
isSaveNeeded
()
|
void
|
redo
()
Redoes my default undo context in my operation history. |
void
|
saveIsDone
()
|
void
|
setEditingDomain
(
InternalTransactionalEditingDomain domain)
Extends the superclass implementation to add/remove listeners on the
editing domain. |
void
|
setResourceUndoContextPolicy
(
IResourceUndoContextPolicy policy)
Sets my resource undo-context policy. |
void
|
undo
()
Undoes my default undo context in my operation history. |
Methods inherited from class org.eclipse.emf.transaction.impl.
AbstractTransactionalCommandStack
|
basicExecute,
execute,
execute,
getDomain,
getExceptionHandler,
getUndoRedoOptions,
handleError,
handleRollback,
makeTriggerTransactionOptions,
rollback,
setExceptionHandler
|
Methods inherited from class java.lang.
Object
|
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait
|
WorkspaceCommandStackImpl
public WorkspaceCommandStackImpl(
IOperationHistory history)
- Initializes me with the operation history to which I delegate command
execution.
-
Parameters:
-
history - my operation history
setEditingDomain
public void setEditingDomain(
InternalTransactionalEditingDomain domain)
- Extends the superclass implementation to add/remove listeners on the
editing domain.
-
-
Specified by:
-
setEditingDomain
in interface
InternalTransactionalCommandStack
-
Overrides:
-
setEditingDomain
in class
AbstractTransactionalCommandStack
-
-
Parameters:
-
domain - my editing domain -
See Also:
-
InternalTransactionalCommandStack.createTransaction(Command, Map)
getOperationHistory
public final
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
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
Command s. 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()
getDefaultUndoContextLabel
protected
String getDefaultUndoContextLabel()
- Obtains the label to display for the default undo context that I apply
to operations executed through me as
Command s. Subclasses may
override to customize the label.
-
-
-
Returns:
- my default undo context label
-
Since:
- 1.2
getSavepointUndoContextLabel
protected
String getSavepointUndoContextLabel()
- Obtains the label to display for the save-point undo context that I apply
to the last operation in my
default undo context
that was executed at the time save was performed (as indicated by invocation
of the
saveIsDone() method). Subclasses may override to customize the label.
-
-
-
Returns:
- my save-point undo context label
-
Since:
- 1.2
doExecute
protected void doExecute(
Command command,
Map<?,?> options)
throws
InterruptedException,
RollbackException
- Implemented by subclasses to perform the execution of the specified
command . Invoked by the
AbstractTransactionalCommandStack.execute(Command, Map)
method.
-
-
Specified by:
-
doExecute
in class
AbstractTransactionalCommandStack
-
-
Parameters:
-
command - the command to execute -
options - the transaction options to apply to execution of the command
-
Throws:
-
InterruptedException
- if the current thread is interrupted while
waiting to start the transaction
-
RollbackException
- if the execution of the command is rolled back -
Since:
- 1.1
canUndo
public boolean canUndo()
- Queries whether we can undo my default undo context in my operation history.
-
-
Specified by:
-
canUndo
in interface
CommandStack
-
Overrides:
-
canUndo
in class
BasicCommandStack
-
undo
public void undo()
- Undoes my default undo context in my operation history.
-
-
Specified by:
-
undo
in interface
CommandStack
-
Overrides:
-
undo
in class
BasicCommandStack
-
canRedo
public boolean canRedo()
- Queries whether we can redo my default undo context in my operation history.
-
-
Specified by:
-
canRedo
in interface
CommandStack
-
Overrides:
-
canRedo
in class
BasicCommandStack
-
redo
public void redo()
- Redoes my default undo context in my operation history.
-
-
Specified by:
-
redo
in interface
CommandStack
-
Overrides:
-
redo
in class
BasicCommandStack
-
flush
public void flush()
- Disposes my default undo context in my operation history.
-
-
Specified by:
-
flush
in interface
CommandStack
-
Overrides:
-
flush
in class
BasicCommandStack
-
getMostRecentCommand
public
Command getMostRecentCommand()
- Gets the command from the most recently executed, done, or redone
operation.
-
-
Specified by:
-
getMostRecentCommand
in interface
CommandStack
-
Overrides:
-
getMostRecentCommand
in class
BasicCommandStack
-
getUndoCommand
public
Command getUndoCommand()
- Gets the command from the top of the undo history, if any.
-
-
Specified by:
-
getUndoCommand
in interface
CommandStack
-
Overrides:
-
getUndoCommand
in class
BasicCommandStack
-
getRedoCommand
public
Command getRedoCommand()
- Gets the command from the top of the redo history, if any.
-
-
Specified by:
-
getRedoCommand
in interface
CommandStack
-
Overrides:
-
getRedoCommand
in class
BasicCommandStack
-
createTransaction
public
EMFCommandTransaction createTransaction(
Command command,
Map<?,?> options)
throws
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:
-
InterruptedException
- if the current thread is interrupted while
waiting for the transaction to start -
See Also:
-
InternalTransactionalCommandStack.getDomain()
executeTriggers
public void executeTriggers(
Command command,
List<
Command> triggers,
Map<?,?> options)
throws
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
Command s to execute.
If there are none, then no transaction needs to be started -
options - the options to apply to the child transaction
-
Throws:
-
InterruptedException
- if the current thread is interrupted while
waiting for the trigger transaction to start
-
RollbackException
- if the trigger transaction rolls back on commit -
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
-
getResourceUndoContextPolicy
public
IResourceUndoContextPolicy getResourceUndoContextPolicy()
- Obtains my resource undo-context policy.
-
-
-
Returns:
- my resource undo-context policy
-
Since:
- 1.3
setResourceUndoContextPolicy
public void setResourceUndoContextPolicy(
IResourceUndoContextPolicy policy)
- Sets my resource undo-context policy.
-
-
-
Parameters:
-
policy - my new policy, or null to restore the default -
Since:
- 1.3
isSaveNeeded
public boolean isSaveNeeded()
-
-
Overrides:
-
isSaveNeeded
in class
BasicCommandStack
-
saveIsDone
public void saveIsDone()
-
-
Overrides:
-
saveIsDone
in class
BasicCommandStack
-
|
|
|