Difference between revisions of "Scripting environment setup"

From Freeplane - free mind mapping and knowledge management software
(Create a Groovy Project for the scripts)
Line 13: Line 13:
  
 
==Setup workspace==
 
==Setup workspace==
===Install freeplane_bin===
 
# Download the current Freeplane binary distribution (e.g. freeplane-1.2.13.zip) and unpack it into the selected workspace
 
# Rename the latter directory into '''''freeplane_bin''''' and make sure this directory is in the workspace.
 
On the command line (Linux/Unix/Mac):
 
    cd <workspace> # your selected workspace, like ~/freeplanescripts
 
    unzip freeplane_bin-1.2.13.zip
 
    mv freeplane-1.2.13 freeplane_bin
 
 
===Install freeplane_src===
 
===Install freeplane_src===
Download matching Freeplane source distribution (e.g. freeplane_src-1.2.13.tar.gz) and unpack it into the selected workspace. Unpacking this archive may require an additional program like 7zip, jzip or winzip on Windows (check by trying to open the file in the Explorer). Unpacking may need two steps:
+
Download the current Freeplane source distribution (e.g. freeplane_src-1.2.13.tar.gz) and unpack it into the selected workspace. Unpacking this archive may require an additional program like 7zip, jzip or winzip on Windows (check by trying to open the file in the Explorer). Unpacking may need two steps:
 
# In a program like 7zip open the archive freeplane_src-1.2.13.tar.gz. Most unpackers will allow directly extract into a directory, but jzip creates an intermediate freeplane_src-1.2.13.tar file
 
# In a program like 7zip open the archive freeplane_src-1.2.13.tar.gz. Most unpackers will allow directly extract into a directory, but jzip creates an intermediate freeplane_src-1.2.13.tar file
 
# Rename freeplane-1.2.13 into freeplane_src and make sure this directory is in the workspace.
 
# Rename freeplane-1.2.13 into freeplane_src and make sure this directory is in the workspace.
Line 35: Line 28:
  
 
==Create projects==
 
==Create projects==
=== Create a Java Project for the Freeplane binaries ===
+
=== Import the Freeplane project(s) ===
 
 
[[File:Eclipse-create-project-freeplane_bin-0.png|700px|border]]
 
 
 
  
2. Set the project name to the name of the folder containing the Freeplane binaries
+
The Freeplane sources in "freeplane_src" consist of multiple projects, which are prepared for Eclipse. We can simply import this projects into our Eclipse workspace:
  
[[File:Eclipse-create-project-freeplane_bin-1.png|500px|border]]
+
1. Select File->Import...
  
 +
[[File:Eclipse-setup-import-project-select1.png|300px|border]]
  
3. Allow scripts access to the Freeplane libraries
 
  
[[File:Eclipse-create-project-freeplane_bin-2.png|500px|border]]
+
2. Set the root directory to freeplane_src and select all projects except freeplane-ant and (unless this happens on a Mac) freeplane-mac. Then click "Finish".
  
 +
[[File:Eclipse-setup-import-project-select2.png|500px|border]]
  
=== Create a Groovy Project for the scripts ===
+
=== Create a Groovy project for the scripts ===
 
(You may have to click on "Other..." to see "Groovy project" option.)
 
(You may have to click on "Other..." to see "Groovy project" option.)
  
Line 58: Line 49:
 
2. Set the project name to "scripts", uncheck "Use default location" and enter the full path to the freeplane scripts folder (<freeplaneuserdir>/scripts):
 
2. Set the project name to "scripts", uncheck "Use default location" and enter the full path to the freeplane scripts folder (<freeplaneuserdir>/scripts):
  
[[File:Eclipse-create-project-scripts-1.png|500px|border]]
+
[[File:Eclipse-create-project-scripts-1.png|450px|border]]
  
  
3. Connect the scripts with the Freeplane libraries.  
+
3. Connect the scripts with Freeplane.  
  
 
  [[File:Eclipse-create-project-scripts-2.png|700px|border]]
 
  [[File:Eclipse-create-project-scripts-2.png|700px|border]]
Line 70: Line 61:
 
[[File:Eclipse-create-project-scripts-3.png|900px|border]]
 
[[File:Eclipse-create-project-scripts-3.png|900px|border]]
  
=== Connect the scripts with the Freeplane source files ===
+
Done. You can proceed now with page [[Edit scripts in Eclipse]].
 
 
1. Type Shift+Ctrl+T ("Open Type") and enter "freeeplanescript" to open the class FreeplaneScriptBaseClass.
 
 
 
[[File:Eclipse-connect-to-freeplane-sources-0.png|450px]]
 
 
 
 
 
2. The source for the class can not be found. Click on "Attach source", then "External folder" and browse to the freeplane_src directory in the workspace
 
 
 
[[File:Eclipse-connect-to-freeplane-sources-1.png|700px]]
 
 
 
and click OK. The source of the class is shown now.
 
 
 
Proceed with page [[Edit scripts in Eclipse]].
 
  
 
[[Category:Script]]
 
[[Category:Script]]

Revision as of 00:36, 22 July 2012

Modern Integrated Development Environments like Eclipse or Idea make it much easier to edit Groovy scripts for Freeplane as in a normal text editor. Syntax highlighting, code completion, error detection, debugging and source navigation are extremely useful especially if you are not that experienced.

But it's more or less difficult for beginners to setup an IDE properly for Groovy scripting, so here's a step-by-step guide. If you have done that you can skip to page Edit scripts in Eclipse.

Installations

  • First download and install a Java Development Kit (JDK) -if you don't have it. There is a hyperlink on the Eclipse download page.
  • Then download and install a "Eclipse IDE for Java Developers" or "Eclipse for RCP and RAP Developers" (the latter is more useful for regular Freeplane developers) from Eclipse download page. Read how to unpack here (N.B. for Windows 7 it is not possible to unpack directly into c:/Program Files; no warning is given !)
  • Launch Eclipse for the first time and select some directory as your workspace root

Eclipse-select-workspace.png

Setup workspace

Install freeplane_src

Download the current Freeplane source distribution (e.g. freeplane_src-1.2.13.tar.gz) and unpack it into the selected workspace. Unpacking this archive may require an additional program like 7zip, jzip or winzip on Windows (check by trying to open the file in the Explorer). Unpacking may need two steps:

  1. In a program like 7zip open the archive freeplane_src-1.2.13.tar.gz. Most unpackers will allow directly extract into a directory, but jzip creates an intermediate freeplane_src-1.2.13.tar file
  2. Rename freeplane-1.2.13 into freeplane_src and make sure this directory is in the workspace.

On the command line (Linux/Unix/Mac):

   cd <workspace> # your selected workspace, like ~/freeplanescripts
   tar -xzvf freeplane_src-1.2.13.tar.gz
   mv freeplane-1.2.13 freeplane_src

Install groovy support

Freeplane's regular script directory <freeplaneuserdir>/scripts will be the script project directory where script development happens. To add special support for Freeplane scripting you have to copy the file freeplane_bin/scripts/freeplane.dsld to the script directory. On the command line (assuming that ~/.freeplane/1.2.x/scripts is Freeplane's script directory; Linux/Unix/Mac):

   cd <workspace> # your selected workspace, like ~/freeplanescripts
   cp ./freeplane_bin/scripts/freeplane.dsld ~/.freeplane/1.2.x/scripts

Create projects

Import the Freeplane project(s)

The Freeplane sources in "freeplane_src" consist of multiple projects, which are prepared for Eclipse. We can simply import this projects into our Eclipse workspace:

1. Select File->Import...

Eclipse-setup-import-project-select1.png


2. Set the root directory to freeplane_src and select all projects except freeplane-ant and (unless this happens on a Mac) freeplane-mac. Then click "Finish".

Eclipse-setup-import-project-select2.png

Create a Groovy project for the scripts

(You may have to click on "Other..." to see "Groovy project" option.)

Eclipse-create-project-scripts-0.png


2. Set the project name to "scripts", uncheck "Use default location" and enter the full path to the freeplane scripts folder (<freeplaneuserdir>/scripts):

Eclipse-create-project-scripts-1.png


3. Connect the scripts with Freeplane.

Eclipse-create-project-scripts-2.png


4. Select a different build output folder. Otherwise a lot of .class files would pollute the scripts directory. This is not required but helpful.

Eclipse-create-project-scripts-3.png

Done. You can proceed now with page Edit scripts in Eclipse.