@@ -24,7 +24,7 @@ class ToM{
2424 static final String attributeTabLabel = ' ToM_TabLabel'
2525 static final String defaultTabLabel = ' Tutorial'
2626 static final String defaultMapTutorialsTabLabel = ' Tutorials'
27-
27+ static final String attributeNewPageLink = ' ToM_LinkToPage '
2828
2929 static final Map styles = [
3030 tutorial : ' ToM-Tutorial' ,
@@ -604,6 +604,61 @@ class ToM{
604604
605605 // end:
606606
607+ // region: Linking tutorial pages from other mindmaps
608+
609+ def static openTutorialPage (nodeDirection , ApiMindMap mapa = null ){
610+ if (nodeDirection instanceof java.net.URI ) {
611+ return openTutorialPageUri(nodeDirection, mapa)
612+ }
613+ if (nodeDirection instanceof java.lang.String ) {
614+ return openTutorialPageString(nodeDirection, mapa)
615+ }
616+ if (nodeDirection instanceof ApiNode ) {
617+ def newPageUri = nodeDirection[attributeNewPageLink]. uri ?: nodeDirection. link?. uri // TODO: probar que tome link de nodo si no existe el del attributo
618+ mapa = mapa ?: nodeDirection. map
619+ return openTutorialPage(newPageUri, mapa)
620+ }
621+ return ' No tutorial node found'
622+ }
623+
624+
625+ def static openTutorialPageUri (URI uri , ApiMindMap mapa ){
626+ // if(!uri) return null
627+ def isMindmap = uri. scheme in [' file' ,' tutorial' ] && uri. path. endsWith(' .mm' )
628+ def nodeId = (! uri. scheme || isMindmap) && uri. fragment?. startsWith(' ID_' )?
629+ uri. fragment
630+ : null
631+ // if (!nodeId) return 'No node ID defined in URI'
632+ def tutMapPath = /* nodeId && */ isMindmap ?
633+ uri. path. drop(1 )
634+ :null
635+ def tutMap = tutMapPath ?
636+ getMapFromPath(tutMapPath, false ) // open mind map not visible
637+ : mapa
638+ openTutorialPageString(nodeId, tutMap)
639+ }
640+
641+
642+ def static openTutorialPageString (String nodeId , ApiMindMap tutMap ){
643+ if (! tutMap) return ' No tutorial mindmap defined'
644+ def targetNode = nodeId ? tutMap. node(nodeId) : null
645+ // if(!targetNode) return 'No tutorial node found'
646+
647+ if (targetNode){
648+ if (! (isTutNode(targetNode) || isTutorialNode(targetNode) )) return ' Indicated node is not part of a tutorial'
649+ def tutorialTabName = getTutorialNode(targetNode)[attributeTabLabel] ?: tutMap. root[attributeTabLabel] ?: defaultMapTutorialsTabLabel
650+ // uiMsg(tutorialTabName)
651+ def myP = tomui. getContentPaneFromMyTab(tutorialTabName. toString(), true )
652+ fillPage(myP, targetNode, true , true )
653+ } else {
654+ showTutorials(tutMap)
655+ }
656+ return ' tutorial displayed'
657+ }
658+
659+
660+ // end:
661+
607662 // region: help / debug
608663
609664 def static uiMsg (texto ){
0 commit comments