|
org.eclipse.gmf.runtime.emf.commands.core.command
Class AbstractTransactionalCommand
java.lang.Object
org.eclipse.core.commands.operations.AbstractOperation
org.eclipse.emf.workspace.AbstractEMFOperation
org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand
-
All Implemented Interfaces:
-
IUndoableOperation,
ICommand, org.eclipse.gmf.runtime.common.core.internal.command.ICommandWithSettableResult
-
Direct Known Subclasses:
-
AddCommand,
CreateDiagramCommand,
DeleteCommand,
DuplicateEObjectsCommand,
EditElementCommand,
GroupCommand,
RemoveBookmarkCommand,
RepositionEObjectCommand,
RestoreDefaultPropertyValueCommand,
SetConnectionAnchorsCommand,
SetConnectionEndsCommand,
SetModelPropertyValueCommand,
SetPropertyCommand,
UngroupCommand,
UpdateGroupLocationCommand
-
public abstract class AbstractTransactionalCommand
- extends org.eclipse.emf.workspace.AbstractEMFOperation
- implements
ICommand, org.eclipse.gmf.runtime.common.core.internal.command.ICommandWithSettableResult
An abstract superclass for GMF
IUndoableOperation s that modify EMF
model resources.
The operation provides a list of
IFile s that are expected to be
modified when the operation is executed, undone or redone. An
IOperationApprover is registered with the
OperationHistoryFactory.getOperationHistory() to validate the
modification to these resources.
Subclasses must return the command execution result in their implementation
of
doExecuteWithResult(IProgressMonitor, IAdaptable) .
This class is meant to be extended by clients.
Constructor Summary
|
AbstractTransactionalCommand
(org.eclipse.emf.transaction.TransactionalEditingDomain domain,
java.lang.String label,
java.util.List affectedFiles)
Initializes me with the editing domain in which I am making model
changes, a label, and a list of
IFile s that I anticipate
modifying when I am executed, undone or redone. |
AbstractTransactionalCommand
(org.eclipse.emf.transaction.TransactionalEditingDomain domain,
java.lang.String label,
java.util.Map options,
java.util.List affectedFiles)
Initializes me with the editing domain, a label, transaction options, and
a list of
IFile s that anticipate modifying when I am executed,
undone or redone. |
Method Summary
|
protected
IStatus
|
aggregateStatuses
(java.util.List statuses)
Considers that the aggregate status may be different from the present
status, and updates the command result accordingly. |
protected void
|
cleanup
()
Subclasses may implement this method to dispose of objects that were
required for execution, but are no longer require to undo or redo this
operation. |
ICommand
|
compose
(
IUndoableOperation operation)
Returns a new command object that represents a composition of this
command with the specified command parameter. |
protected void
|
didRedo
(org.eclipse.emf.transaction.Transaction tx)
|
protected void
|
didUndo
(org.eclipse.emf.transaction.Transaction tx)
|
protected
IStatus
|
doExecute
(
IProgressMonitor monitor,
IAdaptable info)
Delegates to
doExecuteWithResult(IProgressMonitor, IAdaptable)
to perform the model changes. |
protected abstract
CommandResult
|
doExecuteWithResult
(
IProgressMonitor monitor,
IAdaptable info)
Implemented by subclasses to perform the model changes. |
protected
IStatus
|
doRedo
(
IProgressMonitor monitor,
IAdaptable info)
Overrides superclass to set the command result. |
protected
IStatus
|
doUndo
(
IProgressMonitor monitor,
IAdaptable info)
Overrides superclass to set the command result. |
java.util.List
|
getAffectedFiles
()
Returns the
IFile s for resources that may be modified when the
operation is executed, undone or redone. |
CommandResult
|
getCommandResult
()
Retrieves the result of executing, undoing, or redoing this command,
depending on which of these operations was last performed. |
protected static java.util.List
|
getWorkspaceFiles
(org.eclipse.emf.ecore.EObject eObject)
Convenience method to get a list of workspaces files associated with
eObject . |
protected static java.util.List
|
getWorkspaceFiles
(java.util.List eObjects)
Convenience method to get a list of workspaces files associated with
EObject s in eObject . |
void
|
internalSetResult
(
CommandResult result)
Deprecated. internal API
|
ICommand
|
reduce
()
Returns the simplest form of this command that is equivalent. |
protected void
|
setResult
(
CommandResult result)
Sets the command result. |
Methods inherited from class org.eclipse.emf.workspace.AbstractEMFOperation
|
canRedo, canSetOptions, canUndo, didCommit, dispose, execute, getChange, getEditingDomain, getOptions, isReuseParentTransaction, redo, setOptions, setReuseParentTransaction, undo
|
Methods inherited from class java.lang.Object
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
|
Methods inherited from interface org.eclipse.gmf.runtime.common.core.command.
ICommand
|
setLabel
|
Methods inherited from interface org.eclipse.core.commands.operations.
IUndoableOperation
|
addContext,
canExecute,
canRedo,
canUndo,
dispose,
execute,
getContexts,
getLabel,
hasContext,
redo,
removeContext,
undo
|
AbstractTransactionalCommand
public AbstractTransactionalCommand(org.eclipse.emf.transaction.TransactionalEditingDomain domain,
java.lang.String label,
java.util.List affectedFiles)
- Initializes me with the editing domain in which I am making model
changes, a label, and a list of
IFile s that I anticipate
modifying when I am executed, undone or redone.
-
Parameters:
-
domain - my editing domain -
label - my user-readable label, should never be null . -
affectedFiles - the list of affected
IFile s; may be null
AbstractTransactionalCommand
public AbstractTransactionalCommand(org.eclipse.emf.transaction.TransactionalEditingDomain domain,
java.lang.String label,
java.util.Map options,
java.util.List affectedFiles)
- Initializes me with the editing domain, a label, transaction options, and
a list of
IFile s that anticipate modifying when I am executed,
undone or redone.
-
Parameters:
-
domain - my editing domain -
label - my user-readable label, should never be null . -
options - for the transaction in which I execute myself, or
null for the default options -
affectedFiles - the list of affected
IFile s; may be null
getWorkspaceFiles
protected static java.util.List getWorkspaceFiles(org.eclipse.emf.ecore.EObject eObject)
- Convenience method to get a list of workspaces files associated with
eObject .
-
-
-
Parameters:
-
eObject - the model object, may be null
-
Returns:
- the list of
IFile s
getWorkspaceFiles
protected static java.util.List getWorkspaceFiles(java.util.List eObjects)
- Convenience method to get a list of workspaces files associated with
EObject s in eObject .
-
-
-
Parameters:
-
eObjects - the list of model object
-
Returns:
- the list of
IFile s
getAffectedFiles
public java.util.List getAffectedFiles()
- Returns the
IFile s for resources that may be modified when the
operation is executed, undone or redone.
-
-
Specified by:
-
getAffectedFiles
in interface
ICommand
-
-
Returns:
- the list of
IFile s that will be modified
getCommandResult
public final
CommandResult getCommandResult()
-
Description copied from interface:
ICommand
- Retrieves the result of executing, undoing, or redoing this command,
depending on which of these operations was last performed. This value can
be
null if the operation has no meaningful result.
The value of this result is undefined if the command has not yet been
executed, undone or redone.
-
-
Specified by:
-
getCommandResult
in interface
ICommand
-
-
Returns:
- The result of executing, undoing or redoing this command.
setResult
protected final void setResult(
CommandResult result)
- Sets the command result.
-
-
-
Parameters:
-
result - the new result for this command.
compose
public
ICommand compose(
IUndoableOperation operation)
-
Description copied from interface:
ICommand
- Returns a new command object that represents a composition of this
command with the specified
command parameter.
-
-
Specified by:
-
compose
in interface
ICommand
-
-
Parameters:
-
operation - The operation that is to be composed with this command.
-
Returns:
- A command that represents a composition of this command with the
specified command.
reduce
public
ICommand reduce()
-
Description copied from interface:
ICommand
- Returns the simplest form of this command that is equivalent. Use this
method to remove unnecessary nesting of commands.
-
-
Specified by:
-
reduce
in interface
ICommand
-
-
Returns:
- the simplest form of this command that is equivalent
doExecuteWithResult
protected abstract
CommandResult doExecuteWithResult(
IProgressMonitor monitor,
IAdaptable info)
throws
ExecutionException
- Implemented by subclasses to perform the model changes. These changes
are applied by manipulation of the EMF metamodel's API, not
by executing commands on the editing domain's command stack.
-
-
-
Parameters:
-
monitor - the progress monitor provided by the operation history -
info - the adaptable provided by the operation history
-
Returns:
- the result of the execution
-
Throws:
-
ExecutionException
- if, for some reason, I fail to complete
the operation
didUndo
protected void didUndo(org.eclipse.emf.transaction.Transaction tx)
-
-
Overrides:
-
didUndo in class org.eclipse.emf.workspace.AbstractEMFOperation
-
didRedo
protected void didRedo(org.eclipse.emf.transaction.Transaction tx)
-
-
Overrides:
-
didRedo in class org.eclipse.emf.workspace.AbstractEMFOperation
-
doExecute
protected
IStatus doExecute(
IProgressMonitor monitor,
IAdaptable info)
throws
ExecutionException
- Delegates to
doExecuteWithResult(IProgressMonitor, IAdaptable)
to perform the model changes. Sets the command result and calls
cleanup() to give subclasses a chance to dispose of any objects
that were required for the execution but will not be required for undo or
redo.
-
-
Specified by:
-
doExecute in class org.eclipse.emf.workspace.AbstractEMFOperation
-
-
Throws:
-
ExecutionException
doUndo
protected
IStatus doUndo(
IProgressMonitor monitor,
IAdaptable info)
throws
ExecutionException
- Overrides superclass to set the command result.
-
-
Overrides:
-
doUndo in class org.eclipse.emf.workspace.AbstractEMFOperation
-
-
Throws:
-
ExecutionException
doRedo
protected
IStatus doRedo(
IProgressMonitor monitor,
IAdaptable info)
throws
ExecutionException
- Overrides superclass to set the command result.
-
-
Overrides:
-
doRedo in class org.eclipse.emf.workspace.AbstractEMFOperation
-
-
Throws:
-
ExecutionException
aggregateStatuses
protected
IStatus aggregateStatuses(java.util.List statuses)
- Considers that the aggregate status may be different from the present
status, and updates the command result accordingly.
-
-
Overrides:
-
aggregateStatuses in class org.eclipse.emf.workspace.AbstractEMFOperation
-
cleanup
protected void cleanup()
- Subclasses may implement this method to dispose of objects that were
required for execution, but are no longer require to undo or redo this
operation.
This method is invoked at the end of
doExecute(IProgressMonitor, IAdaptable) .
-
-
internalSetResult
public void internalSetResult(
CommandResult result)
-
Deprecated. internal API
- Internal method to set the command result.
-
-
Specified by:
-
internalSetResult in interface org.eclipse.gmf.runtime.common.core.internal.command.ICommandWithSettableResult
-
-
Parameters:
-
result - CommandResult to set
Guidelines for using Eclipse APIs.
Copyright (c) IBM Corp., Borland Software Corp., and others 2005,2006. All rights reserved.
|
|