Package org.eclipse.emf.compare.command.impl

# Class CompareCommandStack

java.lang.Object
com.google.common.collect.ForwardingObject
org.eclipse.emf.compare.command.DelegatingCommandStack
org.eclipse.emf.compare.command.impl.CompareCommandStack

All Implemented Interfaces:
  `CommandStack`, `ICompareCommandStack`, `IDisposable`

public class CompareCommandStack extends DelegatingCommandStack implements ICompareCommandStack, IDisposable
A simple `ICompareCommandStack` that delegate execution to another command stack but keep informations about execution to properly reply to `ICompareCommandStack` protocol.

This implementation is not robust. If an error occurs during execution of a command, the whole state will be corrupted and the undo/redo may have an unknown behavior.

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static class`
`CompareCommandStack.CompareSideCommandStack`
Simple data structure acting like a command stack but without any execution capability.

## Constructor Summary

Constructors
Constructor
Description
`CompareCommandStack(CommandStack commandStack)`
Creates a new instance that delegates to the given `commandStack`.

## Method Summary

Modifier and Type
Method
Description
`boolean`
`canUndo()`
`protected CommandStack`
`delegate()`
Returns the backing delegate instance that methods are forwarded to.
`void`
`dispose()`
`void`
`execute(Command command)`
`void`
`flush()`
`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.
`void`
`redo()`
`void`
`rightSaveIsDone()`
Called after a save of the right model has been successfully performed.
`void`
`undo()`

### Methods inherited from class org.eclipse.emf.compare.command.DelegatingCommandStack

`addCommandStackListener, canRedo, getMostRecentCommand, getRedoCommand, getUndoCommand, notifyListeners, removeCommandStackListener`

### Methods inherited from class com.google.common.collect.ForwardingObject

`toString`

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

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

### Methods inherited from interface org.eclipse.emf.common.command.CommandStack

`addCommandStackListener, canRedo, getMostRecentCommand, getRedoCommand, getUndoCommand, removeCommandStackListener`

## Constructor Details

### CompareCommandStack

public CompareCommandStack(CommandStack commandStack)
Creates a new instance that delegates to the given `commandStack`.

Parameters:
  `commandStack` - the command stack to which this instance will delegate.

## Method Details

### dispose

public void dispose()

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

### delegate

protected CommandStack delegate()
Returns the backing delegate instance that methods are forwarded to.

Specified by:
  `delegate` in class `DelegatingCommandStack`
Returns:
  the backing delegate instance that methods are forwarded to.
See Also:
  - `DelegatingCommandStack.delegate()`

### execute

public void execute(Command command)

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

### canUndo

public boolean canUndo()

Specified by:
  `canUndo` in interface `CommandStack`
Overrides:
  `canUndo` in class `DelegatingCommandStack`
See Also:
  - `CommandStack.canUndo()`

### undo

public void undo()

Specified by:
  `undo` in interface `CommandStack`
Overrides:
  `undo` in class `DelegatingCommandStack`
See Also:
  - `BasicCommandStack.undo()`

### redo

public void redo()

Specified by:
  `redo` in interface `CommandStack`
Overrides:
  `redo` in class `DelegatingCommandStack`
See Also:
  - `BasicCommandStack.redo()`

### flush

public void flush()

Specified by:
  `flush` in interface `CommandStack`
Overrides:
  `flush` in class `DelegatingCommandStack`
See Also:
  - `CommandStack.flush()`

### 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()`