@@ -3,11 +3,16 @@ package edofro.tutorialomatic
33import edofro.tutorialomatic.ToM_ui as tomui
44import edofro.tutorialomatic.ToM_actions as toma
55
6+ import edofro.menuomatic.WSE_redux as WSE
7+
68import org.freeplane.core.ui.components.UITools as ui
9+ import org.freeplane.plugin.script.proxy.ScriptUtils
10+
711
812
913class ToM {
1014
15+ static final c = ScriptUtils . c()
1116 static final String tabName = ' Tutorial'
1217
1318 static final Map styles = [
@@ -20,6 +25,7 @@ class ToM{
2025 toc : ' ToM_TOC' ,
2126 goto : ' ToM_goto' ,
2227 action : ' ToM_menuAction' ,
28+ groovy : ' ToM_groovy' ,
2329 ]
2430
2531 static final exeHowIcons = [' emoji-1F507' , ' emoji-2328' , ' emoji-1F5B1' ]
@@ -82,6 +88,9 @@ class ToM{
8288 case styles. action:
8389 addActionPane(myPanel, tutNode)
8490 break
91+ case styles. groovy:
92+ addGroovyPane(myPanel, tutNode)
93+ break
8594 default :
8695 ui. informationMessage(' node style not defined' )
8796 break
@@ -196,6 +205,32 @@ class ToM{
196205 }
197206 }
198207
208+ def static addGroovyPane (myP , nodoT ){
209+ // TODO: addGroovyPane
210+ def enabled = enableBttn(nodoT)
211+ nodoT. children. findAll{n -> WSE . isGroovyNode(n)}. each{nodo ->
212+ def script = WSE . scriptFromNode(nodo)
213+ if (script){
214+ def scrText = script + " \n c.statusInfo = '---- script executed ----'" . toString()
215+ def msgHtml = nodo. text // TODO: mejorar texto
216+ def bttnText = ' Execute script'
217+ def bttnToolTip = " Click to execute script on selected nodes"
218+ def bttnAction = { e ->
219+ def bttn = e. source
220+ bttn. setEnabled(enabled)
221+ c. script(scrText, " groovy" ). executeOn(c. selected)
222+ }
223+
224+ def buttonPanel = tomui. getButtonPanel(msgHtml,bttnText,bttnToolTip, bttnAction, false )
225+ buttonPanel. metaClass. pending = false
226+ myP. add(buttonPanel, tomui. GBC )
227+ } else {
228+ def textoHtml = ' <html><body><p>Command not encountered in Menu for active map</p></body></html>'
229+ myP. add(tomui. createInstructionsPane(textoHtml), tomui. GBC )
230+ }
231+ }
232+ }
233+
199234 def static addActionPane (myP , nodo ){
200235 def infoAcciones = []
201236 nodo. children. findAll{n -> toma. hasAction(n)}. each{n ->
0 commit comments