External script file execution

From Freeplane - free mind mapping and knowledge management software
Revision as of 14:11, 2 January 2010 by Dimitry (talk | contribs) (Created page with '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 config...')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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. 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 (scriptname without suffix).firstToUpper() as {0}:
ExecuteScript.text=Execute {0}
ExecuteScriptRecursively.text=Execute {0} recursively
  • To be able to use the resulting string as a menu entry it was necessary to add an appropriate language resource dynamically. (See ResourceBundles.addResources(lang, Map<String, String> properties)and the same for ResourceController.)
  • Errors while loading or while execution of scripts are handled by error message popups. (See resources "ExecuteScriptError.text" and "ReadScriptError.text".)