src/Pure/System/system_dialog.scala
changeset 53460 6015a663b889
parent 53458 ddefd18d5ed0
equal deleted inserted replaced
53459:33f773731f0c 53460:6015a663b889
     7 package isabelle
     7 package isabelle
     8 
     8 
     9 
     9 
    10 import java.awt.{GraphicsEnvironment, Point, Font}
    10 import java.awt.{GraphicsEnvironment, Point, Font}
    11 import javax.swing.WindowConstants
    11 import javax.swing.WindowConstants
       
    12 import java.io.{File => JFile, BufferedReader, InputStreamReader}
    12 
    13 
    13 import scala.swing.{ScrollPane, Button, CheckBox, FlowPanel,
    14 import scala.swing.{ScrollPane, Button, CheckBox, FlowPanel,
    14   BorderPanel, Frame, TextArea, Component, Label}
    15   BorderPanel, Frame, TextArea, Component, Label}
    15 import scala.swing.event.ButtonClicked
    16 import scala.swing.event.ButtonClicked
    16 
    17 
    61     try { result.fulfill(_return_code.get) }
    62     try { result.fulfill(_return_code.get) }
    62     catch { case ERROR(_) => }
    63     catch { case ERROR(_) => }
    63   }
    64   }
    64 
    65 
    65   def join(): Int = result.join
    66   def join(): Int = result.join
       
    67   def join_exit(): Nothing = sys.exit(join)
    66 
    68 
    67 
    69 
    68   /* window */
    70   /* window */
    69 
    71 
    70   private class Window extends Frame
    72   private class Window extends Frame
   183   override def theory(session: String, theory: String): Unit =
   185   override def theory(session: String, theory: String): Unit =
   184     echo(session + ": theory " + theory)
   186     echo(session + ": theory " + theory)
   185 
   187 
   186   @volatile private var is_stopped = false
   188   @volatile private var is_stopped = false
   187   override def stopped: Boolean = is_stopped
   189   override def stopped: Boolean = is_stopped
       
   190 
       
   191 
       
   192   /* system operations */
       
   193 
       
   194   def execute(cwd: JFile, env: Map[String, String], args: String*): Int =
       
   195   {
       
   196     val proc = Isabelle_System.raw_execute(cwd, env, true, args: _*)
       
   197     proc.getOutputStream.close
       
   198 
       
   199     val stdout = new BufferedReader(new InputStreamReader(proc.getInputStream, UTF8.charset))
       
   200     try {
       
   201       var line = stdout.readLine
       
   202       while (line != null) {
       
   203         echo(line)
       
   204         line = stdout.readLine
       
   205       }
       
   206     }
       
   207     finally { stdout.close }
       
   208 
       
   209     proc.waitFor
       
   210   }
   188 }
   211 }
   189 
   212