author | wenzelm |
Sun, 06 Dec 2009 20:50:07 +0100 | |
changeset 34748 | a2ed621f5f52 |
parent 34747 | b316d05a66a4 |
child 34749 | e377d3d6910a |
permissions | -rw-r--r-- |
34408 | 1 |
/* |
2 |
* Dockable window with rendered state output |
|
3 |
* |
|
4 |
* @author Fabian Immler, TU Munich |
|
5 |
* @author Johannes Hölzl, TU Munich |
|
6 |
*/ |
|
7 |
||
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
8 |
package isabelle.jedit |
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
9 |
|
34745 | 10 |
import isabelle.renderer.UserAgent |
11 |
import isabelle.XML |
|
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
12 |
|
34745 | 13 |
import java.io.StringReader |
34424 | 14 |
import java.awt.{BorderLayout, Dimension} |
34748 | 15 |
|
34424 | 16 |
import javax.swing.{JButton, JPanel, JScrollPane} |
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
17 |
|
34748 | 18 |
import java.util.logging.{Logger, Level} |
19 |
||
34745 | 20 |
import org.lobobrowser.html.parser._ |
21 |
import org.lobobrowser.html.test._ |
|
22 |
import org.lobobrowser.html.gui._ |
|
23 |
import org.lobobrowser.html._ |
|
24 |
import org.lobobrowser.html.style.CSSUtilities |
|
25 |
import org.lobobrowser.html.domimpl.{HTMLDocumentImpl, HTMLStyleElementImpl, NodeImpl} |
|
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
26 |
|
34428
d69fd18f37f9
basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents:
34424
diff
changeset
|
27 |
import org.gjt.sp.jedit.jEdit |
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
28 |
import org.gjt.sp.jedit.View |
34424 | 29 |
import org.gjt.sp.jedit.gui.DockableWindowManager |
34428
d69fd18f37f9
basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents:
34424
diff
changeset
|
30 |
import org.gjt.sp.jedit.textarea.AntiAlias |
34424 | 31 |
|
34745 | 32 |
import scala.io.Source |
33 |
||
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
34 |
|
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
35 |
class StateViewDockable(view : View, position : String) extends JPanel { |
34424 | 36 |
|
34428
d69fd18f37f9
basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents:
34424
diff
changeset
|
37 |
// outer panel |
34424 | 38 |
if (position == DockableWindowManager.FLOATING) |
39 |
setPreferredSize(new Dimension(500, 250)) |
|
34406
f81cd75ae331
restructured: independent provers in different buffers
immler@in.tum.de
parents:
34397
diff
changeset
|
40 |
setLayout(new BorderLayout) |
f81cd75ae331
restructured: independent provers in different buffers
immler@in.tum.de
parents:
34397
diff
changeset
|
41 |
|
34748 | 42 |
|
43 |
// global logging |
|
34745 | 44 |
|
34748 | 45 |
Logger.getLogger("org.lobobrowser").setLevel(Level.WARNING) |
46 |
||
47 |
||
34745 | 48 |
// document template with styles |
34428
d69fd18f37f9
basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents:
34424
diff
changeset
|
49 |
|
34745 | 50 |
private def try_file(name: String): String = |
51 |
{ |
|
52 |
val file = Isabelle.system.platform_file(name) |
|
53 |
if (file.exists) Source.fromFile(file).mkString else "" |
|
54 |
} |
|
34428
d69fd18f37f9
basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents:
34424
diff
changeset
|
55 |
|
34361 | 56 |
|
34745 | 57 |
// HTML panel |
58 |
||
59 |
val panel = new HtmlPanel |
|
60 |
val ucontext = new SimpleUserAgentContext |
|
61 |
val rcontext = new SimpleHtmlRendererContext(panel, ucontext) |
|
62 |
val doc = { |
|
63 |
val builder = new DocumentBuilderImpl(ucontext, rcontext) |
|
64 |
builder.parse(new InputSourceImpl(new StringReader( |
|
65 |
"""<?xml version="1.0" encoding="utf-8"?> |
|
66 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
|
67 |
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|
68 |
<html xmlns="http://www.w3.org/1999/xhtml"> |
|
69 |
<head> |
|
70 |
<style media="all" type="text/css"> |
|
71 |
""" + |
|
72 |
try_file("$ISABELLE_HOME/lib/html/isabelle.css") + "\n" + |
|
34747 | 73 |
""" |
74 |
body { |
|
75 |
white-space: pre; |
|
76 |
font-family: IsabelleMono; |
|
77 |
font-size: 14pt; |
|
78 |
} |
|
79 |
""" + |
|
34745 | 80 |
try_file("$ISABELLE_HOME_USER/etc/isabelle.css") + "\n" + |
81 |
""" |
|
82 |
</style> |
|
83 |
</head> |
|
84 |
</html> |
|
85 |
"""))) |
|
34428
d69fd18f37f9
basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents:
34424
diff
changeset
|
86 |
} |
d69fd18f37f9
basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents:
34424
diff
changeset
|
87 |
|
34747 | 88 |
val empty_body = XML.document_node(doc, HTML.body(Nil)) |
34745 | 89 |
doc.appendChild(empty_body) |
34428
d69fd18f37f9
basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents:
34424
diff
changeset
|
90 |
|
34745 | 91 |
panel.setDocument(doc, rcontext) |
92 |
add(panel, BorderLayout.CENTER) |
|
34428
d69fd18f37f9
basic setup of anti-aliasing, according to jEdit property;
wenzelm
parents:
34424
diff
changeset
|
93 |
|
34745 | 94 |
|
34669 | 95 |
// register for state-view |
96 |
Isabelle.plugin.state_update += (cmd => { |
|
97 |
val theory_view = Isabelle.prover_setup(view.getBuffer).get.theory_view |
|
34745 | 98 |
|
99 |
val node = |
|
100 |
if (cmd == null) empty_body |
|
34747 | 101 |
else XML.document_node(doc, HTML.body( |
102 |
cmd.results(theory_view.current_document).map((t: XML.Tree) => HTML.div(HTML.spans(t))))) |
|
34745 | 103 |
doc.removeChild(doc.getLastChild()) |
104 |
doc.appendChild(node) |
|
105 |
panel.delayedRelayout(node.asInstanceOf[NodeImpl]) |
|
34669 | 106 |
}) |
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
107 |
} |