1 To avoid typical errors while defining ontology contributions to model browser follow the following check list:
3 ## Step 1: Ontology Plug-in
5 Define an ontology plugin (`org.mylib.ontology`).
7 Define dependencies from Simantics plugins in MANIFEST.MF/Dependencies/Required Plug-ins:
11 org.simantics.modeling.ontology
12 org.simantics.viewpoint.ontology
13 org.simantics.action.ontology
16 Include the following definitions into your ontology file (*.pgraph):
19 L0 = <http://www.simantics.org/Layer0-1.1>
20 VP = <http://www.simantics.org/Viewpoint-1.2>
21 ACT = <http://www.simantics.org/Action-1.1>
22 MOD = <http://www.simantics.org/Modeling-1.2>
25 Define a new library (www.mylib.org) for your ontology under Simantics database root (*http://*):
28 MY_LIB = <http://www.mylib.org> : L0.Library
32 Define your ontology under the library and specify its ResourceClass:
35 MY_ONTOLOGY = <http://www.mylib.org/MyOntology-1.0> : L0.Ontology
37 L0.HasResourceClass "org.mylib.MyOntologyResource" : L0.String
40 Check the Name property of ontology plugin in MANIFEST.MF/Overview/General Information. It has to match with URI (without version number) of your ontology.
43 Name: http://www.mylib.org/MyOntology
46 Export the package (org.mylib) of ResourceClass in MANIFEST.MF/Runtime/Exported Packages.
48 Define a new context and include it into MOD.ModelingActionContext
51 MY_AC = MY_ONTOLOGY.MyActionContext : VP.BrowseContext
52 VP.BrowseContext.IsIncludedIn MOD.ModelingActionContext
55 Define a new ActionContribution for each action in this context
59 VP.BrowseContext.HasActionContribution _ : VP.ActionContribution
60 L0.HasLabel "My action..."
61 VP.ActionContribution.HasAction MY_ONTOLOGY.MyAction : ACT.Action
62 VP.ActionContribution.HasNodeType
66 ## Step 2: Implementation Plug-in
68 Define a plugin for implementation (org.mylib). Options: Generate an activator=checked, This plug-in will make contributions to the UI=checked.
70 Define dependencies from Simantics plugins in *MANIFEST.MF/Dependencies/Required Plug-ins*
73 org.simantics.db.layer0
76 Define a new package `src/org.mylib.actions`.
78 Define a new Java class `MyAction.java` under `org.mylib.actions` package
81 package org.mylib.actions;
82 import org.simantics.db.layer0.adapter.ActionFactory;
83 import org.simantics.db.Resource;
85 public class MyAction implements ActionFactory {
87 public Runnable create(Object target) {
88 if (!(target instanceof Resource))
90 final Resource res = (Resource) target;
91 return new Runnable() {
94 // TODO: put your code here
101 Create a new file (`adapters.xml`, [see spec](../Database/ResourceAdaptation.md)) under implementation plugin to map URI (*unversioned*) of your action to Java class implementation. The content of the file is as follows:
104 <?xml version="1.0" encoding="UTF-8"?>
106 <target interface="org.simantics.db.layer0.adapter.ActionFactory">
108 uri="http://www.mylib.org/MyOntology-0.0/MyAction"
109 class="org.mylib.actions.MyAction" />
114 You can check correctness of URI by Graph Debugger to search a resource:
117 http://www.mylib.org/MyOntology-1.0/MyAction
120 Note! Use *versioned URI* (0.0 -> 1.0) while searching with Graph Debugger.
122 Include `adapters.xml` into build configuration in *MANIFEST.MF/Build/Binary Build*. Also, include SCL packages and SCL modules if your use them in your implementation.
124 Export the implementation package (`org.mylib.actions`) of MyAction.java in *MANIFEST.MF/Runtime/Exported Packages*.
128 Include the ontology and the implementation plug-ins into your product configuration (Debug Configurations/Plug-ins) and validate Plug-ins dependencies before running the product.