Undo and Redo

The Undo/Redo commands in Model RealTime help you to easily undo and redo changes you have made. It's important to understand how the Eclipse concept of Undo contexts work, in order to use the Undo/Redo commands efficiently in Model RealTime.

Eclipse supports multiple Undo contexts. Each Undo context maintains its own history of commands that have been performed in that particular context. At any point in time, only one specific Undo context can be active. When you perform the Undo command (Ctrl + Z) or the Redo command (Ctrl + Y) it's the command history of the currently active Undo context that will be used for deciding which command that will be undone or redone. Eclipse decides the active Undo context based on the active selection. This means that the result of perfoming Undo or Redo will depend on which part of the Eclipse user interface that has the currently active selection.

Note that not all parts of the Eclipse user interface provide an Undo context. For example, views such as the Search and Problems view do not allow edits of any kind, and hence do not provide an Undo context. Certain editors, for example the transformation configuration editor, also do not provide an Undo context. Therefore, if you experience that the Undo/Redo commands are not available at some point in time, it most likely is because the active selection is in a part of Eclipse which has no Undo context. Before you perform Undo or Redo it's important to ensure that the expected Undo context is active. Otherwise you may find yourself undoing changes which were done a long time ago in another Undo context.

Each Undo context has a specific limit for the size of its command history. This is because the need for how many commands that can be undone depends very much on the particular context. For example, modifications to the tree of projects and files in the workspace have a rather small command history size (25) since it's unusual that you need to undo a large number of commands of that kind. On the other hand, when working in a text editor, such as when editing a C++ file, you often need a much bigger command history since it's not uncommon to undo a large number of textual changes. For text editors the command history size is 200 by default. You can increase this limit using the preference General - Editors - Text Editors - Undo history size.

When working in Model RealTime it's common to seamlessly switch between different Undo contexts. For example, you may first create a transition in a state chart diagram. This command will be placed in the command history of the "Modeling" Undo context. Then you may select the transition and use the Code view for editing the effect code snippet for the transition. The textual modifications made there will be placed in the command history of the Code view's Undo context. Finally you may click on a state in the state chart diagram, which leads to that the Code view looses focus. Now all changes you made to the transition effect code snippet will be grouped into a single "Edit Transition Effect" command which will be placed in the command history of the "Modeling" Undo context. While you were still editing in the Code view you could undo individual textual modifications (up to 200 by default) but as soon as you leave the Code view all those changes are grouped into a single "model-level" change, which means that you no longer can undo the small individual modifications.

Note the following:

If you are uncertain of which Undo context that is currently active, it often helps to look in the Edit menu for the name of the Undo or Redo commands. They usually give a hint about which Undo context that is active, and which change that will be undone or redone.