[[BackLinksMenu]]

[[TicketQuery(summary=PRO_CHANGE_COMMONS_R0, format=table, col=summary|owner|status|type|component|priority|effort|importance, rows=description|analysis_owners|analysis_reviewers|analysis_score|design_owners|design_reviewers|design_score|implementation_owners|implementation_reviewers|implementation_score|test_owners|test_reviewers|test_score|)]]

= Analysis =

== Overview ==
This task is related to the !UndoManager. The change manager is like the undo-manager, but allows skipping, unskipping etc. Currently we have an !UndoManger which will later become a change manager with the additional features described bellow.

skip change, unskip change, undo change,  

== Task requirements ==
 * review code in [source:trunk/sophie2-platform/modules/org.sophie2.core/src/main/java/org/sophie2/core/prolib/util/UndoManager.java UndoManager] that represents the current undo manager.
 * besides undo change and redo change the !ChangeManager should also be capable of doing the following:
  * skip a change - the change will be skipped and the next in turn will be available if such exists. Unmanaged changes should all be skipped by default (see [wiki:PRO_CHANGE_PRIMITIVES_R0]). Other changes may be skipped depending on certain situations.
  * unskip a change - will provide the opportunity to revert the skipping of a change. This should be possible only if a skip of the change had been done.
  * undo/redo - the undo/redo mechanism should behave in a generally accepted manner as in most applications nowadays.
  * '''Important:'''
   * skip/unskip and undo/redo are all going to be defined as changes. 
   * undo/redo should be possible to be skipped and unskipped.
   * skip/unskip should be possible to be undone and redone.
  * Provide unit tests for at least 5 scenarios.

== Task result ==
 * review of current source code.
 * more source code.
 * unit tests

== Implementation idea ==
 * review current code.
 * add the new features.
 * write unit tests.
 '''Example scenarios - every number represents a change and its position in the list:'''
{{{
   skip:
   1. a = 5  | 5
   2. a = 6  | 6
   3. a = 7  | 7
   4. skip 2 | 7 because a new change has occurred after 2.

   skip/undo:
   1. b = 10   | 10
   2. b = 5    | 5
   3. skip 2   | 10 is the last change that is to be undone.
   4. undo     | 5 because the skip is undone.
   5. skip 4   | 10 because the last undo is skipped as a change.
  
   more complicated:
   1.  c = 5    | 5
   2.  c = 7    | 7
   3.  c = 10   | 10
   4.  c = 12   | 12
   5.  undo     | 10 this is the current value of c after the undo
   6.  skip 3   | 7 since 10 was last value after the undo which is the third change.
   7.  undo     | 10 again
   8.  skip 7   | 7 after skipping change 7 we should return to value 7.
   9.  redo     | 7 because this should not be possible since the corresponding undo is already missing so nothing changes.
   10. unskip 7 | 10 since the value after the undo should had been 7.
   11. skip 10  | 7 the previous value is returned.
   12. skip 11  | 10 the previous is unskip 10 so the value remains exactly 10.
   13. skip 12  | 7 again
   14. unskip 11| 10
   15. skip 1   | 10
   15. skip 2   | 10
   15. skip 3   | 10
   15. skip 4   | 10 at this point we cannot revert the initializing of c.  Now what ?!?

}}}

'''Notes:'''
 * skipping the previous change acts like a undo.
 * unskipping the previous change acts like a redo.
 * there may be more interesting facts that can be observed. Design should take care of these...

== Related ==

[wiki:PRO_CHANGE_PRIMITIVES_R0] [[BR]]
[wiki:PRO_CHANGE_TRANSACTION_SAFETY_R0] [[BR]]
[wiki:PRO_CHANGE_COMPOSING_R0] [[BR]]
[wiki:PRO_CHANGE_MANAGER_R0] [[BR]]
[wiki:PRO_CHANGE_COMMONS_R0] [[BR]]

== How to demo ==

= Design =

= Implementation =

= Testing =

= Comments =