Jaxe, your XML editor
Jaxe, your XML editor
Home pageSummaryPage for printing<-->

Adding a function

Author: Damien Guillaume

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.

Example

The following example adds a menu giving statistics about the document.

  • Download StatisticsFunction.java.
  • Put it in a folder named pluginsjaxe (it's the name of the package).
  • Compile it. From the location of the pluginsjaxe folder, type on the command line : javac -encoding ISO-8859-1 -classpath .:lib/Jaxe.jar pluginsjaxe/StatisticsFunction.java (assuming Jaxe.jar is in a lib directory under the working directory). This should create a file StatisticsFunction.class in the folder pluginsjaxe.
  • Create a jar file with the folder pluginsjaxe, and add it to the plugins folder.
  • Update the configuration file to add a menu calling the function:
<MENU nom="plugins">
  <MENU_FONCTION classe="pluginsjaxe.StatisticsFunction" nom="Statistics"/>
</MENU>
Previous pageNext page