org.eclipse.emf.compare.command.impl

## Class TransactionalDualCompareCommandStack

- java.lang.Object
- - org.eclipse.emf.compare.command.impl.TransactionalDualCompareCommandStack

All Implemented Interfaces:
  CommandStack, ICompareCommandStack, IDisposable

    public class TransactionalDualCompareCommandStack
    extends Object
    implements ICompareCommandStack, IDisposable

`ICompareCommandStack` implementation that will delegate to two given command stacks; one for each side of the comparison.

This implementation is one of the most robust delegating implementation we can do. If an error occurs during execution of a command, only the dirty state will be reset, all models will stay correct.

### Constructor Summary

Constructors
Constructor and Description
`TransactionalDualCompareCommandStack(org.eclipse.emf.transaction.impl.AbstractTransactionalCommandStack leftCommandStack, org.eclipse.emf.transaction.impl.AbstractTransactionalCommandStack rightCommandStack)` Creates an instance that delegates to two given `AbstractTransactionalCommandStack`.

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `addCommandStackListener(CommandStackListener listener)`
`boolean` `canRedo()`
`boolean` `canUndo()`
`void` `dispose()`
`void` `execute(Command command)`
`void` `flush()`
`Command` `getMostRecentCommand()`
`Command` `getRedoCommand()`
`Command` `getUndoCommand()`
`boolean` `isLeftSaveNeeded()` Returns whether the left model has changes since `ICompareCommandStack.leftSaveIsDone()` was call the last.
`boolean` `isRightSaveNeeded()` Returns whether the right model has changes since `ICompareCommandStack.rightSaveIsDone()` was call the last.
`void` `leftSaveIsDone()` Called after a save of the left model has been successfully performed.
`protected void` `notifyListeners(Object source)` This is called to ensure that `CommandStackListener.commandStackChanged(java.util.EventObject)` is called for each listener.
`void` `redo()`
`void` `removeCommandStackListener(CommandStackListener listener)`
`void` `rightSaveIsDone()` Called after a save of the right model has been successfully performed.
`void` `undo()`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### TransactionalDualCompareCommandStack

    public TransactionalDualCompareCommandStack(org.eclipse.emf.transaction.impl.AbstractTransactionalCommandStack leftCommandStack,
                                                org.eclipse.emf.transaction.impl.AbstractTransactionalCommandStack rightCommandStack)

Creates an instance that delegates to two given `AbstractTransactionalCommandStack`.

Parameters:
  `leftCommandStack` - the left command stack.
  `rightCommandStack` - the right command stack.

### Method Detail

#### dispose

    public void dispose()

Specified by:
  `dispose` in interface `IDisposable`
See Also:
  `IDisposable.dispose()`

#### notifyListeners

    protected void notifyListeners(Object source)

This is called to ensure that `CommandStackListener.commandStackChanged(java.util.EventObject)` is called for each listener.

Parameters:
  `source` - the source of the event.

#### execute

    public void execute(Command command)

Specified by:
  `execute` in interface `CommandStack`
See Also:
  `CommandStack.execute(org.eclipse.emf.common.command.Command)`

#### canUndo

    public boolean canUndo()

Specified by:
  `canUndo` in interface `CommandStack`
See Also:
  `CommandStack.canUndo()`

#### undo

    public void undo()

Specified by:
  `undo` in interface `CommandStack`
See Also:
  `CommandStack.undo()`

#### canRedo

    public boolean canRedo()

Specified by:
  `canRedo` in interface `CommandStack`
See Also:
  `CommandStack.canRedo()`

#### getUndoCommand

    public Command getUndoCommand()

Specified by:
  `getUndoCommand` in interface `CommandStack`
See Also:
  `CommandStack.getUndoCommand()`

#### getRedoCommand

    public Command getRedoCommand()

Specified by:
  `getRedoCommand` in interface `CommandStack`
See Also:
  `CommandStack.getRedoCommand()`

#### getMostRecentCommand

    public Command getMostRecentCommand()

Specified by:
  `getMostRecentCommand` in interface `CommandStack`
See Also:
  `CommandStack.getMostRecentCommand()`

#### redo

    public void redo()

Specified by:
  `redo` in interface `CommandStack`
See Also:
  `CommandStack.redo()`

#### flush

    public void flush()

Specified by:
  `flush` in interface `CommandStack`
See Also:
  `CommandStack.flush()`

#### addCommandStackListener

    public void addCommandStackListener(CommandStackListener listener)

Specified by:
  `addCommandStackListener` in interface `CommandStack`
See Also:
  `CommandStack.addCommandStackListener(org.eclipse.emf.common.command.CommandStackListener)`

#### removeCommandStackListener

    public void removeCommandStackListener(CommandStackListener listener)

Specified by:
  `removeCommandStackListener` in interface `CommandStack`
See Also:
  `CommandStack.removeCommandStackListener(org.eclipse.emf.common.command.CommandStackListener)`

#### isLeftSaveNeeded

    public boolean isLeftSaveNeeded()

Returns whether the left model has changes since `ICompareCommandStack.leftSaveIsDone()` was call the last.

Specified by:
  `isLeftSaveNeeded` in interface `ICompareCommandStack`
Returns:
  whether the left model has changes since `ICompareCommandStack.leftSaveIsDone()` was call the last.
See Also:
  `ICompareCommandStack.isLeftSaveNeeded()`

#### isRightSaveNeeded

    public boolean isRightSaveNeeded()

Returns whether the right model has changes since `ICompareCommandStack.rightSaveIsDone()` was call the last.

Specified by:
  `isRightSaveNeeded` in interface `ICompareCommandStack`
Returns:
  whether the right model has changes since `ICompareCommandStack.rightSaveIsDone()` was call the last.
See Also:
  `ICompareCommandStack.isRightSaveNeeded()`

#### leftSaveIsDone

    public void leftSaveIsDone()

Called after a save of the left model has been successfully performed.

Specified by:
  `leftSaveIsDone` in interface `ICompareCommandStack`
See Also:
  `ICompareCommandStack.leftSaveIsDone()`

#### rightSaveIsDone

    public void rightSaveIsDone()

Called after a save of the right model has been successfully performed.

Specified by:
  `rightSaveIsDone` in interface `ICompareCommandStack`
See Also:
  `ICompareCommandStack.rightSaveIsDone()`