src/Tools/jEdit/src/theories_dockable.scala
author wenzelm
Wed, 20 Nov 2013 16:15:54 +0100
changeset 54531 8330faaeebd5
parent 53715 68c664737d04
child 54671 d64a4ef26edb
permissions -rw-r--r--
restrict node_required status and Theories panel to actual theories;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
50299
f70b3712040f renamed dockable "Prover Session" to "Theories";
wenzelm
parents: 50250
diff changeset
     1
/*  Title:      Tools/jEdit/src/theories_dockable.scala
39515
57ceabb0bb8e basic setup for prover session panel;
wenzelm
parents:
diff changeset
     2
    Author:     Makarius
57ceabb0bb8e basic setup for prover session panel;
wenzelm
parents:
diff changeset
     3
50299
f70b3712040f renamed dockable "Prover Session" to "Theories";
wenzelm
parents: 50250
diff changeset
     4
Dockable window for theories managed by prover.
39515
57ceabb0bb8e basic setup for prover session panel;
wenzelm
parents:
diff changeset
     5
*/
57ceabb0bb8e basic setup for prover session panel;
wenzelm
parents:
diff changeset
     6
57ceabb0bb8e basic setup for prover session panel;
wenzelm
parents:
diff changeset
     7
package isabelle.jedit
57ceabb0bb8e basic setup for prover session panel;
wenzelm
parents:
diff changeset
     8
57ceabb0bb8e basic setup for prover session panel;
wenzelm
parents:
diff changeset
     9
57ceabb0bb8e basic setup for prover session panel;
wenzelm
parents:
diff changeset
    10
import isabelle._
57ceabb0bb8e basic setup for prover session panel;
wenzelm
parents:
diff changeset
    11
57ceabb0bb8e basic setup for prover session panel;
wenzelm
parents:
diff changeset
    12
import scala.actors.Actor._
53711
8ce7795256e1 improved FlowLayout for wrapping of components over multiple lines;
wenzelm
parents: 53178
diff changeset
    13
import scala.swing.{Button, TextArea, Label, ListView, Alignment,
52815
eaad5fe7bb1b actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents: 52809
diff changeset
    14
  ScrollPane, Component, CheckBox, BorderPanel}
53715
68c664737d04 added option "jedit_auto_load";
wenzelm
parents: 53711
diff changeset
    15
import scala.swing.event.{MouseClicked, MouseMoved}
39593
1a34187f0b97 basic setup for Session_Dockable controls;
wenzelm
parents: 39591
diff changeset
    16
43520
cec9b95fa35d explicit import java.lang.System to prevent odd scope problems;
wenzelm
parents: 43282
diff changeset
    17
import java.lang.System
53178
0a3a5f606b2a more precise painting;
wenzelm
parents: 53177
diff changeset
    18
import java.awt.{BorderLayout, Graphics2D, Color, Point, Dimension}
47588
1f8f1c2045fd tuned imports;
wenzelm
parents: 46918
diff changeset
    19
import javax.swing.{JList, BorderFactory}
52802
0b98561d0790 more uniform border;
wenzelm
parents: 52779
diff changeset
    20
import javax.swing.border.{BevelBorder, SoftBevelBorder}
39515
57ceabb0bb8e basic setup for prover session panel;
wenzelm
parents:
diff changeset
    21
44865
679f0d57e831 some keyboard shortcuts for important actions;
wenzelm
parents: 44864
diff changeset
    22
import org.gjt.sp.jedit.{View, jEdit}
39515
57ceabb0bb8e basic setup for prover session panel;
wenzelm
parents:
diff changeset
    23
57ceabb0bb8e basic setup for prover session panel;
wenzelm
parents:
diff changeset
    24
50299
f70b3712040f renamed dockable "Prover Session" to "Theories";
wenzelm
parents: 50250
diff changeset
    25
class Theories_Dockable(view: View, position: String) extends Dockable(view, position)
39515
57ceabb0bb8e basic setup for prover session panel;
wenzelm
parents:
diff changeset
    26
{
48021
d899be1cfe6d separate syslog dockable -- discontinued tendency of sub-window management via tabs;
wenzelm
parents: 48018
diff changeset
    27
  /* status */
39591
a43a723753e6 more content for Session_Dockable;
wenzelm
parents: 39589
diff changeset
    28
48021
d899be1cfe6d separate syslog dockable -- discontinued tendency of sub-window management via tabs;
wenzelm
parents: 48018
diff changeset
    29
  private val status = new ListView(Nil: List[Document.Node.Name]) {
44991
d88f7fc62a40 double clicks switch to document node buffer;
wenzelm
parents: 44990
diff changeset
    30
    listenTo(mouse.clicks)
52817
408fb2e563df added home-made tooltips;
wenzelm
parents: 52816
diff changeset
    31
    listenTo(mouse.moves)
44991
d88f7fc62a40 double clicks switch to document node buffer;
wenzelm
parents: 44990
diff changeset
    32
    reactions += {
52816
c608e0ade554 home-grown mouse handling to pretend that the painted checkbox is actually a Swing component;
wenzelm
parents: 52815
diff changeset
    33
      case MouseClicked(_, point, _, clicks, _) =>
44991
d88f7fc62a40 double clicks switch to document node buffer;
wenzelm
parents: 44990
diff changeset
    34
        val index = peer.locationToIndex(point)
52817
408fb2e563df added home-made tooltips;
wenzelm
parents: 52816
diff changeset
    35
        if (index >= 0) {
408fb2e563df added home-made tooltips;
wenzelm
parents: 52816
diff changeset
    36
          if (in_checkbox(peer.indexToLocation(index), point)) {
408fb2e563df added home-made tooltips;
wenzelm
parents: 52816
diff changeset
    37
            if (clicks == 1) {
408fb2e563df added home-made tooltips;
wenzelm
parents: 52816
diff changeset
    38
              for {
408fb2e563df added home-made tooltips;
wenzelm
parents: 52816
diff changeset
    39
                buffer <- JEdit_Lib.jedit_buffer(listData(index).node)
408fb2e563df added home-made tooltips;
wenzelm
parents: 52816
diff changeset
    40
                model <- PIDE.document_model(buffer)
408fb2e563df added home-made tooltips;
wenzelm
parents: 52816
diff changeset
    41
              } model.node_required = !model.node_required
408fb2e563df added home-made tooltips;
wenzelm
parents: 52816
diff changeset
    42
            }
52816
c608e0ade554 home-grown mouse handling to pretend that the painted checkbox is actually a Swing component;
wenzelm
parents: 52815
diff changeset
    43
          }
52980
28f59ca8ce78 manage hyperlinks via PIDE editor interface;
wenzelm
parents: 52973
diff changeset
    44
          else if (clicks == 2) PIDE.editor.goto(view, listData(index).node)
52816
c608e0ade554 home-grown mouse handling to pretend that the painted checkbox is actually a Swing component;
wenzelm
parents: 52815
diff changeset
    45
        }
52817
408fb2e563df added home-made tooltips;
wenzelm
parents: 52816
diff changeset
    46
      case MouseMoved(_, point, _) =>
408fb2e563df added home-made tooltips;
wenzelm
parents: 52816
diff changeset
    47
        val index = peer.locationToIndex(point)
408fb2e563df added home-made tooltips;
wenzelm
parents: 52816
diff changeset
    48
        if (index >= 0 && in_checkbox(peer.indexToLocation(index), point))
408fb2e563df added home-made tooltips;
wenzelm
parents: 52816
diff changeset
    49
          tooltip = "Mark as required for continuous checking"
408fb2e563df added home-made tooltips;
wenzelm
parents: 52816
diff changeset
    50
        else
408fb2e563df added home-made tooltips;
wenzelm
parents: 52816
diff changeset
    51
          tooltip = null
44991
d88f7fc62a40 double clicks switch to document node buffer;
wenzelm
parents: 44990
diff changeset
    52
    }
d88f7fc62a40 double clicks switch to document node buffer;
wenzelm
parents: 44990
diff changeset
    53
  }
50250
267bd685a69f smarter list layout;
wenzelm
parents: 50209
diff changeset
    54
  status.peer.setLayoutOrientation(JList.HORIZONTAL_WRAP)
267bd685a69f smarter list layout;
wenzelm
parents: 50209
diff changeset
    55
  status.peer.setVisibleRowCount(0)
44609
6ec4a5eb2fc0 some support for theory status overview;
wenzelm
parents: 44335
diff changeset
    56
  status.selection.intervalMode = ListView.IntervalMode.Single
6ec4a5eb2fc0 some support for theory status overview;
wenzelm
parents: 44335
diff changeset
    57
49038
2f0530b81c45 recovered ScrollPane from d899be1cfe6d;
wenzelm
parents: 48870
diff changeset
    58
  set_content(new ScrollPane(status))
39515
57ceabb0bb8e basic setup for prover session panel;
wenzelm
parents:
diff changeset
    59
57ceabb0bb8e basic setup for prover session panel;
wenzelm
parents:
diff changeset
    60
39593
1a34187f0b97 basic setup for Session_Dockable controls;
wenzelm
parents: 39591
diff changeset
    61
  /* controls */
1a34187f0b97 basic setup for Session_Dockable controls;
wenzelm
parents: 39591
diff changeset
    62
50299
f70b3712040f renamed dockable "Prover Session" to "Theories";
wenzelm
parents: 50250
diff changeset
    63
  def phase_text(phase: Session.Phase): String =
f70b3712040f renamed dockable "Prover Session" to "Theories";
wenzelm
parents: 50250
diff changeset
    64
    "Prover: " + Library.lowercase(phase.toString)
f70b3712040f renamed dockable "Prover Session" to "Theories";
wenzelm
parents: 50250
diff changeset
    65
f70b3712040f renamed dockable "Prover Session" to "Theories";
wenzelm
parents: 50250
diff changeset
    66
  private val session_phase = new Label(phase_text(PIDE.session.phase))
39697
d54242927fb1 tuned border;
wenzelm
parents: 39696
diff changeset
    67
  session_phase.border = new SoftBevelBorder(BevelBorder.LOWERED)
50299
f70b3712040f renamed dockable "Prover Session" to "Theories";
wenzelm
parents: 50250
diff changeset
    68
  session_phase.tooltip = "Status of prover session"
39635
5cd8545a070b added Session_Dockable.session_phase label;
wenzelm
parents: 39629
diff changeset
    69
48018
b941dd7df92a make double sure that GUI components are up-to-date after init;
wenzelm
parents: 48014
diff changeset
    70
  private def handle_phase(phase: Session.Phase)
b941dd7df92a make double sure that GUI components are up-to-date after init;
wenzelm
parents: 48014
diff changeset
    71
  {
53177
dcac8d837b9c more uniform treatment of Swing_Thread context switch: prefer asynchronous Swing_Thread.later from actor;
wenzelm
parents: 53176
diff changeset
    72
    Swing_Thread.require()
dcac8d837b9c more uniform treatment of Swing_Thread context switch: prefer asynchronous Swing_Thread.later from actor;
wenzelm
parents: 53176
diff changeset
    73
    session_phase.text = " " + phase_text(phase) + " "
48018
b941dd7df92a make double sure that GUI components are up-to-date after init;
wenzelm
parents: 48014
diff changeset
    74
  }
b941dd7df92a make double sure that GUI components are up-to-date after init;
wenzelm
parents: 48014
diff changeset
    75
53715
68c664737d04 added option "jedit_auto_load";
wenzelm
parents: 53711
diff changeset
    76
  private val continuous_checking = new Isabelle.Continuous_Checking
44776
47e8c8daccae added "check" button: adhoc change to full buffer perspective;
wenzelm
parents: 44775
diff changeset
    77
49246
248e66e8321f more systematic JEdit_Options.make_component;
wenzelm
parents: 49245
diff changeset
    78
  private val logic = Isabelle_Logic.logic_selector(true)
39702
d7c256cb2797 Session_Dockable: more startup controls;
wenzelm
parents: 39701
diff changeset
    79
44775
27930cf6f0f7 added "cancel" button based on cancel_execution, not interrupt (cf. 156be0e43336);
wenzelm
parents: 44734
diff changeset
    80
  private val controls =
53711
8ce7795256e1 improved FlowLayout for wrapping of components over multiple lines;
wenzelm
parents: 53178
diff changeset
    81
    new Wrap_Panel(Wrap_Panel.Alignment.Right)(continuous_checking, session_phase, logic)
39593
1a34187f0b97 basic setup for Session_Dockable controls;
wenzelm
parents: 39591
diff changeset
    82
  add(controls.peer, BorderLayout.NORTH)
1a34187f0b97 basic setup for Session_Dockable controls;
wenzelm
parents: 39591
diff changeset
    83
1a34187f0b97 basic setup for Session_Dockable controls;
wenzelm
parents: 39591
diff changeset
    84
44609
6ec4a5eb2fc0 some support for theory status overview;
wenzelm
parents: 44335
diff changeset
    85
  /* component state -- owned by Swing thread */
6ec4a5eb2fc0 some support for theory status overview;
wenzelm
parents: 44335
diff changeset
    86
45709
87017fcbad83 clarified modules (again) -- NB: both Document and Protocol are specific to this particular prover;
wenzelm
parents: 45672
diff changeset
    87
  private var nodes_status: Map[Document.Node.Name, Protocol.Node_Status] = Map.empty
52815
eaad5fe7bb1b actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents: 52809
diff changeset
    88
  private var nodes_required: Set[Document.Node.Name] = Set.empty
44866
0eb8284a64bd some color scheme for theory status;
wenzelm
parents: 44865
diff changeset
    89
52815
eaad5fe7bb1b actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents: 52809
diff changeset
    90
  private def update_nodes_required()
eaad5fe7bb1b actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents: 52809
diff changeset
    91
  {
eaad5fe7bb1b actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents: 52809
diff changeset
    92
    nodes_required = Set.empty
eaad5fe7bb1b actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents: 52809
diff changeset
    93
    for {
eaad5fe7bb1b actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents: 52809
diff changeset
    94
      buffer <- JEdit_Lib.jedit_buffers
eaad5fe7bb1b actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents: 52809
diff changeset
    95
      model <- PIDE.document_model(buffer)
eaad5fe7bb1b actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents: 52809
diff changeset
    96
      if model.node_required
52973
d5f7fa1498b7 tuned signature;
wenzelm
parents: 52860
diff changeset
    97
    } nodes_required += model.node_name
52815
eaad5fe7bb1b actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents: 52809
diff changeset
    98
  }
52860
f155c38242c1 initial update of nodes_required, for proper GUI state;
wenzelm
parents: 52819
diff changeset
    99
  update_nodes_required()
52815
eaad5fe7bb1b actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents: 52809
diff changeset
   100
52817
408fb2e563df added home-made tooltips;
wenzelm
parents: 52816
diff changeset
   101
  private def in_checkbox(loc0: Point, p: Point): Boolean =
408fb2e563df added home-made tooltips;
wenzelm
parents: 52816
diff changeset
   102
    Node_Renderer_Component != null &&
408fb2e563df added home-made tooltips;
wenzelm
parents: 52816
diff changeset
   103
      (Node_Renderer_Component.checkbox_geometry match {
408fb2e563df added home-made tooltips;
wenzelm
parents: 52816
diff changeset
   104
        case Some((loc, size)) =>
408fb2e563df added home-made tooltips;
wenzelm
parents: 52816
diff changeset
   105
          loc0.x + loc.x <= p.x && p.x < loc0.x + size.width &&
408fb2e563df added home-made tooltips;
wenzelm
parents: 52816
diff changeset
   106
          loc0.y + loc.y <= p.y && p.y < loc0.y + size.height
408fb2e563df added home-made tooltips;
wenzelm
parents: 52816
diff changeset
   107
        case None => false
408fb2e563df added home-made tooltips;
wenzelm
parents: 52816
diff changeset
   108
      })
408fb2e563df added home-made tooltips;
wenzelm
parents: 52816
diff changeset
   109
52815
eaad5fe7bb1b actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents: 52809
diff changeset
   110
  private object Node_Renderer_Component extends BorderPanel
44866
0eb8284a64bd some color scheme for theory status;
wenzelm
parents: 44865
diff changeset
   111
  {
44990
wenzelm
parents: 44989
diff changeset
   112
    opaque = false
53176
f88635e1c52e clarified border (again, see also 7ce3ebc268a1);
wenzelm
parents: 52980
diff changeset
   113
    border = BorderFactory.createEmptyBorder(2, 2, 2, 2)
44957
098dd95349e7 more elaborate Node_Renderer, which paints node_name.theory only;
wenzelm
parents: 44867
diff changeset
   114
098dd95349e7 more elaborate Node_Renderer, which paints node_name.theory only;
wenzelm
parents: 44867
diff changeset
   115
    var node_name = Document.Node.Name.empty
52816
c608e0ade554 home-grown mouse handling to pretend that the painted checkbox is actually a Swing component;
wenzelm
parents: 52815
diff changeset
   116
c608e0ade554 home-grown mouse handling to pretend that the painted checkbox is actually a Swing component;
wenzelm
parents: 52815
diff changeset
   117
    var checkbox_geometry: Option[(Point, Dimension)] = None
c608e0ade554 home-grown mouse handling to pretend that the painted checkbox is actually a Swing component;
wenzelm
parents: 52815
diff changeset
   118
    val checkbox = new CheckBox {
52819
7ce3ebc268a1 proper border (again) -- avoid NPE on Windows;
wenzelm
parents: 52817
diff changeset
   119
      opaque = false
52816
c608e0ade554 home-grown mouse handling to pretend that the painted checkbox is actually a Swing component;
wenzelm
parents: 52815
diff changeset
   120
      override def paintComponent(gfx: Graphics2D)
c608e0ade554 home-grown mouse handling to pretend that the painted checkbox is actually a Swing component;
wenzelm
parents: 52815
diff changeset
   121
      {
c608e0ade554 home-grown mouse handling to pretend that the painted checkbox is actually a Swing component;
wenzelm
parents: 52815
diff changeset
   122
        super.paintComponent(gfx)
c608e0ade554 home-grown mouse handling to pretend that the painted checkbox is actually a Swing component;
wenzelm
parents: 52815
diff changeset
   123
        if (location != null && size != null)
c608e0ade554 home-grown mouse handling to pretend that the painted checkbox is actually a Swing component;
wenzelm
parents: 52815
diff changeset
   124
          checkbox_geometry = Some((location, size))
c608e0ade554 home-grown mouse handling to pretend that the painted checkbox is actually a Swing component;
wenzelm
parents: 52815
diff changeset
   125
      }
c608e0ade554 home-grown mouse handling to pretend that the painted checkbox is actually a Swing component;
wenzelm
parents: 52815
diff changeset
   126
    }
52815
eaad5fe7bb1b actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents: 52809
diff changeset
   127
eaad5fe7bb1b actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents: 52809
diff changeset
   128
    val label = new Label {
eaad5fe7bb1b actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents: 52809
diff changeset
   129
      opaque = false
53176
f88635e1c52e clarified border (again, see also 7ce3ebc268a1);
wenzelm
parents: 52980
diff changeset
   130
      border = BorderFactory.createEmptyBorder()
52815
eaad5fe7bb1b actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents: 52809
diff changeset
   131
      xAlignment = Alignment.Leading
52809
e750169a5884 paint unassigned/unchanged nodes as unprocessed -- relevant for editor_continuous_checking = false;
wenzelm
parents: 52807
diff changeset
   132
52815
eaad5fe7bb1b actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents: 52809
diff changeset
   133
      override def paintComponent(gfx: Graphics2D)
eaad5fe7bb1b actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents: 52809
diff changeset
   134
      {
53178
0a3a5f606b2a more precise painting;
wenzelm
parents: 53177
diff changeset
   135
        def paint_segment(x: Int, w: Int, color: Color)
0a3a5f606b2a more precise painting;
wenzelm
parents: 53177
diff changeset
   136
        {
0a3a5f606b2a more precise painting;
wenzelm
parents: 53177
diff changeset
   137
          gfx.setColor(color)
0a3a5f606b2a more precise painting;
wenzelm
parents: 53177
diff changeset
   138
          gfx.fillRect(x, 0, w, size.height)
0a3a5f606b2a more precise painting;
wenzelm
parents: 53177
diff changeset
   139
        }
50900
6d80709ab862 separate color ranges by 1px to improve discernment of overall theory status;
wenzelm
parents: 50895
diff changeset
   140
52815
eaad5fe7bb1b actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents: 52809
diff changeset
   141
        nodes_status.get(node_name) match {
eaad5fe7bb1b actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents: 52809
diff changeset
   142
          case Some(st) if st.total > 0 =>
53178
0a3a5f606b2a more precise painting;
wenzelm
parents: 53177
diff changeset
   143
            val segments =
0a3a5f606b2a more precise painting;
wenzelm
parents: 53177
diff changeset
   144
              List(
0a3a5f606b2a more precise painting;
wenzelm
parents: 53177
diff changeset
   145
                (st.unprocessed, PIDE.options.color_value("unprocessed1_color")),
0a3a5f606b2a more precise painting;
wenzelm
parents: 53177
diff changeset
   146
                (st.running, PIDE.options.color_value("running_color")),
0a3a5f606b2a more precise painting;
wenzelm
parents: 53177
diff changeset
   147
                (st.warned, PIDE.options.color_value("warning_color")),
0a3a5f606b2a more precise painting;
wenzelm
parents: 53177
diff changeset
   148
                (st.failed, PIDE.options.color_value("error_color"))
0a3a5f606b2a more precise painting;
wenzelm
parents: 53177
diff changeset
   149
              ).filter(_._1 > 0)
52815
eaad5fe7bb1b actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents: 52809
diff changeset
   150
53178
0a3a5f606b2a more precise painting;
wenzelm
parents: 53177
diff changeset
   151
            (size.width /: segments)({ case (last, (n, color)) =>
0a3a5f606b2a more precise painting;
wenzelm
parents: 53177
diff changeset
   152
              val w = (n * (size.width - segments.length) / st.total) max 4
0a3a5f606b2a more precise painting;
wenzelm
parents: 53177
diff changeset
   153
              paint_segment(last - w, w, color)
0a3a5f606b2a more precise painting;
wenzelm
parents: 53177
diff changeset
   154
              last - w - 1
0a3a5f606b2a more precise painting;
wenzelm
parents: 53177
diff changeset
   155
            })
0a3a5f606b2a more precise painting;
wenzelm
parents: 53177
diff changeset
   156
52815
eaad5fe7bb1b actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents: 52809
diff changeset
   157
          case _ =>
53178
0a3a5f606b2a more precise painting;
wenzelm
parents: 53177
diff changeset
   158
            paint_segment(0, size.width, PIDE.options.color_value("unprocessed1_color"))
52815
eaad5fe7bb1b actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents: 52809
diff changeset
   159
        }
eaad5fe7bb1b actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents: 52809
diff changeset
   160
        super.paintComponent(gfx)
44866
0eb8284a64bd some color scheme for theory status;
wenzelm
parents: 44865
diff changeset
   161
      }
0eb8284a64bd some color scheme for theory status;
wenzelm
parents: 44865
diff changeset
   162
    }
52815
eaad5fe7bb1b actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents: 52809
diff changeset
   163
52816
c608e0ade554 home-grown mouse handling to pretend that the painted checkbox is actually a Swing component;
wenzelm
parents: 52815
diff changeset
   164
    layout(checkbox) = BorderPanel.Position.West
52815
eaad5fe7bb1b actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents: 52809
diff changeset
   165
    layout(label) = BorderPanel.Position.Center
44866
0eb8284a64bd some color scheme for theory status;
wenzelm
parents: 44865
diff changeset
   166
  }
0eb8284a64bd some color scheme for theory status;
wenzelm
parents: 44865
diff changeset
   167
44990
wenzelm
parents: 44989
diff changeset
   168
  private class Node_Renderer extends ListView.Renderer[Document.Node.Name]
44957
098dd95349e7 more elaborate Node_Renderer, which paints node_name.theory only;
wenzelm
parents: 44867
diff changeset
   169
  {
44990
wenzelm
parents: 44989
diff changeset
   170
    def componentFor(list: ListView[_], isSelected: Boolean, focused: Boolean,
wenzelm
parents: 44989
diff changeset
   171
      name: Document.Node.Name, index: Int): Component =
44957
098dd95349e7 more elaborate Node_Renderer, which paints node_name.theory only;
wenzelm
parents: 44867
diff changeset
   172
    {
44990
wenzelm
parents: 44989
diff changeset
   173
      val component = Node_Renderer_Component
44957
098dd95349e7 more elaborate Node_Renderer, which paints node_name.theory only;
wenzelm
parents: 44867
diff changeset
   174
      component.node_name = name
52816
c608e0ade554 home-grown mouse handling to pretend that the painted checkbox is actually a Swing component;
wenzelm
parents: 52815
diff changeset
   175
      component.checkbox.selected = nodes_required.contains(name)
52815
eaad5fe7bb1b actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents: 52809
diff changeset
   176
      component.label.text = name.theory
44990
wenzelm
parents: 44989
diff changeset
   177
      component
44957
098dd95349e7 more elaborate Node_Renderer, which paints node_name.theory only;
wenzelm
parents: 44867
diff changeset
   178
    }
098dd95349e7 more elaborate Node_Renderer, which paints node_name.theory only;
wenzelm
parents: 44867
diff changeset
   179
  }
098dd95349e7 more elaborate Node_Renderer, which paints node_name.theory only;
wenzelm
parents: 44867
diff changeset
   180
  status.renderer = new Node_Renderer
44609
6ec4a5eb2fc0 some support for theory status overview;
wenzelm
parents: 44335
diff changeset
   181
45011
436ea69d5d37 more careful treatment of initial update, similar to output panel;
wenzelm
parents: 44991
diff changeset
   182
  private def handle_update(restriction: Option[Set[Document.Node.Name]] = None)
44609
6ec4a5eb2fc0 some support for theory status overview;
wenzelm
parents: 44335
diff changeset
   183
  {
53177
dcac8d837b9c more uniform treatment of Swing_Thread context switch: prefer asynchronous Swing_Thread.later from actor;
wenzelm
parents: 53176
diff changeset
   184
    Swing_Thread.require()
dcac8d837b9c more uniform treatment of Swing_Thread context switch: prefer asynchronous Swing_Thread.later from actor;
wenzelm
parents: 53176
diff changeset
   185
dcac8d837b9c more uniform treatment of Swing_Thread context switch: prefer asynchronous Swing_Thread.later from actor;
wenzelm
parents: 53176
diff changeset
   186
    val snapshot = PIDE.session.snapshot()
44613
a3255c85327b crude display of node status;
wenzelm
parents: 44609
diff changeset
   187
53177
dcac8d837b9c more uniform treatment of Swing_Thread context switch: prefer asynchronous Swing_Thread.later from actor;
wenzelm
parents: 53176
diff changeset
   188
    val iterator =
54531
8330faaeebd5 restrict node_required status and Theories panel to actual theories;
wenzelm
parents: 53715
diff changeset
   189
      (restriction match {
53177
dcac8d837b9c more uniform treatment of Swing_Thread context switch: prefer asynchronous Swing_Thread.later from actor;
wenzelm
parents: 53176
diff changeset
   190
        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: 53176
diff changeset
   191
        case None => snapshot.version.nodes.entries
54531
8330faaeebd5 restrict node_required status and Theories panel to actual theories;
wenzelm
parents: 53715
diff changeset
   192
      }).filter(_._1.is_theory)
53177
dcac8d837b9c more uniform treatment of Swing_Thread context switch: prefer asynchronous Swing_Thread.later from actor;
wenzelm
parents: 53176
diff changeset
   193
    val nodes_status1 =
dcac8d837b9c more uniform treatment of Swing_Thread context switch: prefer asynchronous Swing_Thread.later from actor;
wenzelm
parents: 53176
diff changeset
   194
      (nodes_status /: iterator)({ case (status, (name, node)) =>
dcac8d837b9c more uniform treatment of Swing_Thread context switch: prefer asynchronous Swing_Thread.later from actor;
wenzelm
parents: 53176
diff changeset
   195
          if (PIDE.thy_load.loaded_theories(name.theory)) status
dcac8d837b9c more uniform treatment of Swing_Thread context switch: prefer asynchronous Swing_Thread.later from actor;
wenzelm
parents: 53176
diff changeset
   196
          else status + (name -> Protocol.node_status(snapshot.state, snapshot.version, node)) })
44672
07dad1433cd7 some support to prune_history;
wenzelm
parents: 44641
diff changeset
   197
53177
dcac8d837b9c more uniform treatment of Swing_Thread context switch: prefer asynchronous Swing_Thread.later from actor;
wenzelm
parents: 53176
diff changeset
   198
    if (nodes_status != nodes_status1) {
dcac8d837b9c more uniform treatment of Swing_Thread context switch: prefer asynchronous Swing_Thread.later from actor;
wenzelm
parents: 53176
diff changeset
   199
      nodes_status = nodes_status1
dcac8d837b9c more uniform treatment of Swing_Thread context switch: prefer asynchronous Swing_Thread.later from actor;
wenzelm
parents: 53176
diff changeset
   200
      status.listData =
dcac8d837b9c more uniform treatment of Swing_Thread context switch: prefer asynchronous Swing_Thread.later from actor;
wenzelm
parents: 53176
diff changeset
   201
        snapshot.version.nodes.topological_order.filter(
dcac8d837b9c more uniform treatment of Swing_Thread context switch: prefer asynchronous Swing_Thread.later from actor;
wenzelm
parents: 53176
diff changeset
   202
          (name: Document.Node.Name) => nodes_status.isDefinedAt(name))
44609
6ec4a5eb2fc0 some support for theory status overview;
wenzelm
parents: 44335
diff changeset
   203
    }
6ec4a5eb2fc0 some support for theory status overview;
wenzelm
parents: 44335
diff changeset
   204
  }
6ec4a5eb2fc0 some support for theory status overview;
wenzelm
parents: 44335
diff changeset
   205
6ec4a5eb2fc0 some support for theory status overview;
wenzelm
parents: 44335
diff changeset
   206
39515
57ceabb0bb8e basic setup for prover session panel;
wenzelm
parents:
diff changeset
   207
  /* main actor */
57ceabb0bb8e basic setup for prover session panel;
wenzelm
parents:
diff changeset
   208
57ceabb0bb8e basic setup for prover session panel;
wenzelm
parents:
diff changeset
   209
  private val main_actor = actor {
57ceabb0bb8e basic setup for prover session panel;
wenzelm
parents:
diff changeset
   210
    loop {
57ceabb0bb8e basic setup for prover session panel;
wenzelm
parents:
diff changeset
   211
      react {
53177
dcac8d837b9c more uniform treatment of Swing_Thread context switch: prefer asynchronous Swing_Thread.later from actor;
wenzelm
parents: 53176
diff changeset
   212
        case phase: Session.Phase =>
dcac8d837b9c more uniform treatment of Swing_Thread context switch: prefer asynchronous Swing_Thread.later from actor;
wenzelm
parents: 53176
diff changeset
   213
          Swing_Thread.later { handle_phase(phase) }
39635
5cd8545a070b added Session_Dockable.session_phase label;
wenzelm
parents: 39629
diff changeset
   214
52759
a20631db9c8a support declarative editor_execution_range, instead of old-style check/cancel buttons;
wenzelm
parents: 51535
diff changeset
   215
        case _: Session.Global_Options =>
a20631db9c8a support declarative editor_execution_range, instead of old-style check/cancel buttons;
wenzelm
parents: 51535
diff changeset
   216
          Swing_Thread.later {
52807
b859a180936b simplified flag for continuous checking: avoid GUI complexity and slow checking of all theories (including prints);
wenzelm
parents: 52802
diff changeset
   217
            continuous_checking.load()
52759
a20631db9c8a support declarative editor_execution_range, instead of old-style check/cancel buttons;
wenzelm
parents: 51535
diff changeset
   218
            logic.load ()
52815
eaad5fe7bb1b actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents: 52809
diff changeset
   219
            update_nodes_required()
eaad5fe7bb1b actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents: 52809
diff changeset
   220
            status.repaint()
52759
a20631db9c8a support declarative editor_execution_range, instead of old-style check/cancel buttons;
wenzelm
parents: 51535
diff changeset
   221
          }
49247
ffd9ad9dc35b more detailed option tooltip;
wenzelm
parents: 49246
diff changeset
   222
53177
dcac8d837b9c more uniform treatment of Swing_Thread context switch: prefer asynchronous Swing_Thread.later from actor;
wenzelm
parents: 53176
diff changeset
   223
        case changed: Session.Commands_Changed =>
dcac8d837b9c more uniform treatment of Swing_Thread context switch: prefer asynchronous Swing_Thread.later from actor;
wenzelm
parents: 53176
diff changeset
   224
          Swing_Thread.later { handle_update(Some(changed.nodes)) }
44609
6ec4a5eb2fc0 some support for theory status overview;
wenzelm
parents: 44335
diff changeset
   225
50299
f70b3712040f renamed dockable "Prover Session" to "Theories";
wenzelm
parents: 50250
diff changeset
   226
        case bad => System.err.println("Theories_Dockable: ignoring bad message " + bad)
39515
57ceabb0bb8e basic setup for prover session panel;
wenzelm
parents:
diff changeset
   227
      }
57ceabb0bb8e basic setup for prover session panel;
wenzelm
parents:
diff changeset
   228
    }
57ceabb0bb8e basic setup for prover session panel;
wenzelm
parents:
diff changeset
   229
  }
57ceabb0bb8e basic setup for prover session panel;
wenzelm
parents:
diff changeset
   230
48018
b941dd7df92a make double sure that GUI components are up-to-date after init;
wenzelm
parents: 48014
diff changeset
   231
  override def init()
b941dd7df92a make double sure that GUI components are up-to-date after init;
wenzelm
parents: 48014
diff changeset
   232
  {
53177
dcac8d837b9c more uniform treatment of Swing_Thread context switch: prefer asynchronous Swing_Thread.later from actor;
wenzelm
parents: 53176
diff changeset
   233
    PIDE.session.phase_changed += main_actor
50205
788c8263e634 renamed main plugin object to PIDE;
wenzelm
parents: 50183
diff changeset
   234
    PIDE.session.global_options += main_actor
53177
dcac8d837b9c more uniform treatment of Swing_Thread context switch: prefer asynchronous Swing_Thread.later from actor;
wenzelm
parents: 53176
diff changeset
   235
    PIDE.session.commands_changed += main_actor
dcac8d837b9c more uniform treatment of Swing_Thread context switch: prefer asynchronous Swing_Thread.later from actor;
wenzelm
parents: 53176
diff changeset
   236
dcac8d837b9c more uniform treatment of Swing_Thread context switch: prefer asynchronous Swing_Thread.later from actor;
wenzelm
parents: 53176
diff changeset
   237
    handle_phase(PIDE.session.phase)
dcac8d837b9c more uniform treatment of Swing_Thread context switch: prefer asynchronous Swing_Thread.later from actor;
wenzelm
parents: 53176
diff changeset
   238
    handle_update()
39635
5cd8545a070b added Session_Dockable.session_phase label;
wenzelm
parents: 39629
diff changeset
   239
  }
5cd8545a070b added Session_Dockable.session_phase label;
wenzelm
parents: 39629
diff changeset
   240
48018
b941dd7df92a make double sure that GUI components are up-to-date after init;
wenzelm
parents: 48014
diff changeset
   241
  override def exit()
b941dd7df92a make double sure that GUI components are up-to-date after init;
wenzelm
parents: 48014
diff changeset
   242
  {
50205
788c8263e634 renamed main plugin object to PIDE;
wenzelm
parents: 50183
diff changeset
   243
    PIDE.session.phase_changed -= main_actor
788c8263e634 renamed main plugin object to PIDE;
wenzelm
parents: 50183
diff changeset
   244
    PIDE.session.global_options -= main_actor
788c8263e634 renamed main plugin object to PIDE;
wenzelm
parents: 50183
diff changeset
   245
    PIDE.session.commands_changed -= main_actor
39635
5cd8545a070b added Session_Dockable.session_phase label;
wenzelm
parents: 39629
diff changeset
   246
  }
39515
57ceabb0bb8e basic setup for prover session panel;
wenzelm
parents:
diff changeset
   247
}