author | wenzelm |
Mon, 31 May 2010 09:47:41 +0200 | |
changeset 37203 | c4261f3bbdd7 |
parent 37201 | 8517a650cfdc |
child 37241 | 04d2521e79b0 |
permissions | -rw-r--r-- |
36760 | 1 |
/* Title: Tools/jEdit/src/jedit/plugin.scala |
2 |
Author: Johannes Hölzl, TU Munich |
|
3 |
Author: Fabian Immler, TU Munich |
|
4 |
Author: Makarius |
|
5 |
||
6 |
Main Isabelle/jEdit plugin setup. |
|
7 |
*/ |
|
34407 | 8 |
|
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
9 |
package isabelle.jedit |
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
10 |
|
34429 | 11 |
|
36015 | 12 |
import isabelle._ |
13 |
||
34429 | 14 |
import java.io.{FileInputStream, IOException} |
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
15 |
import java.awt.Font |
34822 | 16 |
import javax.swing.JTextArea |
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
17 |
|
34497 | 18 |
import scala.collection.mutable |
34406
f81cd75ae331
restructured: independent provers in different buffers
immler@in.tum.de
parents:
34337
diff
changeset
|
19 |
|
34429 | 20 |
import org.gjt.sp.jedit.{jEdit, EBMessage, EBPlugin, Buffer, EditPane, ServiceManager, View} |
34406
f81cd75ae331
restructured: independent provers in different buffers
immler@in.tum.de
parents:
34337
diff
changeset
|
21 |
import org.gjt.sp.jedit.buffer.JEditBuffer |
f81cd75ae331
restructured: independent provers in different buffers
immler@in.tum.de
parents:
34337
diff
changeset
|
22 |
import org.gjt.sp.jedit.textarea.JEditTextArea |
34429 | 23 |
import org.gjt.sp.jedit.msg.{EditPaneUpdate, PropertiesChanged} |
37068 | 24 |
import org.gjt.sp.jedit.gui.DockableWindowManager |
34429 | 25 |
|
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
26 |
|
34618 | 27 |
object Isabelle |
28 |
{ |
|
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
29 |
/* plugin instance */ |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
30 |
|
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
31 |
var system: Isabelle_System = null |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
32 |
var session: Session = null |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
33 |
|
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
34 |
|
34618 | 35 |
/* name */ |
36 |
||
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
37 |
val NAME = "Isabelle" |
34623 | 38 |
|
34618 | 39 |
|
40 |
/* properties */ |
|
41 |
||
42 |
val OPTION_PREFIX = "options.isabelle." |
|
43 |
||
44 |
object Property |
|
45 |
{ |
|
36814
dc85664dbf6d
support Isabelle plugin properties with defaults;
wenzelm
parents:
36760
diff
changeset
|
46 |
def apply(name: String): String = |
dc85664dbf6d
support Isabelle plugin properties with defaults;
wenzelm
parents:
36760
diff
changeset
|
47 |
jEdit.getProperty(OPTION_PREFIX + name) |
dc85664dbf6d
support Isabelle plugin properties with defaults;
wenzelm
parents:
36760
diff
changeset
|
48 |
def apply(name: String, default: String): String = |
dc85664dbf6d
support Isabelle plugin properties with defaults;
wenzelm
parents:
36760
diff
changeset
|
49 |
jEdit.getProperty(OPTION_PREFIX + name, default) |
dc85664dbf6d
support Isabelle plugin properties with defaults;
wenzelm
parents:
36760
diff
changeset
|
50 |
def update(name: String, value: String) = |
dc85664dbf6d
support Isabelle plugin properties with defaults;
wenzelm
parents:
36760
diff
changeset
|
51 |
jEdit.setProperty(OPTION_PREFIX + name, value) |
34468
9d4b4f290676
maintain Isabelle properties via object Isabelle.Property with apply/update methods;
wenzelm
parents:
34463
diff
changeset
|
52 |
} |
34433 | 53 |
|
34618 | 54 |
object Boolean_Property |
55 |
{ |
|
36814
dc85664dbf6d
support Isabelle plugin properties with defaults;
wenzelm
parents:
36760
diff
changeset
|
56 |
def apply(name: String): Boolean = |
dc85664dbf6d
support Isabelle plugin properties with defaults;
wenzelm
parents:
36760
diff
changeset
|
57 |
jEdit.getBooleanProperty(OPTION_PREFIX + name) |
dc85664dbf6d
support Isabelle plugin properties with defaults;
wenzelm
parents:
36760
diff
changeset
|
58 |
def apply(name: String, default: Boolean): Boolean = |
dc85664dbf6d
support Isabelle plugin properties with defaults;
wenzelm
parents:
36760
diff
changeset
|
59 |
jEdit.getBooleanProperty(OPTION_PREFIX + name, default) |
dc85664dbf6d
support Isabelle plugin properties with defaults;
wenzelm
parents:
36760
diff
changeset
|
60 |
def update(name: String, value: Boolean) = |
dc85664dbf6d
support Isabelle plugin properties with defaults;
wenzelm
parents:
36760
diff
changeset
|
61 |
jEdit.setBooleanProperty(OPTION_PREFIX + name, value) |
34618 | 62 |
} |
63 |
||
64 |
object Int_Property |
|
65 |
{ |
|
36814
dc85664dbf6d
support Isabelle plugin properties with defaults;
wenzelm
parents:
36760
diff
changeset
|
66 |
def apply(name: String): Int = |
dc85664dbf6d
support Isabelle plugin properties with defaults;
wenzelm
parents:
36760
diff
changeset
|
67 |
jEdit.getIntegerProperty(OPTION_PREFIX + name) |
dc85664dbf6d
support Isabelle plugin properties with defaults;
wenzelm
parents:
36760
diff
changeset
|
68 |
def apply(name: String, default: Int): Int = |
dc85664dbf6d
support Isabelle plugin properties with defaults;
wenzelm
parents:
36760
diff
changeset
|
69 |
jEdit.getIntegerProperty(OPTION_PREFIX + name, default) |
dc85664dbf6d
support Isabelle plugin properties with defaults;
wenzelm
parents:
36760
diff
changeset
|
70 |
def update(name: String, value: Int) = |
dc85664dbf6d
support Isabelle plugin properties with defaults;
wenzelm
parents:
36760
diff
changeset
|
71 |
jEdit.setIntegerProperty(OPTION_PREFIX + name, value) |
34618 | 72 |
} |
73 |
||
37164 | 74 |
|
75 |
/* font */ |
|
76 |
||
77 |
def font_family(): String = jEdit.getProperty("view.font") |
|
78 |
||
37019 | 79 |
def font_size(): Float = |
80 |
(jEdit.getIntegerProperty("view.fontsize", 16) * |
|
81 |
Int_Property("relative-font-size", 100)).toFloat / 100 |
|
36814
dc85664dbf6d
support Isabelle plugin properties with defaults;
wenzelm
parents:
36760
diff
changeset
|
82 |
|
34618 | 83 |
|
37201
8517a650cfdc
control tooltip font via Swing HTML, with tooltip-font-size property;
wenzelm
parents:
37177
diff
changeset
|
84 |
/* tooltip markup */ |
8517a650cfdc
control tooltip font via Swing HTML, with tooltip-font-size property;
wenzelm
parents:
37177
diff
changeset
|
85 |
|
8517a650cfdc
control tooltip font via Swing HTML, with tooltip-font-size property;
wenzelm
parents:
37177
diff
changeset
|
86 |
def tooltip(text: String): String = |
37203
c4261f3bbdd7
more flexibile font size via CSS <style> instead of old <font> element;
wenzelm
parents:
37201
diff
changeset
|
87 |
"<html><pre style=\"font-family: " + font_family() + "; font-size: " + |
c4261f3bbdd7
more flexibile font size via CSS <style> instead of old <font> element;
wenzelm
parents:
37201
diff
changeset
|
88 |
Int_Property("tooltip-font-size", 10).toString + "px; \">" + // FIXME proper scaling (!?) |
c4261f3bbdd7
more flexibile font size via CSS <style> instead of old <font> element;
wenzelm
parents:
37201
diff
changeset
|
89 |
HTML.encode(text) + "</pre></html>" |
37201
8517a650cfdc
control tooltip font via Swing HTML, with tooltip-font-size property;
wenzelm
parents:
37177
diff
changeset
|
90 |
|
8517a650cfdc
control tooltip font via Swing HTML, with tooltip-font-size property;
wenzelm
parents:
37177
diff
changeset
|
91 |
|
34618 | 92 |
/* settings */ |
93 |
||
34782
fcd6a41326a6
refined treatment of default logic concerning property and GUI;
wenzelm
parents:
34781
diff
changeset
|
94 |
def default_logic(): String = |
fcd6a41326a6
refined treatment of default logic concerning property and GUI;
wenzelm
parents:
34781
diff
changeset
|
95 |
{ |
fcd6a41326a6
refined treatment of default logic concerning property and GUI;
wenzelm
parents:
34781
diff
changeset
|
96 |
val logic = system.getenv("JEDIT_LOGIC") |
fcd6a41326a6
refined treatment of default logic concerning property and GUI;
wenzelm
parents:
34781
diff
changeset
|
97 |
if (logic != "") logic |
fcd6a41326a6
refined treatment of default logic concerning property and GUI;
wenzelm
parents:
34781
diff
changeset
|
98 |
else system.getenv_strict("ISABELLE_LOGIC") |
fcd6a41326a6
refined treatment of default logic concerning property and GUI;
wenzelm
parents:
34781
diff
changeset
|
99 |
} |
fcd6a41326a6
refined treatment of default logic concerning property and GUI;
wenzelm
parents:
34781
diff
changeset
|
100 |
|
fcd6a41326a6
refined treatment of default logic concerning property and GUI;
wenzelm
parents:
34781
diff
changeset
|
101 |
def isabelle_args(): List[String] = |
34618 | 102 |
{ |
34780 | 103 |
val modes = system.getenv("JEDIT_PRINT_MODE").split(",").toList.map("-m" + _) |
104 |
val logic = { |
|
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
105 |
val logic = Property("logic") |
34782
fcd6a41326a6
refined treatment of default logic concerning property and GUI;
wenzelm
parents:
34781
diff
changeset
|
106 |
if (logic != null && logic != "") logic |
fcd6a41326a6
refined treatment of default logic concerning property and GUI;
wenzelm
parents:
34781
diff
changeset
|
107 |
else default_logic() |
34780 | 108 |
} |
109 |
modes ++ List(logic) |
|
34502 | 110 |
} |
111 |
||
34618 | 112 |
|
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
113 |
/* main jEdit components */ // FIXME ownership!? |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
114 |
|
37177 | 115 |
def jedit_buffers(): Iterator[Buffer] = jEdit.getBuffers().iterator |
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
116 |
|
37177 | 117 |
def jedit_views(): Iterator[View] = jEdit.getViews().iterator |
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
118 |
|
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
119 |
def jedit_text_areas(view: View): Iterator[JEditTextArea] = |
37177 | 120 |
view.getEditPanes().iterator.map(_.getTextArea) |
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
121 |
|
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
122 |
def jedit_text_areas(): Iterator[JEditTextArea] = |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
123 |
jedit_views().flatMap(jedit_text_areas(_)) |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
124 |
|
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
125 |
def jedit_text_areas(buffer: JEditBuffer): Iterator[JEditTextArea] = |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
126 |
jedit_text_areas().filter(_.getBuffer == buffer) |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
127 |
|
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
128 |
|
37068 | 129 |
/* dockable windows */ |
130 |
||
131 |
private def wm(view: View): DockableWindowManager = view.getDockableWindowManager |
|
132 |
||
133 |
def docked_output(view: View): Option[Output_Dockable] = |
|
134 |
wm(view).getDockableWindow("isabelle-output") match { |
|
135 |
case dockable: Output_Dockable => Some(dockable) |
|
136 |
case _ => None |
|
137 |
} |
|
138 |
||
139 |
def docked_raw_output(view: View): Option[Raw_Output_Dockable] = |
|
140 |
wm(view).getDockableWindow("isabelle-raw-output") match { |
|
141 |
case dockable: Raw_Output_Dockable => Some(dockable) |
|
142 |
case _ => None |
|
143 |
} |
|
144 |
||
145 |
def docked_protocol(view: View): Option[Protocol_Dockable] = |
|
146 |
wm(view).getDockableWindow("isabelle-protocol") match { |
|
147 |
case dockable: Protocol_Dockable => Some(dockable) |
|
148 |
case _ => None |
|
149 |
} |
|
150 |
||
151 |
||
34820
a8ba6cde13e9
basic setup for synchronous / modal (!) prover startup;
wenzelm
parents:
34808
diff
changeset
|
152 |
/* manage prover */ |
a8ba6cde13e9
basic setup for synchronous / modal (!) prover startup;
wenzelm
parents:
34808
diff
changeset
|
153 |
|
a8ba6cde13e9
basic setup for synchronous / modal (!) prover startup;
wenzelm
parents:
34808
diff
changeset
|
154 |
private def prover_started(view: View): Boolean = |
a8ba6cde13e9
basic setup for synchronous / modal (!) prover startup;
wenzelm
parents:
34808
diff
changeset
|
155 |
{ |
a8ba6cde13e9
basic setup for synchronous / modal (!) prover startup;
wenzelm
parents:
34808
diff
changeset
|
156 |
val timeout = Int_Property("startup-timeout") max 1000 |
a8ba6cde13e9
basic setup for synchronous / modal (!) prover startup;
wenzelm
parents:
34808
diff
changeset
|
157 |
session.start(timeout, Isabelle.isabelle_args()) match { |
a8ba6cde13e9
basic setup for synchronous / modal (!) prover startup;
wenzelm
parents:
34808
diff
changeset
|
158 |
case Some(err) => |
34822 | 159 |
val text = new JTextArea(err); text.setEditable(false) |
160 |
Library.error_dialog(view, null, "Failed to start Isabelle process", text) |
|
34820
a8ba6cde13e9
basic setup for synchronous / modal (!) prover startup;
wenzelm
parents:
34808
diff
changeset
|
161 |
false |
a8ba6cde13e9
basic setup for synchronous / modal (!) prover startup;
wenzelm
parents:
34808
diff
changeset
|
162 |
case None => true |
a8ba6cde13e9
basic setup for synchronous / modal (!) prover startup;
wenzelm
parents:
34808
diff
changeset
|
163 |
} |
a8ba6cde13e9
basic setup for synchronous / modal (!) prover startup;
wenzelm
parents:
34808
diff
changeset
|
164 |
} |
a8ba6cde13e9
basic setup for synchronous / modal (!) prover startup;
wenzelm
parents:
34808
diff
changeset
|
165 |
|
a8ba6cde13e9
basic setup for synchronous / modal (!) prover startup;
wenzelm
parents:
34808
diff
changeset
|
166 |
|
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
167 |
/* activation */ |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
168 |
|
34820
a8ba6cde13e9
basic setup for synchronous / modal (!) prover startup;
wenzelm
parents:
34808
diff
changeset
|
169 |
def activate_buffer(view: View, buffer: Buffer) |
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
170 |
{ |
34820
a8ba6cde13e9
basic setup for synchronous / modal (!) prover startup;
wenzelm
parents:
34808
diff
changeset
|
171 |
if (prover_started(view)) { |
a8ba6cde13e9
basic setup for synchronous / modal (!) prover startup;
wenzelm
parents:
34808
diff
changeset
|
172 |
val model = Document_Model.init(session, buffer) |
a8ba6cde13e9
basic setup for synchronous / modal (!) prover startup;
wenzelm
parents:
34808
diff
changeset
|
173 |
for (text_area <- jedit_text_areas(buffer)) |
a8ba6cde13e9
basic setup for synchronous / modal (!) prover startup;
wenzelm
parents:
34808
diff
changeset
|
174 |
Document_View.init(model, text_area) |
a8ba6cde13e9
basic setup for synchronous / modal (!) prover startup;
wenzelm
parents:
34808
diff
changeset
|
175 |
} |
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
176 |
} |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
177 |
|
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
178 |
def deactivate_buffer(buffer: Buffer) |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
179 |
{ |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
180 |
session.stop() // FIXME not yet |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
181 |
|
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
182 |
for (text_area <- jedit_text_areas(buffer)) |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
183 |
Document_View.exit(text_area) |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
184 |
Document_Model.exit(buffer) |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
185 |
} |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
186 |
|
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
187 |
def switch_active(view: View) = |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
188 |
{ |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
189 |
val buffer = view.getBuffer |
34788
3779c54a2d21
direct apply for Document_Model and Document_View;
wenzelm
parents:
34787
diff
changeset
|
190 |
if (Document_Model(buffer).isDefined) deactivate_buffer(buffer) |
34820
a8ba6cde13e9
basic setup for synchronous / modal (!) prover startup;
wenzelm
parents:
34808
diff
changeset
|
191 |
else activate_buffer(view, buffer) |
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
192 |
} |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
193 |
|
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
194 |
def is_active(view: View): Boolean = |
34788
3779c54a2d21
direct apply for Document_Model and Document_View;
wenzelm
parents:
34787
diff
changeset
|
195 |
Document_Model(view.getBuffer).isDefined |
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
196 |
} |
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
197 |
|
34429 | 198 |
|
34618 | 199 |
class Plugin extends EBPlugin |
200 |
{ |
|
201 |
/* main plugin plumbing */ |
|
34433 | 202 |
|
34767 | 203 |
override def handleMessage(message: EBMessage) |
34618 | 204 |
{ |
34767 | 205 |
message match { |
206 |
case msg: EditPaneUpdate => |
|
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
207 |
val edit_pane = msg.getEditPane |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
208 |
val buffer = edit_pane.getBuffer |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
209 |
val text_area = edit_pane.getTextArea |
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
210 |
|
34787
0feac35069c6
need to handle EditPaneUpdate.CREATED explicitly, not included in EditPaneUpdate.BUFFER_CHANGED;
wenzelm
parents:
34784
diff
changeset
|
211 |
def init_view() |
0feac35069c6
need to handle EditPaneUpdate.CREATED explicitly, not included in EditPaneUpdate.BUFFER_CHANGED;
wenzelm
parents:
34784
diff
changeset
|
212 |
{ |
34788
3779c54a2d21
direct apply for Document_Model and Document_View;
wenzelm
parents:
34787
diff
changeset
|
213 |
Document_Model(buffer) match { |
34787
0feac35069c6
need to handle EditPaneUpdate.CREATED explicitly, not included in EditPaneUpdate.BUFFER_CHANGED;
wenzelm
parents:
34784
diff
changeset
|
214 |
case Some(model) => Document_View.init(model, text_area) |
0feac35069c6
need to handle EditPaneUpdate.CREATED explicitly, not included in EditPaneUpdate.BUFFER_CHANGED;
wenzelm
parents:
34784
diff
changeset
|
215 |
case None => |
0feac35069c6
need to handle EditPaneUpdate.CREATED explicitly, not included in EditPaneUpdate.BUFFER_CHANGED;
wenzelm
parents:
34784
diff
changeset
|
216 |
} |
0feac35069c6
need to handle EditPaneUpdate.CREATED explicitly, not included in EditPaneUpdate.BUFFER_CHANGED;
wenzelm
parents:
34784
diff
changeset
|
217 |
} |
0feac35069c6
need to handle EditPaneUpdate.CREATED explicitly, not included in EditPaneUpdate.BUFFER_CHANGED;
wenzelm
parents:
34784
diff
changeset
|
218 |
def exit_view() |
0feac35069c6
need to handle EditPaneUpdate.CREATED explicitly, not included in EditPaneUpdate.BUFFER_CHANGED;
wenzelm
parents:
34784
diff
changeset
|
219 |
{ |
34788
3779c54a2d21
direct apply for Document_Model and Document_View;
wenzelm
parents:
34787
diff
changeset
|
220 |
if (Document_View(text_area).isDefined) |
34787
0feac35069c6
need to handle EditPaneUpdate.CREATED explicitly, not included in EditPaneUpdate.BUFFER_CHANGED;
wenzelm
parents:
34784
diff
changeset
|
221 |
Document_View.exit(text_area) |
0feac35069c6
need to handle EditPaneUpdate.CREATED explicitly, not included in EditPaneUpdate.BUFFER_CHANGED;
wenzelm
parents:
34784
diff
changeset
|
222 |
} |
34767 | 223 |
msg.getWhat match { |
34787
0feac35069c6
need to handle EditPaneUpdate.CREATED explicitly, not included in EditPaneUpdate.BUFFER_CHANGED;
wenzelm
parents:
34784
diff
changeset
|
224 |
case EditPaneUpdate.BUFFER_CHANGED => exit_view(); init_view() |
0feac35069c6
need to handle EditPaneUpdate.CREATED explicitly, not included in EditPaneUpdate.BUFFER_CHANGED;
wenzelm
parents:
34784
diff
changeset
|
225 |
case EditPaneUpdate.CREATED => init_view() |
0feac35069c6
need to handle EditPaneUpdate.CREATED explicitly, not included in EditPaneUpdate.BUFFER_CHANGED;
wenzelm
parents:
34784
diff
changeset
|
226 |
case EditPaneUpdate.DESTROYED => exit_view() |
34671 | 227 |
case _ => |
228 |
} |
|
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
229 |
|
34777
91d6089cef88
class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
34774
diff
changeset
|
230 |
case msg: PropertiesChanged => |
34791 | 231 |
Isabelle.session.global_settings.event(Session.Global_Settings) |
34784
02959dcea756
split Theory_View into Document_Model (connected to Buffer) and Document_View (connected to JEditTextArea);
wenzelm
parents:
34782
diff
changeset
|
232 |
|
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
233 |
case _ => |
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
234 |
} |
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
235 |
} |
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
236 |
|
34618 | 237 |
override def start() |
238 |
{ |
|
34615 | 239 |
Isabelle.system = new Isabelle_System |
34774 | 240 |
Isabelle.system.install_fonts() |
34777
91d6089cef88
class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
34774
diff
changeset
|
241 |
Isabelle.session = new Session(Isabelle.system) // FIXME dialog!? |
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
242 |
} |
34618 | 243 |
|
244 |
override def stop() |
|
245 |
{ |
|
34777
91d6089cef88
class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
34774
diff
changeset
|
246 |
Isabelle.session.stop() // FIXME dialog!? |
91d6089cef88
class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
34774
diff
changeset
|
247 |
Isabelle.session = null |
34441
ff3b7ae2b12a
replaced static IsabelleSystem by Isabelle.system;
wenzelm
parents:
34440
diff
changeset
|
248 |
Isabelle.system = null |
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
249 |
} |
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
250 |
} |