MPS
 
Get MPS

Dive into plugins: the PlantMPS plugin

Last modified: 11 February 2024

and

To use the plugin your concepts should only implement this interface, the rest is handled by the plugin and include:

  • history to handle next and previous diagram visualization.

  • save the generated SVG image.

  • copy the PlantUML source to the clipboard.

  • zoom

  • go-to-node feature when the user click the SVG image.

PlantMPS also differs from the original mbeddr plugin in:

  • mbeddr starts an HTTP server that exposes several services that can be requested by internal or even external processes. In the original plugin the go-to-node feature was implemented transforming the user click over the SVG into an HTTP request. PlantMPS directly select the requested node. In case you are interested in this topic take a look at application plugin and extension point concepts in the c.mbeddr.mpsutil.httpserver module.

Last thing to do to open the tool is to add our action somewhere into the MPS menus:

  • right click the plugin model and select New -> j.m.lang.plugin -> ActionGroup.

  • call it VisualizeActionGroup.

  • you should see a small red/mandatory field, here select element list, another field where you can select actions should appear.

  • select our VisualizeAction, should be the first option.

The modifications section is used to specify where the action menu should appear, as in the case of CommonDataKeys we need to import a model in order to specify interesting places:

  • EditorPopup contained in j.m.ide.editor.actions is the menu that appears when you right click over the editor area.

  • NodeActions contained in j.m.ide.actions is the menu that appears when you right click over a node in the tree area.

  • search ActionGroupDeclaration to find more, another one is ModelActions.

Your action group should be:

It's time to open our tool:

  • rebuild the solution, ctrl+F9.

  • either from a node on the left tree or from the editor you should the menu Visualize.

Also note the event.getPresentation().setText() to dynamically set the text displayed as menu. If you clone and open the PlantMPS plugin you can verify that the Visualize action appears only for IVisualizable nodes, try the DummyVis1 and DummyVis2 nodes.