Persistate

Operation and Operation Group Definition

Hide Navigation Pane

Operation and Operation Group Definition

Previous topic Next topic No directory for this topic  

Operation and Operation Group Definition

Previous topic Next topic Topic directory requires JavaScript JavaScript is required for the print function Mail us feedback on this topic!  

In the Object Class Definition we saw that the syntax of an object class member was defined thus .

Member = ( Property | OperationGroup ) ;

Properties were described along with object classes in that section.  This section describes operation groups and the operations within them.

Future Enhancement

The way that operation groups and operations work in the current version of Persistate is simple but provisional.  A likely future scenario is that operations will have formal parameters, and operation groups will be defined outside of classes.  Operation groups, like object classes, will have their own layouts with placements for each operation within them.  However this is not finalised.

Operations are an important facet of the way in which Persistate separates the user interface from the controller.  The controller module talks to the user interface though the UserInterface abstract class, and the user interface talks to the controller by requesting operation executions.  This means that operations are the quantum of processing in the controller.  As such, all object mutations which happen during an operation execution are by default written to persistent storage at the end of the execution under control of a transaction.

Operation definition for now is limited to giving them a name, a visibility which determines where they will appear in a user interface, and optionally one or two qualifiers.  Operation groups are simply collections of operations, and become the menus holding the operations in the user interface.  Operation groups can also contain other operation groups, and this shows up as nested menus in the user interface.  Finally, as operation groups are object class members, they are used to determine whether and how their operations will appear in the layouts of their parent class.

The following example shows the definition of the View operation group from the Persistate package.

operation group view containing {
   the user interface operation back with menu and toolbar visibility,
   the user interface operation forward with menu and toolbar visibility,
   the operation parent with menu and toolbar visibility,
   the operation save workspace with menu visibility,
   the operation restore workspace with menu visibility,
   the user interface operation apply style with menu visibility,
   the user interface operation select container with menu visibility,
   the user interface operation add tab with menu visibility,
   operation group add pane containing {
      the user interface operation to left with menu visibility,
      the user interface operation to right with menu visibility,
      the user interface operation above with menu visibility,
      the user interface operation below with menu visibility
   }
}

Syntax

OperationGroup = "operation" "group" OperationGroupName "containing" "{" OperationsOrGroups "}" ;
OperationGroupName = <symbol> { <symbol> } ;
OperationsOrGroups = ( Operation | OperationGroup ) { "," ( Operation | OperationGroup ) } ;
Operation = "the" OperationQualifiers "operation" OperationName 
            [ "with" OpVisibilities "visibility" ] [ "selected" "by" OperationShortcut ] ;
OperationQualifiers = { ( "collective" | "user" "interface" ) } ;
OperationName = <symbol> { <symbol> } ;
OpVisibilities = OpVisibility [ { "," OpVisibility } "and" OpVisibility ] ;
OpVisibility = ( "menu" | "context" | "toolbar" | "grid" | "form" ) ;
OperationShortcut = { ( "control" | "shift" | "alt" ) } <symbol> ;

See Grammar Notation in Syntax Sections for an explanation of the format and symbols used here

Description

OperationGroup

This defines an operation group.  There are no optional clauses - everything must be included.

OperationGroupName

The name of the operation group is one or more symbols.  If the operation group is in an object class, the name must be unique within the set of members of the class, including properties.  If it is in another operation group, the name must be unique within the set of operations and operation groups within it.

OperationsOrGroups

As well as containing operations, operation groups can contain other nested operation groups.  This nesting can go to arbitrary depth.  At least one operation or operation group must be defined.  There is no requirement on order, but the order you specify items in will be reflected in their portrayal in a user interface.

Operation

This defines an operation.  You must specify a name for the operation, but all other clauses are optional.

OperationQualifiers

There are two qualifiers you can add to an operation, as described in the following table.

collective

Include this qualifier if the operation can only execute in the context of a collection - in other words when both a target object and a target collection are available.

user interface

By default, operations execute in the controller module.  Include this qualifier to indicate that the operation should execute in the user interface module instead.  This is intended for operations that operate solely on the user interface itself.  These operations are not allowed to modify any objects, or show any objects that have not previously been shown.

OperationName

The name you give to an operation can be one or more symbols.  The name must be unique within the set of operations and operation groups within its parent operation group.

OpVisibilities

If you want an operation to be visible in a user interface, you must include one or more OpVisibility terms here.  Separate the terms with commas, except for the last pair which must be separated with and.

OpVisibility

There are five possible places that operations can appear in a user interface, as described in the following table.

menu

Include this visibility to have your operation appear in a the menu system at the top of a window.  It will appear as an item in a menu with the name of its parent operation group.  This can happen in one of two ways.  The first will be in the .Net 'toolstrip' class generated from a control type layout of the object class containing the operation.  This assumes you select the Menu format for the group in the layout.

The other way happens only if you also set the context visibility.  In this case it will appear in a context sensitive menu with the name of its parent operation group on the menu bar of the current window, whenever on object of the group's parent object class is selected in the user interface.

context

Include this visibility to have your operation appear in right click context menus of forms or grids, when the object right clicked is of the object class containing the operation.  This visibility is also required along with the menu visibility to enable context sensitive menus on the main window menu bar.

toolbar

This visibility allows the operation to appear in a toolbar in the .Net 'toolstrip' class generated from a control type layout of the object class containing the operation.  This assumes you select the Toolbar buttons format for the group in the layout.

grid

This visibility allows the operation to appear as a column in a grid showing objects of the operations containing object class, where you can click the cell to execute the operation for the object showing in that row.

form

Future Enhancement

This feature has not yet been implemented.  It will allow operations to be shown in forms, for example as buttons or clickable images.

OperationShortcut

Including this clause allows the user to execute the operation using a keyboard shortcut.  This works only if the operation is visible and enabled in a menu.  The symbol should be one of the value names from the System.Windows.Forms.Keys enumeration.  Examples are shift alt B and ctrl F12.