Skip to content

Commit 55c7369

Browse files
committed
Update ToM.groovy
1 parent 54986ed commit 55c7369

1 file changed

Lines changed: 94 additions & 83 deletions

File tree

Tutorial-o-Matic/src/main/groovy/ToM.groovy

Lines changed: 94 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import org.freeplane.plugin.script.proxy.ScriptUtils
1313
class ToM{
1414

1515
// region: properties
16+
// this region has all the properties for the ToM class
1617

1718
static final c = ScriptUtils.c()
1819
static final String tabName = 'Tutorial'
@@ -39,6 +40,7 @@ class ToM{
3940
// end:
4041

4142
// region: getting tutorial components nodes
43+
//The methods in this region get the nodes from the mindmap that contain the information needed to build the tutorial
4244

4345
def static getNextTutNodes(n, boolean included = false){
4446
def tutNodes = getTutNodes(getTutorialNode(n))
@@ -62,6 +64,8 @@ class ToM{
6264
// end:
6365

6466
// region: loop fill contentPane
67+
// this region contains the methods that loop over the "tutorial nodes" and builds a tutorial page
68+
6569
def static fillContentPane(myPanel, nextTutNodes, boolean doClear = true){
6670
def interruptLoop = false
6771
def startingNewPage = true
@@ -129,7 +133,8 @@ class ToM{
129133

130134
// end:
131135

132-
// region: components nodes to tutorial
136+
// region: adding tutorial components nodes as contentPanes to tutorial tab
137+
//methods that create the contentPanes used to build a tutorial page
133138

134139
def static addNotes(myP, nodos){
135140
nodos.each{n ->
@@ -195,66 +200,6 @@ class ToM{
195200
}
196201
}
197202

198-
def static showTOC(myP,nodo){
199-
myP.removeAll()
200-
tomui.resizeContentPanel(myP,tomui.maxContentPaneHeigth)
201-
addTOCPane(myP,nodo)
202-
tomui.adjustHeight(myP, true)
203-
}
204-
205-
def static addTOCPane(myP,nodo){
206-
def titleNodes = getNewPageNodes(getTutorialNode(nodo))
207-
def pane = tomui.createEmptyGridBagPanel()
208-
titleNodes.each{ tn ->
209-
def title = tn.text
210-
def bttnAction = { e -> fillPage(myP, tn, true, true) }
211-
def button = tomui.createButton(title, bttnAction)
212-
pane.add(button, tomui.GBC)
213-
}
214-
myP.add(pane, tomui.GBC)
215-
}
216-
217-
def static showTutorials(mapa){
218-
def myP = tomui.getContentPaneFromMyTab(tabName, true)
219-
myP.removeAll()
220-
tomui.resizeContentPanel(myP,tomui.maxContentPaneHeigth)
221-
addTutorialsPane(myP, mapa)
222-
tomui.adjustHeight(myP, true)
223-
}
224-
225-
def static addTutorialsPane(myP, mapa){
226-
def nodosTutoriales = mapa.root.find{it.style.name == styles.tutorial}
227-
if ( nodosTutoriales.size() != 1 ){
228-
def pane = tomui.createEmptyGridBagPanel()
229-
def pre = nodosTutoriales.size() == 0 ? "No t" : "T"
230-
addPageTitle(myP, "${pre}utorials present in '${mapa.name}' map".toString())
231-
nodosTutoriales.each{ nT ->
232-
def title = nT.text
233-
def bttnAction = { e ->
234-
def tutNodes = getTutNodes(nT)
235-
if(tutNodes) {
236-
fillContentPane(myP, tutNodes)
237-
} else {
238-
ui.informationMessage( "no tutorial components(nodes) found for tutorial '${nT.text}'".toString() )
239-
}
240-
}
241-
def button = tomui.createButton(title, bttnAction)
242-
pane.add(button, tomui.GBC)
243-
}
244-
def stopButton = tomui.createButton('Exit tutorial', {tomui.closeTab(tabName)})
245-
pane.add(stopButton, tomui.GBC)
246-
myP.add(pane, tomui.GBC)
247-
} else {
248-
def nT = nodosTutoriales[0]
249-
def tutNodes = getTutNodes(nT)
250-
if(tutNodes) {
251-
fillContentPane(myP, tutNodes)
252-
} else {
253-
ui.informationMessage( "no tutorial components(nodes) found for tutorial '${nT.text}'".toString() )
254-
}
255-
}
256-
}
257-
258203
def static addGotoPane(myP, nodos){
259204
nodos.findAll{n -> n.link.node?true:false}.each{nodo ->
260205
def targetNode = nodo.link.node
@@ -292,13 +237,13 @@ class ToM{
292237
}
293238
}
294239

295-
def static getGroovyHtml(nodo, script){
296-
def showScript = nodo.icons.icons.contains('emoji-1F50D')
297-
uiMsg("showScript ${showScript}")
298-
def html = showScript? tomui.getHtmlFromGroovyNode(nodo, script) : nodo.text
299-
uiMsg("html ${html}")
300-
return html
301-
}
240+
def static getGroovyHtml(nodo, script){
241+
def showScript = nodo.icons.icons.contains('emoji-1F50D')
242+
uiMsg("showScript ${showScript}")
243+
def html = showScript? tomui.getHtmlFromGroovyNode(nodo, script) : nodo.text
244+
uiMsg("html ${html}")
245+
return html
246+
}
302247

303248
def static addActionPane(myP, nodo){
304249
def infoAcciones = []
@@ -321,21 +266,21 @@ class ToM{
321266
myP.add(buttonPanel, tomui.GBC)
322267
}
323268

324-
def static exeActionsHow(nodo){
325-
def iconos = nodo.icons.icons
326-
def iconitos = iconos.intersect(exeHowIcons)
327-
if(iconitos){
328-
def index = exeHowIcons.indexOf(iconitos[0])
329-
return toma.ex.values()[index]
330-
} else {
331-
return toma.ex.showHotKeys
332-
}
333-
}
334-
335-
def static disableBttn(nodo){
336-
def iconos = nodo.icons.icons
337-
return iconos.contains('emoji-1F56F')
338-
}
269+
def static exeActionsHow(nodo){
270+
def iconos = nodo.icons.icons
271+
def iconitos = iconos.intersect(exeHowIcons)
272+
if(iconitos){
273+
def index = exeHowIcons.indexOf(iconitos[0])
274+
return toma.ex.values()[index]
275+
} else {
276+
return toma.ex.showHotKeys
277+
}
278+
}
279+
280+
def static disableBttn(nodo){
281+
def iconos = nodo.icons.icons
282+
return iconos.contains('emoji-1F56F')
283+
}
339284

340285
def static addPastePane(myP, nodoSource){
341286
def enabled = !disableBttn(nodoSource)
@@ -431,10 +376,76 @@ class ToM{
431376
myP.add(buttonPanel, tomui.GBC)
432377
}
433378

379+
def static addTOCPane(myP,nodo){
380+
def titleNodes = getNewPageNodes(getTutorialNode(nodo))
381+
def pane = tomui.createEmptyGridBagPanel()
382+
titleNodes.each{ tn ->
383+
def title = tn.text
384+
def bttnAction = { e -> fillPage(myP, tn, true, true) }
385+
def button = tomui.createButton(title, bttnAction)
386+
pane.add(button, tomui.GBC)
387+
}
388+
myP.add(pane, tomui.GBC)
389+
}
390+
391+
def static addTutorialsPane(myP, mapa){
392+
def nodosTutoriales = mapa.root.find{it.style.name == styles.tutorial}
393+
if ( nodosTutoriales.size() != 1 ){
394+
def pane = tomui.createEmptyGridBagPanel()
395+
def pre = nodosTutoriales.size() == 0 ? "No t" : "T"
396+
addPageTitle(myP, "${pre}utorials present in '${mapa.name}' map".toString())
397+
nodosTutoriales.each{ nT ->
398+
def title = nT.text
399+
def bttnAction = { e ->
400+
def tutNodes = getTutNodes(nT)
401+
if(tutNodes) {
402+
fillContentPane(myP, tutNodes)
403+
} else {
404+
ui.informationMessage( "no tutorial components(nodes) found for tutorial '${nT.text}'".toString() )
405+
}
406+
}
407+
def button = tomui.createButton(title, bttnAction)
408+
pane.add(button, tomui.GBC)
409+
}
410+
def stopButton = tomui.createButton('Exit tutorial', {tomui.closeTab(tabName)})
411+
pane.add(stopButton, tomui.GBC)
412+
myP.add(pane, tomui.GBC)
413+
} else {
414+
def nT = nodosTutoriales[0]
415+
def tutNodes = getTutNodes(nT)
416+
if(tutNodes) {
417+
fillContentPane(myP, tutNodes)
418+
} else {
419+
ui.informationMessage( "no tutorial components(nodes) found for tutorial '${nT.text}'".toString() )
420+
}
421+
}
422+
}
423+
424+
// end:
425+
426+
// region: showing other content in Tutorial Tab
427+
//this region contains the methods that uses the tab to show other content leaving the Tutorial itself
428+
429+
def static showTOC(myP,nodo){
430+
myP.removeAll()
431+
tomui.resizeContentPanel(myP,tomui.maxContentPaneHeigth)
432+
addTOCPane(myP,nodo)
433+
tomui.adjustHeight(myP, true)
434+
}
435+
436+
def static showTutorials(mapa){
437+
def myP = tomui.getContentPaneFromMyTab(tabName, true)
438+
myP.removeAll()
439+
tomui.resizeContentPanel(myP,tomui.maxContentPaneHeigth)
440+
addTutorialsPane(myP, mapa)
441+
tomui.adjustHeight(myP, true)
442+
}
443+
434444

435445
// end:
436446

437447
// region: Getting map
448+
//this region contains the methods used to open mindmaps
438449

439450
def static getMapFromPath(filePath, withView){
440451
if(exists(filePath)){

0 commit comments

Comments
 (0)