src/Tools/jEdit/src/theories_dockable.scala
author wenzelm
Sat, 13 Aug 2022 23:04:53 +0200
changeset 75853 f981111768ec
parent 75849 dfedac6525d4
child 76481 a9d52d02bd83
permissions -rw-r--r--
clarified signature;
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
53711
8ce7795256e1 improved FlowLayout for wrapping of components over multiple lines;
wenzelm
parents: 53178
diff changeset
    12
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
    13
  ScrollPane, Component, CheckBox, BorderPanel}
75853
f981111768ec clarified signature;
wenzelm
parents: 75849
diff changeset
    14
import scala.swing.event.{MouseClicked, MouseMoved}
39593
1a34187f0b97 basic setup for Session_Dockable controls;
wenzelm
parents: 39591
diff changeset
    15
53178
0a3a5f606b2a more precise painting;
wenzelm
parents: 53177
diff changeset
    16
import java.awt.{BorderLayout, Graphics2D, Color, Point, Dimension}
56389
e49561ae3b65 tuned rendering for 5 different look-and-feels;
wenzelm
parents: 56372
diff changeset
    17
import javax.swing.{JList, BorderFactory, UIManager}
e49561ae3b65 tuned rendering for 5 different look-and-feels;
wenzelm
parents: 56372
diff changeset
    18
import javax.swing.border.{BevelBorder, SoftBevelBorder}
39515
57ceabb0bb8e basic setup for prover session panel;
wenzelm
parents:
diff changeset
    19
44865
679f0d57e831 some keyboard shortcuts for important actions;
wenzelm
parents: 44864
diff changeset
    20
import org.gjt.sp.jedit.{View, jEdit}
39515
57ceabb0bb8e basic setup for prover session panel;
wenzelm
parents:
diff changeset
    21
57ceabb0bb8e basic setup for prover session panel;
wenzelm
parents:
diff changeset
    22
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73987
diff changeset
    23
class Theories_Dockable(view: View, position: String) extends Dockable(view, position) {
48021
d899be1cfe6d separate syslog dockable -- discontinued tendency of sub-window management via tabs;
wenzelm
parents: 48018
diff changeset
    24
  /* status */
39591
a43a723753e6 more content for Session_Dockable;
wenzelm
parents: 39589
diff changeset
    25
73361
wenzelm
parents: 73359
diff changeset
    26
  private val status = new ListView(List.empty[Document.Node.Name]) {
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73987
diff changeset
    27
    background = {
56389
e49561ae3b65 tuned rendering for 5 different look-and-feels;
wenzelm
parents: 56372
diff changeset
    28
      // enforce default value
e49561ae3b65 tuned rendering for 5 different look-and-feels;
wenzelm
parents: 56372
diff changeset
    29
      val c = UIManager.getDefaults.getColor("Panel.background")
e49561ae3b65 tuned rendering for 5 different look-and-feels;
wenzelm
parents: 56372
diff changeset
    30
      new Color(c.getRed, c.getGreen, c.getBlue, c.getAlpha)
e49561ae3b65 tuned rendering for 5 different look-and-feels;
wenzelm
parents: 56372
diff changeset
    31
    }
44991
d88f7fc62a40 double clicks switch to document node buffer;
wenzelm
parents: 44990
diff changeset
    32
    listenTo(mouse.clicks)
52817
408fb2e563df added home-made tooltips;
wenzelm
parents: 52816
diff changeset
    33
    listenTo(mouse.moves)
44991
d88f7fc62a40 double clicks switch to document node buffer;
wenzelm
parents: 44990
diff changeset
    34
    reactions += {
52816
c608e0ade554 home-grown mouse handling to pretend that the painted checkbox is actually a Swing component;
wenzelm
parents: 52815
diff changeset
    35
      case MouseClicked(_, point, _, clicks, _) =>
44991
d88f7fc62a40 double clicks switch to document node buffer;
wenzelm
parents: 44990
diff changeset
    36
        val index = peer.locationToIndex(point)
52817
408fb2e563df added home-made tooltips;
wenzelm
parents: 52816
diff changeset
    37
        if (index >= 0) {
408fb2e563df added home-made tooltips;
wenzelm
parents: 52816
diff changeset
    38
          if (in_checkbox(peer.indexToLocation(index), point)) {
64817
0bb6b582bb4f separate Buffer_Model vs. File_Model;
wenzelm
parents: 64813
diff changeset
    39
            if (clicks == 1) Document_Model.node_required(listData(index), toggle = true)
52816
c608e0ade554 home-grown mouse handling to pretend that the painted checkbox is actually a Swing component;
wenzelm
parents: 52815
diff changeset
    40
          }
66082
2d12a730a380 clarified modules;
wenzelm
parents: 66032
diff changeset
    41
          else if (clicks == 2) PIDE.editor.goto_file(true, 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
    42
        }
52817
408fb2e563df added home-made tooltips;
wenzelm
parents: 52816
diff changeset
    43
      case MouseMoved(_, point, _) =>
408fb2e563df added home-made tooltips;
wenzelm
parents: 52816
diff changeset
    44
        val index = peer.locationToIndex(point)
66032
fd8a65b026f1 more tooltips;
wenzelm
parents: 65897
diff changeset
    45
        val index_location = peer.indexToLocation(index)
75834
afa35ed14c71 clarified signature: more explicit types;
wenzelm
parents: 75829
diff changeset
    46
        if (index >= 0 && in_checkbox(index_location, point)) {
52817
408fb2e563df added home-made tooltips;
wenzelm
parents: 52816
diff changeset
    47
          tooltip = "Mark as required for continuous checking"
75834
afa35ed14c71 clarified signature: more explicit types;
wenzelm
parents: 75829
diff changeset
    48
        } else if (index >= 0 && in_label(index_location, point)) {
66418
410b10ea405c tuned GUI;
wenzelm
parents: 66417
diff changeset
    49
          val name = listData(index)
68759
4247e91fa21d clarified modules;
wenzelm
parents: 68758
diff changeset
    50
          val st = nodes_status.overall_node_status(name)
66418
410b10ea405c tuned GUI;
wenzelm
parents: 66417
diff changeset
    51
          tooltip =
410b10ea405c tuned GUI;
wenzelm
parents: 66417
diff changeset
    52
            "theory " + quote(name.theory) +
68759
4247e91fa21d clarified modules;
wenzelm
parents: 68758
diff changeset
    53
              (if (st == Document_Status.Overall_Node_Status.ok) "" else " (" + st + ")")
66418
410b10ea405c tuned GUI;
wenzelm
parents: 66417
diff changeset
    54
        }
410b10ea405c tuned GUI;
wenzelm
parents: 66417
diff changeset
    55
        else tooltip = null
44991
d88f7fc62a40 double clicks switch to document node buffer;
wenzelm
parents: 44990
diff changeset
    56
    }
d88f7fc62a40 double clicks switch to document node buffer;
wenzelm
parents: 44990
diff changeset
    57
  }
50250
267bd685a69f smarter list layout;
wenzelm
parents: 50209
diff changeset
    58
  status.peer.setLayoutOrientation(JList.HORIZONTAL_WRAP)
267bd685a69f smarter list layout;
wenzelm
parents: 50209
diff changeset
    59
  status.peer.setVisibleRowCount(0)
44609
6ec4a5eb2fc0 some support for theory status overview;
wenzelm
parents: 44335
diff changeset
    60
  status.selection.intervalMode = ListView.IntervalMode.Single
6ec4a5eb2fc0 some support for theory status overview;
wenzelm
parents: 44335
diff changeset
    61
49038
2f0530b81c45 recovered ScrollPane from d899be1cfe6d;
wenzelm
parents: 48870
diff changeset
    62
  set_content(new ScrollPane(status))
39515
57ceabb0bb8e basic setup for prover session panel;
wenzelm
parents:
diff changeset
    63
57ceabb0bb8e basic setup for prover session panel;
wenzelm
parents:
diff changeset
    64
39593
1a34187f0b97 basic setup for Session_Dockable controls;
wenzelm
parents: 39591
diff changeset
    65
  /* controls */
1a34187f0b97 basic setup for Session_Dockable controls;
wenzelm
parents: 39591
diff changeset
    66
65206
ff8c3c29a924 clarified Session.Phase;
wenzelm
parents: 64867
diff changeset
    67
  def phase_text(phase: Session.Phase): String = "Prover: " + phase.print
50299
f70b3712040f renamed dockable "Prover Session" to "Theories";
wenzelm
parents: 50250
diff changeset
    68
f70b3712040f renamed dockable "Prover Session" to "Theories";
wenzelm
parents: 50250
diff changeset
    69
  private val session_phase = new Label(phase_text(PIDE.session.phase))
39697
d54242927fb1 tuned border;
wenzelm
parents: 39696
diff changeset
    70
  session_phase.border = new SoftBevelBorder(BevelBorder.LOWERED)
50299
f70b3712040f renamed dockable "Prover Session" to "Theories";
wenzelm
parents: 50250
diff changeset
    71
  session_phase.tooltip = "Status of prover session"
39635
5cd8545a070b added Session_Dockable.session_phase label;
wenzelm
parents: 39629
diff changeset
    72
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73987
diff changeset
    73
  private def handle_phase(phase: Session.Phase): Unit = {
57612
990ffb84489b clarified module name: facilitate alternative GUI frameworks;
wenzelm
parents: 56715
diff changeset
    74
    GUI_Thread.require {}
53177
dcac8d837b9c more uniform treatment of Swing_Thread context switch: prefer asynchronous Swing_Thread.later from actor;
wenzelm
parents: 53176
diff changeset
    75
    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
    76
  }
b941dd7df92a make double sure that GUI components are up-to-date after init;
wenzelm
parents: 48014
diff changeset
    77
75853
f981111768ec clarified signature;
wenzelm
parents: 75849
diff changeset
    78
  private val purge = new GUI.Button("Purge") {
64867
e7220f4de11f support "purge" operation on document model;
wenzelm
parents: 64854
diff changeset
    79
    tooltip = "Restrict document model to theories required for open editor buffers"
75853
f981111768ec clarified signature;
wenzelm
parents: 75849
diff changeset
    80
    override def clicked(): Unit = PIDE.editor.purge()
64867
e7220f4de11f support "purge" operation on document model;
wenzelm
parents: 64854
diff changeset
    81
  }
e7220f4de11f support "purge" operation on document model;
wenzelm
parents: 64854
diff changeset
    82
75849
dfedac6525d4 clarified modules;
wenzelm
parents: 75847
diff changeset
    83
  private val continuous_checking = new JEdit_Options.continuous_checking.GUI
54652
07ee041537a5 non-focusable button, to avoid second interpretation of SPACE in C+e SPACE (isabelle.set-node-required);
wenzelm
parents: 53715
diff changeset
    84
  continuous_checking.focusable = false
44776
47e8c8daccae added "check" button: adhoc change to full buffer perspective;
wenzelm
parents: 44775
diff changeset
    85
75829
b8a4f9b1eed6 clarified signature;
wenzelm
parents: 75393
diff changeset
    86
  private val logic = JEdit_Sessions.logic_selector(PIDE.options, autosave = true)
39702
d7c256cb2797 Session_Dockable: more startup controls;
wenzelm
parents: 39701
diff changeset
    87
44775
27930cf6f0f7 added "cancel" button based on cancel_execution, not interrupt (cf. 156be0e43336);
wenzelm
parents: 44734
diff changeset
    88
  private val controls =
66206
2d2082db735a clarified defaults;
wenzelm
parents: 66205
diff changeset
    89
    Wrap_Panel(List(purge, continuous_checking, session_phase, logic))
66205
e9fa94f43a15 tuned signature;
wenzelm
parents: 66191
diff changeset
    90
39593
1a34187f0b97 basic setup for Session_Dockable controls;
wenzelm
parents: 39591
diff changeset
    91
  add(controls.peer, BorderLayout.NORTH)
1a34187f0b97 basic setup for Session_Dockable controls;
wenzelm
parents: 39591
diff changeset
    92
1a34187f0b97 basic setup for Session_Dockable controls;
wenzelm
parents: 39591
diff changeset
    93
57612
990ffb84489b clarified module name: facilitate alternative GUI frameworks;
wenzelm
parents: 56715
diff changeset
    94
  /* component state -- owned by GUI thread */
44609
6ec4a5eb2fc0 some support for theory status overview;
wenzelm
parents: 44335
diff changeset
    95
68759
4247e91fa21d clarified modules;
wenzelm
parents: 68758
diff changeset
    96
  private var nodes_status = Document_Status.Nodes_Status.empty
64817
0bb6b582bb4f separate Buffer_Model vs. File_Model;
wenzelm
parents: 64813
diff changeset
    97
  private var nodes_required: Set[Document.Node.Name] = Document_Model.required_nodes()
52815
eaad5fe7bb1b actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents: 52809
diff changeset
    98
75834
afa35ed14c71 clarified signature: more explicit types;
wenzelm
parents: 75829
diff changeset
    99
  private class Geometry {
afa35ed14c71 clarified signature: more explicit types;
wenzelm
parents: 75829
diff changeset
   100
    private var location: Point = null
afa35ed14c71 clarified signature: more explicit types;
wenzelm
parents: 75829
diff changeset
   101
    private var size: Dimension = null
afa35ed14c71 clarified signature: more explicit types;
wenzelm
parents: 75829
diff changeset
   102
afa35ed14c71 clarified signature: more explicit types;
wenzelm
parents: 75829
diff changeset
   103
    def in(location0: Point, p: Point): Boolean = {
afa35ed14c71 clarified signature: more explicit types;
wenzelm
parents: 75829
diff changeset
   104
      location != null && size != null &&
afa35ed14c71 clarified signature: more explicit types;
wenzelm
parents: 75829
diff changeset
   105
        location0.x + location.x <= p.x && p.x < location0.x + size.width &&
afa35ed14c71 clarified signature: more explicit types;
wenzelm
parents: 75829
diff changeset
   106
        location0.y + location.y <= p.y && p.y < location0.y + size.height
66032
fd8a65b026f1 more tooltips;
wenzelm
parents: 65897
diff changeset
   107
    }
fd8a65b026f1 more tooltips;
wenzelm
parents: 65897
diff changeset
   108
75834
afa35ed14c71 clarified signature: more explicit types;
wenzelm
parents: 75829
diff changeset
   109
    def update(new_location: Point, new_size: Dimension): Unit = {
afa35ed14c71 clarified signature: more explicit types;
wenzelm
parents: 75829
diff changeset
   110
      if (new_location != null && new_size != null) {
afa35ed14c71 clarified signature: more explicit types;
wenzelm
parents: 75829
diff changeset
   111
        location = new_location
afa35ed14c71 clarified signature: more explicit types;
wenzelm
parents: 75829
diff changeset
   112
        size = new_size
afa35ed14c71 clarified signature: more explicit types;
wenzelm
parents: 75829
diff changeset
   113
      }
afa35ed14c71 clarified signature: more explicit types;
wenzelm
parents: 75829
diff changeset
   114
    }
afa35ed14c71 clarified signature: more explicit types;
wenzelm
parents: 75829
diff changeset
   115
  }
66032
fd8a65b026f1 more tooltips;
wenzelm
parents: 65897
diff changeset
   116
75834
afa35ed14c71 clarified signature: more explicit types;
wenzelm
parents: 75829
diff changeset
   117
  private def in_checkbox(location0: Point, p: Point): Boolean =
afa35ed14c71 clarified signature: more explicit types;
wenzelm
parents: 75829
diff changeset
   118
    Node_Renderer_Component != null && Node_Renderer_Component.checkbox_geometry.in(location0, p)
afa35ed14c71 clarified signature: more explicit types;
wenzelm
parents: 75829
diff changeset
   119
afa35ed14c71 clarified signature: more explicit types;
wenzelm
parents: 75829
diff changeset
   120
  private def in_label(location0: Point, p: Point): Boolean =
afa35ed14c71 clarified signature: more explicit types;
wenzelm
parents: 75829
diff changeset
   121
    Node_Renderer_Component != null && Node_Renderer_Component.label_geometry.in(location0, p)
66032
fd8a65b026f1 more tooltips;
wenzelm
parents: 65897
diff changeset
   122
52817
408fb2e563df added home-made tooltips;
wenzelm
parents: 52816
diff changeset
   123
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73987
diff changeset
   124
  private object Node_Renderer_Component extends BorderPanel {
56389
e49561ae3b65 tuned rendering for 5 different look-and-feels;
wenzelm
parents: 56372
diff changeset
   125
    opaque = true
53176
f88635e1c52e clarified border (again, see also 7ce3ebc268a1);
wenzelm
parents: 52980
diff changeset
   126
    border = BorderFactory.createEmptyBorder(2, 2, 2, 2)
44957
098dd95349e7 more elaborate Node_Renderer, which paints node_name.theory only;
wenzelm
parents: 44867
diff changeset
   127
75835
5c53e24d3dc2 tuned, following hints by IntelliJ IDEA;
wenzelm
parents: 75834
diff changeset
   128
    var node_name: Document.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
   129
75834
afa35ed14c71 clarified signature: more explicit types;
wenzelm
parents: 75829
diff changeset
   130
    val checkbox_geometry = new Geometry
75835
5c53e24d3dc2 tuned, following hints by IntelliJ IDEA;
wenzelm
parents: 75834
diff changeset
   131
    val checkbox: CheckBox = new CheckBox {
52819
7ce3ebc268a1 proper border (again) -- avoid NPE on Windows;
wenzelm
parents: 52817
diff changeset
   132
      opaque = false
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73987
diff changeset
   133
      override def paintComponent(gfx: Graphics2D): Unit = {
52816
c608e0ade554 home-grown mouse handling to pretend that the painted checkbox is actually a Swing component;
wenzelm
parents: 52815
diff changeset
   134
        super.paintComponent(gfx)
75834
afa35ed14c71 clarified signature: more explicit types;
wenzelm
parents: 75829
diff changeset
   135
        checkbox_geometry.update(location, size)
52816
c608e0ade554 home-grown mouse handling to pretend that the painted checkbox is actually a Swing component;
wenzelm
parents: 52815
diff changeset
   136
      }
c608e0ade554 home-grown mouse handling to pretend that the painted checkbox is actually a Swing component;
wenzelm
parents: 52815
diff changeset
   137
    }
52815
eaad5fe7bb1b actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents: 52809
diff changeset
   138
75834
afa35ed14c71 clarified signature: more explicit types;
wenzelm
parents: 75829
diff changeset
   139
    val label_geometry = new Geometry
75835
5c53e24d3dc2 tuned, following hints by IntelliJ IDEA;
wenzelm
parents: 75834
diff changeset
   140
    val label: Label = new Label {
56389
e49561ae3b65 tuned rendering for 5 different look-and-feels;
wenzelm
parents: 56372
diff changeset
   141
      background = view.getTextArea.getPainter.getBackground
e49561ae3b65 tuned rendering for 5 different look-and-feels;
wenzelm
parents: 56372
diff changeset
   142
      foreground = view.getTextArea.getPainter.getForeground
52815
eaad5fe7bb1b actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents: 52809
diff changeset
   143
      opaque = false
eaad5fe7bb1b actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents: 52809
diff changeset
   144
      xAlignment = Alignment.Leading
52809
e750169a5884 paint unassigned/unchanged nodes as unprocessed -- relevant for editor_continuous_checking = false;
wenzelm
parents: 52807
diff changeset
   145
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73987
diff changeset
   146
      override def paintComponent(gfx: Graphics2D): Unit = {
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73987
diff changeset
   147
        def paint_segment(x: Int, w: Int, color: Color): Unit = {
53178
0a3a5f606b2a more precise painting;
wenzelm
parents: 53177
diff changeset
   148
          gfx.setColor(color)
0a3a5f606b2a more precise painting;
wenzelm
parents: 53177
diff changeset
   149
          gfx.fillRect(x, 0, w, size.height)
0a3a5f606b2a more precise painting;
wenzelm
parents: 53177
diff changeset
   150
        }
50900
6d80709ab862 separate color ranges by 1px to improve discernment of overall theory status;
wenzelm
parents: 50895
diff changeset
   151
56389
e49561ae3b65 tuned rendering for 5 different look-and-feels;
wenzelm
parents: 56372
diff changeset
   152
        paint_segment(0, size.width, background)
52815
eaad5fe7bb1b actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents: 52809
diff changeset
   153
        nodes_status.get(node_name) match {
69820
dfc5f8294fbc suppress nodes with vacuous status, notably empty nodes (amending 5f160df596c1);
wenzelm
parents: 69819
diff changeset
   154
          case Some(node_status) =>
53178
0a3a5f606b2a more precise painting;
wenzelm
parents: 53177
diff changeset
   155
            val segments =
0a3a5f606b2a more precise painting;
wenzelm
parents: 53177
diff changeset
   156
              List(
69819
wenzelm
parents: 69818
diff changeset
   157
                (node_status.unprocessed, PIDE.options.color_value("unprocessed1_color")),
wenzelm
parents: 69818
diff changeset
   158
                (node_status.running, PIDE.options.color_value("running_color")),
wenzelm
parents: 69818
diff changeset
   159
                (node_status.warned, PIDE.options.color_value("warning_color")),
wenzelm
parents: 69818
diff changeset
   160
                (node_status.failed, PIDE.options.color_value("error_color"))
53178
0a3a5f606b2a more precise painting;
wenzelm
parents: 53177
diff changeset
   161
              ).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
   162
73359
d8a0e996614b tuned --- fewer warnings;
wenzelm
parents: 73358
diff changeset
   163
            segments.foldLeft(size.width - 2) {
d8a0e996614b tuned --- fewer warnings;
wenzelm
parents: 73358
diff changeset
   164
              case (last, (n, color)) =>
d8a0e996614b tuned --- fewer warnings;
wenzelm
parents: 73358
diff changeset
   165
                val w = (n * ((size.width - 4) - segments.length) / node_status.total) max 4
d8a0e996614b tuned --- fewer warnings;
wenzelm
parents: 73358
diff changeset
   166
                paint_segment(last - w, w, color)
d8a0e996614b tuned --- fewer warnings;
wenzelm
parents: 73358
diff changeset
   167
                last - w - 1
d8a0e996614b tuned --- fewer warnings;
wenzelm
parents: 73358
diff changeset
   168
              }
53178
0a3a5f606b2a more precise painting;
wenzelm
parents: 53177
diff changeset
   169
69820
dfc5f8294fbc suppress nodes with vacuous status, notably empty nodes (amending 5f160df596c1);
wenzelm
parents: 69819
diff changeset
   170
          case None =>
53178
0a3a5f606b2a more precise painting;
wenzelm
parents: 53177
diff changeset
   171
            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
   172
        }
eaad5fe7bb1b actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents: 52809
diff changeset
   173
        super.paintComponent(gfx)
66032
fd8a65b026f1 more tooltips;
wenzelm
parents: 65897
diff changeset
   174
75834
afa35ed14c71 clarified signature: more explicit types;
wenzelm
parents: 75829
diff changeset
   175
        label_geometry.update(location, size)
44866
0eb8284a64bd some color scheme for theory status;
wenzelm
parents: 44865
diff changeset
   176
      }
0eb8284a64bd some color scheme for theory status;
wenzelm
parents: 44865
diff changeset
   177
    }
52815
eaad5fe7bb1b actions and shortcuts to change node_required status, with painter that looks like CheckBox (non-clickable);
wenzelm
parents: 52809
diff changeset
   178
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73987
diff changeset
   179
    def label_border(name: Document.Node.Name): Unit = {
68768
wenzelm
parents: 68767
diff changeset
   180
      val st = nodes_status.overall_node_status(name)
66411
72de7d59e2f7 more explicit failure;
wenzelm
parents: 66410
diff changeset
   181
      val color =
73872
ced6e3c03425 more visual emphasis on node status;
wenzelm
parents: 73361
diff changeset
   182
        st match {
ced6e3c03425 more visual emphasis on node status;
wenzelm
parents: 73361
diff changeset
   183
          case Document_Status.Overall_Node_Status.ok =>
ced6e3c03425 more visual emphasis on node status;
wenzelm
parents: 73361
diff changeset
   184
            PIDE.options.color_value("ok_color")
ced6e3c03425 more visual emphasis on node status;
wenzelm
parents: 73361
diff changeset
   185
          case Document_Status.Overall_Node_Status.failed =>
ced6e3c03425 more visual emphasis on node status;
wenzelm
parents: 73361
diff changeset
   186
            PIDE.options.color_value("failed_color")
ced6e3c03425 more visual emphasis on node status;
wenzelm
parents: 73361
diff changeset
   187
          case _ => label.foreground
ced6e3c03425 more visual emphasis on node status;
wenzelm
parents: 73361
diff changeset
   188
        }
ced6e3c03425 more visual emphasis on node status;
wenzelm
parents: 73361
diff changeset
   189
      val thickness1 = if (st == Document_Status.Overall_Node_Status.pending) 1 else 3
ced6e3c03425 more visual emphasis on node status;
wenzelm
parents: 73361
diff changeset
   190
      val thickness2 = 4 - thickness1
66411
72de7d59e2f7 more explicit failure;
wenzelm
parents: 66410
diff changeset
   191
66410
72a7e29104f1 explicit indication of consolidated nodes;
wenzelm
parents: 66206
diff changeset
   192
      label.border =
72a7e29104f1 explicit indication of consolidated nodes;
wenzelm
parents: 66206
diff changeset
   193
        BorderFactory.createCompoundBorder(
66412
a8556be5be0b tuned GUI;
wenzelm
parents: 66411
diff changeset
   194
          BorderFactory.createLineBorder(color, thickness1),
a8556be5be0b tuned GUI;
wenzelm
parents: 66411
diff changeset
   195
          BorderFactory.createEmptyBorder(thickness2, thickness2, thickness2, thickness2))
66410
72a7e29104f1 explicit indication of consolidated nodes;
wenzelm
parents: 66206
diff changeset
   196
    }
72a7e29104f1 explicit indication of consolidated nodes;
wenzelm
parents: 66206
diff changeset
   197
52816
c608e0ade554 home-grown mouse handling to pretend that the painted checkbox is actually a Swing component;
wenzelm
parents: 52815
diff changeset
   198
    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
   199
    layout(label) = BorderPanel.Position.Center
44866
0eb8284a64bd some color scheme for theory status;
wenzelm
parents: 44865
diff changeset
   200
  }
0eb8284a64bd some color scheme for theory status;
wenzelm
parents: 44865
diff changeset
   201
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73987
diff changeset
   202
  private class Node_Renderer extends ListView.Renderer[Document.Node.Name] {
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73987
diff changeset
   203
    def componentFor(
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73987
diff changeset
   204
      list: ListView[_ <: isabelle.Document.Node.Name],
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73987
diff changeset
   205
      isSelected: Boolean,
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73987
diff changeset
   206
      focused: Boolean,
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73987
diff changeset
   207
      name: Document.Node.Name,
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73987
diff changeset
   208
      index: Int
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73987
diff changeset
   209
    ): Component = {
44990
wenzelm
parents: 44989
diff changeset
   210
      val component = Node_Renderer_Component
44957
098dd95349e7 more elaborate Node_Renderer, which paints node_name.theory only;
wenzelm
parents: 44867
diff changeset
   211
      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
   212
      component.checkbox.selected = nodes_required.contains(name)
66410
72a7e29104f1 explicit indication of consolidated nodes;
wenzelm
parents: 66206
diff changeset
   213
      component.label_border(name)
65493
4729318d3fc3 tuned GUI;
wenzelm
parents: 65361
diff changeset
   214
      component.label.text = name.theory_base_name
44990
wenzelm
parents: 44989
diff changeset
   215
      component
44957
098dd95349e7 more elaborate Node_Renderer, which paints node_name.theory only;
wenzelm
parents: 44867
diff changeset
   216
    }
098dd95349e7 more elaborate Node_Renderer, which paints node_name.theory only;
wenzelm
parents: 44867
diff changeset
   217
  }
098dd95349e7 more elaborate Node_Renderer, which paints node_name.theory only;
wenzelm
parents: 44867
diff changeset
   218
  status.renderer = new Node_Renderer
44609
6ec4a5eb2fc0 some support for theory status overview;
wenzelm
parents: 44335
diff changeset
   219
73340
0ffcad1f6130 tuned --- fewer warnings;
wenzelm
parents: 69820
diff changeset
   220
  private def handle_update(
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73987
diff changeset
   221
    domain: Option[Set[Document.Node.Name]] = None,
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73987
diff changeset
   222
    trim: Boolean = false
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73987
diff changeset
   223
  ): Unit = {
62052
8bcbf1c93119 node_status update is back on GUI thread (reverting 3ad2b2055ffc) -- avoid potential deadlock of GUI_Thread.now during shutdown, when GUI thread is already terminated;
wenzelm
parents: 61716
diff changeset
   224
    GUI_Thread.require {}
53177
dcac8d837b9c more uniform treatment of Swing_Thread context switch: prefer asynchronous Swing_Thread.later from actor;
wenzelm
parents: 53176
diff changeset
   225
62052
8bcbf1c93119 node_status update is back on GUI thread (reverting 3ad2b2055ffc) -- avoid potential deadlock of GUI_Thread.now during shutdown, when GUI thread is already terminated;
wenzelm
parents: 61716
diff changeset
   226
    val snapshot = PIDE.session.snapshot()
44613
a3255c85327b crude display of node status;
wenzelm
parents: 44609
diff changeset
   227
68903
58525b08eed1 clarified Nodes_Status;
wenzelm
parents: 68769
diff changeset
   228
    val (nodes_status_changed, nodes_status1) =
58525b08eed1 clarified Nodes_Status;
wenzelm
parents: 68769
diff changeset
   229
      nodes_status.update(
69255
800b1ce96fce more general support for Isabelle/PIDE file formats -- less hardwired Bibtex operations;
wenzelm
parents: 68904
diff changeset
   230
        PIDE.resources, snapshot.state, snapshot.version, domain = domain, trim = trim)
68903
58525b08eed1 clarified Nodes_Status;
wenzelm
parents: 68769
diff changeset
   231
58525b08eed1 clarified Nodes_Status;
wenzelm
parents: 68769
diff changeset
   232
    nodes_status = nodes_status1
69818
60d0ee8f2ddb more robust: avoid potentially unrelated snapshot for the sake of is_suppressed;
wenzelm
parents: 69817
diff changeset
   233
    if (nodes_status_changed) {
60d0ee8f2ddb more robust: avoid potentially unrelated snapshot for the sake of is_suppressed;
wenzelm
parents: 69817
diff changeset
   234
      status.listData =
69820
dfc5f8294fbc suppress nodes with vacuous status, notably empty nodes (amending 5f160df596c1);
wenzelm
parents: 69819
diff changeset
   235
        (for {
dfc5f8294fbc suppress nodes with vacuous status, notably empty nodes (amending 5f160df596c1);
wenzelm
parents: 69819
diff changeset
   236
          (name, node_status) <- nodes_status1.present.iterator
dfc5f8294fbc suppress nodes with vacuous status, notably empty nodes (amending 5f160df596c1);
wenzelm
parents: 69819
diff changeset
   237
          if !node_status.is_suppressed && node_status.total > 0
dfc5f8294fbc suppress nodes with vacuous status, notably empty nodes (amending 5f160df596c1);
wenzelm
parents: 69819
diff changeset
   238
        } yield name).toList
69818
60d0ee8f2ddb more robust: avoid potentially unrelated snapshot for the sake of is_suppressed;
wenzelm
parents: 69817
diff changeset
   239
    }
44609
6ec4a5eb2fc0 some support for theory status overview;
wenzelm
parents: 44335
diff changeset
   240
  }
6ec4a5eb2fc0 some support for theory status overview;
wenzelm
parents: 44335
diff changeset
   241
6ec4a5eb2fc0 some support for theory status overview;
wenzelm
parents: 44335
diff changeset
   242
56715
52125652e82a clarified Session.Consumer, with Session.Outlet managed by dispatcher thread;
wenzelm
parents: 56662
diff changeset
   243
  /* main */
39515
57ceabb0bb8e basic setup for prover session panel;
wenzelm
parents:
diff changeset
   244
56715
52125652e82a clarified Session.Consumer, with Session.Outlet managed by dispatcher thread;
wenzelm
parents: 56662
diff changeset
   245
  private val main =
52125652e82a clarified Session.Consumer, with Session.Outlet managed by dispatcher thread;
wenzelm
parents: 56662
diff changeset
   246
    Session.Consumer[Any](getClass.getName) {
52125652e82a clarified Session.Consumer, with Session.Outlet managed by dispatcher thread;
wenzelm
parents: 56662
diff changeset
   247
      case phase: Session.Phase =>
57612
990ffb84489b clarified module name: facilitate alternative GUI frameworks;
wenzelm
parents: 56715
diff changeset
   248
        GUI_Thread.later { handle_phase(phase) }
39635
5cd8545a070b added Session_Dockable.session_phase label;
wenzelm
parents: 39629
diff changeset
   249
56715
52125652e82a clarified Session.Consumer, with Session.Outlet managed by dispatcher thread;
wenzelm
parents: 56662
diff changeset
   250
      case _: Session.Global_Options =>
57612
990ffb84489b clarified module name: facilitate alternative GUI frameworks;
wenzelm
parents: 56715
diff changeset
   251
        GUI_Thread.later {
56715
52125652e82a clarified Session.Consumer, with Session.Outlet managed by dispatcher thread;
wenzelm
parents: 56662
diff changeset
   252
          continuous_checking.load()
52125652e82a clarified Session.Consumer, with Session.Outlet managed by dispatcher thread;
wenzelm
parents: 56662
diff changeset
   253
          logic.load ()
64817
0bb6b582bb4f separate Buffer_Model vs. File_Model;
wenzelm
parents: 64813
diff changeset
   254
          nodes_required = Document_Model.required_nodes()
56715
52125652e82a clarified Session.Consumer, with Session.Outlet managed by dispatcher thread;
wenzelm
parents: 56662
diff changeset
   255
          status.repaint()
52125652e82a clarified Session.Consumer, with Session.Outlet managed by dispatcher thread;
wenzelm
parents: 56662
diff changeset
   256
        }
49247
ffd9ad9dc35b more detailed option tooltip;
wenzelm
parents: 49246
diff changeset
   257
56715
52125652e82a clarified Session.Consumer, with Session.Outlet managed by dispatcher thread;
wenzelm
parents: 56662
diff changeset
   258
      case changed: Session.Commands_Changed =>
68766
43a8d0f08600 tuned signature;
wenzelm
parents: 68764
diff changeset
   259
        GUI_Thread.later { handle_update(domain = Some(changed.nodes), trim = changed.assignment) }
39515
57ceabb0bb8e basic setup for prover session panel;
wenzelm
parents:
diff changeset
   260
    }
57ceabb0bb8e basic setup for prover session panel;
wenzelm
parents:
diff changeset
   261
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73987
diff changeset
   262
  override def init(): Unit = {
56715
52125652e82a clarified Session.Consumer, with Session.Outlet managed by dispatcher thread;
wenzelm
parents: 56662
diff changeset
   263
    PIDE.session.phase_changed += main
52125652e82a clarified Session.Consumer, with Session.Outlet managed by dispatcher thread;
wenzelm
parents: 56662
diff changeset
   264
    PIDE.session.global_options += main
52125652e82a clarified Session.Consumer, with Session.Outlet managed by dispatcher thread;
wenzelm
parents: 56662
diff changeset
   265
    PIDE.session.commands_changed += main
53177
dcac8d837b9c more uniform treatment of Swing_Thread context switch: prefer asynchronous Swing_Thread.later from actor;
wenzelm
parents: 53176
diff changeset
   266
dcac8d837b9c more uniform treatment of Swing_Thread context switch: prefer asynchronous Swing_Thread.later from actor;
wenzelm
parents: 53176
diff changeset
   267
    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
   268
    handle_update()
39635
5cd8545a070b added Session_Dockable.session_phase label;
wenzelm
parents: 39629
diff changeset
   269
  }
5cd8545a070b added Session_Dockable.session_phase label;
wenzelm
parents: 39629
diff changeset
   270
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73987
diff changeset
   271
  override def exit(): Unit = {
56715
52125652e82a clarified Session.Consumer, with Session.Outlet managed by dispatcher thread;
wenzelm
parents: 56662
diff changeset
   272
    PIDE.session.phase_changed -= main
52125652e82a clarified Session.Consumer, with Session.Outlet managed by dispatcher thread;
wenzelm
parents: 56662
diff changeset
   273
    PIDE.session.global_options -= main
52125652e82a clarified Session.Consumer, with Session.Outlet managed by dispatcher thread;
wenzelm
parents: 56662
diff changeset
   274
    PIDE.session.commands_changed -= main
39635
5cd8545a070b added Session_Dockable.session_phase label;
wenzelm
parents: 39629
diff changeset
   275
  }
39515
57ceabb0bb8e basic setup for prover session panel;
wenzelm
parents:
diff changeset
   276
}