src/Tools/jEdit/src/syslog_dockable.scala
author wenzelm
Mon Apr 28 16:17:07 2014 +0200 (2014-04-28)
changeset 56775 59f70b89e5fd
parent 56715 52125652e82a
child 57612 990ffb84489b
permissions -rw-r--r--
improved syslog performance -- avoid denial-of-service e.g. with threads_trace = 5 and active Syslog dockable;
     1 /*  Title:      Tools/jEdit/src/syslog_dockable.scala
     2     Author:     Makarius
     3 
     4 Dockable window for syslog.
     5 */
     6 
     7 package isabelle.jedit
     8 
     9 
    10 import isabelle._
    11 
    12 import scala.swing.{TextArea, ScrollPane}
    13 
    14 import org.gjt.sp.jedit.View
    15 
    16 
    17 class Syslog_Dockable(view: View, position: String) extends Dockable(view, position)
    18 {
    19   /* GUI components */
    20 
    21   private val syslog = new TextArea()
    22 
    23   private def syslog_delay = Swing_Thread.delay_first(PIDE.options.seconds("editor_update_delay"))
    24   {
    25     val text = PIDE.session.syslog_content()
    26     if (text != syslog.text) syslog.text = text
    27   }
    28 
    29   set_content(new ScrollPane(syslog))
    30 
    31 
    32   /* main */
    33 
    34   private val main =
    35     Session.Consumer[Prover.Output](getClass.getName) { case _ => syslog_delay.invoke() }
    36 
    37   override def init()
    38   {
    39     PIDE.session.syslog_messages += main
    40     syslog_delay.invoke()
    41   }
    42 
    43   override def exit()
    44   {
    45     PIDE.session.syslog_messages -= main
    46   }
    47 }