--- a/src/Pure/System/cygwin_init.scala Sat Sep 07 16:33:10 2013 +0200
+++ b/src/Pure/System/cygwin_init.scala Sat Sep 07 17:11:44 2013 +0200
@@ -1,107 +1,24 @@
/* Title: Pure/System/cygwin_init.scala
Author: Makarius
-Initialize Isabelle distribution after extracting via 7zip.
+Initialize raw Isabelle distribution (e.g. after extraction via 7zip).
*/
package isabelle
import java.io.{File => JFile, BufferedReader, InputStreamReader}
-import java.nio.file.{Paths, Files}
-import java.awt.{GraphicsEnvironment, Point, Font}
-import javax.swing.ImageIcon
+import java.nio.file.Files
import scala.annotation.tailrec
-import scala.swing.{ScrollPane, Button, FlowPanel,
- BorderPanel, MainFrame, TextArea, SwingApplication}
-import scala.swing.event.ButtonClicked
object Cygwin_Init
{
- /* main GUI entry point */
-
- def main_frame(isabelle_home: String, continue: Int => Unit) = new MainFrame
+ def filesystem(system_dialog: System_Dialog, isabelle_home: String)
{
- title = "Isabelle system initialization"
- iconImage = GUI.isabelle_image()
-
- val layout_panel = new BorderPanel
- contents = layout_panel
-
-
- /* text area */
-
- def echo(msg: String) { text_area.append(msg + "\n") }
-
- val text_area = new TextArea {
- font = new Font("SansSerif", Font.PLAIN, GUI.resolution_scale(10) max 14)
- editable = false
- columns = 50
- rows = 15
- }
-
- layout_panel.layout(new ScrollPane(text_area)) = BorderPanel.Position.Center
-
-
- /* exit button */
-
- var _return_code: Option[Int] = None
- def maybe_exit()
- {
- _return_code match {
- case None =>
- case Some(rc) =>
- visible = false
- continue(rc)
- }
- }
-
- def return_code(rc: Int): Unit =
- Swing_Thread.later {
- _return_code = Some(rc)
- button.peer.getRootPane.setDefaultButton(button.peer)
- layout_panel.repaint
- }
-
- override def closeOperation { maybe_exit() }
-
- val button = new Button {
- text = "Done"
- reactions += { case ButtonClicked(_) => maybe_exit() }
- }
- val button_panel = new FlowPanel(FlowPanel.Alignment.Center)(button)
-
- layout_panel.layout(button_panel) = BorderPanel.Position.South
-
-
- /* show window */
-
- pack()
- val point = GraphicsEnvironment.getLocalGraphicsEnvironment().getCenterPoint()
- location = new Point(point.x - size.width / 2, point.y - size.height / 2)
- visible = true
-
- default_thread_pool.submit(() =>
- try {
- init_filesystem(isabelle_home, echo)
- return_code(0)
- }
- catch {
- case exn: Throwable =>
- text_area.append("Error:\n" + Exn.message(exn) + "\n")
- return_code(2)
- }
- )
- }
-
-
- /* init Cygwin file-system */
-
- private def init_filesystem(isabelle_home: String, echo: String => Unit)
- {
- val cygwin_root = isabelle_home + "\\contrib\\cygwin"
+ system_dialog.title("Isabelle system initialization")
+ system_dialog.echo("Initializing Cygwin:")
def execute(args: String*): Int =
{
@@ -114,7 +31,7 @@
try {
var line = stdout.readLine
while (line != null) {
- echo(line)
+ system_dialog.echo(line)
line = stdout.readLine
}
}
@@ -123,9 +40,9 @@
proc.waitFor
}
- echo("Initializing Cygwin:")
+ val cygwin_root = isabelle_home + "\\contrib\\cygwin"
- echo("symlinks ...")
+ system_dialog.echo("symlinks ...")
val symlinks =
{
val path = (new JFile(cygwin_root + "\\isabelle\\symlinks")).toPath
@@ -150,15 +67,15 @@
}
recover_symlinks(symlinks)
- echo("rebaseall ...")
+ system_dialog.echo("rebaseall ...")
execute(cygwin_root + "\\bin\\dash.exe", "/isabelle/rebaseall")
- echo("postinstall ...")
+ system_dialog.echo("postinstall ...")
execute(cygwin_root + "\\bin\\bash.exe", "/isabelle/postinstall")
- echo("init ...")
+ system_dialog.echo("init ...")
Isabelle_System.init()
- echo("OK")
+ system_dialog.echo("OK")
}
}