@@ -9,6 +9,9 @@ import org.freeplane.core.ui.components.UITools as ui
99import org.freeplane.plugin.script.proxy.ScriptUtils
1010
1111
12+ import org.freeplane.api.Node as ApiNode
13+ import org.freeplane.api.MindMap as ApiMindMap
14+
1215
1316class ToM {
1417
@@ -48,26 +51,38 @@ class ToM{
4851 // region: getting tutorial components nodes
4952 // The methods in this region get the nodes from the mindmap that contain the information needed to build the tutorial
5053
51- def static getNextTutNodes (n , boolean included = false ){
54+ def static getNextTutNodes ( n , boolean included = false ){
5255 def tutNodes = getTutNodes(getTutorialNode(n))
5356 def pos = tutNodes. indexOf(n)
5457 def t = included? 0 : 1
5558 return tutNodes. drop(pos + t)
5659 }
5760
58- def static getTutNodes (nTutorial ){
59- return nTutorial. find{it. style. name?. startsWith(styles. ini)?: false }
61+ def static getTutNodes ( nTutorial ){
62+ return nTutorial. find{isTutNode(it)}
63+ }
64+
65+ def static isTutNode ( n ){
66+ return n?. style?. name?. startsWith(styles. ini)?: false
67+ }
68+
69+ def static getTutorialNode ( n ){
70+ return n. pathToRoot. find{isTutorialNode(it)}
6071 }
6172
62- def static getTutorialNode ( n ){
63- return n. pathToRoot . find{it . style. name == styles. tutorial}
73+ def static isTutorialNode ( n ){
74+ return n. style. name == styles. tutorial
6475 }
6576
66- def static getNewPageNodes (nTutorial ){
67- return nTutorial. find{it . style . name == styles . newPage }
77+ def static getNewPageNodes ( nTutorial ){
78+ return nTutorial. find{isNewPageNode(it) }
6879 }
6980
70- def static isEditingMode (n ){
81+ def static isNewPageNode ( n ){
82+ return n. style. name == styles. newPage
83+ }
84+
85+ def static isEditingMode ( n ){
7186 def nodo = getTutorialNode(n)
7287 return nodo. icons. contains(' emoji-1F58D' )
7388 }
@@ -141,7 +156,7 @@ class ToM{
141156 tomui. adjustHeight(myPanel, doClear)
142157 }
143158
144- def static fillPage (myP , nodo , included , doClear ){
159+ def static fillPage (myP , nodo , boolean included , boolean doClear ){
145160 def nextNodes = getNextTutNodes(nodo, included)
146161 fillContentPane(myP, nextNodes, doClear)
147162 }
@@ -168,7 +183,7 @@ class ToM{
168183 myP. add(tomui. createInstructionsPane(html), tomui. GBC )
169184 }
170185
171- def static addPageTitle (myP , nodo ){
186+ def static addPageTitle (myP , ApiNode nodo ){
172187 if (isEditingMode(nodo)) {
173188 def html = htmlTitle(nodo. text)
174189 def bttnText1 = " inspect"
@@ -191,8 +206,7 @@ class ToM{
191206
192207
193208
194-
195- def static addNextPagePane (myP , lastNode , boolean included = false , boolean showNextButton = true ){
209+ def static addNextPagePane (myP , ApiNode lastNode , boolean included = false , boolean showNextButton = true ){
196210 def closeLabel = ' Stop tutorial'
197211 def closeToolTip = ' Click to stop the tutorial and close the tutorial tab'
198212 def nextLabel = showNextButton? ' Next page' : ' Show tutorials'
@@ -251,14 +265,14 @@ class ToM{
251265 }
252266 }
253267
254- def static gotoAction (myP ,targetNode , backNode ){
268+ def static gotoAction (myP , ApiNode targetNode , ApiNode backNode ){
255269 myP. removeAll()
256270 addReturnPane(myP, backNode)
257271 fillPage(myP, targetNode, true , false )
258272 addReturnPane(myP, backNode)
259273 }
260274
261- def static addReturnPane (myP , backNode ){
275+ def static addReturnPane (myP , ApiNode backNode ){
262276 def msgHtml = " Return to '${ backNode.text} ' page"
263277 def bttnText = ' go back'
264278 def bttnToolTip = " Click to go to '${ backNode.text} ' section"
@@ -267,7 +281,7 @@ class ToM{
267281 myP. add(buttonPanel, tomui. GBC )
268282 }
269283
270- def static addGroovyPane (myP , nodoT ){
284+ def static addGroovyPane (myP , ApiNode nodoT ){
271285 def parentEnabled = ! disableBttn(nodoT)
272286 def parentReadOnly = isReadOnly(nodoT)
273287 nodoT. children. findAll{n -> WSE . isGroovyNode(n)}. each{nodo ->
@@ -298,15 +312,15 @@ class ToM{
298312 }
299313 }
300314
301- def static getGroovyHtml (nodo , script ){
315+ def static getGroovyHtml ( ApiNode nodo , script ){
302316 def showScript = nodo. icons. icons. contains(' emoji-1F50D' ) || nodo. icons. icons. contains(' emoji-1F453' )
303317 uiMsg(" showScript ${ showScript} " )
304318 def html = showScript? tomui. getHtmlFromGroovyNode(nodo, script) : nodo. text
305319 uiMsg(" html ${ html} " )
306320 return html
307321 }
308322
309- def static addActionPane (myP , nodo , options ){
323+ def static addActionPane (myP , ApiNode nodo , options ){
310324 def infoAcciones = []
311325 nodo. children. findAll{n -> toma. hasAction(n)}. each{n ->
312326 def infoAccion = toma. getActionInfoMap(n)
@@ -327,7 +341,7 @@ class ToM{
327341 myP. add(buttonPanel, tomui. GBC )
328342 }
329343
330- def static exeActionsHow (nodo ){
344+ def static exeActionsHow ( ApiNode nodo ){
331345 def iconos = nodo. icons. icons
332346 def iconitos = iconos. intersect(exeHowIcons)
333347 if (iconitos){
@@ -338,17 +352,17 @@ class ToM{
338352 }
339353 }
340354
341- def static disableBttn (nodo ){
355+ def static disableBttn ( ApiNode nodo ){
342356 def iconos = nodo. icons. icons
343357 return iconos. contains(' emoji-1F56F' )
344358 }
345359
346- def static isReadOnly (nodo ){
360+ def static isReadOnly ( ApiNode nodo ){
347361 def iconos = nodo. icons. icons
348362 return iconos. contains(' emoji-1F453' )
349363 }
350364
351- def static addPastePane (myP , nodoSource ){
365+ def static addPastePane (myP , ApiNode nodoSource ){
352366 def enabled = ! disableBttn(nodoSource)
353367 def msgHtml = " Click to paste the example nodes to the selected node"
354368 def bttnText = " Insert nodes"
@@ -377,7 +391,7 @@ class ToM{
377391 myP. add(buttonPanel, tomui. GBC )
378392 }
379393
380- def static addSelectPane (myP , nodo ){
394+ def static addSelectPane (myP , ApiNode nodo ){
381395 def enabled = ! disableBttn(nodo)
382396 def msgHtml = " Click to select the node(s)"
383397 def bttnText = " Select node(s)"
@@ -417,7 +431,7 @@ class ToM{
417431 myP. add(buttonPanel, tomui. GBC )
418432 }
419433
420- def static getIdDictionary (mapa ){
434+ def static getIdDictionary (ApiMindMap mapa ){
421435 def dict = [:]
422436 def textoDict = mapa. storage[idDictStorage]
423437 if (textoDict){
@@ -429,15 +443,15 @@ class ToM{
429443 return dict
430444 }
431445
432- def static setIdDictionary (mapa , dict ){
446+ def static setIdDictionary (ApiMindMap mapa , dict ){
433447 def texto = new StringBuilder ()
434448 dict. each{k ,v ->
435449 texto << " ${ k} :${ v} ;"
436450 }
437451 mapa. storage[idDictStorage] = texto
438452 }
439453
440- def static addOpenMapPane (myP , tutNode , options ){
454+ def static addOpenMapPane (myP , ApiNode tutNode , options ){
441455 def sep = File . separator
442456 def nodoMapa = tutNode. children. find{it. text. endsWith(' .mm' )}
443457 def mapFileName = nodoMapa?. text
@@ -456,7 +470,7 @@ class ToM{
456470 myP. add(buttonPanel, tomui. GBC )
457471 }
458472
459- def static addInspectPane (myP , nodo ){
473+ def static addInspectPane (myP , ApiNode nodo ){
460474 def msgHtml = " Click to inspect this page in the tutorial map"
461475 def bttnText = " inspect"
462476 def bttnToolTip = " Click to select the page's source nodes"
@@ -471,7 +485,7 @@ class ToM{
471485 myP. add(buttonPanel, tomui. GBC )
472486 }
473487
474- def static addShowNodePane (myP , nodo ){
488+ def static addShowNodePane (myP , ApiNode nodo ){
475489 def nodos = nodo. children. findAll{ n -> n. link && (n. link. node || (! n. link. node && ! n. link. file && n. link. uri. scheme == ' file' ))}
476490 nodos. each{ n ->
477491 def msgHtml = " Click to show ${ n.text} "
@@ -504,7 +518,7 @@ class ToM{
504518 }
505519 }
506520
507- def static addTOCPane (myP ,nodo ){
521+ def static addTOCPane (myP , ApiNode nodo ){
508522 def titleNodes = getNewPageNodes(getTutorialNode(nodo))
509523 def pane = tomui. createEmptyGridBagPanel()
510524 titleNodes. each{ tn ->
@@ -516,7 +530,7 @@ class ToM{
516530 myP. add(pane, tomui. GBC )
517531 }
518532
519- def static addTutorialsPane (myP , mapa ){
533+ def static addTutorialsPane (myP , ApiMindMap mapa ){
520534 def nodosTutoriales = mapa. root. find{it. style. name == styles. tutorial}
521535 if ( nodosTutoriales. size() != 1 ){
522536 def pane = tomui. createEmptyGridBagPanel()
0 commit comments