src/Tools/jEdit/src/simplifier_trace_dockable.scala
author wenzelm
Mon, 01 Mar 2021 22:22:12 +0100
changeset 73340 0ffcad1f6130
parent 71704 b9a5eb0f3b43
child 73987 fc363a3b690a
permissions -rw-r--r--
tuned --- fewer warnings;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
55316
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
     1
/*  Title:      Tools/jEdit/src/simplifier_trace_dockable.scala
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
     2
    Author:     Lars Hupel
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
     3
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
     4
Dockable window with interactive simplifier trace.
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
     5
*/
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
     6
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
     7
package isabelle.jedit
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
     8
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
     9
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
    10
import isabelle._
66591
6efa351190d0 more robust: provide docking framework via base plugin;
wenzelm
parents: 66206
diff changeset
    11
import isabelle.jedit_base.Dockable
55316
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
    12
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
    13
import scala.swing.{Button, CheckBox, Orientation, Separator}
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
    14
import scala.swing.event.ButtonClicked
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
    15
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
    16
import java.awt.BorderLayout
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
    17
import java.awt.event.{ComponentEvent, ComponentAdapter}
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
    18
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
    19
import org.gjt.sp.jedit.View
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
    20
55556
60ba93d8f9e5 tuned imports;
wenzelm
parents: 55316
diff changeset
    21
55316
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
    22
class Simplifier_Trace_Dockable(view: View, position: String) extends Dockable(view, position)
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
    23
{
57612
990ffb84489b clarified module name: facilitate alternative GUI frameworks;
wenzelm
parents: 57593
diff changeset
    24
  GUI_Thread.require {}
55316
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
    25
60748
wenzelm
parents: 57612
diff changeset
    26
57612
990ffb84489b clarified module name: facilitate alternative GUI frameworks;
wenzelm
parents: 57593
diff changeset
    27
  /* component state -- owned by GUI thread */
55316
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
    28
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
    29
  private var current_snapshot = Document.State.init.snapshot()
56299
8201790fdeb9 more careful treatment of multiple command states (eval + prints): merge content that is actually required;
wenzelm
parents: 55825
diff changeset
    30
  private var current_command = Command.empty
8201790fdeb9 more careful treatment of multiple command states (eval + prints): merge content that is actually required;
wenzelm
parents: 55825
diff changeset
    31
  private var current_results = Command.Results.empty
55316
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
    32
  private var current_id = 0L
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
    33
  private var do_update = true
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
    34
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
    35
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
    36
  private val text_area = new Pretty_Text_Area(view)
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
    37
  set_content(text_area)
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
    38
73340
0ffcad1f6130 tuned --- fewer warnings;
wenzelm
parents: 71704
diff changeset
    39
  private def update_contents(): Unit =
55316
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
    40
  {
57593
2f7d91242b99 proper Swing buttons instead of active areas within text (by Lars Hupel);
wenzelm
parents: 56770
diff changeset
    41
    val snapshot = current_snapshot
2f7d91242b99 proper Swing buttons instead of active areas within text (by Lars Hupel);
wenzelm
parents: 56770
diff changeset
    42
    val context = Simplifier_Trace.handle_results(PIDE.session, current_id, current_results)
55316
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
    43
57593
2f7d91242b99 proper Swing buttons instead of active areas within text (by Lars Hupel);
wenzelm
parents: 56770
diff changeset
    44
    answers.contents.clear()
2f7d91242b99 proper Swing buttons instead of active areas within text (by Lars Hupel);
wenzelm
parents: 56770
diff changeset
    45
    context.questions.values.toList match {
2f7d91242b99 proper Swing buttons instead of active areas within text (by Lars Hupel);
wenzelm
parents: 56770
diff changeset
    46
      case q :: _ =>
2f7d91242b99 proper Swing buttons instead of active areas within text (by Lars Hupel);
wenzelm
parents: 56770
diff changeset
    47
        val data = q.data
2f7d91242b99 proper Swing buttons instead of active areas within text (by Lars Hupel);
wenzelm
parents: 56770
diff changeset
    48
        val content = Pretty.separate(XML.Text(data.text) :: data.content)
2f7d91242b99 proper Swing buttons instead of active areas within text (by Lars Hupel);
wenzelm
parents: 56770
diff changeset
    49
        text_area.update(snapshot, Command.Results.empty, content)
2f7d91242b99 proper Swing buttons instead of active areas within text (by Lars Hupel);
wenzelm
parents: 56770
diff changeset
    50
        q.answers.foreach { answer =>
2f7d91242b99 proper Swing buttons instead of active areas within text (by Lars Hupel);
wenzelm
parents: 56770
diff changeset
    51
          answers.contents += new Button(answer.string) {
2f7d91242b99 proper Swing buttons instead of active areas within text (by Lars Hupel);
wenzelm
parents: 56770
diff changeset
    52
            reactions += {
2f7d91242b99 proper Swing buttons instead of active areas within text (by Lars Hupel);
wenzelm
parents: 56770
diff changeset
    53
              case ButtonClicked(_) =>
2f7d91242b99 proper Swing buttons instead of active areas within text (by Lars Hupel);
wenzelm
parents: 56770
diff changeset
    54
                Simplifier_Trace.send_reply(PIDE.session, data.serial, answer)
2f7d91242b99 proper Swing buttons instead of active areas within text (by Lars Hupel);
wenzelm
parents: 56770
diff changeset
    55
            }
2f7d91242b99 proper Swing buttons instead of active areas within text (by Lars Hupel);
wenzelm
parents: 56770
diff changeset
    56
          }
2f7d91242b99 proper Swing buttons instead of active areas within text (by Lars Hupel);
wenzelm
parents: 56770
diff changeset
    57
        }
2f7d91242b99 proper Swing buttons instead of active areas within text (by Lars Hupel);
wenzelm
parents: 56770
diff changeset
    58
      case Nil =>
2f7d91242b99 proper Swing buttons instead of active areas within text (by Lars Hupel);
wenzelm
parents: 56770
diff changeset
    59
        text_area.update(snapshot, Command.Results.empty, Nil)
2f7d91242b99 proper Swing buttons instead of active areas within text (by Lars Hupel);
wenzelm
parents: 56770
diff changeset
    60
    }
55316
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
    61
57593
2f7d91242b99 proper Swing buttons instead of active areas within text (by Lars Hupel);
wenzelm
parents: 56770
diff changeset
    62
    do_paint()
55316
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
    63
  }
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
    64
73340
0ffcad1f6130 tuned --- fewer warnings;
wenzelm
parents: 71704
diff changeset
    65
  private def show_trace(): Unit =
55316
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
    66
  {
71650
95ab607398bd support multiple sessions, notably for "isabelle build -P -j2";
wenzelm
parents: 66591
diff changeset
    67
    val trace = Simplifier_Trace.generate_trace(PIDE.session, current_results)
55316
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
    68
    new Simplifier_Trace_Window(view, current_snapshot, trace)
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
    69
  }
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
    70
73340
0ffcad1f6130 tuned --- fewer warnings;
wenzelm
parents: 71704
diff changeset
    71
  private def do_paint(): Unit =
55316
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
    72
  {
57612
990ffb84489b clarified module name: facilitate alternative GUI frameworks;
wenzelm
parents: 57593
diff changeset
    73
    GUI_Thread.later {
55825
694833e3e4a0 tuned signature -- separate module Font_Info;
wenzelm
parents: 55556
diff changeset
    74
      text_area.resize(Font_Info.main(PIDE.options.real("jedit_font_scale")))
55316
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
    75
    }
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
    76
  }
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
    77
73340
0ffcad1f6130 tuned --- fewer warnings;
wenzelm
parents: 71704
diff changeset
    78
  private def handle_resize(): Unit = do_paint()
55316
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
    79
73340
0ffcad1f6130 tuned --- fewer warnings;
wenzelm
parents: 71704
diff changeset
    80
  private def handle_update(follow: Boolean): Unit =
55316
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
    81
  {
56299
8201790fdeb9 more careful treatment of multiple command states (eval + prints): merge content that is actually required;
wenzelm
parents: 55825
diff changeset
    82
    val (new_snapshot, new_command, new_results, new_id) =
66082
2d12a730a380 clarified modules;
wenzelm
parents: 65246
diff changeset
    83
      PIDE.editor.current_node_snapshot(view) match {
55316
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
    84
        case Some(snapshot) =>
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
    85
          if (follow && !snapshot.is_outdated) {
66082
2d12a730a380 clarified modules;
wenzelm
parents: 65246
diff changeset
    86
            PIDE.editor.current_command(view, snapshot) match {
55316
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
    87
              case Some(cmd) =>
65195
wenzelm
parents: 60748
diff changeset
    88
                (snapshot, cmd, snapshot.command_results(cmd), cmd.id)
55316
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
    89
              case None =>
56299
8201790fdeb9 more careful treatment of multiple command states (eval + prints): merge content that is actually required;
wenzelm
parents: 55825
diff changeset
    90
                (Document.State.init.snapshot(), Command.empty, Command.Results.empty, 0L)
55316
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
    91
            }
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
    92
          }
56299
8201790fdeb9 more careful treatment of multiple command states (eval + prints): merge content that is actually required;
wenzelm
parents: 55825
diff changeset
    93
          else (current_snapshot, current_command, current_results, current_id)
8201790fdeb9 more careful treatment of multiple command states (eval + prints): merge content that is actually required;
wenzelm
parents: 55825
diff changeset
    94
        case None => (current_snapshot, current_command, current_results, current_id)
55316
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
    95
      }
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
    96
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
    97
    current_snapshot = new_snapshot
56299
8201790fdeb9 more careful treatment of multiple command states (eval + prints): merge content that is actually required;
wenzelm
parents: 55825
diff changeset
    98
    current_command = new_command
8201790fdeb9 more careful treatment of multiple command states (eval + prints): merge content that is actually required;
wenzelm
parents: 55825
diff changeset
    99
    current_results = new_results
55316
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
   100
    current_id = new_id
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
   101
    update_contents()
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
   102
  }
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
   103
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
   104
56715
52125652e82a clarified Session.Consumer, with Session.Outlet managed by dispatcher thread;
wenzelm
parents: 56662
diff changeset
   105
  /* main */
52125652e82a clarified Session.Consumer, with Session.Outlet managed by dispatcher thread;
wenzelm
parents: 56662
diff changeset
   106
52125652e82a clarified Session.Consumer, with Session.Outlet managed by dispatcher thread;
wenzelm
parents: 56662
diff changeset
   107
  private val main =
52125652e82a clarified Session.Consumer, with Session.Outlet managed by dispatcher thread;
wenzelm
parents: 56662
diff changeset
   108
    Session.Consumer[Any](getClass.getName) {
52125652e82a clarified Session.Consumer, with Session.Outlet managed by dispatcher thread;
wenzelm
parents: 56662
diff changeset
   109
      case _: Session.Global_Options =>
57612
990ffb84489b clarified module name: facilitate alternative GUI frameworks;
wenzelm
parents: 57593
diff changeset
   110
        GUI_Thread.later { handle_resize() }
55316
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
   111
56715
52125652e82a clarified Session.Consumer, with Session.Outlet managed by dispatcher thread;
wenzelm
parents: 56662
diff changeset
   112
      case changed: Session.Commands_Changed =>
57612
990ffb84489b clarified module name: facilitate alternative GUI frameworks;
wenzelm
parents: 57593
diff changeset
   113
        GUI_Thread.later { handle_update(do_update) }
56715
52125652e82a clarified Session.Consumer, with Session.Outlet managed by dispatcher thread;
wenzelm
parents: 56662
diff changeset
   114
52125652e82a clarified Session.Consumer, with Session.Outlet managed by dispatcher thread;
wenzelm
parents: 56662
diff changeset
   115
      case Session.Caret_Focus =>
57612
990ffb84489b clarified module name: facilitate alternative GUI frameworks;
wenzelm
parents: 57593
diff changeset
   116
        GUI_Thread.later { handle_update(do_update) }
56715
52125652e82a clarified Session.Consumer, with Session.Outlet managed by dispatcher thread;
wenzelm
parents: 56662
diff changeset
   117
52125652e82a clarified Session.Consumer, with Session.Outlet managed by dispatcher thread;
wenzelm
parents: 56662
diff changeset
   118
      case Simplifier_Trace.Event =>
57612
990ffb84489b clarified module name: facilitate alternative GUI frameworks;
wenzelm
parents: 57593
diff changeset
   119
        GUI_Thread.later { handle_update(do_update) }
55316
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
   120
    }
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
   121
73340
0ffcad1f6130 tuned --- fewer warnings;
wenzelm
parents: 71704
diff changeset
   122
  override def init(): Unit =
55316
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
   123
  {
56715
52125652e82a clarified Session.Consumer, with Session.Outlet managed by dispatcher thread;
wenzelm
parents: 56662
diff changeset
   124
    PIDE.session.global_options += main
52125652e82a clarified Session.Consumer, with Session.Outlet managed by dispatcher thread;
wenzelm
parents: 56662
diff changeset
   125
    PIDE.session.commands_changed += main
52125652e82a clarified Session.Consumer, with Session.Outlet managed by dispatcher thread;
wenzelm
parents: 56662
diff changeset
   126
    PIDE.session.caret_focus += main
52125652e82a clarified Session.Consumer, with Session.Outlet managed by dispatcher thread;
wenzelm
parents: 56662
diff changeset
   127
    PIDE.session.trace_events += main
55316
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
   128
    handle_update(true)
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
   129
  }
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
   130
73340
0ffcad1f6130 tuned --- fewer warnings;
wenzelm
parents: 71704
diff changeset
   131
  override def exit(): Unit =
55316
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
   132
  {
56715
52125652e82a clarified Session.Consumer, with Session.Outlet managed by dispatcher thread;
wenzelm
parents: 56662
diff changeset
   133
    PIDE.session.global_options -= main
52125652e82a clarified Session.Consumer, with Session.Outlet managed by dispatcher thread;
wenzelm
parents: 56662
diff changeset
   134
    PIDE.session.commands_changed -= main
52125652e82a clarified Session.Consumer, with Session.Outlet managed by dispatcher thread;
wenzelm
parents: 56662
diff changeset
   135
    PIDE.session.caret_focus -= main
52125652e82a clarified Session.Consumer, with Session.Outlet managed by dispatcher thread;
wenzelm
parents: 56662
diff changeset
   136
    PIDE.session.trace_events -= main
55316
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
   137
    delay_resize.revoke()
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
   138
  }
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
   139
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
   140
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
   141
  /* resize */
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
   142
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
   143
  private val delay_resize =
71704
b9a5eb0f3b43 clarified modules;
wenzelm
parents: 71650
diff changeset
   144
    Delay.first(PIDE.options.seconds("editor_update_delay"), gui = true) { handle_resize() }
55316
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
   145
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
   146
  addComponentListener(new ComponentAdapter {
73340
0ffcad1f6130 tuned --- fewer warnings;
wenzelm
parents: 71704
diff changeset
   147
    override def componentResized(e: ComponentEvent): Unit = delay_resize.invoke()
0ffcad1f6130 tuned --- fewer warnings;
wenzelm
parents: 71704
diff changeset
   148
    override def componentShown(e: ComponentEvent): Unit = delay_resize.invoke()
55316
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
   149
  })
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
   150
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
   151
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
   152
  /* controls */
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
   153
66205
e9fa94f43a15 tuned signature;
wenzelm
parents: 66082
diff changeset
   154
  private val controls =
66206
2d2082db735a clarified defaults;
wenzelm
parents: 66205
diff changeset
   155
    Wrap_Panel(
66205
e9fa94f43a15 tuned signature;
wenzelm
parents: 66082
diff changeset
   156
      List(
e9fa94f43a15 tuned signature;
wenzelm
parents: 66082
diff changeset
   157
        new CheckBox("Auto update") {
e9fa94f43a15 tuned signature;
wenzelm
parents: 66082
diff changeset
   158
          selected = do_update
e9fa94f43a15 tuned signature;
wenzelm
parents: 66082
diff changeset
   159
          reactions += {
e9fa94f43a15 tuned signature;
wenzelm
parents: 66082
diff changeset
   160
            case ButtonClicked(_) =>
e9fa94f43a15 tuned signature;
wenzelm
parents: 66082
diff changeset
   161
              do_update = this.selected
e9fa94f43a15 tuned signature;
wenzelm
parents: 66082
diff changeset
   162
              handle_update(do_update)
e9fa94f43a15 tuned signature;
wenzelm
parents: 66082
diff changeset
   163
          }
e9fa94f43a15 tuned signature;
wenzelm
parents: 66082
diff changeset
   164
        },
e9fa94f43a15 tuned signature;
wenzelm
parents: 66082
diff changeset
   165
        new Button("Update") {
e9fa94f43a15 tuned signature;
wenzelm
parents: 66082
diff changeset
   166
          reactions += {
e9fa94f43a15 tuned signature;
wenzelm
parents: 66082
diff changeset
   167
            case ButtonClicked(_) =>
e9fa94f43a15 tuned signature;
wenzelm
parents: 66082
diff changeset
   168
              handle_update(true)
e9fa94f43a15 tuned signature;
wenzelm
parents: 66082
diff changeset
   169
          }
e9fa94f43a15 tuned signature;
wenzelm
parents: 66082
diff changeset
   170
        },
e9fa94f43a15 tuned signature;
wenzelm
parents: 66082
diff changeset
   171
        new Separator(Orientation.Vertical),
e9fa94f43a15 tuned signature;
wenzelm
parents: 66082
diff changeset
   172
        new Button("Show trace") {
e9fa94f43a15 tuned signature;
wenzelm
parents: 66082
diff changeset
   173
          reactions += {
e9fa94f43a15 tuned signature;
wenzelm
parents: 66082
diff changeset
   174
            case ButtonClicked(_) =>
e9fa94f43a15 tuned signature;
wenzelm
parents: 66082
diff changeset
   175
              show_trace()
e9fa94f43a15 tuned signature;
wenzelm
parents: 66082
diff changeset
   176
          }
e9fa94f43a15 tuned signature;
wenzelm
parents: 66082
diff changeset
   177
        },
e9fa94f43a15 tuned signature;
wenzelm
parents: 66082
diff changeset
   178
        new Button("Clear memory") {
e9fa94f43a15 tuned signature;
wenzelm
parents: 66082
diff changeset
   179
          reactions += {
e9fa94f43a15 tuned signature;
wenzelm
parents: 66082
diff changeset
   180
            case ButtonClicked(_) =>
71650
95ab607398bd support multiple sessions, notably for "isabelle build -P -j2";
wenzelm
parents: 66591
diff changeset
   181
              Simplifier_Trace.clear_memory(PIDE.session)
66205
e9fa94f43a15 tuned signature;
wenzelm
parents: 66082
diff changeset
   182
          }
e9fa94f43a15 tuned signature;
wenzelm
parents: 66082
diff changeset
   183
        }))
55316
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
   184
66206
2d2082db735a clarified defaults;
wenzelm
parents: 66205
diff changeset
   185
  private val answers = Wrap_Panel(Nil, Wrap_Panel.Alignment.Left)
57593
2f7d91242b99 proper Swing buttons instead of active areas within text (by Lars Hupel);
wenzelm
parents: 56770
diff changeset
   186
55316
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
   187
  add(controls.peer, BorderLayout.NORTH)
57593
2f7d91242b99 proper Swing buttons instead of active areas within text (by Lars Hupel);
wenzelm
parents: 56770
diff changeset
   188
  add(answers.peer, BorderLayout.SOUTH)
55316
885500f4aa6a interactive simplifier trace: new panel in Isabelle/jEdit to inspect and modify simplification state
Lars Hupel <lars.hupel@mytum.de>
parents:
diff changeset
   189
}