How to Insert Model Reference to Documentation Using API
Visual Paradigm supports inserting different linkage into documentation section of a model element, including reference to another model element in your project. You can do this inside the application user interface in few clicks. But how to do this by using Open API?
Inserting reference
Actually this includes 2 steps, first, you have to obtain the address of the model element within the project, and secondly you need to put the address into the documentation section of a model. Starting from VP Suite5.2 (build 20110515q), we support retrieve the address of a model element using the method
String address = IModelElement. getAddress();
All IModelElement will provide this operation. This operation will return the address of the model element as a string.
Once you got the address, you can then insert it into the documentation of the model element by calling IModelElement. setDocumentation(String doc). But note that you need to quote the address with special character “\0”, otherwise we have no way to identify it is an address, or just string content.
lModelElement.setDocumentation("Reference to \0"+_address+"\0");
Once you quote the address and insert in into the documentation, you will have the reference in your documentation.
Sample plugins
This sample plugin demonstrate how to insert model element reference to documentation of a model element. Once you have deployed the plugin into VP Application, You can right click on a shape and select Add Reference to Use Case from the popup menu. This will create a use case model, and then insert a reference to the documentation of the model you right click on.
You can download the sample plugin at here.
API requirement
This method supported since VP Suite 5.2 build 20110515q. The API documentation can be found at here.
Leave a Reply
Want to join the discussion?Feel free to contribute!