Class AbstractCompositeOperation
- java.lang.Object
-
- org.eclipse.core.commands.operations.AbstractOperation
-
- org.eclipse.gef.mvc.fx.operations.AbstractCompositeOperation
-
- All Implemented Interfaces:
ICompositeOperation
,IUndoableOperation
,ITransactionalOperation
- Direct Known Subclasses:
ForwardUndoCompositeOperation
,ReverseUndoCompositeOperation
public abstract class AbstractCompositeOperation extends AbstractOperation implements ICompositeOperation, ITransactionalOperation
TheAbstractCompositeOperation
is an abstract implementation of theICompositeOperation
interface. The individual operations are stored in aList
. They are executed/redone/undone in forward order.
-
-
Constructor Summary
Constructors Constructor Description AbstractCompositeOperation(java.lang.String label)
Creates a newAbstractCompositeOperation
with the given label.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(IUndoableOperation operation)
void
addAll(java.util.List<ITransactionalOperation> operations)
Adds the givenIUndoableOperation
s to this composite operation.void
addContext(IUndoContext context)
boolean
canExecute()
boolean
canRedo()
boolean
canUndo()
protected IStatus
combine(IStatus s1, IStatus s2)
IStatus
execute(IProgressMonitor monitor, IAdaptable info)
java.util.List<ITransactionalOperation>
getOperations()
Returns the list ofITransactionalOperation
s which are combined in this composite operation.boolean
isContentRelevant()
Returnstrue
if thisITransactionalOperation
is actually changing model data (instead of only affecting the visualization).boolean
isEmpty()
Returnstrue
if no operations are currently combined in this composite operation.boolean
isNoOp()
Returnstrue
if thisITransactionalOperation
has no effect (in comparison to its initial state).IStatus
redo(IProgressMonitor monitor, IAdaptable info)
void
remove(IUndoableOperation operation)
IStatus
undo(IProgressMonitor monitor, IAdaptable info)
ITransactionalOperation
unwrap(boolean filterNoOps)
Simplifies this composite operation if possible and returns the simplified operation.-
Methods inherited from class org.eclipse.core.commands.operations.AbstractOperation
dispose, getContexts, getLabel, hasContext, removeContext, setLabel, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.core.commands.operations.IUndoableOperation
dispose, getContexts, getLabel, hasContext, removeContext
-
-
-
-
Constructor Detail
-
AbstractCompositeOperation
public AbstractCompositeOperation(java.lang.String label)
Creates a newAbstractCompositeOperation
with the given label.- Parameters:
label
- The label for thisAbstractCompositeOperation
.
-
-
Method Detail
-
add
public void add(IUndoableOperation operation)
- Specified by:
add
in interfaceICompositeOperation
-
addAll
public void addAll(java.util.List<ITransactionalOperation> operations)
Adds the givenIUndoableOperation
s to this composite operation.- Parameters:
operations
- TheIUndoableOperation
s which are added to this composite operation.
-
addContext
public void addContext(IUndoContext context)
- Specified by:
addContext
in interfaceIUndoableOperation
- Overrides:
addContext
in classAbstractOperation
-
canExecute
public boolean canExecute()
- Specified by:
canExecute
in interfaceIUndoableOperation
- Overrides:
canExecute
in classAbstractOperation
-
canRedo
public boolean canRedo()
- Specified by:
canRedo
in interfaceIUndoableOperation
- Overrides:
canRedo
in classAbstractOperation
-
canUndo
public boolean canUndo()
- Specified by:
canUndo
in interfaceIUndoableOperation
- Overrides:
canUndo
in classAbstractOperation
-
execute
public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException
- Specified by:
execute
in interfaceIUndoableOperation
- Specified by:
execute
in classAbstractOperation
- Throws:
ExecutionException
-
getOperations
public java.util.List<ITransactionalOperation> getOperations()
Returns the list ofITransactionalOperation
s which are combined in this composite operation.- Returns:
- The list of
ITransactionalOperation
s which are combined in this composite operation.
-
isContentRelevant
public boolean isContentRelevant()
Description copied from interface:ITransactionalOperation
Returnstrue
if thisITransactionalOperation
is actually changing model data (instead of only affecting the visualization). Otherwise returnsfalse
. The content relevance of anITransactionalOperation
can be checked to determine if the execution of the operation will affect the model, for example, to set an editor's dirty flag.- Specified by:
isContentRelevant
in interfaceITransactionalOperation
- Returns:
true
if thisITransactionalOperation
is actually changing model data, otherwisefalse
.
-
isEmpty
public boolean isEmpty()
Returnstrue
if no operations are currently combined in this composite operation. Otherwise returnsfalse
.- Returns:
true
if no operations are currently combined in this composite operation, otherwisefalse
.
-
isNoOp
public boolean isNoOp()
Description copied from interface:ITransactionalOperation
Returnstrue
if thisITransactionalOperation
has no effect (in comparison to its initial state). Otherwise returnsfalse
.- Specified by:
isNoOp
in interfaceITransactionalOperation
- Returns:
true
if thisITransactionalOperation
has no effect, otherwisefalse
.
-
redo
public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException
- Specified by:
redo
in interfaceIUndoableOperation
- Specified by:
redo
in classAbstractOperation
- Throws:
ExecutionException
-
remove
public void remove(IUndoableOperation operation)
- Specified by:
remove
in interfaceICompositeOperation
-
undo
public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException
- Specified by:
undo
in interfaceIUndoableOperation
- Specified by:
undo
in classAbstractOperation
- Throws:
ExecutionException
-
unwrap
public ITransactionalOperation unwrap(boolean filterNoOps)
Simplifies this composite operation if possible and returns the simplified operation. When this composite operation does not contain any operations,null
is returned. When this composite operation contains exactly one operation, that one operation is returned. Otherwise, this composite operation is returned.- Parameters:
filterNoOps
-true
if no-ops (seeITransactionalOperation.isNoOp()
) should be removed from the list of operations, otherwisefalse
.- Returns:
null
when no operations are contained, the one operation when only one operation is contained, this composite when multiple operations are contained.
-
-