src/Tools/jEdit/src/timing_dockable.scala
changeset 73340 0ffcad1f6130
parent 72823 ab1a49ac456b
child 73358 78aa7846e91f
equal deleted inserted replaced
73339:9efdebe24c65 73340:0ffcad1f6130
    37       opaque = false
    37       opaque = false
    38       xAlignment = Alignment.Leading
    38       xAlignment = Alignment.Leading
    39       border = BorderFactory.createEmptyBorder(2, 2, 2, 2)
    39       border = BorderFactory.createEmptyBorder(2, 2, 2, 2)
    40 
    40 
    41       var entry: Entry = null
    41       var entry: Entry = null
    42       override def paintComponent(gfx: Graphics2D)
    42       override def paintComponent(gfx: Graphics2D): Unit =
    43       {
    43       {
    44         def paint_rectangle(color: Color)
    44         def paint_rectangle(color: Color): Unit =
    45         {
    45         {
    46           val size = peer.getSize()
    46           val size = peer.getSize()
    47           val insets = border.getBorderInsets(peer)
    47           val insets = border.getBorderInsets(peer)
    48           val x = insets.left
    48           val x = insets.left
    49           val y = insets.top
    49           val y = insets.top
    79 
    79 
    80   private abstract class Entry
    80   private abstract class Entry
    81   {
    81   {
    82     def timing: Double
    82     def timing: Double
    83     def print: String
    83     def print: String
    84     def follow(snapshot: Document.Snapshot)
    84     def follow(snapshot: Document.Snapshot): Unit
    85   }
    85   }
    86 
    86 
    87   private case class Theory_Entry(name: Document.Node.Name, timing: Double, current: Boolean)
    87   private case class Theory_Entry(name: Document.Node.Name, timing: Double, current: Boolean)
    88     extends Entry
    88     extends Entry
    89   {
    89   {
    90     def print: String =
    90     def print: String =
    91       Time.print_seconds(timing) + "s theory " + quote(name.theory)
    91       Time.print_seconds(timing) + "s theory " + quote(name.theory)
    92     def follow(snapshot: Document.Snapshot) { PIDE.editor.goto_file(true, view, name.node) }
    92     def follow(snapshot: Document.Snapshot): Unit =
       
    93       PIDE.editor.goto_file(true, view, name.node)
    93   }
    94   }
    94 
    95 
    95   private case class Command_Entry(command: Command, timing: Double) extends Entry
    96   private case class Command_Entry(command: Command, timing: Double) extends Entry
    96   {
    97   {
    97     def print: String =
    98     def print: String =
    98       "  " + Time.print_seconds(timing) + "s command " + quote(command.span.name)
    99       "  " + Time.print_seconds(timing) + "s command " + quote(command.span.name)
    99     def follow(snapshot: Document.Snapshot)
   100     def follow(snapshot: Document.Snapshot): Unit =
   100     { PIDE.editor.hyperlink_command(true, snapshot, command.id).foreach(_.follow(view)) }
   101       PIDE.editor.hyperlink_command(true, snapshot, command.id).foreach(_.follow(view))
   101   }
   102   }
   102 
   103 
   103 
   104 
   104   /* timing view */
   105   /* timing view */
   105 
   106 
   173     theories.flatMap(entry =>
   174     theories.flatMap(entry =>
   174       if (entry.name == name) entry.copy(current = true) :: commands
   175       if (entry.name == name) entry.copy(current = true) :: commands
   175       else List(entry))
   176       else List(entry))
   176   }
   177   }
   177 
   178 
   178   private def handle_update(restriction: Option[Set[Document.Node.Name]] = None)
   179   private def handle_update(restriction: Option[Set[Document.Node.Name]] = None): Unit =
   179   {
   180   {
   180     GUI_Thread.require {}
   181     GUI_Thread.require {}
   181 
   182 
   182     val snapshot = PIDE.session.snapshot()
   183     val snapshot = PIDE.session.snapshot()
   183 
   184 
   209     Session.Consumer[Session.Commands_Changed](getClass.getName) {
   210     Session.Consumer[Session.Commands_Changed](getClass.getName) {
   210       case changed =>
   211       case changed =>
   211         GUI_Thread.later { handle_update(Some(changed.nodes)) }
   212         GUI_Thread.later { handle_update(Some(changed.nodes)) }
   212     }
   213     }
   213 
   214 
   214   override def init()
   215   override def init(): Unit =
   215   {
   216   {
   216     PIDE.session.commands_changed += main
   217     PIDE.session.commands_changed += main
   217     handle_update()
   218     handle_update()
   218   }
   219   }
   219 
   220 
   220   override def exit()
   221   override def exit(): Unit =
   221   {
   222   {
   222     PIDE.session.commands_changed -= main
   223     PIDE.session.commands_changed -= main
   223   }
   224   }
   224 }
   225 }