Reload Plugin without Restarting Application
Open API allows you to extend the functionalities of Visual Paradigm’s products by writing simple Java classes. But during development you often need to reload your plugin by restart the application. Starting from version 10 (build 20120720ab) you can reload the plugin on the fly, without restarting the application. This article will teach you how to do this.
Update Plugin Classes
Once you have modified your plugin and compiled it into Java classes, you can simply copy the compiled classes to the plugin deployment folder, which is the plugins folder under VP installation directory.
Reload the Plugin
To reload the plugin classes you will need to create a special plugin action specific for this. You can add this action to the menu bar, or to the application tool bar for easy to access. What this action doing is very simple, just to call the method
ApplicationManager.instance().reloadPluginClasses(%plugin_ID%);
By calling this method the plugin classes with your specified ID will be reloaded.
Sample Plugins
This sample plugin demonstrate how you can reload the plugin classes in runtime. The plugin divided into 2 parts. It will create one action menu in Class Diagram for drawing a custom shape, and one action menu under View menu for reloading the plugin classes.
The ReloadClassesShapeController class will able to draw 2 shapes in class diagram. Which will be drawn is controlled by a compile time variable. By default it will draw an ugly face.
You have to modify the variable in source code and compile it to make it draw a smiley face.
After you modified the source code and compiled it, you can then copy the classes to the plugin deployment folder.
Once the classes are being copied, press the Reload Plugin Classes.
After that draw the custom shape again and it will become smiley face. Note that since the class had been changed, so the original ugly face shape will also being repaint follow to the new implementation, and become smiley face.
Leave a Reply
Want to join the discussion?Feel free to contribute!