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 Project Reload Event onAfterModelUnitLoad Additional Load Event onAfterAutoLoad Background Auto Load Event
The Project Open Event (onAfterOpen) and Project Reload Event (onAfterReload) occur before the background loading of model files is complete. Additionally, the Additional Load Event (onAfterModelUnitLoad) occurs when a model file with manual loading settings is loaded via screen operation. For details, please refer to Changes in V5.1.
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 Model Validation Event 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 within the navigator
Info Window
-
Area Name: informations
-
Event Name
Event Name Description onShow Info Window Page Display Event onHide Info Window Page Hide Event onSelectionChanged Info Window Page Display Element Selection Event onDoubleClick Info 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 corresponding event will be effective in the following 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 events are defined multiple times and an event handler is empty within a higher priority event definition, the event subscription will be canceled. (Example:
"onAfterNew": "") -
If multiple extensions subscribe to the same event, the order in which events fire between extensions cannot be controlled. 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 that event, the event will not fire in the remaining extensions.
Event Filters
- For models, you can narrow down the events you subscribe to by specifying the metamodel class name (or fully qualified class name) 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 information 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 that degrade response times.
Model Event Filters
- By specifying the metamodel class name of the target model in the class property, you can subscribe to events only for models of that specific class.
- You can also specify the fully qualified class name instead of 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 inherited class name. You must specify the model's class name.
Editor Event Filters
- By specifying the target view definition name in the
viewDefinitionproperty, you can subscribe to events only for a specific view definition. - If you want to target multiple view definitions, specify the view definition names separated by commas.
Navigator Event Filters
- By specifying the target navigator name in the
navigatorproperty, you can subscribe to events only for a specific navigator. - The following values can be specified as the target navigator name:
Model: Model NavigatorProductLine: Product Line NavigatorScm: Configuration Management NavigatorProject: Project NavigatorProfile: Profile Navigator
- Specifying the wildcard
*in the value, or omitting the property, allows event subscription for all navigators. - If you want to target multiple navigators, specify the navigator names separated by commas. .
Event Filtering for Information Window
- By specifying the target page name in the information property, you can subscribe to events only on 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, will allow you to subscribe to events on all pages. - If targeting 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"
}
],
"informations": [
{
"information": "*"
}
]
},
"commands": [
{
"id": "myExtension.createBlock",
"execFunc": "createBlock"
},
{
"id": "myExtension.updateBlock",
"execFunc": "updateBlock"
},
{
"id": "myExtension.generateCode",
"execFunc": "generateCode"
}
]
}
}
Please avoid writing empty events in event handlers.
If an event occurs with an empty event description, an error will be displayed in the output tab.
Example of Event Handler Implementation
- 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.