|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eclipse.core.commands.operations.AbstractOperation org.eclipse.emf.workspace.AbstractEMFOperation
public abstract class AbstractEMFOperation
An abstract superclass for IUndoableOperation
s that modify EMF
models. The EMF operation provides a read/write transaction context for the
subclass implementation of the execution logic, with undo/redo support "for
free" (via recording of undo information).
The assumption is that an EMF operation will perform only changes to EMF
models that can be recorded. If concomitant changes to non-EMF models are
also required, then they should be combined with the EMF operation via a
CompositeEMFOperation
, unless ordering of EMF and non-EMF changes
is unimportant. In such cases, it is sufficient to extend the
doUndo(IProgressMonitor, IAdaptable)
and
doRedo(IProgressMonitor, IAdaptable)
methods.
This class is meant to be extended by clients.
CompositeEMFOperation
Constructor Summary | |
---|---|
AbstractEMFOperation(TransactionalEditingDomain domain,
String label)
Initializes me with the editing domain in which I am making model changes and a label. |
|
AbstractEMFOperation(TransactionalEditingDomain domain,
String label,
Map<?,?> options)
Initializes me with the editing domain, a label, and transaction options. |
Method Summary | |
---|---|
protected IStatus |
aggregateStatuses(List<? extends IStatus> statuses)
Creates a suitable aggregate from these statuses. |
boolean |
canRedo()
Queries whether I can be redone. |
boolean |
canUndo()
Queries whether I can be undone. |
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 void |
didRedo(Transaction tx)
Hook for subclasses to learn that the specified transaction
has been successfully redone and, if necessary, to extract information
from it. |
protected void |
didUndo(Transaction tx)
Hook for subclasses to learn that the specified transaction
has been successfully undone and, if necessary, to extract information
from it. |
void |
dispose()
Forgets my transaction and its change description. |
protected abstract IStatus |
doExecute(IProgressMonitor monitor,
IAdaptable info)
Implemented by subclasses to perform the model changes. |
protected IStatus |
doRedo(IProgressMonitor monitor,
IAdaptable info)
Implements the redo behaviour by replaying my recorded changes. |
protected IStatus |
doUndo(IProgressMonitor monitor,
IAdaptable info)
Implements the undo behaviour by inverting my recorded changes. |
IStatus |
execute(IProgressMonitor monitor,
IAdaptable info)
Implements the execution by delegating to the doExecute(IProgressMonitor, IAdaptable) method within a
read/write transaction. |
protected TransactionChangeDescription |
getChange()
Obtains the change description that I recorded during execution of my transaction. |
TransactionalEditingDomain |
getEditingDomain()
Obtains my editing domain. |
Map<?,?> |
getOptions()
Obtains the transaction options that I use to create my transaction. |
IStatus |
redo(IProgressMonitor monitor,
IAdaptable info)
Redoes me by replaying my recorded changes in a transaction. |
IStatus |
undo(IProgressMonitor monitor,
IAdaptable info)
Undoes me by inverting my recorded changes in a transaction. |
Methods inherited from class org.eclipse.core.commands.operations.AbstractOperation |
---|
addContext, canExecute, 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 |
---|
public AbstractEMFOperation(TransactionalEditingDomain domain, String label)
domain
- my editing domainlabel
- my user-readable labelpublic AbstractEMFOperation(TransactionalEditingDomain domain, String label, Map<?,?> options)
domain
- my editing domainlabel
- my user-readable labeloptions
- for the transaction in which I execute myself, or
null
for the default optionsMethod Detail |
---|
public final IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException
doExecute(IProgressMonitor, IAdaptable)
method within a
read/write transaction.
execute
in interface IUndoableOperation
execute
in class AbstractOperation
ExecutionException
doExecute(IProgressMonitor, IAdaptable)
protected IStatus aggregateStatuses(List<? extends IStatus> statuses)
statuses
- the statuses to aggregate. May have zero, one, or more
elements (all must be IStatus
es)
protected final TransactionChangeDescription getChange()
null
, otherwiseprotected 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.
Note: subclasses should call this super implementation to get some default behaviours.
transaction
- a transaction that has committed, which has recorded
our changespublic boolean canUndo()
canUndo
in interface IUndoableOperation
canUndo
in class AbstractOperation
public final IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException
undo
in interface IUndoableOperation
undo
in class AbstractOperation
ExecutionException
protected void didUndo(Transaction tx)
transaction
has been successfully undone and, if necessary, to extract information
from it.
tx
- a transaction that has been undone.public boolean canRedo()
canRedo
in interface IUndoableOperation
canRedo
in class AbstractOperation
public final IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException
redo
in interface IUndoableOperation
redo
in class AbstractOperation
ExecutionException
protected void didRedo(Transaction tx)
transaction
has been successfully redone and, if necessary, to extract information
from it.
tx
- a transaction that has been redone.public final TransactionalEditingDomain getEditingDomain()
public final Map<?,?> getOptions()
protected abstract IStatus doExecute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException
monitor
- the progress monitor provided by the operation history.
Will never be null
because the
execute(IProgressMonitor, IAdaptable)
method would substitute
a NullProgressMonitor
in that caseinfo
- the adaptable provided by the operation history
ExecutionException
- if, for some reason, I fail to complete
the operationprotected IStatus doUndo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException
Note that subclasses overriding this method must invoke the super implementation as well.
monitor
- the progress monitor provided by the operation history
Will never be null
because the
undo(IProgressMonitor, IAdaptable)
method would substitute
a NullProgressMonitor
in that caseinfo
- the adaptable provided by the operation history
ExecutionException
- on failure to undoprotected IStatus doRedo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException
Note that subclasses overriding this method must invoke the super implementation as well.
monitor
- the progress monitor provided by the operation history
Will never be null
because the
redo(IProgressMonitor, IAdaptable)
method would substitute
a NullProgressMonitor
in that caseinfo
- the adaptable provided by the operation history
ExecutionException
- on failure to redopublic void dispose()
dispose
in interface IUndoableOperation
dispose
in class AbstractOperation
|
Copyright 2002, 2007 IBM Corporation and others. All Rights Reserved. |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |