Package org.eclipse.gef.mvc.fx.operations

# 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
The `AbstractCompositeOperation` is an abstract implementation of the `ICompositeOperation` interface. The individual operations are stored in a `List`. They are executed/redone/undone in forward order.

## Constructor Summary

Constructors
Constructor
Description
`AbstractCompositeOperation(String label)`
Creates a new `AbstractCompositeOperation` with the given label.

## Method Summary

Modifier and Type
Method
Description
`void`
`add(IUndoableOperation operation)`
`void`
`addAll(List<ITransactionalOperation> operations)`
Adds the given `IUndoableOperation`s to this composite operation.
`void`
`addContext(IUndoContext context)`
`boolean`
`canExecute()`
`boolean`
`canRedo()`
`boolean`
`canUndo()`
`protected IStatus`
`combine(IStatus s1, IStatus s2)`
Return an `IStatus` representing the merge of the given first and second `IStatus`s.
`IStatus`
`execute(IProgressMonitor monitor, IAdaptable info)`
`List<ITransactionalOperation>`
`getOperations()`
Returns the list of `ITransactionalOperation`s which are combined in this composite operation.
`boolean`
`isContentRelevant()`
Returns `true` if this `ITransactionalOperation` is actually changing model data (instead of only affecting the visualization).
`boolean`
`isEmpty()`
Returns `true` if no operations are currently combined in this composite operation.
`boolean`
`isNoOp()`
Returns `true` if this `ITransactionalOperation` 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 Details

### AbstractCompositeOperation

public AbstractCompositeOperation(String label)
Creates a new `AbstractCompositeOperation` with the given label.

Parameters:
  `label` - The label for this `AbstractCompositeOperation`.

## Method Details

### add

public void add(IUndoableOperation operation)

Specified by:
  `add` in interface `ICompositeOperation`

### addAll

public void addAll(List<ITransactionalOperation> operations)
Adds the given `IUndoableOperation`s to this composite operation.

Parameters:
  `operations` - The `IUndoableOperation`s which are added to this composite operation.

### addContext

public void addContext(IUndoContext context)

Specified by:
  `addContext` in interface `IUndoableOperation`
Overrides:
  `addContext` in class `AbstractOperation`

### canExecute

public boolean canExecute()

Specified by:
  `canExecute` in interface `IUndoableOperation`
Overrides:
  `canExecute` in class `AbstractOperation`

### canRedo

public boolean canRedo()

Specified by:
  `canRedo` in interface `IUndoableOperation`
Overrides:
  `canRedo` in class `AbstractOperation`

### canUndo

public boolean canUndo()

Specified by:
  `canUndo` in interface `IUndoableOperation`
Overrides:
  `canUndo` in class `AbstractOperation`

### combine

protected IStatus combine(IStatus s1, IStatus s2)
Return an `IStatus` representing the merge of the given first and second `IStatus`s.

Parameters:
  `s1` - The first `IStatus`.
  `s2` - The second `IStatus`.
Returns:
  The merge of the first and second `IStatus`.

### execute

public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException

Specified by:
  `execute` in interface `IUndoableOperation`
Specified by:
  `execute` in class `AbstractOperation`
Throws:
  `ExecutionException`

### getOperations

public List<ITransactionalOperation> getOperations()
Returns the list of `ITransactionalOperation`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`
Returns `true` if this `ITransactionalOperation` is actually changing model data (instead of only affecting the visualization). Otherwise returns `false`. The content relevance of an `ITransactionalOperation` 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 interface `ITransactionalOperation`
Returns:
  `true` if this `ITransactionalOperation` is actually changing model data, otherwise `false`.

### isEmpty

public boolean isEmpty()
Returns `true` if no operations are currently combined in this composite operation. Otherwise returns `false`.

Returns:
  `true` if no operations are currently combined in this composite operation, otherwise `false`.

### isNoOp

public boolean isNoOp()
Description copied from interface: `ITransactionalOperation`
Returns `true` if this `ITransactionalOperation` has no effect (in comparison to its initial state). Otherwise returns `false`.

Specified by:
  `isNoOp` in interface `ITransactionalOperation`
Returns:
  `true` if this `ITransactionalOperation` has no effect, otherwise `false`.

### redo

public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException

Specified by:
  `redo` in interface `IUndoableOperation`
Specified by:
  `redo` in class `AbstractOperation`
Throws:
  `ExecutionException`

### remove

public void remove(IUndoableOperation operation)

Specified by:
  `remove` in interface `ICompositeOperation`

### undo

public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException

Specified by:
  `undo` in interface `IUndoableOperation`
Specified by:
  `undo` in class `AbstractOperation`
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 (see `ITransactionalOperation.isNoOp()`) should be removed from the list of operations, otherwise `false`.
Returns:
  `null` when no operations are contained, the one operation when only one operation is contained, this composite when multiple operations are contained.