Event
Overview
- You can receive Next Design internal processing events and add your own functions.
- You can execute your own processing in conjunction with internal processing by declaring the Next Design internal processing events to subscribe to and associating event handlers with those events.
List of subscribeable events
The following is a list of subscribeable events.
For more information, see API > Overview > Events.
Application
- Area name: application
- Event name
Event name | Description |
---|---|
onAfterStart | Event after application start |
onBeforeQuit | Event before application quit |
Command
- Area name: commands
- Event name
Event name | Description |
---|---|
onBeforeExecute | Event before command execution |
onAfterExecute | Event after command execution |
-
Commands that can be subscribed to
Project
-
Area name: project
-
Event name
Event name | Description |
---|---|
onAfterNew | Event after creating a new project |
onBeforeOpen | Event before opening a project |
onAfterOpen | Event after opening a project |
onBeforeSave | Event before saving a project |
onAfterSave | Event after saving a project |
onBeforeClose | Event before closing a project |
onAfterClose | Event after closing a project |
onBeforeReload | Event before reloading a project |
onAfterReload | Event after project reload |
onAfterModelUnitLoad | Event after additional load |
Model
-
Area name: models
-
Event name
Event name | Description |
---|---|
onBeforeNew | Event before adding model |
onAfterNew | Event after adding model |
onFieldChanged | Event after changing field value |
onBeforeDelete | Event before deleting model |
onBeforeChangeOwner | Event before changing model parent |
onAfterChangeOwner | Event after changing model parent |
onBeforeChangeOrder | Event before changing model order |
onAfterChangeOrder | Event after changing model order |
onBeforeNewRelation | Event before adding relation |
onAfterNewRelation | Event after adding relation |
onValidate | Event when validating model |
onError | Event when adding error |
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 | Page before change event |
onAfterChange | Page after change event |
Navigator
-
Area name: navigators
-
Event name
Event name | Description |
---|---|
onShow | Navigator display event |
onHide | Navigator hide event |
onSelectionChanged | Navigator model selection event |
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 you do not subscribe 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 enabled in the following order of priority.
(1) Events that specify a class name or target name as the event filter value.
(2) Events that specify a fully qualified class name as the event filter value (applies only to model event filters).
(3) Events that specify a wildcard: *
as the event filter value or omit the event filter.
Furthermore, if events are defined multiple times within the same priority, the first event defined will be valid.
- If an event is defined multiple times and an event with an empty event handler is written in an event definition with a higher priority, the event subscription will be canceled. (Example:
"onAfterNew": ""
) - If multiple extensions subscribe to the same event, the event firing order between extensions cannot be controlled. The event firing order is the order in which the manifest is loaded.
- If multiple extensions subscribe to the same event and the event is canceled in one of the extensions, the event will not fire in the remaining extensions.
Event Filters
- For models, you can narrow down the events to be subscribed to by specifying the class name (or the fully qualified name of the class) of the metamodel as the value of the event filter.
- For editors, you can narrow down the events to be subscribed to by specifying the view definition name as the value of the event filter.
- For info windows, you can narrow down the events to be subscribed to by specifying the page name as the value of the event filter.
- By using this event filter mechanism to narrow down the events to be subscribed to, you can avoid the slowdown in response caused by unnecessary event handlers being called for unnecessary events.
Event Filters for Models
- Events can be subscribed to only for models of a specific class by specifying the class name in the metamodel of the target model in the class property.
- You can also specify the fully qualified name of the class instead of the class name.
- If multiple classes are to be targeted, specify the class names separated by commas.
- You can also subscribe to events common to all models by specifying the wildcard:
*
as the value or omitting the property. - You cannot specify the inherited class name. You must specify the class name of the model.
Editor event filter
- By specifying the target view definition name in the viewDefinition property, you can subscribe to events only in a specific view definition.
- If you want to target multiple view definitions, specify the view definition names separated by commas.
Navigator event filter
- By specifying the target navigator name in the navigator property, you can subscribe to events only in a specific navigator.
- You can specify the following values as the target navigator name.
Model
: Model navigatorProductLine
: Product line navigatorScm
: Configuration management navigatorProject
: Project navigatorProfile
: Profile navigator- If you specify the wildcard
*
as the value or omit the property, you can subscribe to events in all navigators. - If you want to target multiple navigators, specify the navigator names separated by commas.
Information window event filter
-
By specifying the target page name in the information property, you can subscribe to events only on specific pages.
-
You can specify the following values as the target page name.
-
Error
: Error page -
SearchResult
: Search result page -
Output
: Output page -
If you specify the wildcard
*
as the value or omit the property, you can subscribe to events on all pages. -
If you want to target multiple pages, specify the page names separated by commas.
Example of event definition
{
"name": "Manifest Test",
"main": "main.cs",
"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"
}
]
}
}
Do not write an empty event in the event handler.
If an event occurs with an empty event, an error will be displayed in the output tab.
Example of an event handler implementation
public void ProjectOnBeforeSave(IEventContext context, IEventParams eventParams)
{
var projectBeforeSaveEventParams = eventParams as ProjectBeforeSaveEventParams;
if (( projectBeforeSaveEventParams != null) && (projectBeforeSaveEventParams.Project.Name == "temporary" ))
{
projectBeforeSaveEventParams.Cancel();
}
}
For details on event parameters according to the event type, see the interface for each event area in API > Overview > Events.