src/Tools/jEdit/src/jedit/session_dockable.scala
author wenzelm
Wed Sep 22 16:04:20 2010 +0200 (2010-09-22)
changeset 39591 a43a723753e6
parent 39589 5b81b8df1dde
child 39593 1a34187f0b97
permissions -rw-r--r--
more content for Session_Dockable;
wenzelm@39515
     1
/*  Title:      Tools/jEdit/src/jedit/session_dockable.scala
wenzelm@39515
     2
    Author:     Makarius
wenzelm@39515
     3
wenzelm@39515
     4
Dockable window for prover session management.
wenzelm@39515
     5
*/
wenzelm@39515
     6
wenzelm@39515
     7
package isabelle.jedit
wenzelm@39515
     8
wenzelm@39515
     9
wenzelm@39515
    10
import isabelle._
wenzelm@39515
    11
wenzelm@39515
    12
import scala.actors.Actor._
wenzelm@39591
    13
import scala.swing.{TextArea, ScrollPane, TabbedPane, Component}
wenzelm@39515
    14
wenzelm@39515
    15
import org.gjt.sp.jedit.View
wenzelm@39515
    16
wenzelm@39515
    17
wenzelm@39515
    18
class Session_Dockable(view: View, position: String) extends Dockable(view: View, position: String)
wenzelm@39515
    19
{
wenzelm@39591
    20
  /* main tabs */
wenzelm@39591
    21
wenzelm@39591
    22
  private val readme = new HTML_Panel(Isabelle.system, "SansSerif", 12)
wenzelm@39591
    23
  readme.render_document(Isabelle.system.try_read(List("$JEDIT_HOME/README.html")))
wenzelm@39591
    24
wenzelm@39591
    25
  private val syslog = new TextArea
wenzelm@39591
    26
  syslog.editable = false
wenzelm@39591
    27
wenzelm@39591
    28
  private val tabs = new TabbedPane {
wenzelm@39591
    29
    pages += new TabbedPane.Page("README", Component.wrap(readme))
wenzelm@39591
    30
    pages += new TabbedPane.Page("System log", new ScrollPane(syslog))
wenzelm@39591
    31
  }
wenzelm@39591
    32
wenzelm@39591
    33
  set_content(tabs)
wenzelm@39515
    34
wenzelm@39515
    35
wenzelm@39515
    36
  /* main actor */
wenzelm@39515
    37
wenzelm@39515
    38
  private val main_actor = actor {
wenzelm@39515
    39
    loop {
wenzelm@39515
    40
      react {
wenzelm@39589
    41
        case result: Isabelle_Process.Result =>
wenzelm@39591
    42
          if (result.is_init || result.is_exit || result.is_system || result.is_ready)
wenzelm@39591
    43
            Swing_Thread.now { syslog.append(XML.content(result.message).mkString + "\n") }
wenzelm@39589
    44
wenzelm@39515
    45
        case bad => System.err.println("Session_Dockable: ignoring bad message " + bad)
wenzelm@39515
    46
      }
wenzelm@39515
    47
    }
wenzelm@39515
    48
  }
wenzelm@39515
    49
wenzelm@39589
    50
  override def init() { Isabelle.session.raw_messages += main_actor }
wenzelm@39589
    51
  override def exit() { Isabelle.session.raw_messages -= main_actor }
wenzelm@39515
    52
}