External script file execution

From Freeplane - free mind mapping and knowledge management software
Revision as of 10:30, 4 January 2010 by Boercher (talk | contribs) (no need to add resources dynamically, formatting)

There is a mechanism to load and execute scripts from script directories matching a given name scheme (hardcoded: ".*\.groovy").

  • The list of script directories is configurable in the config file (default: scripts, i.e. directory scripts in the freeplane user home).
  • Matching scripts are listed in the Extra menu in a submenu Scripts.
  • Due to the flexible standard hotkey assignment it's possible to create hotkeys for these scripts.

For each script there are two menu entries, e.g. for a script testscript.groovy:

  • Execute Testscript: This will invoke the script on every selected node, i.e. if three nodes are selected, it will be executed three times, once for each node with the node variable set to the respective node.
  • Execute Testscript recursively: This will invoke the script on every selected node and recursively on all of its children.
    • Note: If a node and a child node are both selected, then the script is invoked on the child node twice.
  • To execute a script on all nodes in a map one has to select the root node and execute the script recursively.
  • The menu entries are formed by evaluating the following language resources with (pseudo code) (scriptname without suffix).firstToUpper() as {0}:
ExecuteScript.text=Execute {0}
ExecuteScriptRecursively.text=Execute {0} recursively
  • Errors while loading or while execution of scripts are handled by error message popups. (See resources ExecuteScriptError.text and ReadScriptError.text.)