No edit summary |
No edit summary |
||
(11 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
Actions can | Actions can do a couple of things. | ||
=== ExecuteExpression === | === ExecuteExpression === | ||
[[File:Can do action -2.png|frameless|466x466px]] | [[File:Can do action -2.png|frameless|466x466px]] | ||
The | The ExecuteExpression is an Extended-Action-Language expression that is rooted in some context. | ||
For '''GlobalActions''' this context is null | 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: | ||
[[File:Can do action -1.png|frameless|330x330px]] | [[File:Can do action -1.png|frameless|330x330px]] | ||
If the Action is a '''ContextAction''', you get access to the variables that the context | If the Action is a '''ContextAction''', you get access to the variables that the context defines. These are named: <code>vCurrent_TheViewModelClassName</code>. 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 | When you have an object context like this, you can call methods that the objects class defines: | ||
[[File:Can do action -5.png|frameless|398x398px]] | [[File:Can do action -5.png|frameless|398x398px]] | ||
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. | 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 === | === EnableExpression === | ||
The EnableExpression is very similar to the ExecuteExpression, except it is not an EAL expression, | 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. | ||
[[File:Can do action -3.png|frameless|360x360px]] | [[File:Can do action -3.png|frameless|360x360px]] | ||
Except | Except for these differences, the expression operates in the same context and can reach the same variables, etc., as described for the ExecuteExpression. | ||
[[File:Can do action -6.png|frameless|376x376px]] | [[File:Can do action -6.png|frameless|376x376px]] | ||
The EnableExpression is used to control | The EnableExpression is used to control whether an action should be executable or not. | ||
Consider that you have a state machine on | 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 === | === BringUpViewModel & ViewModelRootObjectExpression === | ||
An action can bring up a ViewModel defined UI, and when it does it will assign the Root object of the | 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 === | === ViewModelIsModal & ExpressionAfterModalOk === | ||
[[File:Can do action -7.png|frameless|368x368px]] | [[File:Can do action -7.png|frameless|368x368px]] | ||
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 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 window is closed. | 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 | 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_” | The variables taken from the window that is closing are prefixed with “vModalResult_” to avoid name collisions with the calling context. | ||
[[File:Can do action -8.png|frameless|388x388px]] | [[File:Can do action -8.png|frameless|388x388px]] | ||
Line 51: | Line 51: | ||
This will enable you to create a Seek/Pick/Assign pattern in a WECPOF application. | This will enable you to create a Seek/Pick/Assign pattern in a WECPOF application. | ||
Consider that you have a Car-rental-model, you | 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''. | You also define the ExpressionAfterModalOk to be ''vCurrent_RentalContract.AssignedCar:=vModalResult_Current_PickedCar''. | ||
=== Framework Action === | === Framework Action === | ||
If you pick a framework action none of the other expressions will apply. | If you pick a framework action, none of the other expressions will apply. | ||
[[File:Can do action -9.png|frameless|418x418px]] | [[File:Can do action -9.png|frameless|418x418px]] | ||
The Framework action is added to allow access to functions that operate on a different level | 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 - See also: [[Training:Global actions|Global actions]] | |||
[[Category:Actions]] | [[Category:Actions]] | ||
[[Category:MDriven Designer]] | [[Category:MDriven Designer]] | ||
{{Edited|July|12|2024}} |
Latest revision as of 06:05, 13 February 2024
Actions can do a couple of things.
ExecuteExpression
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:
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:
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.
Except for these differences, the expression operates in the same context and can reach the same variables, etc., as described for the ExecuteExpression.
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
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.
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.
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 - See also: Global actions