-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #139 from sifran-github/main
Added Scripting Examples, including structure and examples
- Loading branch information
Showing
12 changed files
with
128 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
## Scripts about the Entire Mind Map | ||
|
||
Everything that has to do with multiple nodes. | ||
|
||
Navigating nodes, selecting nodes etc'. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## Scripts about Node Attributes | ||
|
||
Every attribute that is related to one specific node. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
## Others | ||
|
||
Miscellaneous examples. Not related to one node, or the mind map. | ||
|
||
For example: calling external APIs, external libraries. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
## Scripting Examples | ||
|
||
Scripting Examples by categories. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
## Alias | ||
First, set an alias for a node. right click, choose "Set node alias" and type "alias1". | ||
Then, in another node, you can reference the first node using the following code: | ||
```groovy | ||
node.details=node.at("/**/~alias1").text | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
## Copy link to clipboard | ||
```groovy | ||
// @ExecutionModes({ON_SINGLE_NODE}) | ||
def link = node.link.text | ||
if (link) { | ||
textUtils.copyToClipboard(node.link.text) | ||
c.statusInfo = "Hyperlink Copied." | ||
} else { | ||
c.statusInfo = "no link in ${node.text}" | ||
} | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# GUI | ||
Using simple GUI to display information on the screen, integrated into freeplane. | ||
|
||
### Simple YES/NO Question | ||
|
||
```groovy | ||
import org.freeplane.core.ui.components.UITools; | ||
def result = UITools.showConfirmDialog(node.delegate, "Simple Yes/No Question", "window title",0) | ||
c.statusInfo=result | ||
``` | ||
|
||
### Simple Msgbox | ||
```groovy | ||
script1 import org.freeplane.core.ui.components.UITools; | ||
UITools.informationMessage('Simple Messagebox') | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
## Add custom checkbox (switch between completed and not completed), with icons. | ||
```groovy | ||
// @ExecutionModes({ON_SELECTED_NODE}) | ||
if (node.icons.icons.contains("unchecked")) { | ||
node.icons.remove("unchecked") | ||
node.icons.add("button_ok") | ||
} else { | ||
node.icons.remove("button_ok") | ||
node.icons.add("unchecked") | ||
} | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# LINKS - TBD | ||
content will be taken from here: [setting-links](../scripting/Scripting.html#setting-links) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
## Select children nodes | ||
|
||
This scripts select the children nodes of the selected nodes. | ||
|
||
```groovy | ||
// @ExecutionModes({ON_SINGLE_NODE}) | ||
def toSelect = c.selecteds.collect{ node -> node.find {it.parent == node} }.sum() | ||
c.selectMultipleNodes(toSelect) | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
## Created+ Modified HTML Table | ||
Create an HTML Table of "created" and "modified" dates of all subnodes, from the selected node. Save the result to current node's note. | ||
|
||
```groovy | ||
def date_format(date) { | ||
return date ? date.format('yyyy-MM-dd HH:mm:ss'): 'N/A' | ||
} | ||
def node_to_html_table(starting_node) { | ||
def table = "<html><body><table><tr><th>Node</th><th>Created</th><th>Modified</th></tr>" | ||
starting_node.findAll().each { n -> table += "<tr><td>${n.text}</td><td>${date_format(n.getCreatedAt())}</td><td>${date_format(n.getLastModifiedAt())}</td></tr>" } | ||
table += "</table></body></html>" | ||
return table | ||
} | ||
node.note = node_to_html_table(node) | ||
``` | ||
|
||
## Count number of nodes with the word "ok" in the entire map. | ||
```groovy | ||
def matches = c.find{ it.text.contains('ok') } | ||
c.statusInfo = matches.size() + " nodes contain 'ok'" | ||
``` | ||
|
||
## Create a child node with all icons of all subnodes | ||
```groovy | ||
def usedIcons = node.findAll()*.icons*.icons.flatten().unique().sort() | ||
node.createChild("<-- all icons'").icons.addAll(usedIcons) | ||
``` |