Difference between revisions of "Freeplane/C4/Groovy-Script-and-Freeplane/English"

From Script | Spoken-Tutorial
Jump to: navigation, search
 
(3 intermediate revisions by one other user not shown)
Line 178: Line 178:
 
|-
 
|-
 
|| Click on '''File''' , '''Save'''.
 
|| Click on '''File''' , '''Save'''.
|| Click on '''File''', '''Save''' in the menu to open the save a dialogue box.
+
|| Click on '''File''', '''Save''' in the menu to open the save a dialog box.
  
 
|-
 
|-
Line 248: Line 248:
  
 
Do not press '''Enter'''.
 
Do not press '''Enter'''.
|| Type, '''node.link.text =''', following by a single quote.
+
|| Type, '''node.link.text =''', followed by a single quote.
  
 
|-
 
|-
Line 285: Line 285:
 
|-
 
|-
 
|| Cursor on Save map dialog box.
 
|| Cursor on Save map dialog box.
|| A '''save map''' dialogue box appears.  
+
|| A '''save map''' dialog box appears.  
  
 
|-
 
|-
Line 307: Line 307:
 
|-
 
|-
 
|| Press '''Insert''' to add a child node and name it '''Software skill'''.
 
|| Press '''Insert''' to add a child node and name it '''Software skill'''.
|| I will add child nodes to the map and name it '''Software skill'''.
+
|| I will add a child node to the map and name it '''Software skill'''.
  
 
Let’s add two more children to the root node.
 
Let’s add two more children to the root node.

Latest revision as of 16:04, 28 October 2020

Visual Cue Narration
Slide Number 1

Title Slide

Welcome to the tutorial on

Groovy Script and Freeplane

Slide Number 2

Learning Objectives

In this tutorial, we will,
  • Learn about Groovy script
  • Write Groovy scripts
  • Add the Groovy scripts to the Freeplane scripts folder
  • Run the script in the Freeplane interface
Slide Number 3

Learning Objectives

  • Add child nodes to a map using the script and
  • Add a hyperlink to a node using script
Slide Number 4

System and Software Requirement

To record this tutorial, I am using
  • Ubuntu Linux v16.04 OS
  • Freeplane v1.7.10
  • Firefox web browser v78 and
  • A working Internet connection
Slide Number 5

Pre-requisites

https://www.spoken-tutorial.org

To follow this tutorial,
  • Learner must be familiar with the Freeplane interface.
  • For pre-requisite tutorials, please visit this site.
Slide Number 10

Introduction to Scripting

https://groovy-lang.org/

[https://www.freeplane.org/wiki/index.php/Scripting

  • Link for the Groovy website is shown here.
  • Link for simple example scripts for use in Freeplane is also shown here.
Slide Number 7

Possible Uses

Teachers can extend the Groovy scripting method to import,
  • Student names
  • Marks and grades or
  • To collate results
Slide Number 8

Groovy

  • Groovy is an object oriented programming language, based on Java platform.
  • Groovy scripts can be executed in the nodes in Freeplane.
Open Freeplane. Let’s open Freeplane.
Click on Tools, Scripts. Click on Tools, in the menu and select Scripts.

Notice that, there are no scripts present in the sub-menu now.

Click on Tools, Open user directory. Next, click on Tools and select Open user directory.
Cursor in the freeplane 1.7.x window. A new window opens showing the Freeplane settings for files and folders.
Hover mouse next to .config. Notice the path for the scripts from here.

It is in the dot config directory, under freeplane and 1.7.x.

Learner must note down the path for the scripts folder in your computer.

Hover mouse next to .config. Scripts must be saved in this scripts directory to be executed.

They are named with extension dot groovy.

Click on x sign to close the file manager window. Click on the x sign to close this window.
Press the Windows. Press the Windows key on the keyboard.
Type gedit and press Enter. Type gedit in the search form and press Enter.

Let's open a text editor to write a script.

A gedit window opens.

Cursor on gedit window. Windows users may use notepad.
Slide Number 8

Adding Student Names

  • A teacher wants to add 20 students as 20 child nodes to a Language class.
  • They need to be named as student 1 to student 20, according to roll numbers.
Cursor on gedit window. I will write a short for loop structure and set the number of names required.
Type, for (i=1;i<21;i++) and press Enter. Start a for loop as seen on the screen.


Here, i is a variable.

Cursor on i=1, i<21 and i++. This means the value of i change from one to less than 21.


Value of i is incremented in units of one.

Type { and press Enter.

Type } and press Enter.

I will type a curly brace.

I will also close the curly brace in the next line.

We will enter the required commands betweeen the curly braces.

Type def child = node.createChild("student$i") Next, let's write a command to add the 20 student nodes.

Enter command as seen on the screen.

Cursor on def child and student$i. Here we define a child and create a child node as student$i.
Cursor on the command line. Learner must retain the syntax for the program to be functional.
Click on File , Save. Click on File, Save in the menu to open the save a dialog box.
We cannot change the folder to .config via menu.

It is because, the name starts with a dot.

Cursor on the path folder. So, we will first save the script in the home directory.

Later move the file to the scripts folder using terminal command.

Type addchild.groovy

Click on save

I will give file name addchild.groovy and click on Save.
Click on the x sign. Click on the x sign on the top to close gedit.
Press Ctrl+Alt+T. Open a terminal by pressing Ctrl, Alt and T keys together.
Type,

mv addchild.groovy ~/.config/freeplane/1.7.x/scripts

Move the script file to the scripts directory using the command as seen here.
Press Enter. Press Enter to execute the command.
Type cd .config/freeplane/1.7.x/scripts. Change to the scripts directory using the command as seen here.
Type ls and press Enter. Type ls to list the files in the directory.
Cursor on the scripts folder. Notice that the script file is now in the scripts folder.
Cursor on the path in the terminal. Learners must save the script in the correct script folder in their computer.
Type gedit hyperlink.groovy and press Enter. I will write one more script.

Type gedit hyperlink dot groovy and press Enter.

The text editor opens with a new file.

Show screenshot of spoken tutorial web page. For demonstration, I will choose the web address of the Freeplane tutorial link.
Type, node.link.text = ' .

Do not press Enter.

Type, node.link.text =, followed by a single quote.
Type,

'https://spoken-tutorial.org/tutorial-search/?search_foss=Freeplane&search_language=English'

and press Enter.

Now, copy and paste the desired web address.

I have already copied the desired web address link.

Paste the desired web address and close the single quote.

Press Ctrl+S .

Press Ctrl+Q .

You may pause the video to add the desired web address of your choice.

Press Control-S to save the file and press Control-Q to quit gedit.


The new scripts are saved in the correct path and Freeplane can read it.

Slide Number 9

Reading the script

  • We must close and reopen Freeplane for the scripts folder to be read.
  • Then, the newly added script will be read when Freeplane starts.
Click on File, Quit Freeplane. Click on File , Quit Freeplane, to Close Freeplane.
Cursor on Save map dialog box. A save map dialog box appears.
Click on No. I will Click on No, and will not save the present map.
Open Freeplane. Let’s reopen Freeplane.
Click on Tools, scripts. Click on Tools, scripts in the menu.

Notice that the addchild and hyperlink scripts are visible now.

Type classes in the root node. I will rename the root node to classes.
Press Insert to add a child node and name it Software skill. I will add a child node to the map and name it Software skill.

Let’s add two more children to the root node.

Press Enter, name the child node language 2. I will name them, language1 and language2.
Cursor on language1 node. Let’s add the 20 student names to the language1 node.
Select the language1 node. For this first select the language1 node.
Click on Tools, Scripts, addchild. Next, run the script by clicking on Tools, Scripts, addchild.
Click on Yes. A confirmation prompt appears on the screen with a warning message.

It prompts the user whether to run the script.

Click on Yes to run the script.

Hover mouse over the newly added nodes. Notice that 20 child nodes are added to the map.

They are named student 1 to student 20.

Cursor on the map. We can also modify node properties in a similar fashion using scripts.
Press Control + Z. We can run the script on any number of selected nodes.

Let’s press Control-Z to undo the addition of child nodes in the map.

Select language1 and language2 nodes. Let’s select language1 and language2 nodes.
Click on Tools, Scripts, addchild. Run the addchild script again.
Click on Yes. Again, the confirmation prompt appears on the screen.

Let’s click on Yes.

Show the added nodes. Now, the list of 20 students gets added to both the selected nodes.
Select the Software skill node. Let’s hyperlink the Freeplane tutorial web address to the Software skill node.

Select the Software skill node.

Click on Tools, Scripts, addchild. Next, run the script by clicking on Tools, Scripts, and hyperlink.
Click on Yes. Click on Yes on the prompt to run the script.
Cursor next to the Software skill node. Notice the red arrow, next to the node, indicating the link.
Click on the Software skill node. Click on the Software skill node.

A web browser opens.

Cursor on the web page. If you have a working internet connection, the page will load.

You can also link to files in your computer in this manner.

Many scripts and examples are available online.
Highlight in web browser

https://www.freeplane.org/wiki/index.php/Scripting.

Go to the Freeplane web address, as seen here.
Scroll down. Scroll down and notice the example Groovy scripts available here.
Cursor on groove-learn and Script collection links. Notice the learn Groovy and Script collection link.

Learner may use these resources for learning purposes.

Close the web browser and go back to Freeplane. Close the web browser and go back to Freeplane.
Cursor on Press File , Save map. You may choose to save this file.
Cursor on File , Quit Freeplane. Click on File, Quit Freeplane or press Control-Qto quit Freeplane.
Slide Number 11

Summary

Now let's summarize. In this tutorial we,
  • Learned about Groovy script
  • Wrote Groovy scripts
  • Added the Groovy scripts to the Freeplane scripts folder
Slide Number 12

Summary

  • Executed the script in the Freeplane interface to add
    • Child nodes in the map and
    • Hyperlink to a node
Slide Number 13

Assignment

For assignment activity, please do the following.
  • Write a Groovy script of your choice and execute it in Freeplane.
Slide Number 14

Spoken Tutorial Project

This video summarises the Spoken Tutorial Project.

Please download and watch it.

Slide Number 15

Spoken Tutorial workshops

The Spoken Tutorial team:
  • conducts workshops and
  • give certificates.

For more details, please write to us.

Slide Number 16

Forum for specific questions

Please post your timed queries in this forum.
Slide Number 17

Acknowledgement

Spoken Tutorial Project is funded by NMEICT, MHRD, Government of India.
This is Rani from IIT, Bombay.

Thank you for joining.

Contributors and Content Editors

Madhurig, PoojaMoolya, Ranipv076, Snehalathak