Event
Overview
-
You can receive Next Design internal processing events and add your own functionality.
-
By declaring Next Design internal processing events to subscribe to and associating event handlers with those events, you can execute your own processing in conjunction with internal processing.
List of Subscribeable Events
The list of subscribeable events is shown below.
For details, please refer to API > Overview > Events.
Application
-
Area Name: application
-
Event Name
| Event Name | Description |
|---|---|
| onAfterStart | Event after application startup |
| onBeforeQuit | Event before application shutdown |
Command
-
Area Name: commands
-
Event Name
| Event Name | Description |
|---|---|
| onBeforeExecute | Event before command execution |
| onAfterExecute | Event after command execution |
-
Subscribeable Commands
Project
-
Area Name: project
-
Event Name
| Event Name | Description |
|---|---|
| onAfterNew | Event after new project creation |
| onBeforeOpen | Event before project opening |
| onAfterOpen | Event after project opening |
| onBeforeSave | Event before project saving |
| onAfterSave | Event after project saving |
| onBeforeClose | Event before project closing |
| onAfterClose | Event after project closing |
| onBeforeReload | Event before project reload |
| onAfterReload | Event after project reload |
| onAfterModelUnitLoad | Event after additional load |
Model
-
Area Name: models
-
Event Name
| Event Name | Description |
|---|---|
| onBeforeNew | Event before model addition |
| onAfterNew | Event after model addition |
| onFieldChanged | Event after field value change |
| onBeforeDelete | Event before model deletion |
| onBeforeChangeOwner | Event before model parent change |
| onAfterChangeOwner | Event after model parent change |
| onBeforeChangeOrder | Event before model order change |
| onAfterChangeOrder | Event after model order change |
| onBeforeNewRelation | Event before relation addition |
| onAfterNewRelation | Event after relation addition |
| onValidate | Event during model validation |
| onError | Error Added Event |
| onSelectionChanged | Model Selection Event |
| onModelEdited | Model Editing Event |
| onUndoRedo | Undo/Redo Event |
Editor
-
Area Name: editors
-
Event Name
| Event Name | Description |
|---|---|
| onShow | Editor Display Event |
| onHide | Editor Hide Event |
| onSelectionChanged | Model Selection Event in Editor |
Page
-
Area Name: pages
-
Event Name
| Event Name | Description |
|---|---|
| onBeforeChange | Event before page change |
| onAfterChange | Event after page change |
Navigator
-
Area name: navigators
-
Event name
| Event name | Description |
|---|---|
| onShow | Navigator display event |
| onHide | Navigator hide event |
| onSelectionChanged | Model selection event in navigator |
Information window
-
Area name: informations
-
Event name
| Event name | Description |
|---|---|
| onShow | Information Window Page Display Event |
| onHide | Information Window Page Hide Event |
| onSelectionChanged | Information Window Page Display Element Selection Event |
| onDoubleClick | Information Window Page Display Element Double-Click Event |
Common Events
- Events that are not subscribed to do not need to be described in the manifest.
- If the same event is defined multiple times in the manifest, the following events will be effective in order of priority:
(1) Events where the event filter value specifies a class name or target name
(2) Events where the event filter value specifies the fully qualified name of a class (only applies to model event filters)
(3) Events where the event filter value specifies a wildcard: *, or where the event filter is omitted
Furthermore, if events are defined multiple times within the same priority, the first defined event will be effective.
- If you define an event multiple times and include an event with an empty event handler in a higher-priority event definition, the event subscription will be canceled. (Example:
"onAfterNew": "") - If multiple extensions subscribe to the same event, you cannot control the order in which events fire between extensions. The order in which events fire is determined by the order in which the manifests are read.
- If multiple extensions subscribe to the same event and one extension cancels the event, the remaining extensions will not fire the event.
Event Filters
- For models, you can narrow down the events you subscribe to by specifying the metamodel class name (or the fully qualified name of the class) as the event filter value.
- For editors, you can narrow down the events you subscribe to by specifying the view definition name as the event filter value.
- For info windows, you can narrow down the events you subscribe to by specifying the page name as the event filter value.
- By using this event filter mechanism to narrow down the events you subscribe to, you can avoid unnecessary event handler calls for unnecessary events, which can degrade response times.
Model Event Filtering
- By specifying the class name in the target model's metamodel in the
classproperty, you can subscribe to events only for models of that specific class. - You can also specify the fully qualified name of the class instead of just the class name.
- If targeting multiple classes, specify the class names separated by commas.
- Specifying the wildcard
*as the value, or omitting the property, allows event subscription common to all models. - You cannot specify the name of the inherited class. You must specify the model's class name.
Editor Event Filtering
- By specifying the target view definition name in the
viewDefinitionproperty, you can subscribe to events only for specific view definitions. - If targeting multiple view definitions, specify the view definition names separated by commas.
Navigator Event Filtering
-
By specifying the target navigator name in the
navigatorproperty, you can subscribe to events only for specific navigators. -
The following values can be specified as the target navigator name:
-
Model: Model Navigator -
ProductLine: Product Line Navigator -
Scm: Configuration Management Navigator -
Project: Project Navigator -
Profile: Profile Navigator -
Specifying a wildcard:
*in the value, or omitting the property, allows event subscription for all navigators. -
To target multiple navigators, specify the navigator names separated by commas.
Event Filtering in the Information Window
- Specifying the target page name in the information property allows event subscription only for specific pages.
- The following values can be specified as the target page name:
Error: Error PageSearchResult: Search Results PageOutput: Output Page- Specifying a wildcard:
*in the value, or omitting the property, allows event subscription for all pages. - To target multiple pages, specify the page names separated by commas. ## Example of Event Definition
{
"name": "Manifest Test",
"main": "main.cs", //For C# scripts. "main.py" for Python
"lifecycle": "project",
"extensionPoints":
{
"events":
{
"proejct" :
{
"onBeforeSave": "ProjectOnBeforeSave"
},
"models" :
[
{
"class": "*",
"onAfterNew": "AllModel_OnNew",
"onError": "AllModel_OnError"
},
{
"class": "UseCase",
"onAfterNew": "UseCase_OnNew",
"onFieldChanged": "UseCase_OnFieldChanged",
"onBeforeDelete": "UseCase_OnBeforeDelete",
"onValidate": "UseCase_OnValidate"
},
{
"class": "AnalysisFunctionType,SoftwareFunctionType",
"onAfterNew": "FunctionType_OnNew"
}
],
"commands":
[
{
"commandId": "myExtension.createBlock",
"onBeforeExecute": "CommandOnBeforeCreateBlock"
},
{
"commandId": "myExtension.updateBlock",
"onAfterExecute": "CommandOnAfterUpdateBlock"
}
],
"editors":
[
{
"viewDefinition": "*"
},
{
"viewDefinition": "logicalFunctionDiagaram"
},
{
"viewDefinition": "logicalFunctionDetailForm"
}
],
"navigators":
[
{
"navigator": "Model"
},
{
"navigator": "Profile"
}
],
"information" :
[ {
"information": "*"
}
]
},
"commands": [
{
"id": "myExtension.createBlock",
"execFunc": "createBlock"
},
{
"id": "myExtension.updateBlock",
"execFunc": "updateBlock"
},
{
"id": "myExtension.generateCode",
"execFunc": "generateCode"
}
]
}
}
Please do not write empty events in event handlers.
If an event occurs with an empty event description, an error will be displayed in the output tab.
Event handler implementation example
- C#
- Python
public void ProjectOnBeforeSave(IEventContext context, IEventParams eventParams)
{
var projectBeforeSaveEventParams = eventParams as ProjectBeforeSaveEventParams;
if ((projectBeforeSaveEventParams != null) && (projectBeforeSaveEventParams.Project.Name == "temporary"))
{
projectBeforeSaveEventParams.Cancel();
}
}
from nd.desktop import *
def project_on_before_save(context: IEventContext, eventParams: IEventParams):
if eventParams.Project.Name == "temporary":
eventParams.Cancel()
For details on event parameters depending on the event type, please refer to the interface for each event area in API > Overview > Events.