author | wenzelm |
Tue, 06 Sep 2011 11:25:27 +0200 | |
changeset 44734 | 7313e2db3d39 |
parent 44672 | 07dad1433cd7 |
child 44775 | 27930cf6f0f7 |
permissions | -rw-r--r-- |
43282
5d294220ca43
moved sources -- eliminated Netbeans artifact of jedit package directory;
wenzelm
parents:
39736
diff
changeset
|
1 |
/* Title: Tools/jEdit/src/session_dockable.scala |
39515 | 2 |
Author: Makarius |
3 |
||
4 |
Dockable window for prover session management. |
|
5 |
*/ |
|
6 |
||
7 |
package isabelle.jedit |
|
8 |
||
9 |
||
10 |
import isabelle._ |
|
11 |
||
12 |
import scala.actors.Actor._ |
|
44609 | 13 |
import scala.swing.{FlowPanel, Button, TextArea, Label, ListView, |
14 |
ScrollPane, TabbedPane, Component, Swing} |
|
39638 | 15 |
import scala.swing.event.{ButtonClicked, SelectionChanged} |
39593 | 16 |
|
43520
cec9b95fa35d
explicit import java.lang.System to prevent odd scope problems;
wenzelm
parents:
43282
diff
changeset
|
17 |
import java.lang.System |
39593 | 18 |
import java.awt.BorderLayout |
44609 | 19 |
import javax.swing.JList |
39697 | 20 |
import javax.swing.border.{BevelBorder, SoftBevelBorder} |
39515 | 21 |
|
22 |
import org.gjt.sp.jedit.View |
|
23 |
||
24 |
||
25 |
class Session_Dockable(view: View, position: String) extends Dockable(view: View, position: String) |
|
26 |
{ |
|
39591 | 27 |
/* main tabs */ |
28 |
||
43661
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43606
diff
changeset
|
29 |
private val readme = new HTML_Panel("SansSerif", 14) |
39fdbd814c7f
quasi-static Isabelle_System -- reduced tendency towards "functorial style";
wenzelm
parents:
43606
diff
changeset
|
30 |
readme.render_document(Isabelle_System.try_read(List(Path.explode("$JEDIT_HOME/README.html")))) |
39591 | 31 |
|
44609 | 32 |
val status = new ListView(Nil: List[String]) |
33 |
status.peer.setLayoutOrientation(JList.VERTICAL_WRAP) |
|
34 |
status.selection.intervalMode = ListView.IntervalMode.Single |
|
35 |
||
39629 | 36 |
private val syslog = new TextArea(Isabelle.session.syslog()) |
39591 | 37 |
|
38 |
private val tabs = new TabbedPane { |
|
39 |
pages += new TabbedPane.Page("README", Component.wrap(readme)) |
|
44609 | 40 |
pages += new TabbedPane.Page("Theory Status", new ScrollPane(status)) |
41 |
pages += new TabbedPane.Page("System Log", new ScrollPane(syslog)) |
|
39638 | 42 |
|
43 |
selection.index = |
|
44 |
{ |
|
45 |
val index = Isabelle.Int_Property("session-panel.selection", 0) |
|
46 |
if (index >= pages.length) 0 else index |
|
47 |
} |
|
48 |
listenTo(selection) |
|
49 |
reactions += { |
|
50 |
case SelectionChanged(_) => |
|
51 |
Isabelle.Int_Property("session-panel.selection") = selection.index |
|
52 |
} |
|
39591 | 53 |
} |
54 |
||
55 |
set_content(tabs) |
|
39515 | 56 |
|
57 |
||
39593 | 58 |
/* controls */ |
59 |
||
39635 | 60 |
val session_phase = new Label(Isabelle.session.phase.toString) |
39697 | 61 |
session_phase.border = new SoftBevelBorder(BevelBorder.LOWERED) |
62 |
session_phase.tooltip = "Prover status" |
|
39635 | 63 |
|
39702 | 64 |
private val logic = Isabelle.logic_selector(Isabelle.Property("logic")) |
65 |
logic.listenTo(logic.selection) |
|
66 |
logic.reactions += { |
|
67 |
case SelectionChanged(_) => Isabelle.Property("logic") = logic.selection.item.name |
|
68 |
} |
|
69 |
||
44335
156be0e43336
discontinued "Interrupt", which could disturb administrative tasks of the document model;
wenzelm
parents:
44297
diff
changeset
|
70 |
private val controls = new FlowPanel(FlowPanel.Alignment.Right)(session_phase, logic) |
39593 | 71 |
add(controls.peer, BorderLayout.NORTH) |
72 |
||
73 |
||
44609 | 74 |
/* component state -- owned by Swing thread */ |
75 |
||
44617 | 76 |
private var nodes_status: Map[Document.Node.Name, String] = Map.empty |
44609 | 77 |
|
44615 | 78 |
private def handle_changed(changed_nodes: Set[Document.Node.Name]) |
44609 | 79 |
{ |
80 |
Swing_Thread.now { |
|
44613 | 81 |
// FIXME correlation to changed_nodes!? |
82 |
val state = Isabelle.session.current_state() |
|
44672 | 83 |
val version = state.recent_stable.version.get_finished |
44613 | 84 |
|
44672 | 85 |
var nodes_status1 = nodes_status |
86 |
for { |
|
87 |
name <- changed_nodes |
|
88 |
node <- version.nodes.get(name) |
|
89 |
val status = Isar_Document.node_status(state, version, node) |
|
90 |
} nodes_status1 += (name -> status.toString) |
|
91 |
||
92 |
if (nodes_status != nodes_status1) { |
|
93 |
nodes_status = nodes_status1 |
|
94 |
val order = |
|
95 |
Library.sort_wrt((name: Document.Node.Name) => name.theory, |
|
96 |
nodes_status.keySet.toList) |
|
97 |
status.listData = order.map(name => name.theory + " " + nodes_status(name)) |
|
44609 | 98 |
} |
99 |
} |
|
100 |
} |
|
101 |
||
102 |
||
39515 | 103 |
/* main actor */ |
104 |
||
105 |
private val main_actor = actor { |
|
106 |
loop { |
|
107 |
react { |
|
39589 | 108 |
case result: Isabelle_Process.Result => |
39625 | 109 |
if (result.is_syslog) |
110 |
Swing_Thread.now { |
|
39629 | 111 |
val text = Isabelle.session.syslog() |
39626
a5d0bcfb95a3
manage persistent syslog via Session, not Isabelle_Process;
wenzelm
parents:
39625
diff
changeset
|
112 |
if (text != syslog.text) { |
a5d0bcfb95a3
manage persistent syslog via Session, not Isabelle_Process;
wenzelm
parents:
39625
diff
changeset
|
113 |
syslog.text = text |
a5d0bcfb95a3
manage persistent syslog via Session, not Isabelle_Process;
wenzelm
parents:
39625
diff
changeset
|
114 |
} |
39625 | 115 |
} |
39589 | 116 |
|
39701 | 117 |
case phase: Session.Phase => |
39696 | 118 |
Swing_Thread.now { session_phase.text = " " + phase.toString + " " } |
39635 | 119 |
|
44609 | 120 |
case changed: Session.Commands_Changed => handle_changed(changed.nodes) |
121 |
||
39515 | 122 |
case bad => System.err.println("Session_Dockable: ignoring bad message " + bad) |
123 |
} |
|
124 |
} |
|
125 |
} |
|
126 |
||
39635 | 127 |
override def init() { |
44734
7313e2db3d39
more specific message channels to avoid potential bottle-neck of raw_messages;
wenzelm
parents:
44672
diff
changeset
|
128 |
Isabelle.session.syslog_messages += main_actor |
39635 | 129 |
Isabelle.session.phase_changed += main_actor |
44609 | 130 |
Isabelle.session.commands_changed += main_actor |
39635 | 131 |
} |
132 |
||
133 |
override def exit() { |
|
44734
7313e2db3d39
more specific message channels to avoid potential bottle-neck of raw_messages;
wenzelm
parents:
44672
diff
changeset
|
134 |
Isabelle.session.syslog_messages -= main_actor |
39635 | 135 |
Isabelle.session.phase_changed -= main_actor |
44609 | 136 |
Isabelle.session.commands_changed -= main_actor |
39635 | 137 |
} |
39515 | 138 |
} |