src/Pure/System/gui_setup.scala
author wenzelm
Thu Aug 02 12:36:54 2012 +0200 (2012-08-02)
changeset 48646 91281e9472d8
parent 48192 07a32140ce0d
child 50652 ead5714cc480
permissions -rw-r--r--
more official command specifications, including source position;
wenzelm@31827
     1
/*  Title:      Pure/System/gui_setup.scala
wenzelm@31827
     2
    Author:     Makarius
wenzelm@31827
     3
wenzelm@31827
     4
GUI for basic system setup.
wenzelm@31827
     5
*/
wenzelm@31827
     6
wenzelm@31827
     7
package isabelle
wenzelm@31827
     8
wenzelm@43520
     9
import java.lang.System
wenzelm@43520
    10
wenzelm@47710
    11
import scala.swing.{ScrollPane, Button, FlowPanel,
wenzelm@47710
    12
  BorderPanel, MainFrame, TextArea, SwingApplication}
wenzelm@36994
    13
import scala.swing.event.ButtonClicked
wenzelm@31827
    14
wenzelm@31827
    15
wenzelm@36678
    16
object GUI_Setup extends SwingApplication
wenzelm@31827
    17
{
wenzelm@36678
    18
  def startup(args: Array[String]) =
wenzelm@31828
    19
  {
wenzelm@36786
    20
    Platform.init_laf()
wenzelm@36678
    21
    top.pack()
wenzelm@36678
    22
    top.visible = true
wenzelm@31828
    23
  }
wenzelm@31828
    24
wenzelm@31827
    25
  def top = new MainFrame {
wenzelm@31827
    26
    title = "Isabelle setup"
wenzelm@31827
    27
wenzelm@31843
    28
    // components
wenzelm@31843
    29
    val text = new TextArea {
wenzelm@31843
    30
      editable = false
wenzelm@31860
    31
      columns = 80
wenzelm@31860
    32
      rows = 20
wenzelm@31843
    33
    }
wenzelm@36994
    34
    val ok = new Button { text = "OK" }
wenzelm@36994
    35
    val ok_panel = new FlowPanel(FlowPanel.Alignment.Center)(ok)
wenzelm@36994
    36
wenzelm@36994
    37
    val panel = new BorderPanel
wenzelm@47710
    38
    panel.layout(new ScrollPane(text)) = BorderPanel.Position.Center
wenzelm@36994
    39
    panel.layout(ok_panel) = BorderPanel.Position.South
wenzelm@36994
    40
    contents = panel
wenzelm@31827
    41
wenzelm@31843
    42
    // values
wenzelm@36195
    43
    if (Platform.is_windows)
wenzelm@47998
    44
      text.append("Cygwin root: " + Standard_System.cygwin_root() + "\n")
wenzelm@41381
    45
    text.append("JVM name: " + Platform.jvm_name + "\n")
wenzelm@36207
    46
    text.append("JVM platform: " + Platform.jvm_platform + "\n")
wenzelm@47113
    47
    text.append("JVM home: " + java.lang.System.getProperty("java.home") + "\n")
wenzelm@31928
    48
    try {
wenzelm@43661
    49
      Isabelle_System.init()
wenzelm@43661
    50
      text.append("ML platform: " + Isabelle_System.getenv("ML_PLATFORM") + "\n")
wenzelm@43661
    51
      text.append("Isabelle platform: " + Isabelle_System.getenv("ISABELLE_PLATFORM") + "\n")
wenzelm@43661
    52
      val platform64 = Isabelle_System.getenv("ISABELLE_PLATFORM64")
wenzelm@36197
    53
      if (platform64 != "") text.append("Isabelle platform (64 bit): " + platform64 + "\n")
wenzelm@43661
    54
      text.append("Isabelle home: " + Isabelle_System.getenv("ISABELLE_HOME") + "\n")
wenzelm@47467
    55
      val isabelle_home_windows = Isabelle_System.getenv("ISABELLE_HOME_WINDOWS")
wenzelm@47467
    56
      if (isabelle_home_windows != "")
wenzelm@47467
    57
        text.append("Isabelle home (Windows): " + isabelle_home_windows + "\n")
wenzelm@48017
    58
      text.append("Isabelle JDK home: " + Isabelle_System.getenv("ISABELLE_JDK_HOME") + "\n")
wenzelm@43661
    59
    }
wenzelm@43661
    60
    catch { case ERROR(msg) => text.append(msg + "\n") }
wenzelm@31843
    61
wenzelm@31843
    62
    // reactions
wenzelm@31827
    63
    listenTo(ok)
wenzelm@31827
    64
    reactions += {
wenzelm@48192
    65
      case ButtonClicked(`ok`) => sys.exit(0)
wenzelm@31827
    66
    }
wenzelm@31827
    67
  }
wenzelm@31827
    68
}
wenzelm@31827
    69