Advertisement
Guest User

Untitled

a guest
Feb 15th, 2015
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 1.26 KB | None | 0 0
  1.  val mkOk = (comp:Composite) => {
  2.       val ok = new Button(comp, SWT.PUSH)
  3.       ok.setText("OK")
  4.       ok.addSelectionListener(new SelectionAdapter() {
  5.         var running = false
  6.         override def widgetSelected(e: SelectionEvent) {
  7.           if (running) {
  8.  
  9.           } else {
  10.             running = true
  11.             val input = JsonField.mkObject(Seq(t1, t2, t3, t4))
  12.             val t = new TimedThread {
  13.                 var killproc:Option[() => Unit] = None
  14.                 val name = "Send email"
  15.                 val runnable = new Runnable {
  16.                   val (destroy, doact) = exec(Seq("python", "C:/Users/M/Desktop/test.py"), input)
  17.                   killproc = Some(destroy)
  18.  
  19.                   override def run() {
  20.                     Log.info("Sending email")
  21.                     val (out,err,retval) = doact()
  22.                   }
  23.                 }
  24.  
  25.                 override def cleanup() {
  26.                   running = false
  27.                 }
  28.                 override def kill() {
  29.                   try {
  30.                     killproc foreach (_())
  31.                   } catch {
  32.                     case e:Exception => Log.warn(e.getMessage)
  33.                   }
  34.                 }
  35.               }
  36.               t.start()
  37.             }
  38.           }
  39.         })
  40.         ok
  41.       }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement