Runtime

## org.eclipse.gmf.runtime.common.core.command
Interface ICompositeCommand

All Superinterfaces:
  ICommand, IUndoableOperation

All Known Implementing Classes:
  CompositeCommand, CompositeTransactionalCommand

    public interface ICompositeCommand

extends ICommand

A self-composing undoable operation that is has a `CommandResult`, a list of affected `IFile`s, and is composed of child operations.

Does not extend `ICompositeOperation` because

- `remove(IUndoableOperation)` does not dispose the removed operation
- Children are explicitely composed by the client. Adding to an open composite through the operation history is not supported.

Method Summary
`void` `add(IUndoableOperation operation)` Add the specified operation as a child of this operation.
`boolean` `isEmpty()` Answers whether or not this composite operation has children.
`java.util.Iterator` `iterator()` Obtains an iterator to traverse my child operations.
`java.util.ListIterator` `listIterator()` Obtains an iterator to traverse my child operations in either direction.
`java.util.ListIterator` `listIterator(int index)` Obtains an iterator to traverse my child operations in either direction, starting from the specified `index`.
`void` `remove(IUndoableOperation operation)` Remove the specified operation from this operation.
`int` `size()` Queries the number of child operations that I contain.

Methods inherited from interface org.eclipse.gmf.runtime.common.core.command.ICommand
`compose, getAffectedFiles, getCommandResult, reduce, setLabel`

Methods inherited from interface org.eclipse.core.commands.operations.IUndoableOperation
`addContext, canExecute, canRedo, canUndo, dispose, execute, getContexts, getLabel, hasContext, redo, removeContext, undo`

Method Detail

### add

    void add(IUndoableOperation operation)

  Add the specified operation as a child of this operation.

  Parameters:
    `operation` - the operation to be added. If the operation instance has already been added, this method will have no effect.

### remove

    void remove(IUndoableOperation operation)

  Remove the specified operation from this operation.

  Unlike `ICompositeOperation`, this does not dispose of the removed operation since the composite did not create the operation.

  Parameters:
    `operation` - the operation to be removed. The operation should be disposed by the receiver. This method will have no effect if the operation instance is not already a child.

### isEmpty

    boolean isEmpty()

  Answers whether or not this composite operation has children.

  Returns:
    `true` if the operation does not have children, `false` otherwise.

### size

    int size()

  Queries the number of child operations that I contain.

  Returns:
    my size

### iterator

    java.util.Iterator iterator()

  Obtains an iterator to traverse my child operations. Removing children via this iterator correctly maintains my undo contexts.

  Returns:
    an iterator of my children

### listIterator

    java.util.ListIterator listIterator()

  Obtains an iterator to traverse my child operations in either direction. Adding and removing children via this iterator correctly maintains my undo contexts.

  Note that, unlike list iterators generally, this one does not permit the addition of an operation that I already contain (the composite does not permit duplicates). Moreover, only `IUndoableOperation`s may be added, otherwise `ClassCastException`s will result.

  Returns:
    an iterator of my children

### listIterator

    java.util.ListIterator listIterator(int index)

  Obtains an iterator to traverse my child operations in either direction, starting from the specified `index`. Adding and removing children via this iterator correctly maintains my undo contexts.

  Note that, unlike list iterators generally, this one does not permit the addition of an operation that I already contain (the composite does not permit duplicates). Moreover, only `IUndoableOperation`s may be added, otherwise `ClassCastException`s will result.

  Parameters:
    `index` - the index in my children at which to start iterating
  Returns:
    an iterator of my children

Runtime

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp., Borland Software Corp., and others 2005,2006. All rights reserved.