Skip to content

Commit 189da8c

Browse files
committed
added getGroovyHtml
1 parent afa3da7 commit 189da8c

2 files changed

Lines changed: 28 additions & 17 deletions

File tree

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,9 @@ class ToM{
264264
nodoT.children.findAll{n -> WSE.isGroovyNode(n)}.each{nodo ->
265265
def script = WSE.scriptFromNode(nodo)
266266
if (script){
267-
def scrText = script + "\n c.statusInfo = '---- script executed ----'".toString()
268-
def msgHtml = nodo.text //TODO: mejorar texto
269-
def bttnText = 'Execute script'
267+
def scrText = script + "\n c.statusInfo = '---- ready ----'".toString()
268+
def msgHtml = getGroovyHtml(nodo, script)
269+
def bttnText = 'Execute'
270270
def bttnToolTip = "Click to execute script on selected nodes"
271271
def bttnAction = { e ->
272272
def bttn = e.source
@@ -284,6 +284,14 @@ class ToM{
284284
}
285285
}
286286

287+
def static getGroovyHtml(nodo, script){
288+
def showScript = nodo.icons.icons.contains('emoji-1F50D')
289+
uiMsg("showScript ${showScript}")
290+
def html = showScript? tomui.getHtmlFromGroovyNode(nodo, script) : nodo.text
291+
uiMsg("html ${html}")
292+
return html
293+
}
294+
287295
def static addActionPane(myP, nodo){
288296
def infoAcciones = []
289297
nodo.children.findAll{n -> toma.hasAction(n)}.each{n ->

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

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,22 @@ class ToM_ui{
4040
static final String myPaneName = 'myContentPanel'
4141
static final String myButtonPanelName = 'aButtonPane'
4242
static final String myNextPanelName = 'nextPane'
43+
static final String htmlStyle =
44+
"""
45+
table {border: 0; border-spacing: 0;}
46+
th, td {border: 1px solid;}
47+
pre {
48+
background-color: rgb(230, 230, 230);
49+
border: 1px solid rgb(0, 0, 0);
50+
display: block;
51+
padding: 10px;
52+
}
53+
code {
54+
font-family: Consolas,"courier new";
55+
color: rgb(0, 80, 0);
56+
}
57+
"""
58+
4359

4460
static SwingBuilder swing = new SwingBuilder()
4561

@@ -95,20 +111,7 @@ class ToM_ui{
95111
case 'markdown':
96112
//html = "<html> ${Marked.marked(nodo.note.plain)} </html>"
97113
html = """<html>
98-
<style>
99-
table {border: 0; border-spacing: 0;}
100-
th, td {border: 1px solid;}
101-
pre {
102-
background-color: rgb(230, 230, 230);
103-
border: 1px solid rgb(0, 0, 0);
104-
display: block;
105-
padding: 10px;
106-
}
107-
code {
108-
font-family: Consolas,"courier new";
109-
color: rgb(0, 80, 0);
110-
}
111-
</style>
114+
<style>${htmlStyle}</style>
112115
<body>
113116
${Marked.marked(nodo.note.plain)}
114117
</body>

0 commit comments

Comments
 (0)