Adding a function |
It is easy to add a menu launching a particular function instead of inserting an element. For this, one just needs to derive a class from jaxe.Fonction and implement the method appliquer, which provides the working Jaxe document, and the starting and ending positions of the text selection.
public void appliquer(JaxeDocument doc, int start, int end)
The DOM document can be obtained from the Jaxe document with doc.DOMdoc. A Jaxe element can be obtained from a position in the text with doc.elementA(int pos). All the elements in the interval [start,end] can be obtained with rootJE.elementsDans(start, end). The corresponding DOM node is obtained with JaxeElement.noeud.
The following example adds a menu giving statistics about the document.
<MENU nom="plugins"> <MENU_FONCTION classe="pluginsjaxe.StatisticsFunction" nom="Statistics"/> </MENU>