src/Tools/jEdit/src/jedit/protocol_dockable.scala
author wenzelm
Sat May 22 22:05:41 2010 +0200 (2010-05-22)
changeset 37067 31093f3687b5
parent 37065 2a73253b5898
child 38423 a9cff3f2e479
permissions -rw-r--r--
simplified dockables using class Dockable;
wenzelm@36760
     1
/*  Title:      Tools/jEdit/src/jedit/protocol_dockable.scala
wenzelm@36760
     2
    Author:     Makarius
wenzelm@36760
     3
wenzelm@37067
     4
Dockable window for protocol messages.
wenzelm@36760
     5
*/
wenzelm@34408
     6
wenzelm@34318
     7
package isabelle.jedit
wenzelm@34318
     8
wenzelm@34318
     9
wenzelm@36015
    10
import isabelle._
wenzelm@36015
    11
wenzelm@34772
    12
import scala.actors.Actor._
wenzelm@37067
    13
import scala.swing.{TextArea, ScrollPane}
wenzelm@34318
    14
wenzelm@34318
    15
import org.gjt.sp.jedit.View
wenzelm@34424
    16
wenzelm@34318
    17
wenzelm@37067
    18
class Protocol_Dockable(view: View, position: String) extends Dockable(view, position)
wenzelm@34760
    19
{
wenzelm@37067
    20
  private val text_area = new TextArea
wenzelm@37067
    21
  set_content(new ScrollPane(text_area))
wenzelm@34772
    22
wenzelm@34772
    23
wenzelm@37067
    24
  /* main actor */
immler@34671
    25
wenzelm@37067
    26
  private val main_actor = actor {
wenzelm@34772
    27
    loop {
wenzelm@34772
    28
      react {
wenzelm@34772
    29
        case result: Isabelle_Process.Result =>
wenzelm@36987
    30
          Swing_Thread.now { text_area.append(result.message.toString + "\n") }
wenzelm@34772
    31
wenzelm@37067
    32
        case bad => System.err.println("Protocol_Dockable: ignoring bad message " + bad)
wenzelm@34772
    33
      }
wenzelm@34772
    34
    }
wenzelm@34772
    35
  }
wenzelm@34772
    36
wenzelm@37067
    37
  override def init() { Isabelle.session.raw_results += main_actor }
wenzelm@37067
    38
  override def exit() { Isabelle.session.raw_results -= main_actor }
wenzelm@34318
    39
}