Skip to content

Commit 18b9973

Browse files
committed
Added NewPage
1 parent 59d1c5d commit 18b9973

1 file changed

Lines changed: 34 additions & 4 deletions

File tree

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

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,17 @@ class ToM{
1515
ini : 'ToM_' ,
1616
note : 'ToM_note' ,
1717
nextPage : 'ToM_nextPage' ,
18+
newPage : 'ToM_newPage' ,
1819
showMenu : 'ToM_showMenu' ,
1920
]
2021

2122
// region: getting tutorial components nodes
2223

23-
def static getNextTutNodes(n){
24+
def static getNextTutNodes(n, boolean included = false){
2425
def tutNodes = getTutNodes(getTutorialNode(n))
2526
def pos = tutNodes.indexOf(n)
26-
return tutNodes.drop(pos + 1)
27+
def t = included?0:1
28+
return tutNodes.drop(pos + t)
2729
}
2830

2931
def static getTutNodes(nTutorial){
@@ -33,12 +35,17 @@ class ToM{
3335
def static getTutorialNode(n){
3436
return n.pathToRoot.find{it.style.name == styles.tutorial}
3537
}
38+
39+
def static getNewPageNodes(nTutorial){
40+
return nTutorial.find{it.style.name == styles.newPage}
41+
}
3642

3743
// end:
3844

3945
// region: loop fill contentPane
4046
def static fillContentPane(myPanel, nextTutNodes, boolean doClear = true){
4147
def interruptLoop = false
48+
def startingNewPage = true
4249
if(doClear) myPanel.removeAll()
4350
tomui.resizeContentPanel(myPanel,tomui.maxContentPaneHeigth)
4451
for (tutNode in nextTutNodes){
@@ -47,16 +54,25 @@ class ToM{
4754
addNotes(myPanel, tutNode.children)
4855
break
4956
case styles.nextPage:
50-
addNextPagePane(myPanel, tutNode)
57+
addNextPagePane(myPanel, tutNode, false)
5158
interruptLoop = true
5259
break
60+
case styles.newPage:
61+
if (startingNewPage){
62+
addPageTitle(myPanel, tutNode)
63+
} else {
64+
addNextPagePane(myPanel, tutNode, true)
65+
interruptLoop = true
66+
}
67+
break
5368
case styles.showMenu:
5469
addShowMenuItemPane(myPanel, tutNode.children)
5570
break
5671
default:
5772
ui.informationMessage('node style not defined')
5873
break
5974
}
75+
startingNewPage = false
6076
if(interruptLoop) break
6177
}
6278
if(!interruptLoop) addNextPagePane(myPanel, null)
@@ -74,8 +90,15 @@ class ToM{
7490
}
7591
}
7692
}
93+
94+
def static addPageTitle(myP,nodo){
95+
//TODO: agregar título
96+
def html = "<html><style>h1 {color: rgb(240, 240, 240);background-color: rgb(100, 100, 150);display: block;padding: 10px;}</style><body><h1>${nodo.text}</h1></body></html>"
97+
myP.add(tomui.createInstructionsPane(html), tomui.GBC)
98+
99+
}
77100

78-
def static addNextPagePane(myP, lastNode){
101+
def static addNextPagePane(myP, lastNode, boolean included = false){
79102
def closeLabel = 'Stop tutorial'
80103
def closeToolTip = 'Click to stop the tutorial and close the tutorial tab'
81104
def nextLabel = 'Next page'
@@ -85,8 +108,15 @@ class ToM{
85108
fillContentPane(myP, nextNodes, true)
86109
}:null
87110
def nextButtonPanel = tomui.getNextButtonPanel(tabName, closeLabel, closeToolTip, nextLabel, nextToolTip , bttnAction)
111+
def bttnAction = lastNode? { e -> fillPage(myP, lastNode, included, true) } : null
88112
myP.add(nextButtonPanel, tomui.GBC)
89113
}
114+
115+
def static fillPage(myP, nodo, included, doClear){
116+
def nextNodes = getNextTutNodes(nodo, included)
117+
fillContentPane(myP, nextNodes, doClear)
118+
}
119+
90120

91121
def static addShowMenuItemPane(myP, nodos){
92122
nodos.findAll{n -> toma.hasAction(n)}.each{nodo ->

0 commit comments

Comments
 (0)