
h2(#InteractiveOCL). Console

There are two interactive OCL consoles that enable OCL expressions to be evaluated on a model.

The classic *Interactive Console* may be created by invoking *OCL->Show OCL Console* from the right button menu of some model editors such as the *Sample Ecore Model Editor*. Alternatively the *Console* view may be created by *Window->Show View->Console* followed by selecting *Interactive OCL* from the *Open Console* pull-down in the *Console* View tool bar. See the "OCLinEcore Tutorial":#OCLinEcoreTutorial-Console for detailed step-by-step pictures.

The Pivot *Interactive Xtext Console* may be similarly created by *OCL->Show Xtext OCL Console* from the menu or *Interactive Xtext OCL* from the pull-down.

The two consoles should exhibit similar behaviors, however not all facilities of the classic console have yet been reproduced on the new.

!{width:70%}images/1520-console.png(Console)!

The Console, shown in the bottom half of the figure, comprises a combined Title and Tool Bar, Results Panel and Entry Panel.

h3. Context Object Selection

Expressions are evaluated with respect to a context object @self@ that has a corresponding metamodel type. This object is defined by selecting any widget whose implementation is adaptable to an EObject. Therefore selecting an EAttribute in the Sample Ecore Editor will make the selected EAttribute @self@ and EAttribute the metamodel type. In the figure selecting the Member named m1 in the Sample Reflective Ecore Model Editor has made Member the select type of @self@ and m1 the selected context object. For the Pivot Console there is additional support to use selections from the Outline of an Xtext editor or Variables View of the OCL Debugger as the context object.

The Pivot Console displays the selected object and type in the Console title.

The classic Console relies on the platform selection mechanism to show the selected object in the overall Eclipse Status display at the bottom left of the workspace window. This display may be lost when the selection is changed to a non-EObject selection.

h3. Editing

The bottom panel supports entry and evaluation of a multi-line expression. The expression is evaluated when *Enter* is entered.

The classic Console has hand-coded syntax highlighting and context assist that may be activated by typing *Ctrl* + *Space*.

The Pivot Console uses the Xtext EssentialOCL editor and largely auto-generated syntax highlighting, error indications, hover text, quick fixes and context assist that may be activated by typing *Ctrl* + *Space*.

The content assist for the Pivot Console has not yet been customized, so the classic Console content assist is probably more comprehensive, however the Pivot Console shares the same library definitions as the other editors and so is more consistent.

h3. Editor Keys

The *Page-Up* and *Page-Down* keys may be used to scroll through the history of input commands enabling previous commands to be re-used. Use of the Page keys is necessary since the input is potentially multi-line and so *Up* and *Down* navigate over the multiple lines.

h3. Results

The larger middle panel displays the results of each evaluation in a scrolling window.

h3. Tool Bar

h4. Ecore/UML binding

The classic Console provides a selection to determine whether the context object has a type defined by an Ecore or UML metamodel. This selection is not required for the Pivot Console which automatically converts Ecore or UML models to Pivot models.

h4. M1/M2

The classic Console provides a selection to determine whether the selected metamodel binding is that for objects (M2) or types (M1). This selection is not needed for the Pivot Console since the Pivot metamodel is an instance of itself.

h4. Clear Console

The standard clear console functionality clears the results pane.

h4. Close Console

The standard close console functionality closes the current console.

h4. Debug

Starts the "OCL Debugger":#Debugger using the current mouse selection as self and the text in the Console input as the exopression to execute.

h4. Load/Save an expression

The classic Console provides an ability to save and reload edited expressions as XMI files. The XMI is a pragmatic Eclipse Ecore realisation of the OCL specification for which XMI interchange is not realisable.

The Pivot Console provides a similar ability to save and reload edited expressions as XMI files. The XMI is a prototype that might evolve and be adopted by a future version of the OCL specification. __This functionality has not been properly tested.__

 