/
BHtml.scala
495 lines (384 loc) · 18.9 KB
/
BHtml.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
/* {{{
* Copyright 2012 Franz Bettag <franz@bett.ag>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/// }}}
package ag.bett.lift.bhtml
import net.liftweb.common._
import net.liftweb.mapper._
import net.liftweb.actor._
import net.liftweb.util._
import net.liftweb.util.Helpers._
import net.liftweb.http._
import net.liftweb.http.js._
import net.liftweb.http.js.JsCmds._
import net.liftweb.http.js.JE.JsRaw
import net.liftweb.http.js.JsCmd
import org.joda.time._
import org.joda.time.format._
import scala.xml._
/**
* Adds support for [[http://twitter.github.com/bootstrap Twitter Bootstrap]] CSS-classes for validation, also makes validation for all
* KeyedMapper-derived Models easy through a [[http://twitter.github.com/bootstrap/javascript.html#popover Twitter BootstrapJS Popover]].
*
* All selectors are [[http://api.jquery.com/category/selectors/ jQuery Selectors]].
*
* The <i>save</i>-parameter makes fields auto-commit/auto-save the record on Event (blur).
*
*/
object BHtml {
/**
* Delay a JsCmd
*/
def delay(d: Int, js: JsCmd) = JsRaw("""window.setTimeout(function() {%s}, %s);""".format(js.toJsCmd, d))
/**
* Hide elements matching the jQuery CSS-Selector
*/
def hide(sel: String): JsCmd = JsRaw("""$('%s').hide()""".format(sel))
/**
* Show elements matching the jQuery CSS-Selector
*/
def show(sel: String): JsCmd = JsRaw("""$('%s').show()""".format(sel))
/**
* Toggle elements matching the jQuery CSS-Selector
*/
def toggle(sel: String): JsCmd = JsRaw("""$('%s').toggle()""".format(sel))
object Fx {
/**
* Pulsate elements matching the jQuery CSS-Selector
*/
def success(sel: String): JsCmd =
JsRaw("""$('%s').effect('pulsate', {times: 2}, 200)""".format(sel)).cmd
/**
* Pulsate elements matching the jQuery CSS-Selector
*/
def failed(sel: String): JsCmd =
JsRaw("""$('%s').effect('pulsate', {times: 2}, 200)""".format(sel)).cmd
/**
* Render a List[FieldError] as <code><ul><li/></ul></code> and mark elements invalid using the jQuery CSS-Selector
*/
def invalid(sel: String, errors: List[FieldError]): JsCmd =
invalidated(sel, S.??("Error"), <ul>{errors.map(fe => <li>{fe.msg}</li>)}</ul>)
/**
* Add the CSS-Class <i>success</i> and remove <i>error</i>, also repair from popover for elements matching the jQuery CSS-Selector
*/
def validated(sel: String): JsCmd =
JsRaw("""$('%s').removeClass('error').addClass('success').removeAttr('title data-original-title data-content')""".format(sel)).cmd
/**
* Remove the CSS-Class <i>success</i> and add <i>error</i> for elements matching the jQuery CSS-Selector
*/
def invalidated(sel: String): JsCmd =
JsRaw("""$('%s').removeClass('success').addClass('error')""".format(sel)).cmd
/**
* Remove the CSS-Class <i>success</i> and add <i>error</i> for elements matching the jQuery CSS-Selector and also generate a
* [[http://twitter.github.com/bootstrap/javascript.html#popover JavaScript Popover]].
*/
def invalidated(sel: String, title: String, body: String): JsCmd =
invalidated(sel, title, Text(body))
/**
* Remove the CSS-Class <i>success</i> and add <i>error</i> for elements matching the jQuery CSS-Selector and also generate a
* [[http://twitter.github.com/bootstrap/javascript.html#popover JavaScript Popover]].
*/
def invalidated(sel: String, title: String, body: NodeSeq): JsCmd =
invalidated(sel) & popover(sel, title, body) & delay(2000, JsRaw("""$('%s').popover('hide')""".format(sel)).cmd)
/**
* Reset the CSS-Classes <i>success</i>, <i>error</i> and repair from popover for elements matching the jQuery CSS-Selector
*/
def reset(sel: String): JsCmd =
JsRaw("""$('%s').removeClass('error').removeClass('success').removeAttr('title data-original-title data-content')""".format(sel)).cmd
/**
* Fadeout elements matching the jQuery CSS-Selector
*/
def remove(sel: String): JsCmd =
JsRaw("""$('%s').fadeOut(400).hide(function() { $('%s').remove(); })""".format(sel, sel)).cmd
/**
* Generate a [[http://twitter.github.com/bootstrap/javascript.html#popover JavaScript Popover]]
*/
def popover(sel: String, title: String, body: NodeSeq): JsCmd =
JsRaw("""$('%s').attr('title', "%s").attr('data-content', "%s").popover({ offset: 10, html: true }).popover('show').click(function(e) { e.preventDefault() })"""
.format(sel, title.replaceAll("\"", "\\\""), body.toString.replaceAll("\"", "\\\""))).cmd
}
/** Makes JsCmd into () => JsCmd */
implicit def jsCmd2JsFutureFunction(js: JsCmd) = { () => js }
/** Casts a String into [[java.net.InetAddress]] using InetUtils */
implicit def string2InetAddress(addr: String): java.net.InetAddress = InetUtils.getAddress(addr)
/**
* Generates an ID unique for this record <b>(restrictions apply)</b>
* <b>If the MappedField's fieldOwner is NOT SAVED, this will have -1. Be sure to only have one unsaved per Model on your page.</b>
*/
def getCssId[K, T <: KeyedMapper[K, T]](a: MappedField[K, T]) = "BF-%s-%s".format(a.uniqueFieldId.open_!, a.fieldOwner.primaryKeyField.is)
/**
* Save a Record
*/
def save[K, T <: KeyedMapper[K, T]](a: T, jsSuccess: () => JsCmd = () => Noop, jsFail: () => JsCmd = () => Noop) = {
SHtml.ajaxInvoke(() => {
if (a.validate.length == 0 && a.save) jsSuccess()
else jsFail() & a.allFields.map(bf => {
val css = ".BF-%s-%s".format(bf.uniqueFieldId.open_!, a.primaryKeyField.is)
if (bf.validate.length == 0) Fx.reset(css)
else Fx.invalid(css, bf.validate)
})
})
}
/**
* Reload the record and discard changes, also reset validations.
*/
def reset[K, T <: KeyedMapper[K, T]](a: T) =
SHtml.ajaxInvoke(() => { a.reload; resetValidation[K, T](a) })
/**
* Reset validations for a Record
*/
def resetValidation[K, T <: KeyedMapper[K, T]](a: T): JsCmd =
a.allFields.map(bf => Fx.reset(".BF-%s-%s".format(bf.uniqueFieldId.open_!, a.primaryKeyField.is)))
def checkbox[K, T <: KeyedMapper[K, T]](a: MappedBoolean[T], save: Boolean, jsSuccess: () => JsCmd): NodeSeq =
checkbox[K, T](a, save, Empty, jsSuccess)
def checkbox[K, T <: KeyedMapper[K, T]](a: MappedBoolean[T], save: Boolean, cssSel: String): NodeSeq =
checkbox[K, T](a, save, Full(cssSel))
def checkbox[K, T <: KeyedMapper[K, T]](a: MappedBoolean[T], save: Boolean = false, cssSel: Box[String] = Empty, jsSuccess: () => JsCmd = () => Noop): NodeSeq = {
val cssId = getCssId[K, T](a.asInstanceOf[MappedField[K, T]])
def update(v: Boolean) = {
a.set(v)
if (!save) jsSuccess()
else {
if (a.fieldOwner.save) Fx.success(cssSel openOr("." + cssId)) & jsSuccess()
else Fx.failed(cssSel openOr("." + cssId))
}
}
SHtml.ajaxCheckbox(a.is, update(_), "class" -> cssId)
}
def text[K, T <: KeyedMapper[K, T]](a: MappedString[T], save: Boolean): NodeSeq =
text[K, T](a, Empty, save, Empty)
def text[K, T <: KeyedMapper[K, T]](a: MappedString[T], save: Boolean, cssClass: String): NodeSeq =
text[K, T](a, Empty, save, Full(cssClass))
def text[K, T <: KeyedMapper[K, T]](a: MappedString[T], save: Boolean, jsSuccess: () => JsCmd, jsFail: () => JsCmd): NodeSeq =
text[K, T](a, Empty, save, Empty, jsSuccess, jsFail)
def text[K, T <: KeyedMapper[K, T]](a: MappedString[T], save: Boolean, cssClass: String, jsSuccess: () => JsCmd, jsFail: () => JsCmd): NodeSeq =
text[K, T](a, Empty, save, Full(cssClass), jsSuccess, jsFail)
def text[K, T <: KeyedMapper[K, T]](a: MappedString[T], value: Box[String] = Empty, save: Boolean = false, cssClass: Box[String] = Empty, jsSuccess: () => JsCmd = () => Noop, jsFail: () => JsCmd = () => Noop): NodeSeq = {
val cssId = getCssId[K, T](a.asInstanceOf[MappedField[K, T]])
val css = cssId + " " + (cssClass match { case Full(s) => " " + s case _ => "" })
def update(v: String) = {
a.set(v)
val errors = a.validate
// validation went ok
if (errors.length == 0) Fx.validated("." + cssId) & jsSuccess() & {
// saving went ok
if (!save) Noop else if (a.fieldOwner.save) Fx.success("." + cssId) else Fx.failed("." + cssId)
} else Fx.invalid("." + cssId, errors) & jsFail()
}
SHtml.ajaxText(value openOr a.is, update(_), "class" -> css)
}
def textarea[K, T <: KeyedMapper[K, T]](a: MappedString[T], save: Boolean): NodeSeq =
textarea[K, T](a, Empty, save, Empty)
def textarea[K, T <: KeyedMapper[K, T]](a: MappedString[T], save: Boolean, cssClass: String): NodeSeq =
textarea[K, T](a, Empty, save, Full(cssClass))
def textarea[K, T <: KeyedMapper[K, T]](a: MappedString[T], save: Boolean, jsSuccess: () => JsCmd, jsFail: () => JsCmd): NodeSeq =
textarea[K, T](a, Empty, save, Empty, jsSuccess, jsFail)
def textarea[K, T <: KeyedMapper[K, T]](a: MappedString[T], save: Boolean, cssClass: String, jsSuccess: () => JsCmd, jsFail: () => JsCmd): NodeSeq =
textarea[K, T](a, Empty, save, Full(cssClass), jsSuccess, jsFail)
def textarea[K, T <: KeyedMapper[K, T]](a: MappedString[T], value: Box[String] = Empty, save: Boolean = false, cssClass: Box[String] = Empty, jsSuccess:
() => JsCmd = () => Noop, jsFail: () => JsCmd = () => Noop): NodeSeq = {
val cssId = getCssId[K, T](a.asInstanceOf[MappedField[K, T]])
val css = cssId + " " + (cssClass match { case Full(s) => " " + s case _ => "" })
def update(v: String) = {
a.set(v)
val errors = a.validate
// validation went ok
if (errors.length == 0) Fx.validated("." + cssId) & jsSuccess() & {
// saving went ok
if (!save) Noop else if (a.fieldOwner.save) Fx.success("." + cssId) else Fx.failed("." + cssId)
} else Fx.invalid("." + cssId, errors) & jsFail()
}
SHtml.ajaxTextarea(value openOr a.is, update(_), "class" -> css)
}
/**
* e.g. select[String, StringKeyedClass, Long, LongKeyedClass](..)
*
* @param choices List[(ForeignKeyType, ForeignKeyModel)]
*/
def select[K, T <: KeyedMapper[K, T], OK, O <: KeyedMapper[OK, O]](a: MappedForeignKey[OK, T, O], choices: List[(OK, String)] = List(), save: Boolean = false, cssClass: Box[String] = Empty, jsSuccess: () => JsCmd = () => Noop, jsFail: () => JsCmd = () => Noop): NodeSeq = {
val cssId = getCssId[K, T](a.asInstanceOf[MappedField[K, T]])
val css = cssId + " " + (cssClass match { case Full(s) => " " + s case _ => "" })
def update(v: OK) = {
a.set(v)
val errors = a.validate
// validation went ok
if (errors.length == 0) Fx.validated("." + cssId) & jsSuccess() & {
// saving went ok
if (!save) Noop else if (a.fieldOwner.save) Fx.success("." + cssId) else Fx.failed("." + cssId)
} else Fx.invalid("." + cssId, errors) & jsFail()
}
SHtml.ajaxSelectObj[OK](choices, Full(a.is), update(_), "class" -> css)
}
def int[K, T <: KeyedMapper[K, T]](a: MappedInt[T], cssClass: String): NodeSeq =
int[K, T](a, false, Full(cssClass))
def int[K, T <: KeyedMapper[K, T]](a: MappedInt[T], save: Boolean, cssClass: String): NodeSeq =
int[K, T](a, save, Full(cssClass))
def int[K, T <: KeyedMapper[K, T]](a: MappedInt[T], save: Boolean, cssClass: String, jsSuccess: () => JsCmd, jsFail: () => JsCmd): NodeSeq =
int[K, T](a, save, Full(cssClass), jsSuccess, jsFail)
def int[K, T <: KeyedMapper[K, T]](a: MappedInt[T], save: Boolean = false, cssClass: Box[String] = Empty, jsSuccess: () => JsCmd = () => Noop, jsFail: () => JsCmd = () => Noop): NodeSeq = {
val cssId = getCssId[K, T](a.asInstanceOf[MappedField[K, T]])
val css = cssId + " " + (cssClass match { case Full(s) => " " + s case _ => "" })
def saving = Fx.validated("." + cssId) & jsSuccess() & (if (!save) Noop else if (a.fieldOwner.save) Fx.success("." + cssId) else Fx.failed("." + cssId))
def update(v: String): JsCmd =
try {
a(v.toInt)
if (a.validate.length == 0) saving
else Fx.invalid("." + cssId, a.validate) & jsFail()
} catch { // not a number
case _ => Fx.invalidated("." + cssId, S.??("Error"), S.??("must.be.a.number")) & jsFail()
}
SHtml.ajaxText(a.is.toString, update(_), "class" -> css, "pattern" -> "[0-9]+")
}
def intOptional[K, T <: KeyedMapper[K, T]](a: MappedNullableInt[T], cssClass: String): NodeSeq =
intOptional[K, T](a, false, Full(cssClass))
def intOptional[K, T <: KeyedMapper[K, T]](a: MappedNullableInt[T], save: Boolean, cssClass: String): NodeSeq =
intOptional[K, T](a, save, Full(cssClass))
def intOptional[K, T <: KeyedMapper[K, T]](a: MappedNullableInt[T], save: Boolean, cssClass: String, jsSuccess: () => JsCmd, jsFail: () => JsCmd): NodeSeq =
intOptional[K, T](a, save, Full(cssClass), jsSuccess, jsFail)
def intOptional[K, T <: KeyedMapper[K, T]](a: MappedNullableInt[T], save: Boolean = false, cssClass: Box[String] = Empty, jsSuccess: () => JsCmd = Noop, jsFail: () => JsCmd = Noop): NodeSeq = {
val cssId = getCssId[K, T](a.asInstanceOf[MappedField[K, T]])
val css = cssId + " " + (cssClass match { case Full(s) => " " + s case _ => "" })
def saving = Fx.validated("." + cssId) & jsSuccess() & (if (!save) Noop else if (a.fieldOwner.save) Fx.success("." + cssId) else Fx.failed("." + cssId))
def update(v: String): JsCmd = if (v.matches("(|0(\\.0+)?)")) { a(Empty); saving } else
try {
a(Full(v.toInt))
if (a.validate.length == 0) saving
else Fx.invalid("." + cssId, a.validate) & jsFail()
} catch { // not a number
case _ => Fx.invalidated("." + cssId, S.??("Error"), S.??("must.be.a.number")) & jsFail()
}
SHtml.ajaxText(a.is.toString, update(_), "class" -> css, "pattern" -> "[0-9]*")
}
def float[K, T <: KeyedMapper[K, T]](a: MappedDecimal[T], cssClass: String): NodeSeq =
float[K, T](a, false, Full(cssClass))
def float[K, T <: KeyedMapper[K, T]](a: MappedDecimal[T], save: Boolean, cssClass: String): NodeSeq =
float[K, T](a, save, Full(cssClass))
def float[K, T <: KeyedMapper[K, T]](a: MappedDecimal[T], save: Boolean, cssClass: String, jsSuccess: () => JsCmd, jsFail: () => JsCmd): NodeSeq =
float[K, T](a, save, Full(cssClass), jsSuccess, jsFail)
def float[K, T <: KeyedMapper[K, T]](a: MappedDecimal[T], save: Boolean = false, cssClass: Box[String] = Empty, jsSuccess: () => JsCmd = () => Noop, jsFail: () => JsCmd = () => Noop): NodeSeq = {
val cssId = getCssId[K, T](a.asInstanceOf[MappedField[K, T]])
val css = cssId + " " + (cssClass match { case Full(s) => " " + s case _ => "" })
def saving = Fx.validated("." + cssId) & jsSuccess() & (if (!save) Noop else if (a.fieldOwner.save) Fx.success("." + cssId) else Fx.failed("." + cssId))
def update(v: String): JsCmd =
try {
a(BigDecimal(v.replaceAll(",", ".")))
if (a.validate.length == 0) saving
else Fx.invalid("." + cssId, a.validate) & jsFail()
} catch { // not a number
case _ => Fx.invalidated("." + cssId, S.??("Error"), S.??("must.be.a.number.or.float")) & jsFail()
}
SHtml.ajaxText(a.is.toString, update(_), "class" -> css, "pattern" -> "[0-9.,]+")
}
def floatOptional[K, T <: KeyedMapper[K, T]](a: MappedNullableDecimal[T], cssClass: String): NodeSeq =
floatOptional[K, T](a, false, Full(cssClass))
def floatOptional[K, T <: KeyedMapper[K, T]](a: MappedNullableDecimal[T], save: Boolean, cssClass: String): NodeSeq =
floatOptional[K, T](a, save, Full(cssClass))
def floatOptional[K, T <: KeyedMapper[K, T]](a: MappedNullableDecimal[T], save: Boolean, cssClass: String, jsSuccess: () => JsCmd, jsFail: () => JsCmd): NodeSeq =
floatOptional[K, T](a, save, Full(cssClass), jsSuccess, jsFail)
def floatOptional[K, T <: KeyedMapper[K, T]](a: MappedNullableDecimal[T], save: Boolean = false, cssClass: Box[String] = Empty, jsSuccess: () => JsCmd = Noop, jsFail: () => JsCmd = Noop): NodeSeq = {
val cssId = getCssId[K, T](a.asInstanceOf[MappedField[K, T]])
val css = cssId + " " + (cssClass match { case Full(s) => " " + s case _ => "" })
def saving = Fx.validated("." + cssId) & jsSuccess() & (if (!save) Noop else if (a.fieldOwner.save) Fx.success("." + cssId) else Fx.failed("." + cssId))
def update(v: String): JsCmd = if (v.matches("(|0(\\.0+)?)")) { a(Empty); saving } else
try {
a(Full(BigDecimal(v.replaceAll(",", "."))))
if (a.validate.length == 0) saving
else Fx.invalid("." + cssId, a.validate) & jsFail()
} catch { // not a number
case _ => Fx.invalidated("." + cssId, S.??("Error"), S.??("must.be.a.number.or.float")) & jsFail()
}
SHtml.ajaxText(a.is.toString, update(_), "class" -> css, "pattern" -> "[0-9.,]*")
}
}
object InetUtils {
/**
* Converts given String to [[java.net.InetAddress]]
*
* @param addr Valid IPv4 or IPv6 Address
*/
def getAddress(addr: String): java.net.InetAddress = {
val subnetStripped = addr.replaceAll("/[0-9]+$", "")
java.net.InetAddress.getByAddress({
if (addr.matches(".*\\..*"))
sun.net.util.IPAddressUtil.textToNumericFormatV4(subnetStripped)
else
sun.net.util.IPAddressUtil.textToNumericFormatV6(subnetStripped)
})
}
/**
* Converts given IP Address (as String) to PTR form
*
* @param addr Valid IPv4 or IPv6 Address
*/
def getPtr(addr: java.net.InetAddress): String = {
if (addr.toString().matches(".*\\..*"))
addr.toString().replaceAll("^/|/[0-9]+$", "").split("\\.").reverse.mkString(".") + ".in-addr.arpa"
else
addr.toString().replaceAll("^/|:|/[0-9]+$", "").split("").reverse.mkString(".") + ".ip6.arpa"
}
/**
* Converts given IP Address (as String) to PTR form
*
* @param addr Valid IPv4 or IPv6 Address as String
*/
def getPtr(addr: String): String = getPtr(getAddress(addr))
}
/**
* Extend a snippet and use val <b>month</b> which holds a [[org.joda.time.DateTime]] of the param passed as <i>month</i> (e.g. ?month=2012-01)
*
* Falls back to current Month
*/
trait MonthSnippet {
val month = S.param("month") match {
case Full(a: String) =>
if (a.matches("[0-9]{1,2}"))
try {
DateTimeFormat.forPattern("yyyy-MM-dd").parseDateTime((new DateTime).toString("yyyy-%02d-01".format(a)))
} catch {
case _ => new DateTime
}
else
try {
DateTimeFormat.forPattern("yyyy-MM-dd").parseDateTime(a + "-01")
} catch {
case _ => new DateTime
}
case _ => new DateTime
}
}
import java.lang.reflect._
import java.io._
/**
* Extend a snippet and use method <b>shellExec</b> to execute a command and get the output
*
* Method workDir provides easy access to a Property <b>script.dir</b> to be set in Liftweb's properties-file.
*/
trait ExecSnippet {
def workDir = Props.get("script.dir") openOr "/tmp/i.didnt.configure.jack"
def shellExec(cmds: List[String]): List[String] = {
val process = Runtime.getRuntime.exec(cmds.toArray)
val resultBuffer = new BufferedReader(new InputStreamReader(process.getInputStream))
var retList = List[String]()
var line: String = null
do {
line = resultBuffer.readLine
if (line != null) {
retList = line :: retList
}
} while (line != null)
process.waitFor
resultBuffer.close
retList.reverse
}
}