basic wrapper for session build dialog;
authorwenzelm
Wed, 05 Dec 2012 14:19:44 +0100
changeset 50365 82f5aea343e7
parent 50364 ce2796981c0c
child 50366 b1dd455593a9
basic wrapper for session build dialog;
lib/Tools/build_dialog
src/Pure/System/build_dialog.scala
src/Pure/build-jars
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/Tools/build_dialog	Wed Dec 05 14:19:44 2012 +0100
@@ -0,0 +1,63 @@
+#!/usr/bin/env bash
+#
+# Author: Makarius
+#
+# DESCRIPTION: build Isabelle session images via GUI dialog
+
+
+## diagnostics
+
+PRG="$(basename "$0")"
+
+function usage()
+{
+  echo
+  echo "Usage: isabelle $PRG [OPTIONS] SESSION"
+  echo
+  echo "  Options are:"
+  echo "    -d DIR       include session directory"
+  echo
+  echo "  Build Isabelle session images via GUI dialog."
+  echo
+  exit 1
+}
+
+function fail()
+{
+  echo "$1" >&2
+  exit 2
+}
+
+
+## process command line
+
+declare -a INCLUDE_DIRS=()
+
+while getopts "d:" OPT
+do
+  case "$OPT" in
+    d)
+      INCLUDE_DIRS["${#INCLUDE_DIRS[@]}"]="$OPTARG"
+      ;;
+    \?)
+      usage
+      ;;
+  esac
+done
+
+shift $(($OPTIND - 1))
+
+
+# args
+
+[ "$#" -ne 1 ] && usage
+
+SESSION="$1"; shift
+
+
+## main
+
+[ -e "$ISABELLE_HOME/Admin/build" ] && { "$ISABELLE_HOME/Admin/build" jars || exit $?; }
+
+"$ISABELLE_TOOL" java isabelle.Build_Dialog "${INCLUDE_DIRS[@]}" $'\n' "$SESSION"
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/Pure/System/build_dialog.scala	Wed Dec 05 14:19:44 2012 +0100
@@ -0,0 +1,100 @@
+/*  Title:      Pure/System/build_dialog.scala
+    Author:     Makarius
+
+Dialog for session build process.
+*/
+
+package isabelle
+
+
+import scala.swing.{ScrollPane, Button, CheckBox, FlowPanel,
+  BorderPanel, MainFrame, TextArea, SwingApplication}
+import scala.swing.event.ButtonClicked
+
+
+object Build_Dialog extends SwingApplication
+{
+  def startup(args: Array[String]) =
+  {
+    Platform.init_laf()
+
+    try {
+      args.toList match {
+        case Command_Line.Chunks(include_dirs, List(session)) =>
+          val top = build_dialog(include_dirs.map(Path.explode), session)
+          top.pack()
+          top.visible = true
+        case _ => error("Bad arguments:\n" + cat_lines(args))
+      }
+    }
+    catch {
+      case exn: Throwable =>
+        Library.error_dialog(null, "Isabelle build failure",
+          Library.scrollable_text(Exn.message(exn)))
+        sys.exit(2)
+    }
+  }
+
+
+  def build_dialog(include_dirs: List[Path], session: String): MainFrame = new MainFrame
+  {
+    title = "Isabelle session build"
+
+
+    /* controls */
+
+    private var clean_build = false
+    private var system_build = false
+    private var verbose = false
+
+    private val clean = new CheckBox("Clean build") {
+      reactions += { case ButtonClicked(_) => clean_build = this.selected }
+    }
+    clean.selected = clean_build
+    clean.tooltip = "Delete outdated session images"
+
+    private val system = new CheckBox("System build") {
+      reactions += { case ButtonClicked(_) => system_build = this.selected }
+    }
+    system.selected = system_build
+    system.tooltip = "Produce output in $ISABELLE_HOME instead of $ISABELLE_HOME_USER"
+
+    private val verbose_mode = new CheckBox("Verbose mode") {
+      reactions += { case ButtonClicked(_) => verbose = this.selected }
+    }
+    verbose_mode.selected = verbose
+    verbose_mode.tooltip = "More output during build process"
+
+    val controls = new FlowPanel(FlowPanel.Alignment.Right)(clean, system, verbose_mode)
+
+
+    /* text */
+
+    val text = new TextArea {
+      editable = false
+      columns = 80
+      rows = 15
+    }
+
+
+    /* actions */
+
+    val ok = new Button { text = "OK" }
+    val ok_panel = new FlowPanel(FlowPanel.Alignment.Center)(ok)
+
+    listenTo(ok)
+    reactions += {
+      case ButtonClicked(`ok`) => sys.exit(0)
+    }
+
+
+    /* main panel */
+
+    val panel = new BorderPanel
+    panel.layout(controls) = BorderPanel.Position.North
+    panel.layout(new ScrollPane(text)) = BorderPanel.Position.Center
+    panel.layout(ok_panel) = BorderPanel.Position.South
+    contents = panel
+  }
+}
+
--- a/src/Pure/build-jars	Wed Dec 05 14:13:47 2012 +0100
+++ b/src/Pure/build-jars	Wed Dec 05 14:19:44 2012 +0100
@@ -39,6 +39,7 @@
   PIDE/xml.scala
   PIDE/yxml.scala
   System/build.scala
+  System/build_dialog.scala
   System/color_value.scala
   System/command_line.scala
   System/event_bus.scala