h1. YAKINDU Statechart Tools – Testcase 12 - Refactoring |_. Nr |_. Testname |_. Test Instructions |_. Postconditions |_. Status| | 12.1 | Group states into composite |
Select all states.
Right-click on one of the states, then select _Refactor → Group States Into Composite_.
Rename the new composite state to *LightSwitch*.
Save the statechart.
Run the simulation.
Right-click on the edge or on the title area of the *LightSwitch* composite state.
In the context menu, select _Refactor → Extract Subdiagram_.
Hover over the subdiagram decorator in the lower-right corner of the *LightSwitch* state.
Click on the subdiagram decorator.
Subdiagram extraction leads to a normal-looking *LightSwitch* state, but with a subdiagram decorator in the lower left of state's box.
Hovering over that decorator shows a preview image of the subdiagram.
Clicking the decorator opens the subdiagram in a new editor tab.
| %{color:red}open% | | 12.2.1 | Undo & redo extracting subdiagram |Undo extraction by [Ctrl+Z]
.
Redo extraction by [Ctrl+Y]
.
[Ctrl+Z]
and properly applied again by [Ctrl+Y]
.| %{color:red}open% |
| 12.2.2 | Copy state with subdiagram | Select the subdiagram-containing composite state *LightSwitch*.
Copy it to the clipboard using [Ctrl+C]
resp. [Cmd+C]
(Mac).
Select the main region.
Paste the copied state using [Ctrl+V]
resp. [Cmd+V]
(Mac).
Hover over the subdiagram decorator in the lower-right corner of the *Copy_1_LightSwitch* state.
Click on the subdiagram decorator.
The copied state's name is *Copy_1_LightSwitch*.
Hovering over the decorator of the copied state shows a preview image of the subdiagram.
Clicking on the decorator of the copied state opens the subdiagram in a new editor tab.
| %{color:red}open% | | 12.2.3 | Delete copy |Delete the previously created state *Copy_1_LightSwitch*.
Save the statechart.
Run the simulation.
Right-click on the edge or on the title area of the *LightSwitch* composite state.
In the context menu, select _Refactor → Inline Subdiagram_.
Save the statechart.
Run the simulation.
Delete the transition from *LightOn* to *LightOff*.
Delete the local reactions of both states *LightOn* and *LightOff*.
Create a second transition from *LightOff* to *LightOn*.
Enter "@A.keypress / light = true@" as reaction for _both_ transitions from *LightOff* to *LightOn*.
Right-click on the edge or on the title area of the *LightOn* state.
Select _Refactoring → Fold Incoming Actions_.
The reactions of both transitions from *LightOff* to *LightOn* are "@A.keypress@".
State *LightOn* has a local reaction of "@entry / light = true@".
Right-click on the edge or on the title area of the *LightOn* state.
Select _Refactoring → Unfold Entry Actions_.
The reactions of both transitions from *LightOff* to *LightOn* are "@A.keypress / light = true@".
State *LightOn* has no local reaction.
Right-click on the edge or on the title area of the *LightOff* state.
Select _Refactoring → Fold Outgoing Actions_.
The reactions of both transitions from *LightOff* to *LightOn* are "@A.keypress@".
State *LightOff* has a local reaction of "@exit / light = true@".
Right-click on the edge or on the title area of the *LightOff* state.
Select _Refactoring → Unfold Exit Actions_.
The reactions of both transitions from *LightOff* to *LightOn* are "@A.keypress / light = true@".
State *LightOff* has no local reaction.
Double-click into the statechart's definition section.
Right-click on the name of the _light_ variable declaration.
In the context menu, select _Refactoring → Rename…_
In the dialog box, enter "@lamp@" as the variable's new name.
Click on _OK_.
In one of the two transactions from *LightOff* to *LightOn*, change the reaction to "@A.keypress / lamp = false@". The reaction of the other transition remains at "@A.keypress / lamp = true@".
Right-click on the edge or on the title area of the *LightOn* state.
Right-click on the edge or on the title area of the *LightOff* state.
Create a new statechart model.
Delete the *StateA* state that has been created.
Add an orthogonal state (see the palette on the right).
Ignore any errors.
Right-click on the orthogonal state.
In the context menu, select _Toggle Subregion Alignment_.
Repeat the last action.
An orthogonal state without a name is created.
The state's subregions _r1_ and _r2_ are horizontally arranged, i.e. _r1_ is left from _r2_.
After toggling the subregion alignment for the first time, the subregions are vertically arranged, i.e. _r1_ is above _r2_.
After toggling the subregion alignment for the second time, the subregions are horizontally arranged again, i.e. _r1_ is left from _r2_.