Difference between revisions of "Add-ons (Develop)"

From Freeplane - free mind mapping and knowledge management software
(moved Jokro's installation instructions to the add-on page; added some more details)
(Steps towards your own add-on)
Line 15: Line 15:
 
==Steps towards your own add-on==
 
==Steps towards your own add-on==
  
The goal of the example add-on is to put:
+
The goal of the example is to create an add-on called ''myAddOn'' which puts:
#an existing script <tt>myCoolScript.groovy</tt> in <tt><freeplaneuserdir>/script/myCoolScript.groovy</tt>; and
+
#a hypothetical script <tt>myCoolScript.groovy</tt> in <tt><freeplaneuserdir>/script/myCoolScript.groovy</tt>; and
#an icon <tt>mycoolicon.png</tt> in <tt><freeplaneuserdir>/icons/mycoolicon.png</tt>.
+
#a hypothetical icon <tt>mycoolicon.png</tt> in <tt><freeplaneuserdir>/icons/mycoolicon.png</tt>.
  
  
The steps to follow are:
+
'''First''' prepare a directory called ''myAddOn'' with  the following structure:
# In Freeplane create a new empty map by ''Ctrl+n''.
+
* myAddOn/scripts
# Invoke ''Tools->Developer Tools->Build add-on''. You will be asked for the name of your add-on. Answer ''My Cool Add-on''
+
* myAddOn/zips/icons
# Look through the messages in the info box that is shown if everything looks alright. The ''name'' attribute of the root node will be ''myCoolAddOn''. This is the identifying technical name of the add-on while ''My Cool Add-on'' will be subject to translation.
+
 
# Set the version attribute of the root node to <tt>v0.1</tt>
+
 
# Create a new directory somewhere with the technical name of the add-on, <tt>myCoolAddOn</tt>.
+
'''Second''' put the above files in this structure:
# Save the new map to <tt>myCoolAddOn/myCoolAddOn.mm</tt>.
+
# Copy <tt>myCoolScript.groovy</tt> to <tt>myAddOn/scripts/myCoolScript.groovy</tt>.
# Copy <tt>myCoolScript.groovy</tt> to <tt>myCoolAddOn/scripts/myCoolScript.groovy</tt>.
 
# In the map create a new subnode of the ''scripts'' node with name ''myCoolScript.groovy''.
 
 
# Copy <tt>mycoolicon.png</tt> to <tt>zips/icons/mycoolicon.png</tt>.
 
# Copy <tt>mycoolicon.png</tt> to <tt>zips/icons/mycoolicon.png</tt>.
# In the map create a new subnode of the ''zips'' node with name ''icons''. Create a ''mycoolicon.png'' subnode under ''icons''. The node hierarchy then is ''zips->icons->mycoolicon.png''.
 
# Invoke ''Tools->Developer Tools->Build add-on'' again. This will add the required attributes of the script node and proposes proper ''deinstall'' rules (just accept them when you are asked for it).
 
# Invoke ''Package add-on for publication''. This will create the file <tt>myCoolAddOn-v0.1.mm</tt> which can be installed via ''Tools->Scripts->Install Add-on'' (or via ''Tools->Add-ons'').
 
  
But before publishing your add-on read all notes in the add-on map. (They are meant for developers, not for users since users are not expected to read an add-on package.) The notes should guide you to add all missing information. Carefully revise the defaults that the ''Build add-on'' script has entered.
+
 
 +
'''Third''' create and save the map ''myAddOn''
 +
# Create a new mind map and set the root name (core) to ''myAddOn''
 +
# Select ''Tools->Developer Tools->Build add-on'' to generate the template.  First a dialog with a default name of the add-on displays. Accept the default name ''myAddOn'', or you get an error message. Then a dialog displays a log of the actions which generate the template nodes. 
 +
# The root node myAddOn now has got a number of attributes. The first attribute is ''name'' with value ''myAddOn''. This is the so-called technical name of the add-on which should not be changed. The root name (core) could be changed.
 +
# From the other attributes of the root node, at least the version should be filled in. E.g. fill in for version <tt>v0.1</tt> etc.
 +
# The map ''myAddOn'' has a template node ''scripts''. Create a child node with name ''myCoolScript.groovy''.
 +
# The map ''myAddOn'' has a template node ''zips''. Create a child node with name ''icons''. And create a child of ''icons'' with the name ''mycoolicon.png''.
 +
# Select (again) ''Tools->Developer Tools->Build add-on''. This will add the required attributes of the script node and proposes proper ''deinstall'' rules (just accept them when you are asked for it).
 +
# Select ''Tools > Developer Tools > Package add-on for publication''. This will create the file <tt>myAddOn-v0.1.mm</tt>
 +
 
 +
 
 +
'''Fourth''', install and test:
 +
* Select ''Tools->Scripts->Install Add-on'' (or via ''Tools->Add-ons'').
 +
 
 +
 
 +
Before publishing your add-on read all notes in the add-on map. (They are meant for developers, not for users since users are not expected to read an add-on package.) The notes should guide you to add all missing information. Carefully revise the defaults that the ''Build add-on'' script has entered.
  
 
[[Category:Extension]]
 
[[Category:Extension]]

Revision as of 21:37, 19 November 2011

This page will provide detailed information about developing Freeplane add-ons.

Add-ons are installed in the Freeplane user directory (see Tools->Open user directory). They may contain any number of scripts and Zip archives which are unpacked on installation. Combinations of scripts and Zips especially interesting since this enables you to package scripts with required libraries/JARs/class files. For instance it's possible to bundle some Groovy scripts for creating diagrams with the JFreechart library - so there's no need to download and install the JFreechart libraries anymore.

Since plugins (such as the Scripting, LaTeX or Formula plugin you know) may also be installed into the Freeplane user directory, add-ons may even provide plugins.


Preparation: Install developer tools

Update to the most recent Freeplane version and install the Developer Tools from the Add-ons page (follow the installation instructions there). The add-on provides scripts that relieves you from most of the tedious work.

The add-on functions are available in: Tools > Developer tools


Steps towards your own add-on

The goal of the example is to create an add-on called myAddOn which puts:

  1. a hypothetical script myCoolScript.groovy in <freeplaneuserdir>/script/myCoolScript.groovy; and
  2. a hypothetical icon mycoolicon.png in <freeplaneuserdir>/icons/mycoolicon.png.


First prepare a directory called myAddOn with the following structure:

  • myAddOn/scripts
  • myAddOn/zips/icons


Second put the above files in this structure:

  1. Copy myCoolScript.groovy to myAddOn/scripts/myCoolScript.groovy.
  2. Copy mycoolicon.png to zips/icons/mycoolicon.png.


Third create and save the map myAddOn

  1. Create a new mind map and set the root name (core) to myAddOn
  2. Select Tools->Developer Tools->Build add-on to generate the template. First a dialog with a default name of the add-on displays. Accept the default name myAddOn, or you get an error message. Then a dialog displays a log of the actions which generate the template nodes.
  3. The root node myAddOn now has got a number of attributes. The first attribute is name with value myAddOn. This is the so-called technical name of the add-on which should not be changed. The root name (core) could be changed.
  4. From the other attributes of the root node, at least the version should be filled in. E.g. fill in for version v0.1 etc.
  5. The map myAddOn has a template node scripts. Create a child node with name myCoolScript.groovy.
  6. The map myAddOn has a template node zips. Create a child node with name icons. And create a child of icons with the name mycoolicon.png.
  7. Select (again) Tools->Developer Tools->Build add-on. This will add the required attributes of the script node and proposes proper deinstall rules (just accept them when you are asked for it).
  8. Select Tools > Developer Tools > Package add-on for publication. This will create the file myAddOn-v0.1.mm


Fourth, install and test:

  • Select Tools->Scripts->Install Add-on (or via Tools->Add-ons).


Before publishing your add-on read all notes in the add-on map. (They are meant for developers, not for users since users are not expected to read an add-on package.) The notes should guide you to add all missing information. Carefully revise the defaults that the Build add-on script has entered.