src/Tools/jEdit/src/timing_dockable.scala
author wenzelm
Thu, 20 Feb 2014 14:36:17 +0100
changeset 55618 995162143ef4
parent 53711 8ce7795256e1
child 55877 65c9968286d5
permissions -rw-r--r--
tuned imports;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
51533
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
     1
/*  Title:      Tools/jEdit/src/timing_dockable.scala
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
     2
    Author:     Makarius
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
     3
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
     4
Dockable window for timing information.
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
     5
*/
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
     6
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
     7
package isabelle.jedit
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
     8
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
     9
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
    10
import isabelle._
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
    11
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
    12
import scala.actors.Actor._
53711
8ce7795256e1 improved FlowLayout for wrapping of components over multiple lines;
wenzelm
parents: 53177
diff changeset
    13
import scala.swing.{Label, ListView, Alignment, ScrollPane, Component, TextField}
51538
637e64effda2 proper input event handling;
wenzelm
parents: 51536
diff changeset
    14
import scala.swing.event.{MouseClicked, ValueChanged}
51533
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
    15
51536
a1d324ef12d4 more specific Entry painting;
wenzelm
parents: 51534
diff changeset
    16
import java.awt.{BorderLayout, Graphics2D, Insets, Color}
51533
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
    17
import javax.swing.{JList, BorderFactory}
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
    18
import javax.swing.border.{BevelBorder, SoftBevelBorder}
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
    19
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
    20
import org.gjt.sp.jedit.{View, jEdit}
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
    21
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
    22
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
    23
class Timing_Dockable(view: View, position: String) extends Dockable(view, position)
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
    24
{
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
    25
  /* entry */
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
    26
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
    27
  private object Entry
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
    28
  {
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
    29
    object Ordering extends scala.math.Ordering[Entry]
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
    30
    {
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
    31
      def compare(entry1: Entry, entry2: Entry): Int =
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
    32
        entry2.timing compare entry1.timing
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
    33
    }
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
    34
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
    35
    object Renderer_Component extends Label
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
    36
    {
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
    37
      opaque = false
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
    38
      xAlignment = Alignment.Leading
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
    39
      border = BorderFactory.createEmptyBorder(2, 2, 2, 2)
51536
a1d324ef12d4 more specific Entry painting;
wenzelm
parents: 51534
diff changeset
    40
a1d324ef12d4 more specific Entry painting;
wenzelm
parents: 51534
diff changeset
    41
      var entry: Entry = null
a1d324ef12d4 more specific Entry painting;
wenzelm
parents: 51534
diff changeset
    42
      override def paintComponent(gfx: Graphics2D)
a1d324ef12d4 more specific Entry painting;
wenzelm
parents: 51534
diff changeset
    43
      {
a1d324ef12d4 more specific Entry painting;
wenzelm
parents: 51534
diff changeset
    44
        def paint_rectangle(color: Color)
a1d324ef12d4 more specific Entry painting;
wenzelm
parents: 51534
diff changeset
    45
        {
a1d324ef12d4 more specific Entry painting;
wenzelm
parents: 51534
diff changeset
    46
          val size = peer.getSize()
a1d324ef12d4 more specific Entry painting;
wenzelm
parents: 51534
diff changeset
    47
          val insets = border.getBorderInsets(peer)
a1d324ef12d4 more specific Entry painting;
wenzelm
parents: 51534
diff changeset
    48
          val x = insets.left
a1d324ef12d4 more specific Entry painting;
wenzelm
parents: 51534
diff changeset
    49
          val y = insets.top
a1d324ef12d4 more specific Entry painting;
wenzelm
parents: 51534
diff changeset
    50
          val w = size.width - x - insets.right
a1d324ef12d4 more specific Entry painting;
wenzelm
parents: 51534
diff changeset
    51
          val h = size.height - y - insets.bottom
a1d324ef12d4 more specific Entry painting;
wenzelm
parents: 51534
diff changeset
    52
          gfx.setColor(color)
a1d324ef12d4 more specific Entry painting;
wenzelm
parents: 51534
diff changeset
    53
          gfx.fillRect(x, y, w, h)
a1d324ef12d4 more specific Entry painting;
wenzelm
parents: 51534
diff changeset
    54
        }
a1d324ef12d4 more specific Entry painting;
wenzelm
parents: 51534
diff changeset
    55
a1d324ef12d4 more specific Entry painting;
wenzelm
parents: 51534
diff changeset
    56
        entry match {
a1d324ef12d4 more specific Entry painting;
wenzelm
parents: 51534
diff changeset
    57
          case theory_entry: Theory_Entry if theory_entry.current =>
a1d324ef12d4 more specific Entry painting;
wenzelm
parents: 51534
diff changeset
    58
            paint_rectangle(view.getTextArea.getPainter.getSelectionColor)
a1d324ef12d4 more specific Entry painting;
wenzelm
parents: 51534
diff changeset
    59
          case _: Command_Entry =>
a1d324ef12d4 more specific Entry painting;
wenzelm
parents: 51534
diff changeset
    60
            paint_rectangle(view.getTextArea.getPainter.getMultipleSelectionColor)
a1d324ef12d4 more specific Entry painting;
wenzelm
parents: 51534
diff changeset
    61
          case _ =>
a1d324ef12d4 more specific Entry painting;
wenzelm
parents: 51534
diff changeset
    62
        }
a1d324ef12d4 more specific Entry painting;
wenzelm
parents: 51534
diff changeset
    63
        super.paintComponent(gfx)
a1d324ef12d4 more specific Entry painting;
wenzelm
parents: 51534
diff changeset
    64
      }
51533
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
    65
    }
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
    66
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
    67
    class Renderer extends ListView.Renderer[Entry]
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
    68
    {
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
    69
      def componentFor(list: ListView[_], isSelected: Boolean, focused: Boolean,
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
    70
        entry: Entry, index: Int): Component =
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
    71
      {
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
    72
        val component = Renderer_Component
51536
a1d324ef12d4 more specific Entry painting;
wenzelm
parents: 51534
diff changeset
    73
        component.entry = entry
51534
123bd97fcea1 mixed theory/command entries;
wenzelm
parents: 51533
diff changeset
    74
        component.text = entry.print
51533
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
    75
        component
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
    76
      }
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
    77
    }
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
    78
  }
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
    79
51534
123bd97fcea1 mixed theory/command entries;
wenzelm
parents: 51533
diff changeset
    80
  private abstract class Entry
123bd97fcea1 mixed theory/command entries;
wenzelm
parents: 51533
diff changeset
    81
  {
123bd97fcea1 mixed theory/command entries;
wenzelm
parents: 51533
diff changeset
    82
    def timing: Double
123bd97fcea1 mixed theory/command entries;
wenzelm
parents: 51533
diff changeset
    83
    def print: String
123bd97fcea1 mixed theory/command entries;
wenzelm
parents: 51533
diff changeset
    84
    def follow(snapshot: Document.Snapshot)
123bd97fcea1 mixed theory/command entries;
wenzelm
parents: 51533
diff changeset
    85
  }
123bd97fcea1 mixed theory/command entries;
wenzelm
parents: 51533
diff changeset
    86
51536
a1d324ef12d4 more specific Entry painting;
wenzelm
parents: 51534
diff changeset
    87
  private case class Theory_Entry(name: Document.Node.Name, timing: Double, current: Boolean)
a1d324ef12d4 more specific Entry painting;
wenzelm
parents: 51534
diff changeset
    88
    extends Entry
51533
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
    89
  {
51534
123bd97fcea1 mixed theory/command entries;
wenzelm
parents: 51533
diff changeset
    90
    def print: String = Time.print_seconds(timing) + "s theory " + quote(name.theory)
52980
28f59ca8ce78 manage hyperlinks via PIDE editor interface;
wenzelm
parents: 52973
diff changeset
    91
    def follow(snapshot: Document.Snapshot) { PIDE.editor.goto(view, name.node) }
51534
123bd97fcea1 mixed theory/command entries;
wenzelm
parents: 51533
diff changeset
    92
  }
123bd97fcea1 mixed theory/command entries;
wenzelm
parents: 51533
diff changeset
    93
123bd97fcea1 mixed theory/command entries;
wenzelm
parents: 51533
diff changeset
    94
  private case class Command_Entry(command: Command, timing: Double) extends Entry
123bd97fcea1 mixed theory/command entries;
wenzelm
parents: 51533
diff changeset
    95
  {
123bd97fcea1 mixed theory/command entries;
wenzelm
parents: 51533
diff changeset
    96
    def print: String = "  " + Time.print_seconds(timing) + "s command " + quote(command.name)
51533
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
    97
    def follow(snapshot: Document.Snapshot)
52980
28f59ca8ce78 manage hyperlinks via PIDE editor interface;
wenzelm
parents: 52973
diff changeset
    98
    { PIDE.editor.hyperlink_command(snapshot, command).foreach(_.follow(view)) }
51533
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
    99
  }
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   100
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   101
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   102
  /* timing view */
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   103
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   104
  private val timing_view = new ListView(Nil: List[Entry]) {
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   105
    listenTo(mouse.clicks)
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   106
    reactions += {
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   107
      case MouseClicked(_, point, _, clicks, _) if clicks == 2 =>
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   108
        val index = peer.locationToIndex(point)
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   109
        if (index >= 0) listData(index).follow(PIDE.session.snapshot())
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   110
    }
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   111
  }
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   112
  timing_view.peer.setLayoutOrientation(JList.VERTICAL_WRAP)
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   113
  timing_view.peer.setVisibleRowCount(0)
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   114
  timing_view.selection.intervalMode = ListView.IntervalMode.Single
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   115
  timing_view.renderer = new Entry.Renderer
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   116
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   117
  set_content(new ScrollPane(timing_view))
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   118
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   119
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   120
  /* timing threshold */
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   121
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   122
  private var timing_threshold = PIDE.options.real("jedit_timing_threshold")
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   123
51549
37211c7c2894 tuned GUI;
wenzelm
parents: 51538
diff changeset
   124
  private val threshold_tooltip = "Threshold for timing display (seconds)"
37211c7c2894 tuned GUI;
wenzelm
parents: 51538
diff changeset
   125
37211c7c2894 tuned GUI;
wenzelm
parents: 51538
diff changeset
   126
  private val threshold_label = new Label("Threshold: ") {
37211c7c2894 tuned GUI;
wenzelm
parents: 51538
diff changeset
   127
    tooltip = threshold_tooltip
37211c7c2894 tuned GUI;
wenzelm
parents: 51538
diff changeset
   128
  }
51533
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   129
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   130
  private val threshold_value = new TextField(Time.print_seconds(timing_threshold)) {
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   131
    reactions += {
51538
637e64effda2 proper input event handling;
wenzelm
parents: 51536
diff changeset
   132
      case _: ValueChanged =>
51533
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   133
        text match {
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   134
          case Properties.Value.Double(x) if x >= 0.0 => timing_threshold = x
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   135
          case _ =>
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   136
        }
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   137
        handle_update()
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   138
    }
51549
37211c7c2894 tuned GUI;
wenzelm
parents: 51538
diff changeset
   139
    tooltip = threshold_tooltip
51538
637e64effda2 proper input event handling;
wenzelm
parents: 51536
diff changeset
   140
    verifier = ((s: String) =>
637e64effda2 proper input event handling;
wenzelm
parents: 51536
diff changeset
   141
      s match { case Properties.Value.Double(x) => x >= 0.0 case _ => false })
51533
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   142
  }
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   143
53711
8ce7795256e1 improved FlowLayout for wrapping of components over multiple lines;
wenzelm
parents: 53177
diff changeset
   144
  private val controls =
8ce7795256e1 improved FlowLayout for wrapping of components over multiple lines;
wenzelm
parents: 53177
diff changeset
   145
    new Wrap_Panel(Wrap_Panel.Alignment.Right)(threshold_label, threshold_value)
51533
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   146
  add(controls.peer, BorderLayout.NORTH)
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   147
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   148
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   149
  /* component state -- owned by Swing thread */
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   150
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   151
  private var nodes_timing = Map.empty[Document.Node.Name, Protocol.Node_Timing]
51534
123bd97fcea1 mixed theory/command entries;
wenzelm
parents: 51533
diff changeset
   152
123bd97fcea1 mixed theory/command entries;
wenzelm
parents: 51533
diff changeset
   153
  private def make_entries(): List[Entry] =
123bd97fcea1 mixed theory/command entries;
wenzelm
parents: 51533
diff changeset
   154
  {
123bd97fcea1 mixed theory/command entries;
wenzelm
parents: 51533
diff changeset
   155
    Swing_Thread.require()
123bd97fcea1 mixed theory/command entries;
wenzelm
parents: 51533
diff changeset
   156
123bd97fcea1 mixed theory/command entries;
wenzelm
parents: 51533
diff changeset
   157
    val name =
123bd97fcea1 mixed theory/command entries;
wenzelm
parents: 51533
diff changeset
   158
      Document_View(view.getTextArea) match {
123bd97fcea1 mixed theory/command entries;
wenzelm
parents: 51533
diff changeset
   159
        case None => Document.Node.Name.empty
52973
d5f7fa1498b7 tuned signature;
wenzelm
parents: 52888
diff changeset
   160
        case Some(doc_view) => doc_view.model.node_name
51534
123bd97fcea1 mixed theory/command entries;
wenzelm
parents: 51533
diff changeset
   161
      }
52888
wenzelm
parents: 51549
diff changeset
   162
    val timing = nodes_timing.getOrElse(name, Protocol.empty_node_timing)
51534
123bd97fcea1 mixed theory/command entries;
wenzelm
parents: 51533
diff changeset
   163
123bd97fcea1 mixed theory/command entries;
wenzelm
parents: 51533
diff changeset
   164
    val theories =
51536
a1d324ef12d4 more specific Entry painting;
wenzelm
parents: 51534
diff changeset
   165
      (for ((node_name, node_timing) <- nodes_timing.toList if !node_timing.commands.isEmpty)
a1d324ef12d4 more specific Entry painting;
wenzelm
parents: 51534
diff changeset
   166
        yield Theory_Entry(node_name, node_timing.total, false)).sorted(Entry.Ordering)
51534
123bd97fcea1 mixed theory/command entries;
wenzelm
parents: 51533
diff changeset
   167
    val commands =
123bd97fcea1 mixed theory/command entries;
wenzelm
parents: 51533
diff changeset
   168
      (for ((command, command_timing) <- timing.commands.toList)
123bd97fcea1 mixed theory/command entries;
wenzelm
parents: 51533
diff changeset
   169
        yield Command_Entry(command, command_timing)).sorted(Entry.Ordering)
123bd97fcea1 mixed theory/command entries;
wenzelm
parents: 51533
diff changeset
   170
51536
a1d324ef12d4 more specific Entry painting;
wenzelm
parents: 51534
diff changeset
   171
    theories.flatMap(entry =>
a1d324ef12d4 more specific Entry painting;
wenzelm
parents: 51534
diff changeset
   172
      if (entry.name == name) entry.copy(current = true) :: commands
a1d324ef12d4 more specific Entry painting;
wenzelm
parents: 51534
diff changeset
   173
      else List(entry))
51534
123bd97fcea1 mixed theory/command entries;
wenzelm
parents: 51533
diff changeset
   174
  }
51533
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   175
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   176
  private def handle_update(restriction: Option[Set[Document.Node.Name]] = None)
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   177
  {
53177
dcac8d837b9c more uniform treatment of Swing_Thread context switch: prefer asynchronous Swing_Thread.later from actor;
wenzelm
parents: 52980
diff changeset
   178
    Swing_Thread.require()
dcac8d837b9c more uniform treatment of Swing_Thread context switch: prefer asynchronous Swing_Thread.later from actor;
wenzelm
parents: 52980
diff changeset
   179
dcac8d837b9c more uniform treatment of Swing_Thread context switch: prefer asynchronous Swing_Thread.later from actor;
wenzelm
parents: 52980
diff changeset
   180
    val snapshot = PIDE.session.snapshot()
51533
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   181
53177
dcac8d837b9c more uniform treatment of Swing_Thread context switch: prefer asynchronous Swing_Thread.later from actor;
wenzelm
parents: 52980
diff changeset
   182
    val iterator =
dcac8d837b9c more uniform treatment of Swing_Thread context switch: prefer asynchronous Swing_Thread.later from actor;
wenzelm
parents: 52980
diff changeset
   183
      restriction match {
dcac8d837b9c more uniform treatment of Swing_Thread context switch: prefer asynchronous Swing_Thread.later from actor;
wenzelm
parents: 52980
diff changeset
   184
        case Some(names) => names.iterator.map(name => (name, snapshot.version.nodes(name)))
dcac8d837b9c more uniform treatment of Swing_Thread context switch: prefer asynchronous Swing_Thread.later from actor;
wenzelm
parents: 52980
diff changeset
   185
        case None => snapshot.version.nodes.entries
dcac8d837b9c more uniform treatment of Swing_Thread context switch: prefer asynchronous Swing_Thread.later from actor;
wenzelm
parents: 52980
diff changeset
   186
      }
dcac8d837b9c more uniform treatment of Swing_Thread context switch: prefer asynchronous Swing_Thread.later from actor;
wenzelm
parents: 52980
diff changeset
   187
    val nodes_timing1 =
dcac8d837b9c more uniform treatment of Swing_Thread context switch: prefer asynchronous Swing_Thread.later from actor;
wenzelm
parents: 52980
diff changeset
   188
      (nodes_timing /: iterator)({ case (timing1, (name, node)) =>
dcac8d837b9c more uniform treatment of Swing_Thread context switch: prefer asynchronous Swing_Thread.later from actor;
wenzelm
parents: 52980
diff changeset
   189
          if (PIDE.thy_load.loaded_theories(name.theory)) timing1
dcac8d837b9c more uniform treatment of Swing_Thread context switch: prefer asynchronous Swing_Thread.later from actor;
wenzelm
parents: 52980
diff changeset
   190
          else {
dcac8d837b9c more uniform treatment of Swing_Thread context switch: prefer asynchronous Swing_Thread.later from actor;
wenzelm
parents: 52980
diff changeset
   191
            val node_timing =
dcac8d837b9c more uniform treatment of Swing_Thread context switch: prefer asynchronous Swing_Thread.later from actor;
wenzelm
parents: 52980
diff changeset
   192
              Protocol.node_timing(snapshot.state, snapshot.version, node, timing_threshold)
dcac8d837b9c more uniform treatment of Swing_Thread context switch: prefer asynchronous Swing_Thread.later from actor;
wenzelm
parents: 52980
diff changeset
   193
            timing1 + (name -> node_timing)
dcac8d837b9c more uniform treatment of Swing_Thread context switch: prefer asynchronous Swing_Thread.later from actor;
wenzelm
parents: 52980
diff changeset
   194
          }
dcac8d837b9c more uniform treatment of Swing_Thread context switch: prefer asynchronous Swing_Thread.later from actor;
wenzelm
parents: 52980
diff changeset
   195
      })
dcac8d837b9c more uniform treatment of Swing_Thread context switch: prefer asynchronous Swing_Thread.later from actor;
wenzelm
parents: 52980
diff changeset
   196
    nodes_timing = nodes_timing1
51533
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   197
53177
dcac8d837b9c more uniform treatment of Swing_Thread context switch: prefer asynchronous Swing_Thread.later from actor;
wenzelm
parents: 52980
diff changeset
   198
    val entries = make_entries()
dcac8d837b9c more uniform treatment of Swing_Thread context switch: prefer asynchronous Swing_Thread.later from actor;
wenzelm
parents: 52980
diff changeset
   199
    if (timing_view.listData.toList != entries) timing_view.listData = entries
51533
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   200
  }
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   201
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   202
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   203
  /* main actor */
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   204
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   205
  private val main_actor = actor {
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   206
    loop {
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   207
      react {
53177
dcac8d837b9c more uniform treatment of Swing_Thread context switch: prefer asynchronous Swing_Thread.later from actor;
wenzelm
parents: 52980
diff changeset
   208
        case changed: Session.Commands_Changed =>
dcac8d837b9c more uniform treatment of Swing_Thread context switch: prefer asynchronous Swing_Thread.later from actor;
wenzelm
parents: 52980
diff changeset
   209
          Swing_Thread.later { handle_update(Some(changed.nodes)) }
51533
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   210
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   211
        case bad => System.err.println("Timing_Dockable: ignoring bad message " + bad)
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   212
      }
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   213
    }
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   214
  }
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   215
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   216
  override def init()
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   217
  {
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   218
    PIDE.session.commands_changed += main_actor
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   219
    handle_update()
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   220
  }
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   221
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   222
  override def exit()
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   223
  {
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   224
    PIDE.session.commands_changed -= main_actor
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   225
  }
3f6280aedbcc dockable window for timing information;
wenzelm
parents:
diff changeset
   226
}