8 |
8 |
9 |
9 |
10 import isabelle._ |
10 import isabelle._ |
11 |
11 |
12 import scala.actors.Actor._ |
12 import scala.actors.Actor._ |
13 import scala.swing.{FlowPanel, Button, TextArea, Label, ListView, Alignment, ScrollPane, Component} |
13 import scala.swing.{FlowPanel, Button, TextArea, Label, ListView, Alignment, ScrollPane, Component, |
|
14 BoxPanel, Orientation, RadioButton, ButtonGroup} |
14 import scala.swing.event.{ButtonClicked, MouseClicked} |
15 import scala.swing.event.{ButtonClicked, MouseClicked} |
15 |
16 |
16 import java.lang.System |
17 import java.lang.System |
17 import java.awt.{BorderLayout, Graphics2D, Insets} |
18 import java.awt.{BorderLayout, Graphics2D, Insets, Color} |
18 import javax.swing.{JList, BorderFactory} |
19 import javax.swing.{JList, BorderFactory} |
19 import javax.swing.border.{BevelBorder, SoftBevelBorder} |
20 import javax.swing.border.{BevelBorder, SoftBevelBorder, LineBorder} |
20 |
21 |
21 import org.gjt.sp.jedit.{View, jEdit} |
22 import org.gjt.sp.jedit.{View, jEdit} |
22 |
23 |
23 |
24 |
24 class Theories_Dockable(view: View, position: String) extends Dockable(view, position) |
25 class Theories_Dockable(view: View, position: String) extends Dockable(view, position) |
52 private def handle_phase(phase: Session.Phase) |
53 private def handle_phase(phase: Session.Phase) |
53 { |
54 { |
54 Swing_Thread.later { session_phase.text = " " + phase_text(phase) + " " } |
55 Swing_Thread.later { session_phase.text = " " + phase_text(phase) + " " } |
55 } |
56 } |
56 |
57 |
57 private val cancel = new Button("Cancel") { |
58 private val execution_range = new BoxPanel(Orientation.Horizontal) { |
58 reactions += { case ButtonClicked(_) => PIDE.cancel_execution() } |
59 private def button(range: PIDE.Execution_Range.Value): RadioButton = |
|
60 new RadioButton(range.toString) { |
|
61 reactions += { case ButtonClicked(_) => PIDE.update_execution_range(range) } |
|
62 } |
|
63 private val label = new Label("Range:") { tooltip = "range of continuous document processing" } |
|
64 private val b1 = button(PIDE.Execution_Range.ALL) |
|
65 private val b2 = button(PIDE.Execution_Range.NONE) |
|
66 private val b3 = button(PIDE.Execution_Range.VISIBLE) |
|
67 private val group = new ButtonGroup(b1, b2, b3) |
|
68 contents ++= List(label, b1, b2, b3) |
|
69 border = new LineBorder(Color.GRAY) |
|
70 |
|
71 def load() |
|
72 { |
|
73 PIDE.execution_range() match { |
|
74 case PIDE.Execution_Range.ALL => group.select(b1) |
|
75 case PIDE.Execution_Range.NONE => group.select(b2) |
|
76 case PIDE.Execution_Range.VISIBLE => group.select(b3) |
|
77 } |
|
78 } |
59 } |
79 } |
60 cancel.tooltip = "Cancel current checking process" |
|
61 |
|
62 private val check = new Button("Check") { |
|
63 reactions += { case ButtonClicked(_) => PIDE.check_buffer(view.getBuffer) } |
|
64 } |
|
65 check.tooltip = "Commence full checking of current buffer" |
|
66 |
80 |
67 private val logic = Isabelle_Logic.logic_selector(true) |
81 private val logic = Isabelle_Logic.logic_selector(true) |
68 |
82 |
69 private val controls = |
83 private val controls = |
70 new FlowPanel(FlowPanel.Alignment.Right)(check, cancel, session_phase, logic) |
84 new FlowPanel(FlowPanel.Alignment.Right)(execution_range, session_phase, logic) |
71 add(controls.peer, BorderLayout.NORTH) |
85 add(controls.peer, BorderLayout.NORTH) |
72 |
86 |
73 |
87 |
74 /* component state -- owned by Swing thread */ |
88 /* component state -- owned by Swing thread */ |
75 |
89 |
154 private val main_actor = actor { |
168 private val main_actor = actor { |
155 loop { |
169 loop { |
156 react { |
170 react { |
157 case phase: Session.Phase => handle_phase(phase) |
171 case phase: Session.Phase => handle_phase(phase) |
158 |
172 |
159 case _: Session.Global_Options => Swing_Thread.later { logic.load () } |
173 case _: Session.Global_Options => |
|
174 Swing_Thread.later { |
|
175 execution_range.load() |
|
176 logic.load () |
|
177 } |
160 |
178 |
161 case changed: Session.Commands_Changed => handle_update(Some(changed.nodes)) |
179 case changed: Session.Commands_Changed => handle_update(Some(changed.nodes)) |
162 |
180 |
163 case bad => System.err.println("Theories_Dockable: ignoring bad message " + bad) |
181 case bad => System.err.println("Theories_Dockable: ignoring bad message " + bad) |
164 } |
182 } |