Difference between revisions of "Scripting environment setup"

From Freeplane - free mind mapping and knowledge management software
m (Intall groovy support)
Line 27: Line 27:
  
 
===Install freeplane_bin===
 
===Install freeplane_bin===
#Copy your freeplane directory to the workspace directory AND rename it into freeplane_bin; OR Download the current Freeplane binary distribution (e.g. freeplane-1.2.13.zip) and unpack it into the workspace (e.g. freeplane-1.2.13)
+
# Download the current Freeplane binary distribution (e.g. freeplane-1.2.13.zip) and unpack it into the workspace (e.g. freeplane-1.2.13)
 
# Rename the latter directory into '''''freeplane_bin'''''.  
 
# Rename the latter directory into '''''freeplane_bin'''''.  
  
Line 36: Line 36:
 
Next rename freeplane-1.2.13 into freeplane_src and make sure this directory is in the workspace.   
 
Next rename freeplane-1.2.13 into freeplane_src and make sure this directory is in the workspace.   
  
===Intall groovy support===
+
===Install groovy support===
 
Install the eclipse support for the Freeplane extensions to Groovy scripts (<freeplaneuserdir>/scripts will be our scripts project directory):
 
Install the eclipse support for the Freeplane extensions to Groovy scripts (<freeplaneuserdir>/scripts will be our scripts project directory):
#Make a directory ''.freeplane'' in the workspace. Windows doesn't let you add a dot for the filename directly from the file window. Therefore go to the cmd window by: select the Windows Start button (left under). In field "finding programs and files", type cmd. Click cmd as it is found. To set the current directory to your workspace directory, in general, you type in the cmd window: ''cd workspace'' <enter>. To make direcory .freeplane, type ''md .freeplane'' <enter>
+
Copy file '''freeplane.dsld''' from your ''/workspace/freeplane_bin/scripts/freeplane.dsld'' to ''<freeplaneuserdir>/scripts/freeplane.dsld''.
# Now return to your regular files window (or if you are familiar with the cmd window you can continue there), and define in .freeplane a subdirectory 1.2.x/scripts. Finally copy file '''freeplane.dsld''' from your ''/workspace/freeplane_bin/scripts/freeplane.dsld'' to ''workspace/.freeplane/1.2.x/scripts/freeplane.dsld''.
 
  
 
==Create projects==
 
==Create projects==

Revision as of 12:49, 3 June 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:

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 unix/linux

  • Download current Freeplane binary distribution and unpack it into the workspace, and rename directory:
   cd ~/freeplanescripts
   unzip freeplane_bin-1.2.13.zip
   mv freeplane-1.2.13 freeplane_bin
  • Download matching Freeplane source distribution and unpack it into the workspace and rename directory:
   cd ~/freeplanescripts
   tar -xzvf freeplane_src-1.2.13.tar.gz
   mv freeplane-1.2.13 freeplane_src
  • Install the eclipse support for the Freeplane extensions to Groovy scripts (<freeplaneuserdir>/scripts will be our scripts project directory):
   cp ./freeplane_bin/scripts/freeplane.dsld ~/.freeplane/1.2.x/scripts

Setup workspace Windows

Install freeplane_bin

  1. Download the current Freeplane binary distribution (e.g. freeplane-1.2.13.zip) and unpack it into the workspace (e.g. freeplane-1.2.13)
  2. Rename the latter directory into freeplane_bin.

Install freeplane_src

Download matching Freeplane source distribution (e.g. freeplane_src-1.2.13.tar.gz) and unpack it. Unpacking requires a free program like jzip. It may need two steps:

  1. In a program like jzip open the archive freeplane_src-1.2.13.tar.gz. Choose extract which will give freeplane_src-1.2.13.tar
  2. Open freeplane_src-1.2.13.tar in the same program. Choose extract which will give freeplane-1.2.13

Next rename freeplane-1.2.13 into freeplane_src and make sure this directory is in the workspace.

Install groovy support

Install the eclipse support for the Freeplane extensions to Groovy scripts (<freeplaneuserdir>/scripts will be our scripts project directory): Copy file freeplane.dsld from your /workspace/freeplane_bin/scripts/freeplane.dsld to <freeplaneuserdir>/scripts/freeplane.dsld.

Create projects

Create a Java Project for the Freeplane binaries

Eclipse-create-project-freeplane bin-0.png

2. Set the project name to the name of the folder containing the Freeplane binaries

Eclipse-create-project-freeplane bin-1.png

3. Allow scripts access to the Freeplane libraries

Eclipse-create-project-freeplane bin-2.png

Create a Groovy Project for the scripts

Eclipse-create-project-scripts-0.png

2. Set the project name to the name of the folder containing the scripts

Eclipse-create-project-scripts-1.png

3. Connect the scripts with the Freeplane libraries.

Eclipse-create-project-scripts-2.png

4. Select a different 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

Connect the scripts with the Freeplane source files

1. Type Shift+Ctrl+T ("Open Type") and enter "freeeplanescript" to open the class FreeplaneScriptBaseClass.

Eclipse-connect-to-freeplane-sources-0.png

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

Eclipse-connect-to-freeplane-sources-1.png

and click OK. The source of the class is shown now.

Using Eclipse

Edit a script

Eclipse-edit-script.png

Magic keys

  • ALT+Space
    • Initiates content assist, completes typed texts.
    • Import declarations for completed types are automatically added.
    • Example: type "str" (without the quotes) and hit ALT space.
  • F3
    • Navigates to the definition of the variable/class under the cursor.
    • This also works for Java and Freeplane classes - allowes to lookup details of the class.
  • ALT+Cursor_Left
    • Navigates to the last remembered location.
  • Shift+Ctrl+T
    • Open a type (e.g. a class or interface).
    • Try entering "proxy" and select the Proxy from org.freeplane.plugin.script.proxy
    • Proxy is the API definition.
  • Shift+Ctrl+R
    • Use this to open a script.