What an Action can do

Actions can do a couple of things.

ExecuteExpression

Can do action -2.png

The ExecuteExpression is an Extended-Action-Language expression that is rooted in some context.

For GlobalActions, this context is null. What you can do is limited to expressions that stem from a class of your model, like X.allinstances or X.Create. The EAL Editor is displayed by the button next to the expression:

Can do action -1.png

If the Action is a ContextAction, you get access to the variables that the context defines. These are named: vCurrent_TheViewModelClassName. You can either act on classes as with GlobalActions or act on the current value of variables from the context. The variables follow the selections the users make in ViewModel grids, so you can act on things the user has selected.

When you have an object context like this, you can call methods that the objects class defines:

Can do action -5.png

You can use all the attributes and navigate all the associations in as many steps as you need to get the desired effect.

If the action is a ClassAction, the action is rooted in an object of that class, and you use the OCL identifier “self” to operate on this.

EnableExpression

The EnableExpression is very similar to the ExecuteExpression, except it is not an EAL expression but rather, an OCL Expression. As such, it cannot have side effects (it cannot change anything in your domain of objects). The EnableExpression must also evaluate to a Boolean value of true or false.

Can do action -3.png

Except for these differences, the expression operates in the same context and can reach the same variables, etc., as described for the ExecuteExpression.

Can do action -6.png

The EnableExpression is used to control whether an action should be executable or not.

Consider that you have a state machine on class X and you only want the Delete action enabled when X is in the state Deletable: self.oclIsInState(#Deletable)

BringUpViewModel & ViewModelRootObjectExpression

An action can bring up a ViewModel-defined UI, and when it does, it will assign the Root object of the ViewModel, the result of the ViewModelRootObjectExpression. If the ViewModel RootObject Expression is empty, the Root object of the brought-up ViewModel-defined UI will be unassigned – and this might be perfectly fine for certain types of UIs, like UIs designed to seek persistent storage, for example.

ViewModelIsModal & ExpressionAfterModalOk

Can do action -7.png

If the action is set to bring up a ViewModel-powered UI, you may also choose to bring that UI up as a Modal window (a dialog you need to Ok or Cancel to get away from). The WECPOF runtime will add an OK and Cancel button to the bottom of your window if this is set.

If the user clicks Cancel in such a window, nothing else happens besides the fact that the window is closed. However, if the user clicks Ok, the WECPOF runtime will execute the ExpressionAfterModalOk if you have defined it.

The ExpressionAfterModalOk is an EAL expression that works on the context exactly as the ExecuteExpression does, but the ExpressionAfterModalOk also brings the variables from the ViewModel UI that were modal and are now closing. This fact enables you to read the values of the window about to close and to apply these values to your current context.

The variables taken from the window that is closing are prefixed with “vModalResult_” to avoid name collisions with the calling context.

Can do action -8.png

This will enable you to create a Seek/Pick/Assign pattern in a WECPOF application.

Consider that you have a Car-rental-model, you have a ViewModel that shows the rental contract and you now need to assign a Car to the Contract. The choice to use a ComboBox to scroll and find a car is no good because the number of possible Cars is 500+. Instead, add a ContextAction to the Rental contract ViewModel that brings up the Free-Car-Seeker-ViewModel, and you tick the ViewModelIsModal checkbox.

You also define the ExpressionAfterModalOk to be vCurrent_RentalContract.AssignedCar:=vModalResult_Current_PickedCar.

Framework Action

If you pick a framework action, none of the other expressions will apply.

Can do action -9.png

The Framework action is added to allow access to functions that operate on a different level than your model.

  • Save – saves the changed (created, deleted, updated) objects using the persistence mapper you have used in your EcoSpace (Or in Gaffr).
  • Refresh – calls refresh on your Persistence mapper if it supports Refresh (set up sync server to allow)
  • Undo/Redo – calls undo or redo on your ecospace. The current  WECPOF runtime uses a timer to create new undo-blocks every other second if there are new changes.
  • Exit – quits the WECPOF application

The MDriven Book - Next Chapter: Global actions

This page was edited 62 days ago on 10/02/2024. What links here