Navigation:  Application Architecture > Structure of a ClearCanvas Application >

Actions and Action Models

Previous pageReturn to chapter overviewNext page

Recall that an IDesktopWindow exposes two properties named MenuModel and ToolbarModel.  Each of these is an instance of an action model.  An action model is a logical model of the structure of a set of menus or toolbars.

In order to understand action models, one must first consider the IAction interface.

An IAction represents a single atomic action that can be taken by a user. IClickAction, more specifically, represents an action that is invoked upon the act of a single-click.  Both menu items and toolbar buttons fall into this category. ButtonAction and MenuAction provide concrete implementations of IClickAction.

In a user-interface, menu items and toolbar buttons tend to be organized into hierarchical structures. Menus contain sub-menus, which may contain other sub-menus.  Toolbar buttons are grouped into distinct toolbars.  The hierarchical structures of menus and toolbars can be modelled as a tree.

Modeling a menu in this manner is most obvious: each node in the tree represents a menu item.  If that node has children, then those children represent sub menu-items.  Toolbars can be modelled in a similar way.  For example, the first level of the tree might specify which toolbar a button is placed on, and the second level might specify the button itself.

An action model is just a tree of ActionModelNode objects, the leaf nodes of which hold references to IAction objects, as illustrated in the following diagram.

To understand why only the leaf nodes hold references to IAction objects, consider that, in both menus and toolbars, only the terminal menu items and terminal toolbar items (the buttons themselves) cause the application to take actions.