The CDE animator allows the user to interactively create and delete component and contract instances, to call methods on those instances, to trace calls through message sequence diagrams, and to see in tabular format the state of all instances of a given class. These features allow one to quickly test several scenarios and configurations without actually coding a test application.
Like the CDE editor, the animator is divided into five areas: the menu bar, the toolbar, and three panes. The left pane shows an hierarchical view of the current animation project, the right pane contains tabbed windows for the diagrams and tables, and the bottom pane shows any messages issued to the user.
The animator project pane works like the one in the CDE editor, only the content differs. The pop-up menu for the project root node has the following commands:
.class files
without having to exit the animator. A confirmation dialog appears before
actually resetting the project.The project root node may have as children two types of nodes: component class nodes and contract class nodes.
The pop-up menu for this kind of nodes has three commands:
A component class node has one child node for each instance (i.e., object of that class) that exists in the animator. Each component instance node is labeled by the string returned by the toString() method. It has one child for each message sent to it from an execution window, beginning with the constructor message. In this way one can quickly see the history of operations performed by the user on any object. Note that any methods called by other methods of other instances do not show up in the project pane.
The pop-up menu for component instance nodes has three operations:
Contract class nodes have the same pop-up menu as component class nodes. The difference is in the methods that show in the pull-down menu of the method execution window. The contract class that was generated by the CDE editor for a contract named X has the following methods:
The constructor takes as arguments the actual contract participants. The parameters have the same names and are in the same order as the participants that appear in the contract definition.
At the end of the constructor, a parameterless method initialize
is called. By default, CDE generates an empty method that does nothing,
unless you provide your own method in the operations section of
the contract. This method is useful to initialize any contract
attributes.
The "destructor" removes the contract between the participants,
but, as in all Java programs, it doesn't actually remove the contract
object; the contract just becomes inactive. This method is always called Delete
and takes
no arguments. After this method executes, the contract no longer is active.
No other methods should be called on the contract object after this
one.
The method getName, without arguments, returns the name X
of the contract.
For each participant there is a getparticipant
method, without arguments, that returns the participant that in the contract
definition has name participant. The return type of this method
is the participant class declared in the contract definition.
For each attribute, there is getattribute method,
without arguments, that returns the attribute with the given name.
The return type of this method is the one declared in the
contract definition.
For each attribute, there is a setattribute method,
with a single parameter, that sets the attribute with the given name to the
value given as argument.
The type of the parameter is the type of the attribute declared in the
contract.
The method toString() is overridden to return a string of the
form "ContractName (participant1,
participant2, ...)",
where the contract's name is obtained by calling getName, and participanti
is obtained by calling toString on the respective participant
object.
Like for components, each contract class node has one child per instance, and each instance has one child node for each method called. The pop-up menu for contract instance nodes is the same as for component instance nodes.
The animation pane may have two kinds of tabbed windows: population windows to show in a tabular way all current instances of a given class and diagram windows with simplified message sequence diagrams to show the interactions between component and contract instances.
A class population window is a table with a line for each instance of that class. There is one column for each attribute. Each cell shows the value of the attribute in that column, for the instance in that line. The ordering of columns can be changed by dragging them. The width of columns can be changed by dragging the separator lines.
A diagram window shows a message sequence chart with all the interactions that occur between the instances added by the user to this diagram. If any of the instances interacts with an instance currently not in the diagram, then the needed instance is automatically added to the diagram. The same happens if the user calls a method on an instance not present in the diagram.
The animator does not implement the full possibilities of sequence diagrams, in particular nested calls.
There is one lifeline for each (component or contract) instance, labeled
at the top by the name of the class and the name of the instance, as returned by
toString(). Horizontal arrows denote messages sent and received.
The arrows are labeled with the message name; arguments are not shown. A diamond
at the end of an arrow's shaft indicates that the message was sent by the user
from an execution window.
The actual execution of methods is indicated by small brown boxes. A box indicates that the method was entered, not that it was completed. In other words, it doesn't show all the activation time of the method.
A delete message and method invocation immediately followed
by a cross on a lifeline indicates that the corresponding object was
deleted.
At the bottom of the pane there are 8 buttons. The two left-most buttons allow to change the order of the objects in the diagram. For that, first the object has to be selected by clicking on its label at the top. The box and lifeline become red. Now one can use the left and right arrow buttons to swap the selected object with the one on its left or right. The arrows across lifelines are automatically redrawn. To deselect the object, click anywhere on the diagram except object headings. The buttons labeled Up and Down scroll the diagram up or down one event (message or method) at a time, maintaining the labels at the top of diagram always visible. The Top button shows the diagram since its beginning, i.e., it is equivalent to presssing Up until it no longer has effect. The Clear button makes all events disappear from the diagram. The two right-most buttons shrink and grow the diagram.
The bottom pane shows any exceptions that arise during the execution of methods on components or contracts.
The only button in the toolbar is a shortcut to File->Close. The button is inactive (i.e., the icon is grayed out) whenever the corresponding command is. When the mouse cursor is left for a while over a button, a tool tip appears: a small text box describing the action associated to the button.