src/Pure/System/gui_setup.scala
author haftmann
Tue Oct 20 16:13:01 2009 +0200 (2009-10-20)
changeset 33037 b22e44496dc2
parent 31928 2d8e50886558
child 34045 bc71778a327d
permissions -rw-r--r--
replaced old_style infixes eq_set, subset, union, inter and variants by generic versions
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@31828
     9
import javax.swing.UIManager
wenzelm@31828
    10
wenzelm@31827
    11
import scala.swing._
wenzelm@31827
    12
import scala.swing.event._
wenzelm@31827
    13
wenzelm@31827
    14
wenzelm@31828
    15
object GUI_Setup extends GUIApplication
wenzelm@31827
    16
{
wenzelm@31828
    17
  def main(args: Array[String]) =
wenzelm@31828
    18
  {
wenzelm@31862
    19
    Swing_Thread.later {
wenzelm@31828
    20
      UIManager.setLookAndFeel(Platform.look_and_feel)
wenzelm@31828
    21
      top.pack()
wenzelm@31828
    22
      top.visible = true
wenzelm@31828
    23
    }
wenzelm@31828
    24
  }
wenzelm@31828
    25
wenzelm@31827
    26
  def top = new MainFrame {
wenzelm@31827
    27
    title = "Isabelle setup"
wenzelm@31827
    28
wenzelm@31843
    29
    // components
wenzelm@31843
    30
    val text = new TextArea {
wenzelm@31843
    31
      editable = false
wenzelm@31860
    32
      columns = 80
wenzelm@31860
    33
      rows = 20
wenzelm@31843
    34
      xLayoutAlignment = 0.5
wenzelm@31843
    35
    }
wenzelm@31843
    36
    val ok = new Button {
wenzelm@31843
    37
      text = "OK"
wenzelm@31843
    38
      xLayoutAlignment = 0.5
wenzelm@31843
    39
    }
wenzelm@31827
    40
    contents = new BoxPanel(Orientation.Vertical) {
wenzelm@31843
    41
      contents += text
wenzelm@31827
    42
      contents += ok
wenzelm@31827
    43
    }
wenzelm@31827
    44
wenzelm@31843
    45
    // values
wenzelm@31843
    46
    Platform.defaults match {
wenzelm@31843
    47
      case None =>
wenzelm@31844
    48
      case Some((name, None)) => text.append("Platform: " + name + "\n")
wenzelm@31843
    49
      case Some((name1, Some(name2))) =>
wenzelm@31844
    50
        text.append("Main platform: " + name1 + "\n")
wenzelm@31844
    51
        text.append("Alternative platform: " + name2 + "\n")
wenzelm@31843
    52
    }
wenzelm@31928
    53
    if (Platform.is_windows) {
wenzelm@31928
    54
      text.append("Cygwin root: " + Cygwin.config()._1 + "\n")
wenzelm@31928
    55
    }
wenzelm@31928
    56
    try {
wenzelm@31928
    57
      val isabelle_system = new Isabelle_System
wenzelm@31928
    58
      text.append("Isabelle home: " + isabelle_system.getenv("ISABELLE_HOME") + "\n")
wenzelm@31928
    59
    } catch {
wenzelm@31928
    60
      case e: RuntimeException => text.append(e.getMessage + "\n")
wenzelm@31928
    61
    }
wenzelm@31843
    62
wenzelm@31843
    63
    // reactions
wenzelm@31827
    64
    listenTo(ok)
wenzelm@31827
    65
    reactions += {
wenzelm@31827
    66
      case ButtonClicked(`ok`) => System.exit(0)
wenzelm@31827
    67
    }
wenzelm@31827
    68
  }
wenzelm@31827
    69
}
wenzelm@31827
    70